diff --git a/.vscode/launch.json b/.vscode/launch.json index 569b390ed6f..e5f01f82789 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -34,7 +34,7 @@ "request": "launch", "preLaunchTask": "build", "program": "${workspaceFolder}/src/bin/Debug/net6.0/mgc.dll", - "args": ["me", "get"], + "args": ["me", "get", "--output", "TABLE"], "cwd": "${workspaceFolder}/src", "envFile": "${workspaceFolder}/src/.env", "console": "internalConsole", diff --git a/msgraph-cli-core b/msgraph-cli-core index dfc089883f4..054666af988 160000 --- a/msgraph-cli-core +++ b/msgraph-cli-core @@ -1 +1 @@ -Subproject commit dfc089883f4922a8be1cceeeff47172893a3c13a +Subproject commit 054666af98888a334f0f83185b153681a69b88f6 diff --git a/src/Program.cs b/src/Program.cs index 3be8c2736af..1656eacb60a 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -8,7 +8,9 @@ using Microsoft.Graph.Cli.Core.Configuration; using Microsoft.Graph.Cli.Core.IO; using Microsoft.Graph.Cli.Core.Utils; +using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Authentication.Azure; +using Microsoft.Kiota.Cli.Commons.IO; using Microsoft.Kiota.Http.HttpClientLibrary; using Microsoft.Kiota.Http.HttpClientLibrary.Middleware; using Microsoft.Kiota.Http.HttpClientLibrary.Middleware.Options; @@ -43,7 +45,7 @@ static async Task Main(string[] args) var authStrategy = AuthenticationStrategy.DeviceCode; var credential = await authServiceFactory.GetTokenCredentialAsync(authStrategy, authSettings?.TenantId, authSettings?.ClientId); - var authProvider = new AzureIdentityAuthenticationProvider(credential); + var authProvider = new AzureIdentityAuthenticationProvider(credential, new string[] {"graph.microsoft.com"}); var defaultHandlers = KiotaClientFactory.CreateDefaultHandlers(); var assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version; @@ -67,8 +69,6 @@ static async Task Main(string[] args) using var httpClient = KiotaClientFactory.Create(finalHandler); var core = new HttpClientRequestAdapter(authProvider, httpClient: httpClient); var client = new GraphClient(core); - var rootCommand = client.BuildCommand(); - rootCommand.Description = "Microsoft Graph CLI"; var commands = new List(); var loginCommand = new LoginCommand(authServiceFactory); @@ -77,7 +77,12 @@ static async Task Main(string[] args) var logoutCommand = new LogoutCommand(new LogoutService()); commands.Add(logoutCommand.Build()); - var builder = BuildCommandLine(client, commands).UseDefaults(); + var builder = BuildCommandLine(client, commands).UseDefaults().UseHost(CreateHostBuilder); + builder.AddMiddleware((invocation) => { + var host = invocation.GetHost(); + var outputFormatterFactory = host.Services.GetRequiredService(); + invocation.BindingContext.AddService(_ => outputFormatterFactory); + }); builder.UseExceptionHandler((ex, context) => { if (ex is AuthenticationRequiredException) { Console.ResetColor(); @@ -87,14 +92,14 @@ static async Task Main(string[] args) } }); - var parser = builder.UseHost(CreateHostBuilder).Build(); + var parser = builder.Build(); return await parser.InvokeAsync(args); } static CommandLineBuilder BuildCommandLine(GraphClient client, IEnumerable commands) { - var rootCommand = client.BuildCommand(); + var rootCommand = client.BuildRootCommand(); rootCommand.Description = "Microsoft Graph CLI"; foreach (var command in commands) { @@ -113,6 +118,7 @@ static IHostBuilder CreateHostBuilder(string[] args) => var authSection = ctx.Configuration.GetSection(Constants.AuthenticationSection); services.Configure(authSection); services.AddSingleton(); + services.AddSingleton(); }); static void ConfigureAppConfiguration(IConfigurationBuilder builder) { diff --git a/src/generated/Admin/AdminRequestBuilder.cs b/src/generated/Admin/AdminRequestBuilder.cs index 22ba6cb3d3e..1719f3f65ce 100644 --- a/src/generated/Admin/AdminRequestBuilder.cs +++ b/src/generated/Admin/AdminRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,20 +37,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -64,14 +63,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -139,31 +137,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get admin - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update admin - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Admin model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get admin public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Admin/ServiceAnnouncement/HealthOverviews/HealthOverviewsRequestBuilder.cs b/src/generated/Admin/ServiceAnnouncement/HealthOverviews/HealthOverviewsRequestBuilder.cs index af7961d3940..2cbbb9d2f7f 100644 --- a/src/generated/Admin/ServiceAnnouncement/HealthOverviews/HealthOverviewsRequestBuilder.cs +++ b/src/generated/Admin/ServiceAnnouncement/HealthOverviews/HealthOverviewsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class HealthOverviewsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ServiceHealthRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildIssuesCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildIssuesCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(ServiceHealth body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of service health information for tenant. This property is a contained navigation property, it is nullable and readonly. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of service health information for tenant. This property is a contained navigation property, it is nullable and readonly. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ServiceHealth model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of service health information for tenant. This property is a contained navigation property, it is nullable and readonly. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Admin/ServiceAnnouncement/HealthOverviews/Item/Issues/IssuesRequestBuilder.cs b/src/generated/Admin/ServiceAnnouncement/HealthOverviews/Item/Issues/IssuesRequestBuilder.cs index d717a5346d7..d5939626420 100644 --- a/src/generated/Admin/ServiceAnnouncement/HealthOverviews/Item/Issues/IssuesRequestBuilder.cs +++ b/src/generated/Admin/ServiceAnnouncement/HealthOverviews/Item/Issues/IssuesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,21 +22,20 @@ public class IssuesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ServiceHealthIssueRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// - /// A collection of issues happened on the service, with detailed information for each issue. + /// A collection of issues that happened on the service, with detailed information for each issue. /// public Command BuildCreateCommand() { var command = new Command("create"); - command.Description = "A collection of issues happened on the service, with detailed information for each issue."; + command.Description = "A collection of issues that happened on the service, with detailed information for each issue."; // Create options for all the parameters - var serviceHealthIdOption = new Option("--servicehealth-id", description: "key: id of serviceHealth") { + var serviceHealthIdOption = new Option("--service-health-id", description: "key: id of serviceHealth") { }; serviceHealthIdOption.IsRequired = true; command.AddOption(serviceHealthIdOption); @@ -44,31 +43,30 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string serviceHealthId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string serviceHealthId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, serviceHealthIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, serviceHealthIdOption, bodyOption, outputOption); return command; } /// - /// A collection of issues happened on the service, with detailed information for each issue. + /// A collection of issues that happened on the service, with detailed information for each issue. /// public Command BuildListCommand() { var command = new Command("list"); - command.Description = "A collection of issues happened on the service, with detailed information for each issue."; + command.Description = "A collection of issues that happened on the service, with detailed information for each issue."; // Create options for all the parameters - var serviceHealthIdOption = new Option("--servicehealth-id", description: "key: id of serviceHealth") { + var serviceHealthIdOption = new Option("--service-health-id", description: "key: id of serviceHealth") { }; serviceHealthIdOption.IsRequired = true; command.AddOption(serviceHealthIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string serviceHealthId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string serviceHealthId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, serviceHealthIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, serviceHealthIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -143,7 +140,7 @@ public IssuesRequestBuilder(Dictionary pathParameters, IRequestA RequestAdapter = requestAdapter; } /// - /// A collection of issues happened on the service, with detailed information for each issue. + /// A collection of issues that happened on the service, with detailed information for each issue. /// Request headers /// Request options /// Request query parameters @@ -164,7 +161,7 @@ public RequestInformation CreateGetRequestInformation(Action return requestInfo; } /// - /// A collection of issues happened on the service, with detailed information for each issue. + /// A collection of issues that happened on the service, with detailed information for each issue. /// /// Request headers /// Request options @@ -181,32 +178,7 @@ public RequestInformation CreatePostRequestInformation(ServiceHealthIssue body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of issues happened on the service, with detailed information for each issue. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of issues happened on the service, with detailed information for each issue. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ServiceHealthIssue model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// A collection of issues happened on the service, with detailed information for each issue. + /// A collection of issues that happened on the service, with detailed information for each issue. public class GetQueryParameters : QueryParametersBase { /// Include count of items public bool? Count { get; set; } diff --git a/src/generated/Admin/ServiceAnnouncement/HealthOverviews/Item/Issues/Item/IncidentReport/IncidentReportRequestBuilder.cs b/src/generated/Admin/ServiceAnnouncement/HealthOverviews/Item/Issues/Item/IncidentReport/IncidentReportRequestBuilder.cs index ec83cc7d2ac..86ebccf378b 100644 --- a/src/generated/Admin/ServiceAnnouncement/HealthOverviews/Item/Issues/Item/IncidentReport/IncidentReportRequestBuilder.cs +++ b/src/generated/Admin/ServiceAnnouncement/HealthOverviews/Item/Issues/Item/IncidentReport/IncidentReportRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,32 +25,34 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function incidentReport"; // Create options for all the parameters - var serviceHealthIdOption = new Option("--servicehealth-id", description: "key: id of serviceHealth") { + var serviceHealthIdOption = new Option("--service-health-id", description: "key: id of serviceHealth") { }; serviceHealthIdOption.IsRequired = true; command.AddOption(serviceHealthIdOption); - var serviceHealthIssueIdOption = new Option("--servicehealthissue-id", description: "key: id of serviceHealthIssue") { + var serviceHealthIssueIdOption = new Option("--service-health-issue-id", description: "key: id of serviceHealthIssue") { }; serviceHealthIssueIdOption.IsRequired = true; command.AddOption(serviceHealthIssueIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string serviceHealthId, string serviceHealthIssueId, FileInfo output) => { + command.SetHandler(async (string serviceHealthId, string serviceHealthIssueId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, serviceHealthIdOption, serviceHealthIssueIdOption, outputOption); + }, serviceHealthIdOption, serviceHealthIssueIdOption, fileOption, outputOption); return command; } /// @@ -81,16 +83,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function incidentReport - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Admin/ServiceAnnouncement/HealthOverviews/Item/Issues/Item/ServiceHealthIssueRequestBuilder.cs b/src/generated/Admin/ServiceAnnouncement/HealthOverviews/Item/Issues/Item/ServiceHealthIssueRequestBuilder.cs index 713d85c8346..dfa8e4c8b80 100644 --- a/src/generated/Admin/ServiceAnnouncement/HealthOverviews/Item/Issues/Item/ServiceHealthIssueRequestBuilder.cs +++ b/src/generated/Admin/ServiceAnnouncement/HealthOverviews/Item/Issues/Item/ServiceHealthIssueRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -21,41 +21,40 @@ public class ServiceHealthIssueRequestBuilder { /// Url template to use to build the URL for the current request builder private string UrlTemplate { get; set; } /// - /// A collection of issues happened on the service, with detailed information for each issue. + /// A collection of issues that happened on the service, with detailed information for each issue. /// public Command BuildDeleteCommand() { var command = new Command("delete"); - command.Description = "A collection of issues happened on the service, with detailed information for each issue."; + command.Description = "A collection of issues that happened on the service, with detailed information for each issue."; // Create options for all the parameters - var serviceHealthIdOption = new Option("--servicehealth-id", description: "key: id of serviceHealth") { + var serviceHealthIdOption = new Option("--service-health-id", description: "key: id of serviceHealth") { }; serviceHealthIdOption.IsRequired = true; command.AddOption(serviceHealthIdOption); - var serviceHealthIssueIdOption = new Option("--servicehealthissue-id", description: "key: id of serviceHealthIssue") { + var serviceHealthIssueIdOption = new Option("--service-health-issue-id", description: "key: id of serviceHealthIssue") { }; serviceHealthIssueIdOption.IsRequired = true; command.AddOption(serviceHealthIssueIdOption); - command.SetHandler(async (string serviceHealthId, string serviceHealthIssueId) => { + command.SetHandler(async (string serviceHealthId, string serviceHealthIssueId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, serviceHealthIdOption, serviceHealthIssueIdOption); return command; } /// - /// A collection of issues happened on the service, with detailed information for each issue. + /// A collection of issues that happened on the service, with detailed information for each issue. /// public Command BuildGetCommand() { var command = new Command("get"); - command.Description = "A collection of issues happened on the service, with detailed information for each issue."; + command.Description = "A collection of issues that happened on the service, with detailed information for each issue."; // Create options for all the parameters - var serviceHealthIdOption = new Option("--servicehealth-id", description: "key: id of serviceHealth") { + var serviceHealthIdOption = new Option("--service-health-id", description: "key: id of serviceHealth") { }; serviceHealthIdOption.IsRequired = true; command.AddOption(serviceHealthIdOption); - var serviceHealthIssueIdOption = new Option("--servicehealthissue-id", description: "key: id of serviceHealthIssue") { + var serviceHealthIssueIdOption = new Option("--service-health-issue-id", description: "key: id of serviceHealthIssue") { }; serviceHealthIssueIdOption.IsRequired = true; command.AddOption(serviceHealthIssueIdOption); @@ -69,34 +68,33 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string serviceHealthId, string serviceHealthIssueId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string serviceHealthId, string serviceHealthIssueId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, serviceHealthIdOption, serviceHealthIssueIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, serviceHealthIdOption, serviceHealthIssueIdOption, selectOption, expandOption, outputOption); return command; } /// - /// A collection of issues happened on the service, with detailed information for each issue. + /// A collection of issues that happened on the service, with detailed information for each issue. /// public Command BuildPatchCommand() { var command = new Command("patch"); - command.Description = "A collection of issues happened on the service, with detailed information for each issue."; + command.Description = "A collection of issues that happened on the service, with detailed information for each issue."; // Create options for all the parameters - var serviceHealthIdOption = new Option("--servicehealth-id", description: "key: id of serviceHealth") { + var serviceHealthIdOption = new Option("--service-health-id", description: "key: id of serviceHealth") { }; serviceHealthIdOption.IsRequired = true; command.AddOption(serviceHealthIdOption); - var serviceHealthIssueIdOption = new Option("--servicehealthissue-id", description: "key: id of serviceHealthIssue") { + var serviceHealthIssueIdOption = new Option("--service-health-issue-id", description: "key: id of serviceHealthIssue") { }; serviceHealthIssueIdOption.IsRequired = true; command.AddOption(serviceHealthIssueIdOption); @@ -104,14 +102,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string serviceHealthId, string serviceHealthIssueId, string body) => { + command.SetHandler(async (string serviceHealthId, string serviceHealthIssueId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, serviceHealthIdOption, serviceHealthIssueIdOption, bodyOption); return command; @@ -130,7 +127,7 @@ public ServiceHealthIssueRequestBuilder(Dictionary pathParameter RequestAdapter = requestAdapter; } /// - /// A collection of issues happened on the service, with detailed information for each issue. + /// A collection of issues that happened on the service, with detailed information for each issue. /// Request headers /// Request options /// @@ -145,7 +142,7 @@ public RequestInformation CreateDeleteRequestInformation(Action - /// A collection of issues happened on the service, with detailed information for each issue. + /// A collection of issues that happened on the service, with detailed information for each issue. /// Request headers /// Request options /// Request query parameters @@ -166,7 +163,7 @@ public RequestInformation CreateGetRequestInformation(Action return requestInfo; } /// - /// A collection of issues happened on the service, with detailed information for each issue. + /// A collection of issues that happened on the service, with detailed information for each issue. /// /// Request headers /// Request options @@ -184,48 +181,12 @@ public RequestInformation CreatePatchRequestInformation(ServiceHealthIssue body, return requestInfo; } /// - /// A collection of issues happened on the service, with detailed information for each issue. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of issues happened on the service, with detailed information for each issue. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \admin\serviceAnnouncement\healthOverviews\{serviceHealth-id}\issues\{serviceHealthIssue-id}\microsoft.graph.incidentReport() /// public IncidentReportRequestBuilder IncidentReport() { return new IncidentReportRequestBuilder(PathParameters, RequestAdapter); } - /// - /// A collection of issues happened on the service, with detailed information for each issue. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ServiceHealthIssue model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// A collection of issues happened on the service, with detailed information for each issue. + /// A collection of issues that happened on the service, with detailed information for each issue. public class GetQueryParameters : QueryParametersBase { /// Expand related entities public string[] Expand { get; set; } diff --git a/src/generated/Admin/ServiceAnnouncement/HealthOverviews/Item/ServiceHealthRequestBuilder.cs b/src/generated/Admin/ServiceAnnouncement/HealthOverviews/Item/ServiceHealthRequestBuilder.cs index 123e785f271..f39875bb88d 100644 --- a/src/generated/Admin/ServiceAnnouncement/HealthOverviews/Item/ServiceHealthRequestBuilder.cs +++ b/src/generated/Admin/ServiceAnnouncement/HealthOverviews/Item/ServiceHealthRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,15 +27,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "A collection of service health information for tenant. This property is a contained navigation property, it is nullable and readonly."; // Create options for all the parameters - var serviceHealthIdOption = new Option("--servicehealth-id", description: "key: id of serviceHealth") { + var serviceHealthIdOption = new Option("--service-health-id", description: "key: id of serviceHealth") { }; serviceHealthIdOption.IsRequired = true; command.AddOption(serviceHealthIdOption); - command.SetHandler(async (string serviceHealthId) => { + command.SetHandler(async (string serviceHealthId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, serviceHealthIdOption); return command; @@ -47,7 +46,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "A collection of service health information for tenant. This property is a contained navigation property, it is nullable and readonly."; // Create options for all the parameters - var serviceHealthIdOption = new Option("--servicehealth-id", description: "key: id of serviceHealth") { + var serviceHealthIdOption = new Option("--service-health-id", description: "key: id of serviceHealth") { }; serviceHealthIdOption.IsRequired = true; command.AddOption(serviceHealthIdOption); @@ -61,25 +60,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string serviceHealthId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string serviceHealthId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, serviceHealthIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, serviceHealthIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildIssuesCommand() { var command = new Command("issues"); var builder = new ApiSdk.Admin.ServiceAnnouncement.HealthOverviews.Item.Issues.IssuesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -91,7 +92,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "A collection of service health information for tenant. This property is a contained navigation property, it is nullable and readonly."; // Create options for all the parameters - var serviceHealthIdOption = new Option("--servicehealth-id", description: "key: id of serviceHealth") { + var serviceHealthIdOption = new Option("--service-health-id", description: "key: id of serviceHealth") { }; serviceHealthIdOption.IsRequired = true; command.AddOption(serviceHealthIdOption); @@ -99,14 +100,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string serviceHealthId, string body) => { + command.SetHandler(async (string serviceHealthId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, serviceHealthIdOption, bodyOption); return command; @@ -178,42 +178,6 @@ public RequestInformation CreatePatchRequestInformation(ServiceHealth body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of service health information for tenant. This property is a contained navigation property, it is nullable and readonly. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of service health information for tenant. This property is a contained navigation property, it is nullable and readonly. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of service health information for tenant. This property is a contained navigation property, it is nullable and readonly. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ServiceHealth model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of service health information for tenant. This property is a contained navigation property, it is nullable and readonly. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Admin/ServiceAnnouncement/Issues/IssuesRequestBuilder.cs b/src/generated/Admin/ServiceAnnouncement/Issues/IssuesRequestBuilder.cs index ac0fe069a1a..1999723a3f0 100644 --- a/src/generated/Admin/ServiceAnnouncement/Issues/IssuesRequestBuilder.cs +++ b/src/generated/Admin/ServiceAnnouncement/Issues/IssuesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class IssuesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ServiceHealthIssueRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(ServiceHealthIssue body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of service issues for tenant. This property is a contained navigation property, it is nullable and readonly. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of service issues for tenant. This property is a contained navigation property, it is nullable and readonly. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ServiceHealthIssue model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of service issues for tenant. This property is a contained navigation property, it is nullable and readonly. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Admin/ServiceAnnouncement/Issues/Item/IncidentReport/IncidentReportRequestBuilder.cs b/src/generated/Admin/ServiceAnnouncement/Issues/Item/IncidentReport/IncidentReportRequestBuilder.cs index 86e9f945b64..aafe66b9f23 100644 --- a/src/generated/Admin/ServiceAnnouncement/Issues/Item/IncidentReport/IncidentReportRequestBuilder.cs +++ b/src/generated/Admin/ServiceAnnouncement/Issues/Item/IncidentReport/IncidentReportRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,28 +25,30 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function incidentReport"; // Create options for all the parameters - var serviceHealthIssueIdOption = new Option("--servicehealthissue-id", description: "key: id of serviceHealthIssue") { + var serviceHealthIssueIdOption = new Option("--service-health-issue-id", description: "key: id of serviceHealthIssue") { }; serviceHealthIssueIdOption.IsRequired = true; command.AddOption(serviceHealthIssueIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string serviceHealthIssueId, FileInfo output) => { + command.SetHandler(async (string serviceHealthIssueId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, serviceHealthIssueIdOption, outputOption); + }, serviceHealthIssueIdOption, fileOption, outputOption); return command; } /// @@ -77,16 +79,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function incidentReport - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Admin/ServiceAnnouncement/Issues/Item/ServiceHealthIssueRequestBuilder.cs b/src/generated/Admin/ServiceAnnouncement/Issues/Item/ServiceHealthIssueRequestBuilder.cs index 87201059fcd..fd2f789470c 100644 --- a/src/generated/Admin/ServiceAnnouncement/Issues/Item/ServiceHealthIssueRequestBuilder.cs +++ b/src/generated/Admin/ServiceAnnouncement/Issues/Item/ServiceHealthIssueRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,15 +27,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "A collection of service issues for tenant. This property is a contained navigation property, it is nullable and readonly."; // Create options for all the parameters - var serviceHealthIssueIdOption = new Option("--servicehealthissue-id", description: "key: id of serviceHealthIssue") { + var serviceHealthIssueIdOption = new Option("--service-health-issue-id", description: "key: id of serviceHealthIssue") { }; serviceHealthIssueIdOption.IsRequired = true; command.AddOption(serviceHealthIssueIdOption); - command.SetHandler(async (string serviceHealthIssueId) => { + command.SetHandler(async (string serviceHealthIssueId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, serviceHealthIssueIdOption); return command; @@ -47,7 +46,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "A collection of service issues for tenant. This property is a contained navigation property, it is nullable and readonly."; // Create options for all the parameters - var serviceHealthIssueIdOption = new Option("--servicehealthissue-id", description: "key: id of serviceHealthIssue") { + var serviceHealthIssueIdOption = new Option("--service-health-issue-id", description: "key: id of serviceHealthIssue") { }; serviceHealthIssueIdOption.IsRequired = true; command.AddOption(serviceHealthIssueIdOption); @@ -61,20 +60,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string serviceHealthIssueId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string serviceHealthIssueId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, serviceHealthIssueIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, serviceHealthIssueIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "A collection of service issues for tenant. This property is a contained navigation property, it is nullable and readonly."; // Create options for all the parameters - var serviceHealthIssueIdOption = new Option("--servicehealthissue-id", description: "key: id of serviceHealthIssue") { + var serviceHealthIssueIdOption = new Option("--service-health-issue-id", description: "key: id of serviceHealthIssue") { }; serviceHealthIssueIdOption.IsRequired = true; command.AddOption(serviceHealthIssueIdOption); @@ -92,14 +90,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string serviceHealthIssueId, string body) => { + command.SetHandler(async (string serviceHealthIssueId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, serviceHealthIssueIdOption, bodyOption); return command; @@ -172,47 +169,11 @@ public RequestInformation CreatePatchRequestInformation(ServiceHealthIssue body, return requestInfo; } /// - /// A collection of service issues for tenant. This property is a contained navigation property, it is nullable and readonly. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of service issues for tenant. This property is a contained navigation property, it is nullable and readonly. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \admin\serviceAnnouncement\issues\{serviceHealthIssue-id}\microsoft.graph.incidentReport() /// public IncidentReportRequestBuilder IncidentReport() { return new IncidentReportRequestBuilder(PathParameters, RequestAdapter); } - /// - /// A collection of service issues for tenant. This property is a contained navigation property, it is nullable and readonly. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ServiceHealthIssue model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of service issues for tenant. This property is a contained navigation property, it is nullable and readonly. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Admin/ServiceAnnouncement/Messages/Archive/ArchiveRequestBuilder.cs b/src/generated/Admin/ServiceAnnouncement/Messages/Archive/ArchiveRequestBuilder.cs index ffa50cc69f6..506b5e378ef 100644 --- a/src/generated/Admin/ServiceAnnouncement/Messages/Archive/ArchiveRequestBuilder.cs +++ b/src/generated/Admin/ServiceAnnouncement/Messages/Archive/ArchiveRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +29,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteBoolValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +76,5 @@ public RequestInformation CreatePostRequestInformation(ArchiveRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action archive - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ArchiveRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Admin/ServiceAnnouncement/Messages/Favorite/FavoriteRequestBuilder.cs b/src/generated/Admin/ServiceAnnouncement/Messages/Favorite/FavoriteRequestBuilder.cs index 4f98eb5e943..baea6e839f7 100644 --- a/src/generated/Admin/ServiceAnnouncement/Messages/Favorite/FavoriteRequestBuilder.cs +++ b/src/generated/Admin/ServiceAnnouncement/Messages/Favorite/FavoriteRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +29,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteBoolValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +76,5 @@ public RequestInformation CreatePostRequestInformation(FavoriteRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action favorite - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(FavoriteRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Admin/ServiceAnnouncement/Messages/Item/Attachments/AttachmentsRequestBuilder.cs b/src/generated/Admin/ServiceAnnouncement/Messages/Item/Attachments/AttachmentsRequestBuilder.cs index a7098d722d2..5ea6548ce49 100644 --- a/src/generated/Admin/ServiceAnnouncement/Messages/Item/Attachments/AttachmentsRequestBuilder.cs +++ b/src/generated/Admin/ServiceAnnouncement/Messages/Item/Attachments/AttachmentsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,22 +22,21 @@ public class AttachmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ServiceAnnouncementAttachmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// - /// Create new navigation property to attachments for admin + /// A collection of serviceAnnouncementAttachments. /// public Command BuildCreateCommand() { var command = new Command("create"); - command.Description = "Create new navigation property to attachments for admin"; + command.Description = "A collection of serviceAnnouncementAttachments."; // Create options for all the parameters - var serviceUpdateMessageIdOption = new Option("--serviceupdatemessage-id", description: "key: id of serviceUpdateMessage") { + var serviceUpdateMessageIdOption = new Option("--service-update-message-id", description: "key: id of serviceUpdateMessage") { }; serviceUpdateMessageIdOption.IsRequired = true; command.AddOption(serviceUpdateMessageIdOption); @@ -45,31 +44,30 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string serviceUpdateMessageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string serviceUpdateMessageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, serviceUpdateMessageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, serviceUpdateMessageIdOption, bodyOption, outputOption); return command; } /// - /// Get attachments from admin + /// A collection of serviceAnnouncementAttachments. /// public Command BuildListCommand() { var command = new Command("list"); - command.Description = "Get attachments from admin"; + command.Description = "A collection of serviceAnnouncementAttachments."; // Create options for all the parameters - var serviceUpdateMessageIdOption = new Option("--serviceupdatemessage-id", description: "key: id of serviceUpdateMessage") { + var serviceUpdateMessageIdOption = new Option("--service-update-message-id", description: "key: id of serviceUpdateMessage") { }; serviceUpdateMessageIdOption.IsRequired = true; command.AddOption(serviceUpdateMessageIdOption); @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string serviceUpdateMessageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string serviceUpdateMessageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, serviceUpdateMessageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, serviceUpdateMessageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -144,7 +141,7 @@ public AttachmentsRequestBuilder(Dictionary pathParameters, IReq RequestAdapter = requestAdapter; } /// - /// Get attachments from admin + /// A collection of serviceAnnouncementAttachments. /// Request headers /// Request options /// Request query parameters @@ -165,7 +162,7 @@ public RequestInformation CreateGetRequestInformation(Action return requestInfo; } /// - /// Create new navigation property to attachments for admin + /// A collection of serviceAnnouncementAttachments. /// /// Request headers /// Request options @@ -182,32 +179,7 @@ public RequestInformation CreatePostRequestInformation(ServiceAnnouncementAttach requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get attachments from admin - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to attachments for admin - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ServiceAnnouncementAttachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Get attachments from admin + /// A collection of serviceAnnouncementAttachments. public class GetQueryParameters : QueryParametersBase { /// Include count of items public bool? Count { get; set; } diff --git a/src/generated/Admin/ServiceAnnouncement/Messages/Item/Attachments/Item/Content/ContentRequestBuilder.cs b/src/generated/Admin/ServiceAnnouncement/Messages/Item/Attachments/Item/Content/ContentRequestBuilder.cs index c31e8f3a180..1e1c67af1db 100644 --- a/src/generated/Admin/ServiceAnnouncement/Messages/Item/Attachments/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Admin/ServiceAnnouncement/Messages/Item/Attachments/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,32 +25,34 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get media content for the navigation property attachments from admin"; // Create options for all the parameters - var serviceUpdateMessageIdOption = new Option("--serviceupdatemessage-id", description: "key: id of serviceUpdateMessage") { + var serviceUpdateMessageIdOption = new Option("--service-update-message-id", description: "key: id of serviceUpdateMessage") { }; serviceUpdateMessageIdOption.IsRequired = true; command.AddOption(serviceUpdateMessageIdOption); - var serviceAnnouncementAttachmentIdOption = new Option("--serviceannouncementattachment-id", description: "key: id of serviceAnnouncementAttachment") { + var serviceAnnouncementAttachmentIdOption = new Option("--service-announcement-attachment-id", description: "key: id of serviceAnnouncementAttachment") { }; serviceAnnouncementAttachmentIdOption.IsRequired = true; command.AddOption(serviceAnnouncementAttachmentIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string serviceUpdateMessageId, string serviceAnnouncementAttachmentId, FileInfo output) => { + command.SetHandler(async (string serviceUpdateMessageId, string serviceAnnouncementAttachmentId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, serviceUpdateMessageIdOption, serviceAnnouncementAttachmentIdOption, outputOption); + }, serviceUpdateMessageIdOption, serviceAnnouncementAttachmentIdOption, fileOption, outputOption); return command; } /// @@ -60,11 +62,11 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "Update media content for the navigation property attachments in admin"; // Create options for all the parameters - var serviceUpdateMessageIdOption = new Option("--serviceupdatemessage-id", description: "key: id of serviceUpdateMessage") { + var serviceUpdateMessageIdOption = new Option("--service-update-message-id", description: "key: id of serviceUpdateMessage") { }; serviceUpdateMessageIdOption.IsRequired = true; command.AddOption(serviceUpdateMessageIdOption); - var serviceAnnouncementAttachmentIdOption = new Option("--serviceannouncementattachment-id", description: "key: id of serviceAnnouncementAttachment") { + var serviceAnnouncementAttachmentIdOption = new Option("--service-announcement-attachment-id", description: "key: id of serviceAnnouncementAttachment") { }; serviceAnnouncementAttachmentIdOption.IsRequired = true; command.AddOption(serviceAnnouncementAttachmentIdOption); @@ -72,12 +74,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string serviceUpdateMessageId, string serviceAnnouncementAttachmentId, FileInfo file) => { + command.SetHandler(async (string serviceUpdateMessageId, string serviceAnnouncementAttachmentId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, serviceUpdateMessageIdOption, serviceAnnouncementAttachmentIdOption, bodyOption); return command; @@ -128,29 +129,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property attachments from admin - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property attachments in admin - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Admin/ServiceAnnouncement/Messages/Item/Attachments/Item/ServiceAnnouncementAttachmentRequestBuilder.cs b/src/generated/Admin/ServiceAnnouncement/Messages/Item/Attachments/Item/ServiceAnnouncementAttachmentRequestBuilder.cs index 91f1dca4c8e..e63bbb47758 100644 --- a/src/generated/Admin/ServiceAnnouncement/Messages/Item/Attachments/Item/ServiceAnnouncementAttachmentRequestBuilder.cs +++ b/src/generated/Admin/ServiceAnnouncement/Messages/Item/Attachments/Item/ServiceAnnouncementAttachmentRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,41 +28,40 @@ public Command BuildContentCommand() { return command; } /// - /// Delete navigation property attachments for admin + /// A collection of serviceAnnouncementAttachments. /// public Command BuildDeleteCommand() { var command = new Command("delete"); - command.Description = "Delete navigation property attachments for admin"; + command.Description = "A collection of serviceAnnouncementAttachments."; // Create options for all the parameters - var serviceUpdateMessageIdOption = new Option("--serviceupdatemessage-id", description: "key: id of serviceUpdateMessage") { + var serviceUpdateMessageIdOption = new Option("--service-update-message-id", description: "key: id of serviceUpdateMessage") { }; serviceUpdateMessageIdOption.IsRequired = true; command.AddOption(serviceUpdateMessageIdOption); - var serviceAnnouncementAttachmentIdOption = new Option("--serviceannouncementattachment-id", description: "key: id of serviceAnnouncementAttachment") { + var serviceAnnouncementAttachmentIdOption = new Option("--service-announcement-attachment-id", description: "key: id of serviceAnnouncementAttachment") { }; serviceAnnouncementAttachmentIdOption.IsRequired = true; command.AddOption(serviceAnnouncementAttachmentIdOption); - command.SetHandler(async (string serviceUpdateMessageId, string serviceAnnouncementAttachmentId) => { + command.SetHandler(async (string serviceUpdateMessageId, string serviceAnnouncementAttachmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, serviceUpdateMessageIdOption, serviceAnnouncementAttachmentIdOption); return command; } /// - /// Get attachments from admin + /// A collection of serviceAnnouncementAttachments. /// public Command BuildGetCommand() { var command = new Command("get"); - command.Description = "Get attachments from admin"; + command.Description = "A collection of serviceAnnouncementAttachments."; // Create options for all the parameters - var serviceUpdateMessageIdOption = new Option("--serviceupdatemessage-id", description: "key: id of serviceUpdateMessage") { + var serviceUpdateMessageIdOption = new Option("--service-update-message-id", description: "key: id of serviceUpdateMessage") { }; serviceUpdateMessageIdOption.IsRequired = true; command.AddOption(serviceUpdateMessageIdOption); - var serviceAnnouncementAttachmentIdOption = new Option("--serviceannouncementattachment-id", description: "key: id of serviceAnnouncementAttachment") { + var serviceAnnouncementAttachmentIdOption = new Option("--service-announcement-attachment-id", description: "key: id of serviceAnnouncementAttachment") { }; serviceAnnouncementAttachmentIdOption.IsRequired = true; command.AddOption(serviceAnnouncementAttachmentIdOption); @@ -76,34 +75,33 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string serviceUpdateMessageId, string serviceAnnouncementAttachmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string serviceUpdateMessageId, string serviceAnnouncementAttachmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, serviceUpdateMessageIdOption, serviceAnnouncementAttachmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, serviceUpdateMessageIdOption, serviceAnnouncementAttachmentIdOption, selectOption, expandOption, outputOption); return command; } /// - /// Update the navigation property attachments in admin + /// A collection of serviceAnnouncementAttachments. /// public Command BuildPatchCommand() { var command = new Command("patch"); - command.Description = "Update the navigation property attachments in admin"; + command.Description = "A collection of serviceAnnouncementAttachments."; // Create options for all the parameters - var serviceUpdateMessageIdOption = new Option("--serviceupdatemessage-id", description: "key: id of serviceUpdateMessage") { + var serviceUpdateMessageIdOption = new Option("--service-update-message-id", description: "key: id of serviceUpdateMessage") { }; serviceUpdateMessageIdOption.IsRequired = true; command.AddOption(serviceUpdateMessageIdOption); - var serviceAnnouncementAttachmentIdOption = new Option("--serviceannouncementattachment-id", description: "key: id of serviceAnnouncementAttachment") { + var serviceAnnouncementAttachmentIdOption = new Option("--service-announcement-attachment-id", description: "key: id of serviceAnnouncementAttachment") { }; serviceAnnouncementAttachmentIdOption.IsRequired = true; command.AddOption(serviceAnnouncementAttachmentIdOption); @@ -111,14 +109,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string serviceUpdateMessageId, string serviceAnnouncementAttachmentId, string body) => { + command.SetHandler(async (string serviceUpdateMessageId, string serviceAnnouncementAttachmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, serviceUpdateMessageIdOption, serviceAnnouncementAttachmentIdOption, bodyOption); return command; @@ -137,7 +134,7 @@ public ServiceAnnouncementAttachmentRequestBuilder(Dictionary pa RequestAdapter = requestAdapter; } /// - /// Delete navigation property attachments for admin + /// A collection of serviceAnnouncementAttachments. /// Request headers /// Request options /// @@ -152,7 +149,7 @@ public RequestInformation CreateDeleteRequestInformation(Action - /// Get attachments from admin + /// A collection of serviceAnnouncementAttachments. /// Request headers /// Request options /// Request query parameters @@ -173,7 +170,7 @@ public RequestInformation CreateGetRequestInformation(Action return requestInfo; } /// - /// Update the navigation property attachments in admin + /// A collection of serviceAnnouncementAttachments. /// /// Request headers /// Request options @@ -190,43 +187,7 @@ public RequestInformation CreatePatchRequestInformation(ServiceAnnouncementAttac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property attachments for admin - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get attachments from admin - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property attachments in admin - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ServiceAnnouncementAttachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// Get attachments from admin + /// A collection of serviceAnnouncementAttachments. public class GetQueryParameters : QueryParametersBase { /// Expand related entities public string[] Expand { get; set; } diff --git a/src/generated/Admin/ServiceAnnouncement/Messages/Item/AttachmentsArchive/AttachmentsArchiveRequestBuilder.cs b/src/generated/Admin/ServiceAnnouncement/Messages/Item/AttachmentsArchive/AttachmentsArchiveRequestBuilder.cs index a4c4d7e429b..542b04dc447 100644 --- a/src/generated/Admin/ServiceAnnouncement/Messages/Item/AttachmentsArchive/AttachmentsArchiveRequestBuilder.cs +++ b/src/generated/Admin/ServiceAnnouncement/Messages/Item/AttachmentsArchive/AttachmentsArchiveRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,28 +25,30 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get media content for the navigation property messages from admin"; // Create options for all the parameters - var serviceUpdateMessageIdOption = new Option("--serviceupdatemessage-id", description: "key: id of serviceUpdateMessage") { + var serviceUpdateMessageIdOption = new Option("--service-update-message-id", description: "key: id of serviceUpdateMessage") { }; serviceUpdateMessageIdOption.IsRequired = true; command.AddOption(serviceUpdateMessageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string serviceUpdateMessageId, FileInfo output) => { + command.SetHandler(async (string serviceUpdateMessageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, serviceUpdateMessageIdOption, outputOption); + }, serviceUpdateMessageIdOption, fileOption, outputOption); return command; } /// @@ -56,7 +58,7 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "Update media content for the navigation property messages in admin"; // Create options for all the parameters - var serviceUpdateMessageIdOption = new Option("--serviceupdatemessage-id", description: "key: id of serviceUpdateMessage") { + var serviceUpdateMessageIdOption = new Option("--service-update-message-id", description: "key: id of serviceUpdateMessage") { }; serviceUpdateMessageIdOption.IsRequired = true; command.AddOption(serviceUpdateMessageIdOption); @@ -64,12 +66,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string serviceUpdateMessageId, FileInfo file) => { + command.SetHandler(async (string serviceUpdateMessageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, serviceUpdateMessageIdOption, bodyOption); return command; @@ -120,29 +121,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property messages from admin - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property messages in admin - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Admin/ServiceAnnouncement/Messages/Item/ServiceUpdateMessageRequestBuilder.cs b/src/generated/Admin/ServiceAnnouncement/Messages/Item/ServiceUpdateMessageRequestBuilder.cs index 845d385a9a4..2267913f57e 100644 --- a/src/generated/Admin/ServiceAnnouncement/Messages/Item/ServiceUpdateMessageRequestBuilder.cs +++ b/src/generated/Admin/ServiceAnnouncement/Messages/Item/ServiceUpdateMessageRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,6 +31,9 @@ public Command BuildAttachmentsArchiveCommand() { public Command BuildAttachmentsCommand() { var command = new Command("attachments"); var builder = new ApiSdk.Admin.ServiceAnnouncement.Messages.Item.Attachments.AttachmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -42,15 +45,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "A collection of service messages for tenant. This property is a contained navigation property, it is nullable and readonly."; // Create options for all the parameters - var serviceUpdateMessageIdOption = new Option("--serviceupdatemessage-id", description: "key: id of serviceUpdateMessage") { + var serviceUpdateMessageIdOption = new Option("--service-update-message-id", description: "key: id of serviceUpdateMessage") { }; serviceUpdateMessageIdOption.IsRequired = true; command.AddOption(serviceUpdateMessageIdOption); - command.SetHandler(async (string serviceUpdateMessageId) => { + command.SetHandler(async (string serviceUpdateMessageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, serviceUpdateMessageIdOption); return command; @@ -62,7 +64,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "A collection of service messages for tenant. This property is a contained navigation property, it is nullable and readonly."; // Create options for all the parameters - var serviceUpdateMessageIdOption = new Option("--serviceupdatemessage-id", description: "key: id of serviceUpdateMessage") { + var serviceUpdateMessageIdOption = new Option("--service-update-message-id", description: "key: id of serviceUpdateMessage") { }; serviceUpdateMessageIdOption.IsRequired = true; command.AddOption(serviceUpdateMessageIdOption); @@ -76,20 +78,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string serviceUpdateMessageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string serviceUpdateMessageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, serviceUpdateMessageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, serviceUpdateMessageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,7 +100,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "A collection of service messages for tenant. This property is a contained navigation property, it is nullable and readonly."; // Create options for all the parameters - var serviceUpdateMessageIdOption = new Option("--serviceupdatemessage-id", description: "key: id of serviceUpdateMessage") { + var serviceUpdateMessageIdOption = new Option("--service-update-message-id", description: "key: id of serviceUpdateMessage") { }; serviceUpdateMessageIdOption.IsRequired = true; command.AddOption(serviceUpdateMessageIdOption); @@ -107,14 +108,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string serviceUpdateMessageId, string body) => { + command.SetHandler(async (string serviceUpdateMessageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, serviceUpdateMessageIdOption, bodyOption); return command; @@ -186,42 +186,6 @@ public RequestInformation CreatePatchRequestInformation(ServiceUpdateMessage bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of service messages for tenant. This property is a contained navigation property, it is nullable and readonly. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of service messages for tenant. This property is a contained navigation property, it is nullable and readonly. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of service messages for tenant. This property is a contained navigation property, it is nullable and readonly. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ServiceUpdateMessage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of service messages for tenant. This property is a contained navigation property, it is nullable and readonly. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Admin/ServiceAnnouncement/Messages/MarkRead/MarkReadRequestBuilder.cs b/src/generated/Admin/ServiceAnnouncement/Messages/MarkRead/MarkReadRequestBuilder.cs index bba59d8e8be..c65d0460c97 100644 --- a/src/generated/Admin/ServiceAnnouncement/Messages/MarkRead/MarkReadRequestBuilder.cs +++ b/src/generated/Admin/ServiceAnnouncement/Messages/MarkRead/MarkReadRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +29,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteBoolValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +76,5 @@ public RequestInformation CreatePostRequestInformation(MarkReadRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action markRead - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MarkReadRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Admin/ServiceAnnouncement/Messages/MarkUnread/MarkUnreadRequestBuilder.cs b/src/generated/Admin/ServiceAnnouncement/Messages/MarkUnread/MarkUnreadRequestBuilder.cs index ed3e416a5d7..99df182728d 100644 --- a/src/generated/Admin/ServiceAnnouncement/Messages/MarkUnread/MarkUnreadRequestBuilder.cs +++ b/src/generated/Admin/ServiceAnnouncement/Messages/MarkUnread/MarkUnreadRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +29,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteBoolValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +76,5 @@ public RequestInformation CreatePostRequestInformation(MarkUnreadRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action markUnread - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MarkUnreadRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Admin/ServiceAnnouncement/Messages/MessagesRequestBuilder.cs b/src/generated/Admin/ServiceAnnouncement/Messages/MessagesRequestBuilder.cs index f944af161af..16e2a069605 100644 --- a/src/generated/Admin/ServiceAnnouncement/Messages/MessagesRequestBuilder.cs +++ b/src/generated/Admin/ServiceAnnouncement/Messages/MessagesRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,13 +34,12 @@ public Command BuildArchiveCommand() { } public List BuildCommand() { var builder = new ServiceUpdateMessageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAttachmentsArchiveCommand(), - builder.BuildAttachmentsCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAttachmentsArchiveCommand()); + commands.Add(builder.BuildAttachmentsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } public Command BuildFavoriteCommand() { @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -130,15 +132,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildMarkReadCommand() { @@ -217,31 +214,6 @@ public RequestInformation CreatePostRequestInformation(ServiceUpdateMessage body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of service messages for tenant. This property is a contained navigation property, it is nullable and readonly. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of service messages for tenant. This property is a contained navigation property, it is nullable and readonly. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ServiceUpdateMessage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of service messages for tenant. This property is a contained navigation property, it is nullable and readonly. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Admin/ServiceAnnouncement/Messages/Unarchive/UnarchiveRequestBuilder.cs b/src/generated/Admin/ServiceAnnouncement/Messages/Unarchive/UnarchiveRequestBuilder.cs index 2c14fa15b05..5e641569835 100644 --- a/src/generated/Admin/ServiceAnnouncement/Messages/Unarchive/UnarchiveRequestBuilder.cs +++ b/src/generated/Admin/ServiceAnnouncement/Messages/Unarchive/UnarchiveRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +29,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteBoolValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +76,5 @@ public RequestInformation CreatePostRequestInformation(UnarchiveRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action unarchive - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UnarchiveRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Admin/ServiceAnnouncement/Messages/Unfavorite/UnfavoriteRequestBuilder.cs b/src/generated/Admin/ServiceAnnouncement/Messages/Unfavorite/UnfavoriteRequestBuilder.cs index f5794b7007c..00ecb68988b 100644 --- a/src/generated/Admin/ServiceAnnouncement/Messages/Unfavorite/UnfavoriteRequestBuilder.cs +++ b/src/generated/Admin/ServiceAnnouncement/Messages/Unfavorite/UnfavoriteRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +29,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteBoolValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +76,5 @@ public RequestInformation CreatePostRequestInformation(UnfavoriteRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action unfavorite - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UnfavoriteRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Admin/ServiceAnnouncement/ServiceAnnouncementRequestBuilder.cs b/src/generated/Admin/ServiceAnnouncement/ServiceAnnouncementRequestBuilder.cs index 3d488d67f5e..ddb5f9b5a97 100644 --- a/src/generated/Admin/ServiceAnnouncement/ServiceAnnouncementRequestBuilder.cs +++ b/src/generated/Admin/ServiceAnnouncement/ServiceAnnouncementRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "A container for service communications resources. Read-only."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -55,25 +54,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } public Command BuildHealthOverviewsCommand() { var command = new Command("health-overviews"); var builder = new ApiSdk.Admin.ServiceAnnouncement.HealthOverviews.HealthOverviewsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -81,6 +82,9 @@ public Command BuildHealthOverviewsCommand() { public Command BuildIssuesCommand() { var command = new Command("issues"); var builder = new ApiSdk.Admin.ServiceAnnouncement.Issues.IssuesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -89,6 +93,9 @@ public Command BuildMessagesCommand() { var command = new Command("messages"); var builder = new ApiSdk.Admin.ServiceAnnouncement.Messages.MessagesRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildArchiveCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildFavoriteCommand()); command.AddCommand(builder.BuildListCommand()); @@ -109,14 +116,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -188,42 +194,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A container for service communications resources. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A container for service communications resources. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A container for service communications resources. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.ServiceAnnouncement model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A container for service communications resources. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/AgreementAcceptances/AgreementAcceptancesRequestBuilder.cs b/src/generated/AgreementAcceptances/AgreementAcceptancesRequestBuilder.cs index 428a4a36992..74d25b8c0bd 100644 --- a/src/generated/AgreementAcceptances/AgreementAcceptancesRequestBuilder.cs +++ b/src/generated/AgreementAcceptances/AgreementAcceptancesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AgreementAcceptancesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AgreementAcceptanceRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -73,20 +71,19 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string search, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string search, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { if (!String.IsNullOrEmpty(search)) q.Search = search; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, searchOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, searchOption, selectOption, outputOption); return command; } /// @@ -141,31 +138,6 @@ public RequestInformation CreatePostRequestInformation(AgreementAcceptance body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get entities from agreementAcceptances - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to agreementAcceptances - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AgreementAcceptance model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from agreementAcceptances public class GetQueryParameters : QueryParametersBase { /// Search items by search phrases diff --git a/src/generated/AgreementAcceptances/Item/AgreementAcceptanceRequestBuilder.cs b/src/generated/AgreementAcceptances/Item/AgreementAcceptanceRequestBuilder.cs index ad5bd901649..4b45951a75e 100644 --- a/src/generated/AgreementAcceptances/Item/AgreementAcceptanceRequestBuilder.cs +++ b/src/generated/AgreementAcceptances/Item/AgreementAcceptanceRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete entity from agreementAcceptances"; // Create options for all the parameters - var agreementAcceptanceIdOption = new Option("--agreementacceptance-id", description: "key: id of agreementAcceptance") { + var agreementAcceptanceIdOption = new Option("--agreement-acceptance-id", description: "key: id of agreementAcceptance") { }; agreementAcceptanceIdOption.IsRequired = true; command.AddOption(agreementAcceptanceIdOption); - command.SetHandler(async (string agreementAcceptanceId) => { + command.SetHandler(async (string agreementAcceptanceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, agreementAcceptanceIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get entity from agreementAcceptances by key"; // Create options for all the parameters - var agreementAcceptanceIdOption = new Option("--agreementacceptance-id", description: "key: id of agreementAcceptance") { + var agreementAcceptanceIdOption = new Option("--agreement-acceptance-id", description: "key: id of agreementAcceptance") { }; agreementAcceptanceIdOption.IsRequired = true; command.AddOption(agreementAcceptanceIdOption); @@ -55,19 +54,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string agreementAcceptanceId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string agreementAcceptanceId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, agreementAcceptanceIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, agreementAcceptanceIdOption, selectOption, outputOption); return command; } /// @@ -77,7 +75,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update entity in agreementAcceptances"; // Create options for all the parameters - var agreementAcceptanceIdOption = new Option("--agreementacceptance-id", description: "key: id of agreementAcceptance") { + var agreementAcceptanceIdOption = new Option("--agreement-acceptance-id", description: "key: id of agreementAcceptance") { }; agreementAcceptanceIdOption.IsRequired = true; command.AddOption(agreementAcceptanceIdOption); @@ -85,14 +83,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string agreementAcceptanceId, string body) => { + command.SetHandler(async (string agreementAcceptanceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, agreementAcceptanceIdOption, bodyOption); return command; @@ -164,42 +161,6 @@ public RequestInformation CreatePatchRequestInformation(AgreementAcceptance body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from agreementAcceptances - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from agreementAcceptances by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in agreementAcceptances - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AgreementAcceptance model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from agreementAcceptances by key public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Agreements/AgreementsRequestBuilder.cs b/src/generated/Agreements/AgreementsRequestBuilder.cs index 453600e478a..318e5a61715 100644 --- a/src/generated/Agreements/AgreementsRequestBuilder.cs +++ b/src/generated/Agreements/AgreementsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class AgreementsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AgreementRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptancesCommand(), - builder.BuildDeleteCommand(), - builder.BuildFileCommand(), - builder.BuildFilesCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptancesCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFileCommand()); + commands.Add(builder.BuildFilesCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -43,21 +42,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -76,20 +74,19 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string search, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string search, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { if (!String.IsNullOrEmpty(search)) q.Search = search; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, searchOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, searchOption, selectOption, outputOption); return command; } /// @@ -144,31 +141,6 @@ public RequestInformation CreatePostRequestInformation(Agreement body, Action - /// Get entities from agreements - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to agreements - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Agreement model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from agreements public class GetQueryParameters : QueryParametersBase { /// Search items by search phrases diff --git a/src/generated/Agreements/Item/Acceptances/AcceptancesRequestBuilder.cs b/src/generated/Agreements/Item/Acceptances/AcceptancesRequestBuilder.cs index 4f88202b76a..f502940c50b 100644 --- a/src/generated/Agreements/Item/Acceptances/AcceptancesRequestBuilder.cs +++ b/src/generated/Agreements/Item/Acceptances/AcceptancesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AcceptancesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AgreementAcceptanceRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string agreementId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string agreementId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, agreementIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, agreementIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string agreementId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string agreementId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, agreementIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, agreementIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(AgreementAcceptance body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Information about acceptances of this agreement. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Information about acceptances of this agreement. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AgreementAcceptance model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Information about acceptances of this agreement. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Agreements/Item/Acceptances/Item/AgreementAcceptanceRequestBuilder.cs b/src/generated/Agreements/Item/Acceptances/Item/AgreementAcceptanceRequestBuilder.cs index 33c14adfdc1..6cd0529372f 100644 --- a/src/generated/Agreements/Item/Acceptances/Item/AgreementAcceptanceRequestBuilder.cs +++ b/src/generated/Agreements/Item/Acceptances/Item/AgreementAcceptanceRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; agreementIdOption.IsRequired = true; command.AddOption(agreementIdOption); - var agreementAcceptanceIdOption = new Option("--agreementacceptance-id", description: "key: id of agreementAcceptance") { + var agreementAcceptanceIdOption = new Option("--agreement-acceptance-id", description: "key: id of agreementAcceptance") { }; agreementAcceptanceIdOption.IsRequired = true; command.AddOption(agreementAcceptanceIdOption); - command.SetHandler(async (string agreementId, string agreementAcceptanceId) => { + command.SetHandler(async (string agreementId, string agreementAcceptanceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, agreementIdOption, agreementAcceptanceIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; agreementIdOption.IsRequired = true; command.AddOption(agreementIdOption); - var agreementAcceptanceIdOption = new Option("--agreementacceptance-id", description: "key: id of agreementAcceptance") { + var agreementAcceptanceIdOption = new Option("--agreement-acceptance-id", description: "key: id of agreementAcceptance") { }; agreementAcceptanceIdOption.IsRequired = true; command.AddOption(agreementAcceptanceIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string agreementId, string agreementAcceptanceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string agreementId, string agreementAcceptanceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, agreementIdOption, agreementAcceptanceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, agreementIdOption, agreementAcceptanceIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; agreementIdOption.IsRequired = true; command.AddOption(agreementIdOption); - var agreementAcceptanceIdOption = new Option("--agreementacceptance-id", description: "key: id of agreementAcceptance") { + var agreementAcceptanceIdOption = new Option("--agreement-acceptance-id", description: "key: id of agreementAcceptance") { }; agreementAcceptanceIdOption.IsRequired = true; command.AddOption(agreementAcceptanceIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string agreementId, string agreementAcceptanceId, string body) => { + command.SetHandler(async (string agreementId, string agreementAcceptanceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, agreementIdOption, agreementAcceptanceIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(AgreementAcceptance body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Information about acceptances of this agreement. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Information about acceptances of this agreement. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Information about acceptances of this agreement. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AgreementAcceptance model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Information about acceptances of this agreement. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Agreements/Item/AgreementRequestBuilder.cs b/src/generated/Agreements/Item/AgreementRequestBuilder.cs index 2b519a491d3..6dd67d27363 100644 --- a/src/generated/Agreements/Item/AgreementRequestBuilder.cs +++ b/src/generated/Agreements/Item/AgreementRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,6 +25,9 @@ public class AgreementRequestBuilder { public Command BuildAcceptancesCommand() { var command = new Command("acceptances"); var builder = new ApiSdk.Agreements.Item.Acceptances.AcceptancesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -40,11 +43,10 @@ public Command BuildDeleteCommand() { }; agreementIdOption.IsRequired = true; command.AddOption(agreementIdOption); - command.SetHandler(async (string agreementId) => { + command.SetHandler(async (string agreementId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, agreementIdOption); return command; @@ -61,6 +63,9 @@ public Command BuildFileCommand() { public Command BuildFilesCommand() { var command = new Command("files"); var builder = new ApiSdk.Agreements.Item.Files.FilesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -81,19 +86,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string agreementId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string agreementId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, agreementIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, agreementIdOption, selectOption, outputOption); return command; } /// @@ -111,14 +115,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string agreementId, string body) => { + command.SetHandler(async (string agreementId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, agreementIdOption, bodyOption); return command; @@ -190,42 +193,6 @@ public RequestInformation CreatePatchRequestInformation(Agreement body, Action - /// Delete entity from agreements - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from agreements by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in agreements - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Agreement model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from agreements by key public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Agreements/Item/File/FileRequestBuilder.cs b/src/generated/Agreements/Item/File/FileRequestBuilder.cs index f606a319c46..6bbe0336436 100644 --- a/src/generated/Agreements/Item/File/FileRequestBuilder.cs +++ b/src/generated/Agreements/Item/File/FileRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,11 +31,10 @@ public Command BuildDeleteCommand() { }; agreementIdOption.IsRequired = true; command.AddOption(agreementIdOption); - command.SetHandler(async (string agreementId) => { + command.SetHandler(async (string agreementId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, agreementIdOption); return command; @@ -61,25 +60,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string agreementId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string agreementId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, agreementIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, agreementIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLocalizationsCommand() { var command = new Command("localizations"); var builder = new ApiSdk.Agreements.Item.File.Localizations.LocalizationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -99,14 +100,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string agreementId, string body) => { + command.SetHandler(async (string agreementId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, agreementIdOption, bodyOption); return command; @@ -178,42 +178,6 @@ public RequestInformation CreatePatchRequestInformation(AgreementFile body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Default PDF linked to this agreement. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Default PDF linked to this agreement. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Default PDF linked to this agreement. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AgreementFile model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Default PDF linked to this agreement. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Agreements/Item/File/Localizations/Item/AgreementFileLocalizationRequestBuilder.cs b/src/generated/Agreements/Item/File/Localizations/Item/AgreementFileLocalizationRequestBuilder.cs index 7243d62b921..9460c71268f 100644 --- a/src/generated/Agreements/Item/File/Localizations/Item/AgreementFileLocalizationRequestBuilder.cs +++ b/src/generated/Agreements/Item/File/Localizations/Item/AgreementFileLocalizationRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,15 +31,14 @@ public Command BuildDeleteCommand() { }; agreementIdOption.IsRequired = true; command.AddOption(agreementIdOption); - var agreementFileLocalizationIdOption = new Option("--agreementfilelocalization-id", description: "key: id of agreementFileLocalization") { + var agreementFileLocalizationIdOption = new Option("--agreement-file-localization-id", description: "key: id of agreementFileLocalization") { }; agreementFileLocalizationIdOption.IsRequired = true; command.AddOption(agreementFileLocalizationIdOption); - command.SetHandler(async (string agreementId, string agreementFileLocalizationId) => { + command.SetHandler(async (string agreementId, string agreementFileLocalizationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, agreementIdOption, agreementFileLocalizationIdOption); return command; @@ -55,7 +54,7 @@ public Command BuildGetCommand() { }; agreementIdOption.IsRequired = true; command.AddOption(agreementIdOption); - var agreementFileLocalizationIdOption = new Option("--agreementfilelocalization-id", description: "key: id of agreementFileLocalization") { + var agreementFileLocalizationIdOption = new Option("--agreement-file-localization-id", description: "key: id of agreementFileLocalization") { }; agreementFileLocalizationIdOption.IsRequired = true; command.AddOption(agreementFileLocalizationIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string agreementId, string agreementFileLocalizationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string agreementId, string agreementFileLocalizationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, agreementIdOption, agreementFileLocalizationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, agreementIdOption, agreementFileLocalizationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -96,7 +94,7 @@ public Command BuildPatchCommand() { }; agreementIdOption.IsRequired = true; command.AddOption(agreementIdOption); - var agreementFileLocalizationIdOption = new Option("--agreementfilelocalization-id", description: "key: id of agreementFileLocalization") { + var agreementFileLocalizationIdOption = new Option("--agreement-file-localization-id", description: "key: id of agreementFileLocalization") { }; agreementFileLocalizationIdOption.IsRequired = true; command.AddOption(agreementFileLocalizationIdOption); @@ -104,14 +102,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string agreementId, string agreementFileLocalizationId, string body) => { + command.SetHandler(async (string agreementId, string agreementFileLocalizationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, agreementIdOption, agreementFileLocalizationIdOption, bodyOption); return command; @@ -119,6 +116,9 @@ public Command BuildPatchCommand() { public Command BuildVersionsCommand() { var command = new Command("versions"); var builder = new ApiSdk.Agreements.Item.File.Localizations.Item.Versions.VersionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -190,42 +190,6 @@ public RequestInformation CreatePatchRequestInformation(AgreementFileLocalizatio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The localized version of the terms of use agreement files attached to the agreement. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The localized version of the terms of use agreement files attached to the agreement. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The localized version of the terms of use agreement files attached to the agreement. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AgreementFileLocalization model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The localized version of the terms of use agreement files attached to the agreement. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Agreements/Item/File/Localizations/Item/Versions/Item/AgreementFileVersionRequestBuilder.cs b/src/generated/Agreements/Item/File/Localizations/Item/Versions/Item/AgreementFileVersionRequestBuilder.cs index 9b7c6f95c3c..f1fc04b3788 100644 --- a/src/generated/Agreements/Item/File/Localizations/Item/Versions/Item/AgreementFileVersionRequestBuilder.cs +++ b/src/generated/Agreements/Item/File/Localizations/Item/Versions/Item/AgreementFileVersionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; agreementIdOption.IsRequired = true; command.AddOption(agreementIdOption); - var agreementFileLocalizationIdOption = new Option("--agreementfilelocalization-id", description: "key: id of agreementFileLocalization") { + var agreementFileLocalizationIdOption = new Option("--agreement-file-localization-id", description: "key: id of agreementFileLocalization") { }; agreementFileLocalizationIdOption.IsRequired = true; command.AddOption(agreementFileLocalizationIdOption); - var agreementFileVersionIdOption = new Option("--agreementfileversion-id", description: "key: id of agreementFileVersion") { + var agreementFileVersionIdOption = new Option("--agreement-file-version-id", description: "key: id of agreementFileVersion") { }; agreementFileVersionIdOption.IsRequired = true; command.AddOption(agreementFileVersionIdOption); - command.SetHandler(async (string agreementId, string agreementFileLocalizationId, string agreementFileVersionId) => { + command.SetHandler(async (string agreementId, string agreementFileLocalizationId, string agreementFileVersionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, agreementIdOption, agreementFileLocalizationIdOption, agreementFileVersionIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; agreementIdOption.IsRequired = true; command.AddOption(agreementIdOption); - var agreementFileLocalizationIdOption = new Option("--agreementfilelocalization-id", description: "key: id of agreementFileLocalization") { + var agreementFileLocalizationIdOption = new Option("--agreement-file-localization-id", description: "key: id of agreementFileLocalization") { }; agreementFileLocalizationIdOption.IsRequired = true; command.AddOption(agreementFileLocalizationIdOption); - var agreementFileVersionIdOption = new Option("--agreementfileversion-id", description: "key: id of agreementFileVersion") { + var agreementFileVersionIdOption = new Option("--agreement-file-version-id", description: "key: id of agreementFileVersion") { }; agreementFileVersionIdOption.IsRequired = true; command.AddOption(agreementFileVersionIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string agreementId, string agreementFileLocalizationId, string agreementFileVersionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string agreementId, string agreementFileLocalizationId, string agreementFileVersionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, agreementIdOption, agreementFileLocalizationIdOption, agreementFileVersionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, agreementIdOption, agreementFileLocalizationIdOption, agreementFileVersionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; agreementIdOption.IsRequired = true; command.AddOption(agreementIdOption); - var agreementFileLocalizationIdOption = new Option("--agreementfilelocalization-id", description: "key: id of agreementFileLocalization") { + var agreementFileLocalizationIdOption = new Option("--agreement-file-localization-id", description: "key: id of agreementFileLocalization") { }; agreementFileLocalizationIdOption.IsRequired = true; command.AddOption(agreementFileLocalizationIdOption); - var agreementFileVersionIdOption = new Option("--agreementfileversion-id", description: "key: id of agreementFileVersion") { + var agreementFileVersionIdOption = new Option("--agreement-file-version-id", description: "key: id of agreementFileVersion") { }; agreementFileVersionIdOption.IsRequired = true; command.AddOption(agreementFileVersionIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string agreementId, string agreementFileLocalizationId, string agreementFileVersionId, string body) => { + command.SetHandler(async (string agreementId, string agreementFileLocalizationId, string agreementFileVersionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, agreementIdOption, agreementFileLocalizationIdOption, agreementFileVersionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(AgreementFileVersion bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Customized versions of the terms of use agreement in the Azure AD tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Customized versions of the terms of use agreement in the Azure AD tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Customized versions of the terms of use agreement in the Azure AD tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AgreementFileVersion model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Customized versions of the terms of use agreement in the Azure AD tenant. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Agreements/Item/File/Localizations/Item/Versions/VersionsRequestBuilder.cs b/src/generated/Agreements/Item/File/Localizations/Item/Versions/VersionsRequestBuilder.cs index 5d156c12355..f6b2c487155 100644 --- a/src/generated/Agreements/Item/File/Localizations/Item/Versions/VersionsRequestBuilder.cs +++ b/src/generated/Agreements/Item/File/Localizations/Item/Versions/VersionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class VersionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AgreementFileVersionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; agreementIdOption.IsRequired = true; command.AddOption(agreementIdOption); - var agreementFileLocalizationIdOption = new Option("--agreementfilelocalization-id", description: "key: id of agreementFileLocalization") { + var agreementFileLocalizationIdOption = new Option("--agreement-file-localization-id", description: "key: id of agreementFileLocalization") { }; agreementFileLocalizationIdOption.IsRequired = true; command.AddOption(agreementFileLocalizationIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string agreementId, string agreementFileLocalizationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string agreementId, string agreementFileLocalizationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, agreementIdOption, agreementFileLocalizationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, agreementIdOption, agreementFileLocalizationIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; agreementIdOption.IsRequired = true; command.AddOption(agreementIdOption); - var agreementFileLocalizationIdOption = new Option("--agreementfilelocalization-id", description: "key: id of agreementFileLocalization") { + var agreementFileLocalizationIdOption = new Option("--agreement-file-localization-id", description: "key: id of agreementFileLocalization") { }; agreementFileLocalizationIdOption.IsRequired = true; command.AddOption(agreementFileLocalizationIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string agreementId, string agreementFileLocalizationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string agreementId, string agreementFileLocalizationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, agreementIdOption, agreementFileLocalizationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, agreementIdOption, agreementFileLocalizationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(AgreementFileVersion body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Customized versions of the terms of use agreement in the Azure AD tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Customized versions of the terms of use agreement in the Azure AD tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AgreementFileVersion model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Customized versions of the terms of use agreement in the Azure AD tenant. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Agreements/Item/File/Localizations/LocalizationsRequestBuilder.cs b/src/generated/Agreements/Item/File/Localizations/LocalizationsRequestBuilder.cs index bd655878e8b..8b639ab1c01 100644 --- a/src/generated/Agreements/Item/File/Localizations/LocalizationsRequestBuilder.cs +++ b/src/generated/Agreements/Item/File/Localizations/LocalizationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class LocalizationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AgreementFileLocalizationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildVersionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildVersionsCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string agreementId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string agreementId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, agreementIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, agreementIdOption, bodyOption, outputOption); return command; } /// @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string agreementId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string agreementId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, agreementIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, agreementIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(AgreementFileLocalization requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The localized version of the terms of use agreement files attached to the agreement. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The localized version of the terms of use agreement files attached to the agreement. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AgreementFileLocalization model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The localized version of the terms of use agreement files attached to the agreement. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Agreements/Item/Files/FilesRequestBuilder.cs b/src/generated/Agreements/Item/Files/FilesRequestBuilder.cs index 8efcd82c4c7..92103a5a8c9 100644 --- a/src/generated/Agreements/Item/Files/FilesRequestBuilder.cs +++ b/src/generated/Agreements/Item/Files/FilesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class FilesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AgreementFileLocalizationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildVersionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildVersionsCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string agreementId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string agreementId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, agreementIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, agreementIdOption, bodyOption, outputOption); return command; } /// @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string agreementId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string agreementId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, agreementIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, agreementIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(AgreementFileLocalization requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// PDFs linked to this agreement. Note: This property is in the process of being deprecated. Use the file property instead. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// PDFs linked to this agreement. Note: This property is in the process of being deprecated. Use the file property instead. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AgreementFileLocalization model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// PDFs linked to this agreement. Note: This property is in the process of being deprecated. Use the file property instead. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Agreements/Item/Files/Item/AgreementFileLocalizationRequestBuilder.cs b/src/generated/Agreements/Item/Files/Item/AgreementFileLocalizationRequestBuilder.cs index b58008cd78e..2b7ad39f6b2 100644 --- a/src/generated/Agreements/Item/Files/Item/AgreementFileLocalizationRequestBuilder.cs +++ b/src/generated/Agreements/Item/Files/Item/AgreementFileLocalizationRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,15 +31,14 @@ public Command BuildDeleteCommand() { }; agreementIdOption.IsRequired = true; command.AddOption(agreementIdOption); - var agreementFileLocalizationIdOption = new Option("--agreementfilelocalization-id", description: "key: id of agreementFileLocalization") { + var agreementFileLocalizationIdOption = new Option("--agreement-file-localization-id", description: "key: id of agreementFileLocalization") { }; agreementFileLocalizationIdOption.IsRequired = true; command.AddOption(agreementFileLocalizationIdOption); - command.SetHandler(async (string agreementId, string agreementFileLocalizationId) => { + command.SetHandler(async (string agreementId, string agreementFileLocalizationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, agreementIdOption, agreementFileLocalizationIdOption); return command; @@ -55,7 +54,7 @@ public Command BuildGetCommand() { }; agreementIdOption.IsRequired = true; command.AddOption(agreementIdOption); - var agreementFileLocalizationIdOption = new Option("--agreementfilelocalization-id", description: "key: id of agreementFileLocalization") { + var agreementFileLocalizationIdOption = new Option("--agreement-file-localization-id", description: "key: id of agreementFileLocalization") { }; agreementFileLocalizationIdOption.IsRequired = true; command.AddOption(agreementFileLocalizationIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string agreementId, string agreementFileLocalizationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string agreementId, string agreementFileLocalizationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, agreementIdOption, agreementFileLocalizationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, agreementIdOption, agreementFileLocalizationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -96,7 +94,7 @@ public Command BuildPatchCommand() { }; agreementIdOption.IsRequired = true; command.AddOption(agreementIdOption); - var agreementFileLocalizationIdOption = new Option("--agreementfilelocalization-id", description: "key: id of agreementFileLocalization") { + var agreementFileLocalizationIdOption = new Option("--agreement-file-localization-id", description: "key: id of agreementFileLocalization") { }; agreementFileLocalizationIdOption.IsRequired = true; command.AddOption(agreementFileLocalizationIdOption); @@ -104,14 +102,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string agreementId, string agreementFileLocalizationId, string body) => { + command.SetHandler(async (string agreementId, string agreementFileLocalizationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, agreementIdOption, agreementFileLocalizationIdOption, bodyOption); return command; @@ -119,6 +116,9 @@ public Command BuildPatchCommand() { public Command BuildVersionsCommand() { var command = new Command("versions"); var builder = new ApiSdk.Agreements.Item.Files.Item.Versions.VersionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -190,42 +190,6 @@ public RequestInformation CreatePatchRequestInformation(AgreementFileLocalizatio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// PDFs linked to this agreement. Note: This property is in the process of being deprecated. Use the file property instead. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// PDFs linked to this agreement. Note: This property is in the process of being deprecated. Use the file property instead. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// PDFs linked to this agreement. Note: This property is in the process of being deprecated. Use the file property instead. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AgreementFileLocalization model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// PDFs linked to this agreement. Note: This property is in the process of being deprecated. Use the file property instead. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Agreements/Item/Files/Item/Versions/Item/AgreementFileVersionRequestBuilder.cs b/src/generated/Agreements/Item/Files/Item/Versions/Item/AgreementFileVersionRequestBuilder.cs index 0afb51d9eb4..e900023a7ec 100644 --- a/src/generated/Agreements/Item/Files/Item/Versions/Item/AgreementFileVersionRequestBuilder.cs +++ b/src/generated/Agreements/Item/Files/Item/Versions/Item/AgreementFileVersionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; agreementIdOption.IsRequired = true; command.AddOption(agreementIdOption); - var agreementFileLocalizationIdOption = new Option("--agreementfilelocalization-id", description: "key: id of agreementFileLocalization") { + var agreementFileLocalizationIdOption = new Option("--agreement-file-localization-id", description: "key: id of agreementFileLocalization") { }; agreementFileLocalizationIdOption.IsRequired = true; command.AddOption(agreementFileLocalizationIdOption); - var agreementFileVersionIdOption = new Option("--agreementfileversion-id", description: "key: id of agreementFileVersion") { + var agreementFileVersionIdOption = new Option("--agreement-file-version-id", description: "key: id of agreementFileVersion") { }; agreementFileVersionIdOption.IsRequired = true; command.AddOption(agreementFileVersionIdOption); - command.SetHandler(async (string agreementId, string agreementFileLocalizationId, string agreementFileVersionId) => { + command.SetHandler(async (string agreementId, string agreementFileLocalizationId, string agreementFileVersionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, agreementIdOption, agreementFileLocalizationIdOption, agreementFileVersionIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; agreementIdOption.IsRequired = true; command.AddOption(agreementIdOption); - var agreementFileLocalizationIdOption = new Option("--agreementfilelocalization-id", description: "key: id of agreementFileLocalization") { + var agreementFileLocalizationIdOption = new Option("--agreement-file-localization-id", description: "key: id of agreementFileLocalization") { }; agreementFileLocalizationIdOption.IsRequired = true; command.AddOption(agreementFileLocalizationIdOption); - var agreementFileVersionIdOption = new Option("--agreementfileversion-id", description: "key: id of agreementFileVersion") { + var agreementFileVersionIdOption = new Option("--agreement-file-version-id", description: "key: id of agreementFileVersion") { }; agreementFileVersionIdOption.IsRequired = true; command.AddOption(agreementFileVersionIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string agreementId, string agreementFileLocalizationId, string agreementFileVersionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string agreementId, string agreementFileLocalizationId, string agreementFileVersionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, agreementIdOption, agreementFileLocalizationIdOption, agreementFileVersionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, agreementIdOption, agreementFileLocalizationIdOption, agreementFileVersionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; agreementIdOption.IsRequired = true; command.AddOption(agreementIdOption); - var agreementFileLocalizationIdOption = new Option("--agreementfilelocalization-id", description: "key: id of agreementFileLocalization") { + var agreementFileLocalizationIdOption = new Option("--agreement-file-localization-id", description: "key: id of agreementFileLocalization") { }; agreementFileLocalizationIdOption.IsRequired = true; command.AddOption(agreementFileLocalizationIdOption); - var agreementFileVersionIdOption = new Option("--agreementfileversion-id", description: "key: id of agreementFileVersion") { + var agreementFileVersionIdOption = new Option("--agreement-file-version-id", description: "key: id of agreementFileVersion") { }; agreementFileVersionIdOption.IsRequired = true; command.AddOption(agreementFileVersionIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string agreementId, string agreementFileLocalizationId, string agreementFileVersionId, string body) => { + command.SetHandler(async (string agreementId, string agreementFileLocalizationId, string agreementFileVersionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, agreementIdOption, agreementFileLocalizationIdOption, agreementFileVersionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(AgreementFileVersion bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Customized versions of the terms of use agreement in the Azure AD tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Customized versions of the terms of use agreement in the Azure AD tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Customized versions of the terms of use agreement in the Azure AD tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AgreementFileVersion model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Customized versions of the terms of use agreement in the Azure AD tenant. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Agreements/Item/Files/Item/Versions/VersionsRequestBuilder.cs b/src/generated/Agreements/Item/Files/Item/Versions/VersionsRequestBuilder.cs index cc3d8c4b878..9c130d7c797 100644 --- a/src/generated/Agreements/Item/Files/Item/Versions/VersionsRequestBuilder.cs +++ b/src/generated/Agreements/Item/Files/Item/Versions/VersionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class VersionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AgreementFileVersionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; agreementIdOption.IsRequired = true; command.AddOption(agreementIdOption); - var agreementFileLocalizationIdOption = new Option("--agreementfilelocalization-id", description: "key: id of agreementFileLocalization") { + var agreementFileLocalizationIdOption = new Option("--agreement-file-localization-id", description: "key: id of agreementFileLocalization") { }; agreementFileLocalizationIdOption.IsRequired = true; command.AddOption(agreementFileLocalizationIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string agreementId, string agreementFileLocalizationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string agreementId, string agreementFileLocalizationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, agreementIdOption, agreementFileLocalizationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, agreementIdOption, agreementFileLocalizationIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; agreementIdOption.IsRequired = true; command.AddOption(agreementIdOption); - var agreementFileLocalizationIdOption = new Option("--agreementfilelocalization-id", description: "key: id of agreementFileLocalization") { + var agreementFileLocalizationIdOption = new Option("--agreement-file-localization-id", description: "key: id of agreementFileLocalization") { }; agreementFileLocalizationIdOption.IsRequired = true; command.AddOption(agreementFileLocalizationIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string agreementId, string agreementFileLocalizationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string agreementId, string agreementFileLocalizationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, agreementIdOption, agreementFileLocalizationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, agreementIdOption, agreementFileLocalizationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(AgreementFileVersion body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Customized versions of the terms of use agreement in the Azure AD tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Customized versions of the terms of use agreement in the Azure AD tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AgreementFileVersion model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Customized versions of the terms of use agreement in the Azure AD tenant. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/AppCatalogs/AppCatalogsRequestBuilder.cs b/src/generated/AppCatalogs/AppCatalogsRequestBuilder.cs index fe08ec3e23a..2fb69d14bd7 100644 --- a/src/generated/AppCatalogs/AppCatalogsRequestBuilder.cs +++ b/src/generated/AppCatalogs/AppCatalogsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,20 +37,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -64,14 +63,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -79,6 +77,9 @@ public Command BuildPatchCommand() { public Command BuildTeamsAppsCommand() { var command = new Command("teams-apps"); var builder = new ApiSdk.AppCatalogs.TeamsApps.TeamsAppsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -135,31 +136,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get appCatalogs - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update appCatalogs - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.AppCatalogs model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get appCatalogs public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/AppCatalogs/TeamsApps/Item/AppDefinitions/AppDefinitionsRequestBuilder.cs b/src/generated/AppCatalogs/TeamsApps/Item/AppDefinitions/AppDefinitionsRequestBuilder.cs index c67b3a4d8ca..c0225c55cad 100644 --- a/src/generated/AppCatalogs/TeamsApps/Item/AppDefinitions/AppDefinitionsRequestBuilder.cs +++ b/src/generated/AppCatalogs/TeamsApps/Item/AppDefinitions/AppDefinitionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class AppDefinitionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TeamsAppDefinitionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildBotCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildBotCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -37,7 +36,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The details for each version of the app."; // Create options for all the parameters - var teamsAppIdOption = new Option("--teamsapp-id", description: "key: id of teamsApp") { + var teamsAppIdOption = new Option("--teams-app-id", description: "key: id of teamsApp") { }; teamsAppIdOption.IsRequired = true; command.AddOption(teamsAppIdOption); @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamsAppId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamsAppId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamsAppIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamsAppIdOption, bodyOption, outputOption); return command; } /// @@ -69,7 +67,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The details for each version of the app."; // Create options for all the parameters - var teamsAppIdOption = new Option("--teamsapp-id", description: "key: id of teamsApp") { + var teamsAppIdOption = new Option("--teams-app-id", description: "key: id of teamsApp") { }; teamsAppIdOption.IsRequired = true; command.AddOption(teamsAppIdOption); @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamsAppId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamsAppId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamsAppIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamsAppIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The details for each version of the app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The details for each version of the app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.TeamsAppDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The details for each version of the app. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/AppCatalogs/TeamsApps/Item/AppDefinitions/Item/Bot/BotRequestBuilder.cs b/src/generated/AppCatalogs/TeamsApps/Item/AppDefinitions/Item/Bot/BotRequestBuilder.cs index 15907912cf3..fbb3063bc88 100644 --- a/src/generated/AppCatalogs/TeamsApps/Item/AppDefinitions/Item/Bot/BotRequestBuilder.cs +++ b/src/generated/AppCatalogs/TeamsApps/Item/AppDefinitions/Item/Bot/BotRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The details of the bot specified in the Teams app manifest."; // Create options for all the parameters - var teamsAppIdOption = new Option("--teamsapp-id", description: "key: id of teamsApp") { + var teamsAppIdOption = new Option("--teams-app-id", description: "key: id of teamsApp") { }; teamsAppIdOption.IsRequired = true; command.AddOption(teamsAppIdOption); - var teamsAppDefinitionIdOption = new Option("--teamsappdefinition-id", description: "key: id of teamsAppDefinition") { + var teamsAppDefinitionIdOption = new Option("--teams-app-definition-id", description: "key: id of teamsAppDefinition") { }; teamsAppDefinitionIdOption.IsRequired = true; command.AddOption(teamsAppDefinitionIdOption); - command.SetHandler(async (string teamsAppId, string teamsAppDefinitionId) => { + command.SetHandler(async (string teamsAppId, string teamsAppDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamsAppIdOption, teamsAppDefinitionIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The details of the bot specified in the Teams app manifest."; // Create options for all the parameters - var teamsAppIdOption = new Option("--teamsapp-id", description: "key: id of teamsApp") { + var teamsAppIdOption = new Option("--teams-app-id", description: "key: id of teamsApp") { }; teamsAppIdOption.IsRequired = true; command.AddOption(teamsAppIdOption); - var teamsAppDefinitionIdOption = new Option("--teamsappdefinition-id", description: "key: id of teamsAppDefinition") { + var teamsAppDefinitionIdOption = new Option("--teams-app-definition-id", description: "key: id of teamsAppDefinition") { }; teamsAppDefinitionIdOption.IsRequired = true; command.AddOption(teamsAppDefinitionIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamsAppId, string teamsAppDefinitionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamsAppId, string teamsAppDefinitionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamsAppIdOption, teamsAppDefinitionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamsAppIdOption, teamsAppDefinitionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The details of the bot specified in the Teams app manifest."; // Create options for all the parameters - var teamsAppIdOption = new Option("--teamsapp-id", description: "key: id of teamsApp") { + var teamsAppIdOption = new Option("--teams-app-id", description: "key: id of teamsApp") { }; teamsAppIdOption.IsRequired = true; command.AddOption(teamsAppIdOption); - var teamsAppDefinitionIdOption = new Option("--teamsappdefinition-id", description: "key: id of teamsAppDefinition") { + var teamsAppDefinitionIdOption = new Option("--teams-app-definition-id", description: "key: id of teamsAppDefinition") { }; teamsAppDefinitionIdOption.IsRequired = true; command.AddOption(teamsAppDefinitionIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamsAppId, string teamsAppDefinitionId, string body) => { + command.SetHandler(async (string teamsAppId, string teamsAppDefinitionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamsAppIdOption, teamsAppDefinitionIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(TeamworkBot body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The details of the bot specified in the Teams app manifest. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The details of the bot specified in the Teams app manifest. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The details of the bot specified in the Teams app manifest. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(TeamworkBot model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The details of the bot specified in the Teams app manifest. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/AppCatalogs/TeamsApps/Item/AppDefinitions/Item/TeamsAppDefinitionRequestBuilder.cs b/src/generated/AppCatalogs/TeamsApps/Item/AppDefinitions/Item/TeamsAppDefinitionRequestBuilder.cs index 15538a42745..2f558e46512 100644 --- a/src/generated/AppCatalogs/TeamsApps/Item/AppDefinitions/Item/TeamsAppDefinitionRequestBuilder.cs +++ b/src/generated/AppCatalogs/TeamsApps/Item/AppDefinitions/Item/TeamsAppDefinitionRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,19 +35,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The details for each version of the app."; // Create options for all the parameters - var teamsAppIdOption = new Option("--teamsapp-id", description: "key: id of teamsApp") { + var teamsAppIdOption = new Option("--teams-app-id", description: "key: id of teamsApp") { }; teamsAppIdOption.IsRequired = true; command.AddOption(teamsAppIdOption); - var teamsAppDefinitionIdOption = new Option("--teamsappdefinition-id", description: "key: id of teamsAppDefinition") { + var teamsAppDefinitionIdOption = new Option("--teams-app-definition-id", description: "key: id of teamsAppDefinition") { }; teamsAppDefinitionIdOption.IsRequired = true; command.AddOption(teamsAppDefinitionIdOption); - command.SetHandler(async (string teamsAppId, string teamsAppDefinitionId) => { + command.SetHandler(async (string teamsAppId, string teamsAppDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamsAppIdOption, teamsAppDefinitionIdOption); return command; @@ -59,11 +58,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The details for each version of the app."; // Create options for all the parameters - var teamsAppIdOption = new Option("--teamsapp-id", description: "key: id of teamsApp") { + var teamsAppIdOption = new Option("--teams-app-id", description: "key: id of teamsApp") { }; teamsAppIdOption.IsRequired = true; command.AddOption(teamsAppIdOption); - var teamsAppDefinitionIdOption = new Option("--teamsappdefinition-id", description: "key: id of teamsAppDefinition") { + var teamsAppDefinitionIdOption = new Option("--teams-app-definition-id", description: "key: id of teamsAppDefinition") { }; teamsAppDefinitionIdOption.IsRequired = true; command.AddOption(teamsAppDefinitionIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamsAppId, string teamsAppDefinitionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamsAppId, string teamsAppDefinitionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamsAppIdOption, teamsAppDefinitionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamsAppIdOption, teamsAppDefinitionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -100,11 +98,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The details for each version of the app."; // Create options for all the parameters - var teamsAppIdOption = new Option("--teamsapp-id", description: "key: id of teamsApp") { + var teamsAppIdOption = new Option("--teams-app-id", description: "key: id of teamsApp") { }; teamsAppIdOption.IsRequired = true; command.AddOption(teamsAppIdOption); - var teamsAppDefinitionIdOption = new Option("--teamsappdefinition-id", description: "key: id of teamsAppDefinition") { + var teamsAppDefinitionIdOption = new Option("--teams-app-definition-id", description: "key: id of teamsAppDefinition") { }; teamsAppDefinitionIdOption.IsRequired = true; command.AddOption(teamsAppDefinitionIdOption); @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamsAppId, string teamsAppDefinitionId, string body) => { + command.SetHandler(async (string teamsAppId, string teamsAppDefinitionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamsAppIdOption, teamsAppDefinitionIdOption, bodyOption); return command; @@ -191,42 +188,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The details for each version of the app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The details for each version of the app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The details for each version of the app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.TeamsAppDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The details for each version of the app. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/AppCatalogs/TeamsApps/Item/TeamsAppRequestBuilder.cs b/src/generated/AppCatalogs/TeamsApps/Item/TeamsAppRequestBuilder.cs index 06d4a741d36..a1c5119a548 100644 --- a/src/generated/AppCatalogs/TeamsApps/Item/TeamsAppRequestBuilder.cs +++ b/src/generated/AppCatalogs/TeamsApps/Item/TeamsAppRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,6 +23,9 @@ public class TeamsAppRequestBuilder { public Command BuildAppDefinitionsCommand() { var command = new Command("app-definitions"); var builder = new ApiSdk.AppCatalogs.TeamsApps.Item.AppDefinitions.AppDefinitionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -34,15 +37,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property teamsApps for appCatalogs"; // Create options for all the parameters - var teamsAppIdOption = new Option("--teamsapp-id", description: "key: id of teamsApp") { + var teamsAppIdOption = new Option("--teams-app-id", description: "key: id of teamsApp") { }; teamsAppIdOption.IsRequired = true; command.AddOption(teamsAppIdOption); - command.SetHandler(async (string teamsAppId) => { + command.SetHandler(async (string teamsAppId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamsAppIdOption); return command; @@ -54,7 +56,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get teamsApps from appCatalogs"; // Create options for all the parameters - var teamsAppIdOption = new Option("--teamsapp-id", description: "key: id of teamsApp") { + var teamsAppIdOption = new Option("--teams-app-id", description: "key: id of teamsApp") { }; teamsAppIdOption.IsRequired = true; command.AddOption(teamsAppIdOption); @@ -68,20 +70,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamsAppId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamsAppId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamsAppIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamsAppIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,7 +92,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property teamsApps in appCatalogs"; // Create options for all the parameters - var teamsAppIdOption = new Option("--teamsapp-id", description: "key: id of teamsApp") { + var teamsAppIdOption = new Option("--teams-app-id", description: "key: id of teamsApp") { }; teamsAppIdOption.IsRequired = true; command.AddOption(teamsAppIdOption); @@ -99,14 +100,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamsAppId, string body) => { + command.SetHandler(async (string teamsAppId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamsAppIdOption, bodyOption); return command; @@ -178,42 +178,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property teamsApps for appCatalogs - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get teamsApps from appCatalogs - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property teamsApps in appCatalogs - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.TeamsApp model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get teamsApps from appCatalogs public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/AppCatalogs/TeamsApps/TeamsAppsRequestBuilder.cs b/src/generated/AppCatalogs/TeamsApps/TeamsAppsRequestBuilder.cs index c23b45655fd..07ecfdde790 100644 --- a/src/generated/AppCatalogs/TeamsApps/TeamsAppsRequestBuilder.cs +++ b/src/generated/AppCatalogs/TeamsApps/TeamsAppsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class TeamsAppsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TeamsAppRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAppDefinitionsCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAppDefinitionsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get teamsApps from appCatalogs - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to teamsApps for appCatalogs - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.TeamsApp model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get teamsApps from appCatalogs public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/ApplicationTemplates/ApplicationTemplatesRequestBuilder.cs b/src/generated/ApplicationTemplates/ApplicationTemplatesRequestBuilder.cs index 31537228890..69fee8c2389 100644 --- a/src/generated/ApplicationTemplates/ApplicationTemplatesRequestBuilder.cs +++ b/src/generated/ApplicationTemplates/ApplicationTemplatesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class ApplicationTemplatesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ApplicationTemplateRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildInstantiateCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInstantiateCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(ApplicationTemplate body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get entities from applicationTemplates - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to applicationTemplates - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplicationTemplate model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from applicationTemplates public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/ApplicationTemplates/Item/ApplicationTemplateRequestBuilder.cs b/src/generated/ApplicationTemplates/Item/ApplicationTemplateRequestBuilder.cs index 4ee1dbadbb1..92cd8a40b34 100644 --- a/src/generated/ApplicationTemplates/Item/ApplicationTemplateRequestBuilder.cs +++ b/src/generated/ApplicationTemplates/Item/ApplicationTemplateRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,15 +27,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete entity from applicationTemplates"; // Create options for all the parameters - var applicationTemplateIdOption = new Option("--applicationtemplate-id", description: "key: id of applicationTemplate") { + var applicationTemplateIdOption = new Option("--application-template-id", description: "key: id of applicationTemplate") { }; applicationTemplateIdOption.IsRequired = true; command.AddOption(applicationTemplateIdOption); - command.SetHandler(async (string applicationTemplateId) => { + command.SetHandler(async (string applicationTemplateId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, applicationTemplateIdOption); return command; @@ -47,7 +46,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get entity from applicationTemplates by key"; // Create options for all the parameters - var applicationTemplateIdOption = new Option("--applicationtemplate-id", description: "key: id of applicationTemplate") { + var applicationTemplateIdOption = new Option("--application-template-id", description: "key: id of applicationTemplate") { }; applicationTemplateIdOption.IsRequired = true; command.AddOption(applicationTemplateIdOption); @@ -61,20 +60,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string applicationTemplateId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string applicationTemplateId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, applicationTemplateIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, applicationTemplateIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildInstantiateCommand() { @@ -90,7 +88,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update entity in applicationTemplates"; // Create options for all the parameters - var applicationTemplateIdOption = new Option("--applicationtemplate-id", description: "key: id of applicationTemplate") { + var applicationTemplateIdOption = new Option("--application-template-id", description: "key: id of applicationTemplate") { }; applicationTemplateIdOption.IsRequired = true; command.AddOption(applicationTemplateIdOption); @@ -98,14 +96,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string applicationTemplateId, string body) => { + command.SetHandler(async (string applicationTemplateId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, applicationTemplateIdOption, bodyOption); return command; @@ -177,42 +174,6 @@ public RequestInformation CreatePatchRequestInformation(ApplicationTemplate body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from applicationTemplates - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from applicationTemplates by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in applicationTemplates - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApplicationTemplate model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from applicationTemplates by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/ApplicationTemplates/Item/Instantiate/InstantiateRequestBuilder.cs b/src/generated/ApplicationTemplates/Item/Instantiate/InstantiateRequestBuilder.cs index 454a5d1b574..70de83798d8 100644 --- a/src/generated/ApplicationTemplates/Item/Instantiate/InstantiateRequestBuilder.cs +++ b/src/generated/ApplicationTemplates/Item/Instantiate/InstantiateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action instantiate"; // Create options for all the parameters - var applicationTemplateIdOption = new Option("--applicationtemplate-id", description: "key: id of applicationTemplate") { + var applicationTemplateIdOption = new Option("--application-template-id", description: "key: id of applicationTemplate") { }; applicationTemplateIdOption.IsRequired = true; command.AddOption(applicationTemplateIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string applicationTemplateId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string applicationTemplateId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, applicationTemplateIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, applicationTemplateIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(InstantiateRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action instantiate - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(InstantiateRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes applicationServicePrincipal public class InstantiateResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Applications/ApplicationsRequestBuilder.cs b/src/generated/Applications/ApplicationsRequestBuilder.cs index 83fd49e7628..808d98c3937 100644 --- a/src/generated/Applications/ApplicationsRequestBuilder.cs +++ b/src/generated/Applications/ApplicationsRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,29 +26,28 @@ public class ApplicationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ApplicationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAddKeyCommand(), - builder.BuildAddPasswordCommand(), - builder.BuildCheckMemberGroupsCommand(), - builder.BuildCheckMemberObjectsCommand(), - builder.BuildCreatedOnBehalfOfCommand(), - builder.BuildDeleteCommand(), - builder.BuildExtensionPropertiesCommand(), - builder.BuildGetCommand(), - builder.BuildGetMemberGroupsCommand(), - builder.BuildGetMemberObjectsCommand(), - builder.BuildHomeRealmDiscoveryPoliciesCommand(), - builder.BuildLogoCommand(), - builder.BuildOwnersCommand(), - builder.BuildPatchCommand(), - builder.BuildRemoveKeyCommand(), - builder.BuildRemovePasswordCommand(), - builder.BuildRestoreCommand(), - builder.BuildSetVerifiedPublisherCommand(), - builder.BuildTokenIssuancePoliciesCommand(), - builder.BuildTokenLifetimePoliciesCommand(), - builder.BuildUnsetVerifiedPublisherCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAddKeyCommand()); + commands.Add(builder.BuildAddPasswordCommand()); + commands.Add(builder.BuildCheckMemberGroupsCommand()); + commands.Add(builder.BuildCheckMemberObjectsCommand()); + commands.Add(builder.BuildCreatedOnBehalfOfCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildExtensionPropertiesCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildGetMemberGroupsCommand()); + commands.Add(builder.BuildGetMemberObjectsCommand()); + commands.Add(builder.BuildHomeRealmDiscoveryPoliciesCommand()); + commands.Add(builder.BuildLogoCommand()); + commands.Add(builder.BuildOwnersCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRemoveKeyCommand()); + commands.Add(builder.BuildRemovePasswordCommand()); + commands.Add(builder.BuildRestoreCommand()); + commands.Add(builder.BuildSetVerifiedPublisherCommand()); + commands.Add(builder.BuildTokenIssuancePoliciesCommand()); + commands.Add(builder.BuildTokenLifetimePoliciesCommand()); + commands.Add(builder.BuildUnsetVerifiedPublisherCommand()); return commands; } /// @@ -62,21 +61,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } public Command BuildGetAvailableExtensionPropertiesCommand() { @@ -133,7 +131,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -144,15 +146,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildValidatePropertiesCommand() { @@ -219,31 +216,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// Get entities from applications - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to applications - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Application model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from applications public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Applications/Delta/DeltaRequestBuilder.cs b/src/generated/Applications/Delta/DeltaRequestBuilder.cs index d73068c4b32..2b8de54854c 100644 --- a/src/generated/Applications/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Applications/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Applications/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs b/src/generated/Applications/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs deleted file mode 100644 index 8c502ee05b0..00000000000 --- a/src/generated/Applications/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs +++ /dev/null @@ -1,45 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Applications.GetAvailableExtensionProperties { - public class GetAvailableExtensionProperties : DirectoryObject, IParsable { - /// Display name of the application object on which this extension property is defined. Read-only. - public string AppDisplayName { get; set; } - /// Specifies the data type of the value the extension property can hold. Following values are supported. Not nullable. Binary - 256 bytes maximumBooleanDateTime - Must be specified in ISO 8601 format. Will be stored in UTC.Integer - 32-bit value.LargeInteger - 64-bit value.String - 256 characters maximum - public string DataType { get; set; } - /// Indicates if this extension property was sycned from onpremises directory using Azure AD Connect. Read-only. - public bool? IsSyncedFromOnPremises { get; set; } - /// Name of the extension property. Not nullable. - public string Name { get; set; } - /// Following values are supported. Not nullable. UserGroupOrganizationDeviceApplication - public List TargetObjects { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"appDisplayName", (o,n) => { (o as GetAvailableExtensionProperties).AppDisplayName = n.GetStringValue(); } }, - {"dataType", (o,n) => { (o as GetAvailableExtensionProperties).DataType = n.GetStringValue(); } }, - {"isSyncedFromOnPremises", (o,n) => { (o as GetAvailableExtensionProperties).IsSyncedFromOnPremises = n.GetBoolValue(); } }, - {"name", (o,n) => { (o as GetAvailableExtensionProperties).Name = n.GetStringValue(); } }, - {"targetObjects", (o,n) => { (o as GetAvailableExtensionProperties).TargetObjects = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteStringValue("appDisplayName", AppDisplayName); - writer.WriteStringValue("dataType", DataType); - writer.WriteBoolValue("isSyncedFromOnPremises", IsSyncedFromOnPremises); - writer.WriteStringValue("name", Name); - writer.WriteCollectionOfPrimitiveValues("targetObjects", TargetObjects); - } - } -} diff --git a/src/generated/Applications/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs b/src/generated/Applications/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs index ea83a363a11..6ef7ca0b2fc 100644 --- a/src/generated/Applications/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs +++ b/src/generated/Applications/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(GetAvailableExtensionProp requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getAvailableExtensionProperties - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetAvailableExtensionPropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Applications/GetByIds/GetByIds.cs b/src/generated/Applications/GetByIds/GetByIds.cs deleted file mode 100644 index 16bcafce21e..00000000000 --- a/src/generated/Applications/GetByIds/GetByIds.cs +++ /dev/null @@ -1,28 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Applications.GetByIds { - public class GetByIds : Entity, IParsable { - public DateTimeOffset? DeletedDateTime { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"deletedDateTime", (o,n) => { (o as GetByIds).DeletedDateTime = n.GetDateTimeOffsetValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteDateTimeOffsetValue("deletedDateTime", DeletedDateTime); - } - } -} diff --git a/src/generated/Applications/GetByIds/GetByIdsRequestBuilder.cs b/src/generated/Applications/GetByIds/GetByIdsRequestBuilder.cs index 7bcd5479b88..617b3059c8c 100644 --- a/src/generated/Applications/GetByIds/GetByIdsRequestBuilder.cs +++ b/src/generated/Applications/GetByIds/GetByIdsRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(GetByIdsRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getByIds - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetByIdsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Applications/Item/AddKey/AddKeyRequestBuilder.cs b/src/generated/Applications/Item/AddKey/AddKeyRequestBuilder.cs index 0dda5673be6..d3ec6c503fc 100644 --- a/src/generated/Applications/Item/AddKey/AddKeyRequestBuilder.cs +++ b/src/generated/Applications/Item/AddKey/AddKeyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string applicationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string applicationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, applicationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, applicationIdOption, bodyOption, outputOption); return command; } /// @@ -82,18 +81,5 @@ public RequestInformation CreatePostRequestInformation(KeyCredentialRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action addKey - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(KeyCredentialRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Applications/Item/AddPassword/AddPasswordRequestBuilder.cs b/src/generated/Applications/Item/AddPassword/AddPasswordRequestBuilder.cs index de248c5c3e8..c36f8e01963 100644 --- a/src/generated/Applications/Item/AddPassword/AddPasswordRequestBuilder.cs +++ b/src/generated/Applications/Item/AddPassword/AddPasswordRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string applicationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string applicationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, applicationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, applicationIdOption, bodyOption, outputOption); return command; } /// @@ -82,18 +81,5 @@ public RequestInformation CreatePostRequestInformation(PasswordCredentialRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action addPassword - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PasswordCredentialRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Applications/Item/ApplicationRequestBuilder.cs b/src/generated/Applications/Item/ApplicationRequestBuilder.cs index aa0be8d047e..8917b2e9561 100644 --- a/src/generated/Applications/Item/ApplicationRequestBuilder.cs +++ b/src/generated/Applications/Item/ApplicationRequestBuilder.cs @@ -19,10 +19,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -79,11 +79,10 @@ public Command BuildDeleteCommand() { }; applicationIdOption.IsRequired = true; command.AddOption(applicationIdOption); - command.SetHandler(async (string applicationId) => { + command.SetHandler(async (string applicationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, applicationIdOption); return command; @@ -91,6 +90,9 @@ public Command BuildDeleteCommand() { public Command BuildExtensionPropertiesCommand() { var command = new Command("extension-properties"); var builder = new ApiSdk.Applications.Item.ExtensionProperties.ExtensionPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -116,20 +118,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string applicationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string applicationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, applicationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, applicationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildGetMemberGroupsCommand() { @@ -180,14 +181,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string applicationId, string body) => { + command.SetHandler(async (string applicationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, applicationIdOption, bodyOption); return command; @@ -303,42 +303,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from applications - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from applications by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in applications - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Application model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from applications by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Applications/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs b/src/generated/Applications/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs index 0f1af1906a7..6985ef74da2 100644 --- a/src/generated/Applications/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs +++ b/src/generated/Applications/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string applicationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string applicationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, applicationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, applicationIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberGroupsRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Applications/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs b/src/generated/Applications/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs index 68e852ddabc..e258f087c58 100644 --- a/src/generated/Applications/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs +++ b/src/generated/Applications/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string applicationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string applicationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, applicationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, applicationIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberObjectsRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Applications/Item/CreatedOnBehalfOf/@Ref/@Ref.cs b/src/generated/Applications/Item/CreatedOnBehalfOf/@Ref/@Ref.cs deleted file mode 100644 index 3af2a9342f6..00000000000 --- a/src/generated/Applications/Item/CreatedOnBehalfOf/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Applications.Item.CreatedOnBehalfOf.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Applications/Item/CreatedOnBehalfOf/@Ref/RefRequestBuilder.cs b/src/generated/Applications/Item/CreatedOnBehalfOf/@Ref/RefRequestBuilder.cs deleted file mode 100644 index d1c6e0fe75f..00000000000 --- a/src/generated/Applications/Item/CreatedOnBehalfOf/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Applications.Item.CreatedOnBehalfOf.@Ref { - /// Builds and executes requests for operations under \applications\{application-id}\createdOnBehalfOf\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Read-only. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Read-only."; - // Create options for all the parameters - var applicationIdOption = new Option("--application-id", description: "key: id of application") { - }; - applicationIdOption.IsRequired = true; - command.AddOption(applicationIdOption); - command.SetHandler(async (string applicationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, applicationIdOption); - return command; - } - /// - /// Read-only. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Read-only."; - // Create options for all the parameters - var applicationIdOption = new Option("--application-id", description: "key: id of application") { - }; - applicationIdOption.IsRequired = true; - command.AddOption(applicationIdOption); - command.SetHandler(async (string applicationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, applicationIdOption); - return command; - } - /// - /// Read-only. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Read-only."; - // Create options for all the parameters - var applicationIdOption = new Option("--application-id", description: "key: id of application") { - }; - applicationIdOption.IsRequired = true; - command.AddOption(applicationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string applicationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, applicationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/applications/{application_id}/createdOnBehalfOf/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Read-only. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Applications.Item.CreatedOnBehalfOf.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Applications.Item.CreatedOnBehalfOf.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Applications/Item/CreatedOnBehalfOf/CreatedOnBehalfOfRequestBuilder.cs b/src/generated/Applications/Item/CreatedOnBehalfOf/CreatedOnBehalfOfRequestBuilder.cs index 4a09fea6e32..12e54910c74 100644 --- a/src/generated/Applications/Item/CreatedOnBehalfOf/CreatedOnBehalfOfRequestBuilder.cs +++ b/src/generated/Applications/Item/CreatedOnBehalfOf/CreatedOnBehalfOfRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string applicationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string applicationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, applicationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, applicationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Applications.Item.CreatedOnBehalfOf.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Applications.Item.CreatedOnBehalfOf.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Applications/Item/CreatedOnBehalfOf/Ref/Ref.cs b/src/generated/Applications/Item/CreatedOnBehalfOf/Ref/Ref.cs new file mode 100644 index 00000000000..b3566fa02e7 --- /dev/null +++ b/src/generated/Applications/Item/CreatedOnBehalfOf/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Applications.Item.CreatedOnBehalfOf.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Applications/Item/CreatedOnBehalfOf/Ref/RefRequestBuilder.cs b/src/generated/Applications/Item/CreatedOnBehalfOf/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..f8f04b6160d --- /dev/null +++ b/src/generated/Applications/Item/CreatedOnBehalfOf/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Applications.Item.CreatedOnBehalfOf.Ref { + /// Builds and executes requests for operations under \applications\{application-id}\createdOnBehalfOf\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Read-only. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Read-only."; + // Create options for all the parameters + var applicationIdOption = new Option("--application-id", description: "key: id of application") { + }; + applicationIdOption.IsRequired = true; + command.AddOption(applicationIdOption); + command.SetHandler(async (string applicationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, applicationIdOption); + return command; + } + /// + /// Read-only. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Read-only."; + // Create options for all the parameters + var applicationIdOption = new Option("--application-id", description: "key: id of application") { + }; + applicationIdOption.IsRequired = true; + command.AddOption(applicationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string applicationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, applicationIdOption, outputOption); + return command; + } + /// + /// Read-only. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Read-only."; + // Create options for all the parameters + var applicationIdOption = new Option("--application-id", description: "key: id of application") { + }; + applicationIdOption.IsRequired = true; + command.AddOption(applicationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string applicationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, applicationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/applications/{application_id}/createdOnBehalfOf/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Read-only. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Read-only. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Read-only. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Applications.Item.CreatedOnBehalfOf.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Applications/Item/ExtensionProperties/ExtensionPropertiesRequestBuilder.cs b/src/generated/Applications/Item/ExtensionProperties/ExtensionPropertiesRequestBuilder.cs index cbcd48e6575..cc8f4acf910 100644 --- a/src/generated/Applications/Item/ExtensionProperties/ExtensionPropertiesRequestBuilder.cs +++ b/src/generated/Applications/Item/ExtensionProperties/ExtensionPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string applicationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string applicationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, applicationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, applicationIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string applicationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string applicationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, applicationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, applicationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ExtensionProperty body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ExtensionProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Applications/Item/ExtensionProperties/Item/ExtensionPropertyRequestBuilder.cs b/src/generated/Applications/Item/ExtensionProperties/Item/ExtensionPropertyRequestBuilder.cs index 42243186dc2..9a8778a22d6 100644 --- a/src/generated/Applications/Item/ExtensionProperties/Item/ExtensionPropertyRequestBuilder.cs +++ b/src/generated/Applications/Item/ExtensionProperties/Item/ExtensionPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; applicationIdOption.IsRequired = true; command.AddOption(applicationIdOption); - var extensionPropertyIdOption = new Option("--extensionproperty-id", description: "key: id of extensionProperty") { + var extensionPropertyIdOption = new Option("--extension-property-id", description: "key: id of extensionProperty") { }; extensionPropertyIdOption.IsRequired = true; command.AddOption(extensionPropertyIdOption); - command.SetHandler(async (string applicationId, string extensionPropertyId) => { + command.SetHandler(async (string applicationId, string extensionPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, applicationIdOption, extensionPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; applicationIdOption.IsRequired = true; command.AddOption(applicationIdOption); - var extensionPropertyIdOption = new Option("--extensionproperty-id", description: "key: id of extensionProperty") { + var extensionPropertyIdOption = new Option("--extension-property-id", description: "key: id of extensionProperty") { }; extensionPropertyIdOption.IsRequired = true; command.AddOption(extensionPropertyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string applicationId, string extensionPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string applicationId, string extensionPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, applicationIdOption, extensionPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, applicationIdOption, extensionPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; applicationIdOption.IsRequired = true; command.AddOption(applicationIdOption); - var extensionPropertyIdOption = new Option("--extensionproperty-id", description: "key: id of extensionProperty") { + var extensionPropertyIdOption = new Option("--extension-property-id", description: "key: id of extensionProperty") { }; extensionPropertyIdOption.IsRequired = true; command.AddOption(extensionPropertyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string applicationId, string extensionPropertyId, string body) => { + command.SetHandler(async (string applicationId, string extensionPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, applicationIdOption, extensionPropertyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ExtensionProperty body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ExtensionProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Applications/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs b/src/generated/Applications/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs index f8e3487a564..658a0e49aaf 100644 --- a/src/generated/Applications/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs +++ b/src/generated/Applications/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string applicationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string applicationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, applicationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, applicationIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberGroupsRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Applications/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs b/src/generated/Applications/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs index 86ac707f698..c91e30ac06e 100644 --- a/src/generated/Applications/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs +++ b/src/generated/Applications/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string applicationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string applicationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, applicationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, applicationIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberObjectsRequestBo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Applications/Item/HomeRealmDiscoveryPolicies/@Ref/@Ref.cs b/src/generated/Applications/Item/HomeRealmDiscoveryPolicies/@Ref/@Ref.cs deleted file mode 100644 index 0e66d86529a..00000000000 --- a/src/generated/Applications/Item/HomeRealmDiscoveryPolicies/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Applications.Item.HomeRealmDiscoveryPolicies.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Applications/Item/HomeRealmDiscoveryPolicies/@Ref/RefRequestBuilder.cs b/src/generated/Applications/Item/HomeRealmDiscoveryPolicies/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 8b69eeebe78..00000000000 --- a/src/generated/Applications/Item/HomeRealmDiscoveryPolicies/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Applications.Item.HomeRealmDiscoveryPolicies.@Ref { - /// Builds and executes requests for operations under \applications\{application-id}\homeRealmDiscoveryPolicies\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Get ref of homeRealmDiscoveryPolicies from applications - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Get ref of homeRealmDiscoveryPolicies from applications"; - // Create options for all the parameters - var applicationIdOption = new Option("--application-id", description: "key: id of application") { - }; - applicationIdOption.IsRequired = true; - command.AddOption(applicationIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string applicationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, applicationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Create new navigation property ref to homeRealmDiscoveryPolicies for applications - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Create new navigation property ref to homeRealmDiscoveryPolicies for applications"; - // Create options for all the parameters - var applicationIdOption = new Option("--application-id", description: "key: id of application") { - }; - applicationIdOption.IsRequired = true; - command.AddOption(applicationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string applicationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, applicationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/applications/{application_id}/homeRealmDiscoveryPolicies/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Get ref of homeRealmDiscoveryPolicies from applications - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Create new navigation property ref to homeRealmDiscoveryPolicies for applications - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Applications.Item.HomeRealmDiscoveryPolicies.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Get ref of homeRealmDiscoveryPolicies from applications - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property ref to homeRealmDiscoveryPolicies for applications - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Applications.Item.HomeRealmDiscoveryPolicies.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Get ref of homeRealmDiscoveryPolicies from applications - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Applications/Item/HomeRealmDiscoveryPolicies/@Ref/RefResponse.cs b/src/generated/Applications/Item/HomeRealmDiscoveryPolicies/@Ref/RefResponse.cs deleted file mode 100644 index 445a1bcc325..00000000000 --- a/src/generated/Applications/Item/HomeRealmDiscoveryPolicies/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Applications.Item.HomeRealmDiscoveryPolicies.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Applications/Item/HomeRealmDiscoveryPolicies/HomeRealmDiscoveryPoliciesRequestBuilder.cs b/src/generated/Applications/Item/HomeRealmDiscoveryPolicies/HomeRealmDiscoveryPoliciesRequestBuilder.cs index 8e52a7ab3ab..69954f5fe41 100644 --- a/src/generated/Applications/Item/HomeRealmDiscoveryPolicies/HomeRealmDiscoveryPoliciesRequestBuilder.cs +++ b/src/generated/Applications/Item/HomeRealmDiscoveryPolicies/HomeRealmDiscoveryPoliciesRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Applications.Item.HomeRealmDiscoveryPolicies.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string applicationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string applicationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, applicationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, applicationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Applications.Item.HomeRealmDiscoveryPolicies.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Applications.Item.HomeRealmDiscoveryPolicies.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get homeRealmDiscoveryPolicies from applications - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get homeRealmDiscoveryPolicies from applications public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Applications/Item/HomeRealmDiscoveryPolicies/Ref/Ref.cs b/src/generated/Applications/Item/HomeRealmDiscoveryPolicies/Ref/Ref.cs new file mode 100644 index 00000000000..5940364cf19 --- /dev/null +++ b/src/generated/Applications/Item/HomeRealmDiscoveryPolicies/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Applications.Item.HomeRealmDiscoveryPolicies.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Applications/Item/HomeRealmDiscoveryPolicies/Ref/RefRequestBuilder.cs b/src/generated/Applications/Item/HomeRealmDiscoveryPolicies/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..5137a658ca6 --- /dev/null +++ b/src/generated/Applications/Item/HomeRealmDiscoveryPolicies/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Applications.Item.HomeRealmDiscoveryPolicies.Ref { + /// Builds and executes requests for operations under \applications\{application-id}\homeRealmDiscoveryPolicies\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Get ref of homeRealmDiscoveryPolicies from applications + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Get ref of homeRealmDiscoveryPolicies from applications"; + // Create options for all the parameters + var applicationIdOption = new Option("--application-id", description: "key: id of application") { + }; + applicationIdOption.IsRequired = true; + command.AddOption(applicationIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string applicationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, applicationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Create new navigation property ref to homeRealmDiscoveryPolicies for applications + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Create new navigation property ref to homeRealmDiscoveryPolicies for applications"; + // Create options for all the parameters + var applicationIdOption = new Option("--application-id", description: "key: id of application") { + }; + applicationIdOption.IsRequired = true; + command.AddOption(applicationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string applicationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, applicationIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/applications/{application_id}/homeRealmDiscoveryPolicies/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Get ref of homeRealmDiscoveryPolicies from applications + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Create new navigation property ref to homeRealmDiscoveryPolicies for applications + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Applications.Item.HomeRealmDiscoveryPolicies.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Get ref of homeRealmDiscoveryPolicies from applications + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Applications/Item/HomeRealmDiscoveryPolicies/Ref/RefResponse.cs b/src/generated/Applications/Item/HomeRealmDiscoveryPolicies/Ref/RefResponse.cs new file mode 100644 index 00000000000..fe3a76fbb20 --- /dev/null +++ b/src/generated/Applications/Item/HomeRealmDiscoveryPolicies/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Applications.Item.HomeRealmDiscoveryPolicies.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Applications/Item/Logo/LogoRequestBuilder.cs b/src/generated/Applications/Item/Logo/LogoRequestBuilder.cs index 93ee785c8c6..172ce28d041 100644 --- a/src/generated/Applications/Item/Logo/LogoRequestBuilder.cs +++ b/src/generated/Applications/Item/Logo/LogoRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; applicationIdOption.IsRequired = true; command.AddOption(applicationIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string applicationId, FileInfo output) => { + command.SetHandler(async (string applicationId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, applicationIdOption, outputOption); + }, applicationIdOption, fileOption, outputOption); return command; } /// @@ -64,12 +66,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string applicationId, FileInfo file) => { + command.SetHandler(async (string applicationId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, applicationIdOption, bodyOption); return command; @@ -120,29 +121,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// The main logo for the application. Not nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The main logo for the application. Not nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Applications/Item/Owners/@Ref/@Ref.cs b/src/generated/Applications/Item/Owners/@Ref/@Ref.cs deleted file mode 100644 index df51b184592..00000000000 --- a/src/generated/Applications/Item/Owners/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Applications.Item.Owners.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Applications/Item/Owners/@Ref/RefRequestBuilder.cs b/src/generated/Applications/Item/Owners/@Ref/RefRequestBuilder.cs deleted file mode 100644 index da874bd2e10..00000000000 --- a/src/generated/Applications/Item/Owners/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Applications.Item.Owners.@Ref { - /// Builds and executes requests for operations under \applications\{application-id}\owners\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Directory objects that are owners of the application. Read-only. Nullable. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Directory objects that are owners of the application. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var applicationIdOption = new Option("--application-id", description: "key: id of application") { - }; - applicationIdOption.IsRequired = true; - command.AddOption(applicationIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string applicationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, applicationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Directory objects that are owners of the application. Read-only. Nullable. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Directory objects that are owners of the application. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var applicationIdOption = new Option("--application-id", description: "key: id of application") { - }; - applicationIdOption.IsRequired = true; - command.AddOption(applicationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string applicationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, applicationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/applications/{application_id}/owners/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Directory objects that are owners of the application. Read-only. Nullable. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Directory objects that are owners of the application. Read-only. Nullable. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Applications.Item.Owners.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Directory objects that are owners of the application. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Directory objects that are owners of the application. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Applications.Item.Owners.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Directory objects that are owners of the application. Read-only. Nullable. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Applications/Item/Owners/@Ref/RefResponse.cs b/src/generated/Applications/Item/Owners/@Ref/RefResponse.cs deleted file mode 100644 index 2a015efb5b9..00000000000 --- a/src/generated/Applications/Item/Owners/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Applications.Item.Owners.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Applications/Item/Owners/OwnersRequestBuilder.cs b/src/generated/Applications/Item/Owners/OwnersRequestBuilder.cs index df44209905c..30b7091c33c 100644 --- a/src/generated/Applications/Item/Owners/OwnersRequestBuilder.cs +++ b/src/generated/Applications/Item/Owners/OwnersRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Applications.Item.Owners.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string applicationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string applicationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, applicationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, applicationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Applications.Item.Owners.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Applications.Item.Owners.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Directory objects that are owners of the application. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Directory objects that are owners of the application. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Applications/Item/Owners/Ref/Ref.cs b/src/generated/Applications/Item/Owners/Ref/Ref.cs new file mode 100644 index 00000000000..a3a6a90d470 --- /dev/null +++ b/src/generated/Applications/Item/Owners/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Applications.Item.Owners.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Applications/Item/Owners/Ref/RefRequestBuilder.cs b/src/generated/Applications/Item/Owners/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..a51edf56f0f --- /dev/null +++ b/src/generated/Applications/Item/Owners/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Applications.Item.Owners.Ref { + /// Builds and executes requests for operations under \applications\{application-id}\owners\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Directory objects that are owners of the application. Read-only. Nullable. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Directory objects that are owners of the application. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var applicationIdOption = new Option("--application-id", description: "key: id of application") { + }; + applicationIdOption.IsRequired = true; + command.AddOption(applicationIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string applicationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, applicationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Directory objects that are owners of the application. Read-only. Nullable. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Directory objects that are owners of the application. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var applicationIdOption = new Option("--application-id", description: "key: id of application") { + }; + applicationIdOption.IsRequired = true; + command.AddOption(applicationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string applicationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, applicationIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/applications/{application_id}/owners/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Directory objects that are owners of the application. Read-only. Nullable. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Directory objects that are owners of the application. Read-only. Nullable. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Applications.Item.Owners.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Directory objects that are owners of the application. Read-only. Nullable. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Applications/Item/Owners/Ref/RefResponse.cs b/src/generated/Applications/Item/Owners/Ref/RefResponse.cs new file mode 100644 index 00000000000..c4f26c2fda8 --- /dev/null +++ b/src/generated/Applications/Item/Owners/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Applications.Item.Owners.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Applications/Item/RemoveKey/RemoveKeyRequestBuilder.cs b/src/generated/Applications/Item/RemoveKey/RemoveKeyRequestBuilder.cs index a4b85a90494..23befa5ab7c 100644 --- a/src/generated/Applications/Item/RemoveKey/RemoveKeyRequestBuilder.cs +++ b/src/generated/Applications/Item/RemoveKey/RemoveKeyRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string applicationId, string body) => { + command.SetHandler(async (string applicationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, applicationIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(RemoveKeyRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action removeKey - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RemoveKeyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Applications/Item/RemovePassword/RemovePasswordRequestBuilder.cs b/src/generated/Applications/Item/RemovePassword/RemovePasswordRequestBuilder.cs index 8a1dca24c21..b63c256e002 100644 --- a/src/generated/Applications/Item/RemovePassword/RemovePasswordRequestBuilder.cs +++ b/src/generated/Applications/Item/RemovePassword/RemovePasswordRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string applicationId, string body) => { + command.SetHandler(async (string applicationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, applicationIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(RemovePasswordRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action removePassword - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RemovePasswordRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Applications/Item/Restore/RestoreRequestBuilder.cs b/src/generated/Applications/Item/Restore/RestoreRequestBuilder.cs index 231adf8fc58..052499e477d 100644 --- a/src/generated/Applications/Item/Restore/RestoreRequestBuilder.cs +++ b/src/generated/Applications/Item/Restore/RestoreRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildPostCommand() { }; applicationIdOption.IsRequired = true; command.AddOption(applicationIdOption); - command.SetHandler(async (string applicationId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string applicationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, applicationIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, applicationIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action restore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes directoryObject public class RestoreResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Applications/Item/SetVerifiedPublisher/SetVerifiedPublisherRequestBuilder.cs b/src/generated/Applications/Item/SetVerifiedPublisher/SetVerifiedPublisherRequestBuilder.cs index 45d0140a5c9..828402df6aa 100644 --- a/src/generated/Applications/Item/SetVerifiedPublisher/SetVerifiedPublisherRequestBuilder.cs +++ b/src/generated/Applications/Item/SetVerifiedPublisher/SetVerifiedPublisherRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string applicationId, string body) => { + command.SetHandler(async (string applicationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, applicationIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(SetVerifiedPublisherReque requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setVerifiedPublisher - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetVerifiedPublisherRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Applications/Item/TokenIssuancePolicies/@Ref/@Ref.cs b/src/generated/Applications/Item/TokenIssuancePolicies/@Ref/@Ref.cs deleted file mode 100644 index 474b1027460..00000000000 --- a/src/generated/Applications/Item/TokenIssuancePolicies/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Applications.Item.TokenIssuancePolicies.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Applications/Item/TokenIssuancePolicies/@Ref/RefRequestBuilder.cs b/src/generated/Applications/Item/TokenIssuancePolicies/@Ref/RefRequestBuilder.cs deleted file mode 100644 index c56b7b7d79c..00000000000 --- a/src/generated/Applications/Item/TokenIssuancePolicies/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Applications.Item.TokenIssuancePolicies.@Ref { - /// Builds and executes requests for operations under \applications\{application-id}\tokenIssuancePolicies\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Get ref of tokenIssuancePolicies from applications - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Get ref of tokenIssuancePolicies from applications"; - // Create options for all the parameters - var applicationIdOption = new Option("--application-id", description: "key: id of application") { - }; - applicationIdOption.IsRequired = true; - command.AddOption(applicationIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string applicationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, applicationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Create new navigation property ref to tokenIssuancePolicies for applications - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Create new navigation property ref to tokenIssuancePolicies for applications"; - // Create options for all the parameters - var applicationIdOption = new Option("--application-id", description: "key: id of application") { - }; - applicationIdOption.IsRequired = true; - command.AddOption(applicationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string applicationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, applicationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/applications/{application_id}/tokenIssuancePolicies/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Get ref of tokenIssuancePolicies from applications - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Create new navigation property ref to tokenIssuancePolicies for applications - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Applications.Item.TokenIssuancePolicies.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Get ref of tokenIssuancePolicies from applications - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property ref to tokenIssuancePolicies for applications - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Applications.Item.TokenIssuancePolicies.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Get ref of tokenIssuancePolicies from applications - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Applications/Item/TokenIssuancePolicies/@Ref/RefResponse.cs b/src/generated/Applications/Item/TokenIssuancePolicies/@Ref/RefResponse.cs deleted file mode 100644 index a9b2b756ac0..00000000000 --- a/src/generated/Applications/Item/TokenIssuancePolicies/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Applications.Item.TokenIssuancePolicies.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Applications/Item/TokenIssuancePolicies/Ref/Ref.cs b/src/generated/Applications/Item/TokenIssuancePolicies/Ref/Ref.cs new file mode 100644 index 00000000000..778fdc6af77 --- /dev/null +++ b/src/generated/Applications/Item/TokenIssuancePolicies/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Applications.Item.TokenIssuancePolicies.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Applications/Item/TokenIssuancePolicies/Ref/RefRequestBuilder.cs b/src/generated/Applications/Item/TokenIssuancePolicies/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..cb19df20efe --- /dev/null +++ b/src/generated/Applications/Item/TokenIssuancePolicies/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Applications.Item.TokenIssuancePolicies.Ref { + /// Builds and executes requests for operations under \applications\{application-id}\tokenIssuancePolicies\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Get ref of tokenIssuancePolicies from applications + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Get ref of tokenIssuancePolicies from applications"; + // Create options for all the parameters + var applicationIdOption = new Option("--application-id", description: "key: id of application") { + }; + applicationIdOption.IsRequired = true; + command.AddOption(applicationIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string applicationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, applicationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Create new navigation property ref to tokenIssuancePolicies for applications + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Create new navigation property ref to tokenIssuancePolicies for applications"; + // Create options for all the parameters + var applicationIdOption = new Option("--application-id", description: "key: id of application") { + }; + applicationIdOption.IsRequired = true; + command.AddOption(applicationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string applicationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, applicationIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/applications/{application_id}/tokenIssuancePolicies/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Get ref of tokenIssuancePolicies from applications + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Create new navigation property ref to tokenIssuancePolicies for applications + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Applications.Item.TokenIssuancePolicies.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Get ref of tokenIssuancePolicies from applications + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Applications/Item/TokenIssuancePolicies/Ref/RefResponse.cs b/src/generated/Applications/Item/TokenIssuancePolicies/Ref/RefResponse.cs new file mode 100644 index 00000000000..b827d6e5612 --- /dev/null +++ b/src/generated/Applications/Item/TokenIssuancePolicies/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Applications.Item.TokenIssuancePolicies.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Applications/Item/TokenIssuancePolicies/TokenIssuancePoliciesRequestBuilder.cs b/src/generated/Applications/Item/TokenIssuancePolicies/TokenIssuancePoliciesRequestBuilder.cs index d3e73b9879e..b0238a7b054 100644 --- a/src/generated/Applications/Item/TokenIssuancePolicies/TokenIssuancePoliciesRequestBuilder.cs +++ b/src/generated/Applications/Item/TokenIssuancePolicies/TokenIssuancePoliciesRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Applications.Item.TokenIssuancePolicies.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string applicationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string applicationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, applicationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, applicationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Applications.Item.TokenIssuancePolicies.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Applications.Item.TokenIssuancePolicies.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get tokenIssuancePolicies from applications - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get tokenIssuancePolicies from applications public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Applications/Item/TokenLifetimePolicies/@Ref/@Ref.cs b/src/generated/Applications/Item/TokenLifetimePolicies/@Ref/@Ref.cs deleted file mode 100644 index 2db7c5d1d28..00000000000 --- a/src/generated/Applications/Item/TokenLifetimePolicies/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Applications.Item.TokenLifetimePolicies.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Applications/Item/TokenLifetimePolicies/@Ref/RefRequestBuilder.cs b/src/generated/Applications/Item/TokenLifetimePolicies/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 040452eabfa..00000000000 --- a/src/generated/Applications/Item/TokenLifetimePolicies/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Applications.Item.TokenLifetimePolicies.@Ref { - /// Builds and executes requests for operations under \applications\{application-id}\tokenLifetimePolicies\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The tokenLifetimePolicies assigned to this application. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The tokenLifetimePolicies assigned to this application. Supports $expand."; - // Create options for all the parameters - var applicationIdOption = new Option("--application-id", description: "key: id of application") { - }; - applicationIdOption.IsRequired = true; - command.AddOption(applicationIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string applicationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, applicationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The tokenLifetimePolicies assigned to this application. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The tokenLifetimePolicies assigned to this application. Supports $expand."; - // Create options for all the parameters - var applicationIdOption = new Option("--application-id", description: "key: id of application") { - }; - applicationIdOption.IsRequired = true; - command.AddOption(applicationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string applicationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, applicationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/applications/{application_id}/tokenLifetimePolicies/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The tokenLifetimePolicies assigned to this application. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The tokenLifetimePolicies assigned to this application. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Applications.Item.TokenLifetimePolicies.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The tokenLifetimePolicies assigned to this application. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The tokenLifetimePolicies assigned to this application. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Applications.Item.TokenLifetimePolicies.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The tokenLifetimePolicies assigned to this application. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Applications/Item/TokenLifetimePolicies/@Ref/RefResponse.cs b/src/generated/Applications/Item/TokenLifetimePolicies/@Ref/RefResponse.cs deleted file mode 100644 index e025df0fd59..00000000000 --- a/src/generated/Applications/Item/TokenLifetimePolicies/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Applications.Item.TokenLifetimePolicies.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Applications/Item/TokenLifetimePolicies/Ref/Ref.cs b/src/generated/Applications/Item/TokenLifetimePolicies/Ref/Ref.cs new file mode 100644 index 00000000000..d380c27e59f --- /dev/null +++ b/src/generated/Applications/Item/TokenLifetimePolicies/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Applications.Item.TokenLifetimePolicies.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Applications/Item/TokenLifetimePolicies/Ref/RefRequestBuilder.cs b/src/generated/Applications/Item/TokenLifetimePolicies/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..a01b717b2a7 --- /dev/null +++ b/src/generated/Applications/Item/TokenLifetimePolicies/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Applications.Item.TokenLifetimePolicies.Ref { + /// Builds and executes requests for operations under \applications\{application-id}\tokenLifetimePolicies\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The tokenLifetimePolicies assigned to this application. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The tokenLifetimePolicies assigned to this application. Supports $expand."; + // Create options for all the parameters + var applicationIdOption = new Option("--application-id", description: "key: id of application") { + }; + applicationIdOption.IsRequired = true; + command.AddOption(applicationIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string applicationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, applicationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The tokenLifetimePolicies assigned to this application. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The tokenLifetimePolicies assigned to this application. Supports $expand."; + // Create options for all the parameters + var applicationIdOption = new Option("--application-id", description: "key: id of application") { + }; + applicationIdOption.IsRequired = true; + command.AddOption(applicationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string applicationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, applicationIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/applications/{application_id}/tokenLifetimePolicies/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The tokenLifetimePolicies assigned to this application. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The tokenLifetimePolicies assigned to this application. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Applications.Item.TokenLifetimePolicies.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The tokenLifetimePolicies assigned to this application. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Applications/Item/TokenLifetimePolicies/Ref/RefResponse.cs b/src/generated/Applications/Item/TokenLifetimePolicies/Ref/RefResponse.cs new file mode 100644 index 00000000000..fb0810fabfe --- /dev/null +++ b/src/generated/Applications/Item/TokenLifetimePolicies/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Applications.Item.TokenLifetimePolicies.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Applications/Item/TokenLifetimePolicies/TokenLifetimePoliciesRequestBuilder.cs b/src/generated/Applications/Item/TokenLifetimePolicies/TokenLifetimePoliciesRequestBuilder.cs index 9e5beb53174..7d6aab844eb 100644 --- a/src/generated/Applications/Item/TokenLifetimePolicies/TokenLifetimePoliciesRequestBuilder.cs +++ b/src/generated/Applications/Item/TokenLifetimePolicies/TokenLifetimePoliciesRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Applications.Item.TokenLifetimePolicies.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string applicationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string applicationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, applicationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, applicationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Applications.Item.TokenLifetimePolicies.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Applications.Item.TokenLifetimePolicies.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The tokenLifetimePolicies assigned to this application. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The tokenLifetimePolicies assigned to this application. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Applications/Item/UnsetVerifiedPublisher/UnsetVerifiedPublisherRequestBuilder.cs b/src/generated/Applications/Item/UnsetVerifiedPublisher/UnsetVerifiedPublisherRequestBuilder.cs index 59ec9549e4f..1839a06f493 100644 --- a/src/generated/Applications/Item/UnsetVerifiedPublisher/UnsetVerifiedPublisherRequestBuilder.cs +++ b/src/generated/Applications/Item/UnsetVerifiedPublisher/UnsetVerifiedPublisherRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,10 @@ public Command BuildPostCommand() { }; applicationIdOption.IsRequired = true; command.AddOption(applicationIdOption); - command.SetHandler(async (string applicationId) => { + command.SetHandler(async (string applicationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, applicationIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action unsetVerifiedPublisher - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Applications/ValidateProperties/ValidatePropertiesRequestBuilder.cs b/src/generated/Applications/ValidateProperties/ValidatePropertiesRequestBuilder.cs index bc95d381789..20721351e05 100644 --- a/src/generated/Applications/ValidateProperties/ValidatePropertiesRequestBuilder.cs +++ b/src/generated/Applications/ValidateProperties/ValidatePropertiesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,14 +29,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -72,18 +71,5 @@ public RequestInformation CreatePostRequestInformation(ValidatePropertiesRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action validateProperties - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ValidatePropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/AuditLogs/AuditLogsRequestBuilder.cs b/src/generated/AuditLogs/AuditLogsRequestBuilder.cs index e5ae6ba5453..1a69d43b74d 100644 --- a/src/generated/AuditLogs/AuditLogsRequestBuilder.cs +++ b/src/generated/AuditLogs/AuditLogsRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,6 +26,9 @@ public class AuditLogsRequestBuilder { public Command BuildDirectoryAuditsCommand() { var command = new Command("directory-audits"); var builder = new ApiSdk.AuditLogs.DirectoryAudits.DirectoryAuditsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -47,20 +50,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -74,14 +76,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -89,6 +90,9 @@ public Command BuildPatchCommand() { public Command BuildProvisioningCommand() { var command = new Command("provisioning"); var builder = new ApiSdk.AuditLogs.Provisioning.ProvisioningRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -96,6 +100,9 @@ public Command BuildProvisioningCommand() { public Command BuildRestrictedSignInsCommand() { var command = new Command("restricted-sign-ins"); var builder = new ApiSdk.AuditLogs.RestrictedSignIns.RestrictedSignInsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -103,6 +110,9 @@ public Command BuildRestrictedSignInsCommand() { public Command BuildSignInsCommand() { var command = new Command("sign-ins"); var builder = new ApiSdk.AuditLogs.SignIns.SignInsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -159,31 +169,6 @@ public RequestInformation CreatePatchRequestInformation(AuditLogRoot body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get auditLogs - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update auditLogs - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AuditLogRoot model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get auditLogs public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/AuditLogs/DirectoryAudits/DirectoryAuditsRequestBuilder.cs b/src/generated/AuditLogs/DirectoryAudits/DirectoryAuditsRequestBuilder.cs index f7af7b1cdbc..00ee65d7ae2 100644 --- a/src/generated/AuditLogs/DirectoryAudits/DirectoryAuditsRequestBuilder.cs +++ b/src/generated/AuditLogs/DirectoryAudits/DirectoryAuditsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DirectoryAuditsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DirectoryAuditRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(DirectoryAudit body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DirectoryAudit model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/AuditLogs/DirectoryAudits/Item/DirectoryAuditRequestBuilder.cs b/src/generated/AuditLogs/DirectoryAudits/Item/DirectoryAuditRequestBuilder.cs index c0b28013188..c0244a789ff 100644 --- a/src/generated/AuditLogs/DirectoryAudits/Item/DirectoryAuditRequestBuilder.cs +++ b/src/generated/AuditLogs/DirectoryAudits/Item/DirectoryAuditRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var directoryAuditIdOption = new Option("--directoryaudit-id", description: "key: id of directoryAudit") { + var directoryAuditIdOption = new Option("--directory-audit-id", description: "key: id of directoryAudit") { }; directoryAuditIdOption.IsRequired = true; command.AddOption(directoryAuditIdOption); - command.SetHandler(async (string directoryAuditId) => { + command.SetHandler(async (string directoryAuditId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, directoryAuditIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var directoryAuditIdOption = new Option("--directoryaudit-id", description: "key: id of directoryAudit") { + var directoryAuditIdOption = new Option("--directory-audit-id", description: "key: id of directoryAudit") { }; directoryAuditIdOption.IsRequired = true; command.AddOption(directoryAuditIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string directoryAuditId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string directoryAuditId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, directoryAuditIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, directoryAuditIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var directoryAuditIdOption = new Option("--directoryaudit-id", description: "key: id of directoryAudit") { + var directoryAuditIdOption = new Option("--directory-audit-id", description: "key: id of directoryAudit") { }; directoryAuditIdOption.IsRequired = true; command.AddOption(directoryAuditIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string directoryAuditId, string body) => { + command.SetHandler(async (string directoryAuditId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, directoryAuditIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(DirectoryAudit body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DirectoryAudit model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/AuditLogs/Provisioning/Item/ProvisioningObjectSummaryRequestBuilder.cs b/src/generated/AuditLogs/Provisioning/Item/ProvisioningObjectSummaryRequestBuilder.cs index d0477bee634..cb5814205d1 100644 --- a/src/generated/AuditLogs/Provisioning/Item/ProvisioningObjectSummaryRequestBuilder.cs +++ b/src/generated/AuditLogs/Provisioning/Item/ProvisioningObjectSummaryRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property provisioning for auditLogs"; // Create options for all the parameters - var provisioningObjectSummaryIdOption = new Option("--provisioningobjectsummary-id", description: "key: id of provisioningObjectSummary") { + var provisioningObjectSummaryIdOption = new Option("--provisioning-object-summary-id", description: "key: id of provisioningObjectSummary") { }; provisioningObjectSummaryIdOption.IsRequired = true; command.AddOption(provisioningObjectSummaryIdOption); - command.SetHandler(async (string provisioningObjectSummaryId) => { + command.SetHandler(async (string provisioningObjectSummaryId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, provisioningObjectSummaryIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get provisioning from auditLogs"; // Create options for all the parameters - var provisioningObjectSummaryIdOption = new Option("--provisioningobjectsummary-id", description: "key: id of provisioningObjectSummary") { + var provisioningObjectSummaryIdOption = new Option("--provisioning-object-summary-id", description: "key: id of provisioningObjectSummary") { }; provisioningObjectSummaryIdOption.IsRequired = true; command.AddOption(provisioningObjectSummaryIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string provisioningObjectSummaryId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string provisioningObjectSummaryId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, provisioningObjectSummaryIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, provisioningObjectSummaryIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property provisioning in auditLogs"; // Create options for all the parameters - var provisioningObjectSummaryIdOption = new Option("--provisioningobjectsummary-id", description: "key: id of provisioningObjectSummary") { + var provisioningObjectSummaryIdOption = new Option("--provisioning-object-summary-id", description: "key: id of provisioningObjectSummary") { }; provisioningObjectSummaryIdOption.IsRequired = true; command.AddOption(provisioningObjectSummaryIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string provisioningObjectSummaryId, string body) => { + command.SetHandler(async (string provisioningObjectSummaryId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, provisioningObjectSummaryIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ProvisioningObjectSummar requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property provisioning for auditLogs - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get provisioning from auditLogs - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property provisioning in auditLogs - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ProvisioningObjectSummary model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get provisioning from auditLogs public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/AuditLogs/Provisioning/ProvisioningRequestBuilder.cs b/src/generated/AuditLogs/Provisioning/ProvisioningRequestBuilder.cs index 8564b93ae35..923159ff2b8 100644 --- a/src/generated/AuditLogs/Provisioning/ProvisioningRequestBuilder.cs +++ b/src/generated/AuditLogs/Provisioning/ProvisioningRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ProvisioningRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ProvisioningObjectSummaryRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(ProvisioningObjectSummary requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get provisioning from auditLogs - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to provisioning for auditLogs - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ProvisioningObjectSummary model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get provisioning from auditLogs public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/AuditLogs/RestrictedSignIns/Item/RestrictedSignInRequestBuilder.cs b/src/generated/AuditLogs/RestrictedSignIns/Item/RestrictedSignInRequestBuilder.cs index 31260273975..a0a6deac0ab 100644 --- a/src/generated/AuditLogs/RestrictedSignIns/Item/RestrictedSignInRequestBuilder.cs +++ b/src/generated/AuditLogs/RestrictedSignIns/Item/RestrictedSignInRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property restrictedSignIns for auditLogs"; // Create options for all the parameters - var restrictedSignInIdOption = new Option("--restrictedsignin-id", description: "key: id of restrictedSignIn") { + var restrictedSignInIdOption = new Option("--restricted-sign-in-id", description: "key: id of restrictedSignIn") { }; restrictedSignInIdOption.IsRequired = true; command.AddOption(restrictedSignInIdOption); - command.SetHandler(async (string restrictedSignInId) => { + command.SetHandler(async (string restrictedSignInId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, restrictedSignInIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get restrictedSignIns from auditLogs"; // Create options for all the parameters - var restrictedSignInIdOption = new Option("--restrictedsignin-id", description: "key: id of restrictedSignIn") { + var restrictedSignInIdOption = new Option("--restricted-sign-in-id", description: "key: id of restrictedSignIn") { }; restrictedSignInIdOption.IsRequired = true; command.AddOption(restrictedSignInIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string restrictedSignInId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string restrictedSignInId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, restrictedSignInIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, restrictedSignInIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property restrictedSignIns in auditLogs"; // Create options for all the parameters - var restrictedSignInIdOption = new Option("--restrictedsignin-id", description: "key: id of restrictedSignIn") { + var restrictedSignInIdOption = new Option("--restricted-sign-in-id", description: "key: id of restrictedSignIn") { }; restrictedSignInIdOption.IsRequired = true; command.AddOption(restrictedSignInIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string restrictedSignInId, string body) => { + command.SetHandler(async (string restrictedSignInId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, restrictedSignInIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(RestrictedSignIn body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property restrictedSignIns for auditLogs - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get restrictedSignIns from auditLogs - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property restrictedSignIns in auditLogs - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(RestrictedSignIn model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get restrictedSignIns from auditLogs public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/AuditLogs/RestrictedSignIns/RestrictedSignInsRequestBuilder.cs b/src/generated/AuditLogs/RestrictedSignIns/RestrictedSignInsRequestBuilder.cs index e2eb88c0429..1b03f97d738 100644 --- a/src/generated/AuditLogs/RestrictedSignIns/RestrictedSignInsRequestBuilder.cs +++ b/src/generated/AuditLogs/RestrictedSignIns/RestrictedSignInsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class RestrictedSignInsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new RestrictedSignInRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(RestrictedSignIn body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get restrictedSignIns from auditLogs - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to restrictedSignIns for auditLogs - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RestrictedSignIn model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get restrictedSignIns from auditLogs public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/AuditLogs/SignIns/Item/SignInRequestBuilder.cs b/src/generated/AuditLogs/SignIns/Item/SignInRequestBuilder.cs index 8abfd27f5da..94daffb5d31 100644 --- a/src/generated/AuditLogs/SignIns/Item/SignInRequestBuilder.cs +++ b/src/generated/AuditLogs/SignIns/Item/SignInRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var signInIdOption = new Option("--signin-id", description: "key: id of signIn") { + var signInIdOption = new Option("--sign-in-id", description: "key: id of signIn") { }; signInIdOption.IsRequired = true; command.AddOption(signInIdOption); - command.SetHandler(async (string signInId) => { + command.SetHandler(async (string signInId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, signInIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var signInIdOption = new Option("--signin-id", description: "key: id of signIn") { + var signInIdOption = new Option("--sign-in-id", description: "key: id of signIn") { }; signInIdOption.IsRequired = true; command.AddOption(signInIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string signInId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string signInId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, signInIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, signInIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var signInIdOption = new Option("--signin-id", description: "key: id of signIn") { + var signInIdOption = new Option("--sign-in-id", description: "key: id of signIn") { }; signInIdOption.IsRequired = true; command.AddOption(signInIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string signInId, string body) => { + command.SetHandler(async (string signInId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, signInIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(SignIn body, Action - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SignIn model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/AuditLogs/SignIns/SignInsRequestBuilder.cs b/src/generated/AuditLogs/SignIns/SignInsRequestBuilder.cs index fed1e1baee7..de9ff31e716 100644 --- a/src/generated/AuditLogs/SignIns/SignInsRequestBuilder.cs +++ b/src/generated/AuditLogs/SignIns/SignInsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SignInsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SignInRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(SignIn body, Action - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SignIn model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/AuthenticationMethodConfigurations/AuthenticationMethodConfigurationsRequestBuilder.cs b/src/generated/AuthenticationMethodConfigurations/AuthenticationMethodConfigurationsRequestBuilder.cs index b677ab01802..47d9b7e7ad3 100644 --- a/src/generated/AuthenticationMethodConfigurations/AuthenticationMethodConfigurationsRequestBuilder.cs +++ b/src/generated/AuthenticationMethodConfigurations/AuthenticationMethodConfigurationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AuthenticationMethodConfigurationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AuthenticationMethodConfigurationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(AuthenticationMethodConfi requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get entities from authenticationMethodConfigurations - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to authenticationMethodConfigurations - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AuthenticationMethodConfiguration model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from authenticationMethodConfigurations public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/AuthenticationMethodConfigurations/Item/AuthenticationMethodConfigurationRequestBuilder.cs b/src/generated/AuthenticationMethodConfigurations/Item/AuthenticationMethodConfigurationRequestBuilder.cs index 8e78a5eacda..8e11225992d 100644 --- a/src/generated/AuthenticationMethodConfigurations/Item/AuthenticationMethodConfigurationRequestBuilder.cs +++ b/src/generated/AuthenticationMethodConfigurations/Item/AuthenticationMethodConfigurationRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete entity from authenticationMethodConfigurations"; // Create options for all the parameters - var authenticationMethodConfigurationIdOption = new Option("--authenticationmethodconfiguration-id", description: "key: id of authenticationMethodConfiguration") { + var authenticationMethodConfigurationIdOption = new Option("--authentication-method-configuration-id", description: "key: id of authenticationMethodConfiguration") { }; authenticationMethodConfigurationIdOption.IsRequired = true; command.AddOption(authenticationMethodConfigurationIdOption); - command.SetHandler(async (string authenticationMethodConfigurationId) => { + command.SetHandler(async (string authenticationMethodConfigurationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, authenticationMethodConfigurationIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get entity from authenticationMethodConfigurations by key"; // Create options for all the parameters - var authenticationMethodConfigurationIdOption = new Option("--authenticationmethodconfiguration-id", description: "key: id of authenticationMethodConfiguration") { + var authenticationMethodConfigurationIdOption = new Option("--authentication-method-configuration-id", description: "key: id of authenticationMethodConfiguration") { }; authenticationMethodConfigurationIdOption.IsRequired = true; command.AddOption(authenticationMethodConfigurationIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string authenticationMethodConfigurationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string authenticationMethodConfigurationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, authenticationMethodConfigurationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, authenticationMethodConfigurationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update entity in authenticationMethodConfigurations"; // Create options for all the parameters - var authenticationMethodConfigurationIdOption = new Option("--authenticationmethodconfiguration-id", description: "key: id of authenticationMethodConfiguration") { + var authenticationMethodConfigurationIdOption = new Option("--authentication-method-configuration-id", description: "key: id of authenticationMethodConfiguration") { }; authenticationMethodConfigurationIdOption.IsRequired = true; command.AddOption(authenticationMethodConfigurationIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string authenticationMethodConfigurationId, string body) => { + command.SetHandler(async (string authenticationMethodConfigurationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, authenticationMethodConfigurationIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(AuthenticationMethodConf requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from authenticationMethodConfigurations - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from authenticationMethodConfigurations by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in authenticationMethodConfigurations - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AuthenticationMethodConfiguration model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from authenticationMethodConfigurations by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/AuthenticationMethodsPolicy/AuthenticationMethodConfigurations/AuthenticationMethodConfigurationsRequestBuilder.cs b/src/generated/AuthenticationMethodsPolicy/AuthenticationMethodConfigurations/AuthenticationMethodConfigurationsRequestBuilder.cs index 21d8476d420..749aef043bd 100644 --- a/src/generated/AuthenticationMethodsPolicy/AuthenticationMethodConfigurations/AuthenticationMethodConfigurationsRequestBuilder.cs +++ b/src/generated/AuthenticationMethodsPolicy/AuthenticationMethodConfigurations/AuthenticationMethodConfigurationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AuthenticationMethodConfigurationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AuthenticationMethodConfigurationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(AuthenticationMethodConfi requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the settings for each authentication method. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the settings for each authentication method. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AuthenticationMethodConfiguration model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the settings for each authentication method. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/AuthenticationMethodsPolicy/AuthenticationMethodConfigurations/Item/AuthenticationMethodConfigurationRequestBuilder.cs b/src/generated/AuthenticationMethodsPolicy/AuthenticationMethodConfigurations/Item/AuthenticationMethodConfigurationRequestBuilder.cs index dd1a8ed379f..0f12284e262 100644 --- a/src/generated/AuthenticationMethodsPolicy/AuthenticationMethodConfigurations/Item/AuthenticationMethodConfigurationRequestBuilder.cs +++ b/src/generated/AuthenticationMethodsPolicy/AuthenticationMethodConfigurations/Item/AuthenticationMethodConfigurationRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the settings for each authentication method."; // Create options for all the parameters - var authenticationMethodConfigurationIdOption = new Option("--authenticationmethodconfiguration-id", description: "key: id of authenticationMethodConfiguration") { + var authenticationMethodConfigurationIdOption = new Option("--authentication-method-configuration-id", description: "key: id of authenticationMethodConfiguration") { }; authenticationMethodConfigurationIdOption.IsRequired = true; command.AddOption(authenticationMethodConfigurationIdOption); - command.SetHandler(async (string authenticationMethodConfigurationId) => { + command.SetHandler(async (string authenticationMethodConfigurationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, authenticationMethodConfigurationIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the settings for each authentication method."; // Create options for all the parameters - var authenticationMethodConfigurationIdOption = new Option("--authenticationmethodconfiguration-id", description: "key: id of authenticationMethodConfiguration") { + var authenticationMethodConfigurationIdOption = new Option("--authentication-method-configuration-id", description: "key: id of authenticationMethodConfiguration") { }; authenticationMethodConfigurationIdOption.IsRequired = true; command.AddOption(authenticationMethodConfigurationIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string authenticationMethodConfigurationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string authenticationMethodConfigurationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, authenticationMethodConfigurationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, authenticationMethodConfigurationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the settings for each authentication method."; // Create options for all the parameters - var authenticationMethodConfigurationIdOption = new Option("--authenticationmethodconfiguration-id", description: "key: id of authenticationMethodConfiguration") { + var authenticationMethodConfigurationIdOption = new Option("--authentication-method-configuration-id", description: "key: id of authenticationMethodConfiguration") { }; authenticationMethodConfigurationIdOption.IsRequired = true; command.AddOption(authenticationMethodConfigurationIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string authenticationMethodConfigurationId, string body) => { + command.SetHandler(async (string authenticationMethodConfigurationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, authenticationMethodConfigurationIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(AuthenticationMethodConf requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the settings for each authentication method. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the settings for each authentication method. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the settings for each authentication method. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AuthenticationMethodConfiguration model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the settings for each authentication method. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/AuthenticationMethodsPolicy/AuthenticationMethodsPolicyRequestBuilder.cs b/src/generated/AuthenticationMethodsPolicy/AuthenticationMethodsPolicyRequestBuilder.cs index 905d8684d5a..e6e72d15d3d 100644 --- a/src/generated/AuthenticationMethodsPolicy/AuthenticationMethodsPolicyRequestBuilder.cs +++ b/src/generated/AuthenticationMethodsPolicy/AuthenticationMethodsPolicyRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,6 +23,9 @@ public class AuthenticationMethodsPolicyRequestBuilder { public Command BuildAuthenticationMethodConfigurationsCommand() { var command = new Command("authentication-method-configurations"); var builder = new ApiSdk.AuthenticationMethodsPolicy.AuthenticationMethodConfigurations.AuthenticationMethodConfigurationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -44,20 +47,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -71,14 +73,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -135,31 +136,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get authenticationMethodsPolicy - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update authenticationMethodsPolicy - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.AuthenticationMethodsPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get authenticationMethodsPolicy public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Branding/BrandingRequestBuilder.cs b/src/generated/Branding/BrandingRequestBuilder.cs index a3b9281ae2c..3072515c834 100644 --- a/src/generated/Branding/BrandingRequestBuilder.cs +++ b/src/generated/Branding/BrandingRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,25 +37,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } public Command BuildLocalizationsCommand() { var command = new Command("localizations"); var builder = new ApiSdk.Branding.Localizations.LocalizationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -71,14 +73,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -135,31 +136,6 @@ public RequestInformation CreatePatchRequestInformation(OrganizationalBranding b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get branding - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update branding - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OrganizationalBranding model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get branding public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Branding/Localizations/Item/OrganizationalBrandingLocalizationRequestBuilder.cs b/src/generated/Branding/Localizations/Item/OrganizationalBrandingLocalizationRequestBuilder.cs index ea0033a3c18..a03e7850cbf 100644 --- a/src/generated/Branding/Localizations/Item/OrganizationalBrandingLocalizationRequestBuilder.cs +++ b/src/generated/Branding/Localizations/Item/OrganizationalBrandingLocalizationRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Add different branding based on a locale."; // Create options for all the parameters - var organizationalBrandingLocalizationIdOption = new Option("--organizationalbrandinglocalization-id", description: "key: id of organizationalBrandingLocalization") { + var organizationalBrandingLocalizationIdOption = new Option("--organizational-branding-localization-id", description: "key: id of organizationalBrandingLocalization") { }; organizationalBrandingLocalizationIdOption.IsRequired = true; command.AddOption(organizationalBrandingLocalizationIdOption); - command.SetHandler(async (string organizationalBrandingLocalizationId) => { + command.SetHandler(async (string organizationalBrandingLocalizationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, organizationalBrandingLocalizationIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Add different branding based on a locale."; // Create options for all the parameters - var organizationalBrandingLocalizationIdOption = new Option("--organizationalbrandinglocalization-id", description: "key: id of organizationalBrandingLocalization") { + var organizationalBrandingLocalizationIdOption = new Option("--organizational-branding-localization-id", description: "key: id of organizationalBrandingLocalization") { }; organizationalBrandingLocalizationIdOption.IsRequired = true; command.AddOption(organizationalBrandingLocalizationIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string organizationalBrandingLocalizationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string organizationalBrandingLocalizationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, organizationalBrandingLocalizationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, organizationalBrandingLocalizationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Add different branding based on a locale."; // Create options for all the parameters - var organizationalBrandingLocalizationIdOption = new Option("--organizationalbrandinglocalization-id", description: "key: id of organizationalBrandingLocalization") { + var organizationalBrandingLocalizationIdOption = new Option("--organizational-branding-localization-id", description: "key: id of organizationalBrandingLocalization") { }; organizationalBrandingLocalizationIdOption.IsRequired = true; command.AddOption(organizationalBrandingLocalizationIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string organizationalBrandingLocalizationId, string body) => { + command.SetHandler(async (string organizationalBrandingLocalizationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, organizationalBrandingLocalizationIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(OrganizationalBrandingLo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Add different branding based on a locale. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add different branding based on a locale. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add different branding based on a locale. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OrganizationalBrandingLocalization model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Add different branding based on a locale. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Branding/Localizations/LocalizationsRequestBuilder.cs b/src/generated/Branding/Localizations/LocalizationsRequestBuilder.cs index 9385528b687..6e06ae11d3d 100644 --- a/src/generated/Branding/Localizations/LocalizationsRequestBuilder.cs +++ b/src/generated/Branding/Localizations/LocalizationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class LocalizationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OrganizationalBrandingLocalizationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(OrganizationalBrandingLoc requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Add different branding based on a locale. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add different branding based on a locale. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OrganizationalBrandingLocalization model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Add different branding based on a locale. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/CertificateBasedAuthConfiguration/CertificateBasedAuthConfigurationRequestBuilder.cs b/src/generated/CertificateBasedAuthConfiguration/CertificateBasedAuthConfigurationRequestBuilder.cs index 8ffc95f1849..43b7ee05846 100644 --- a/src/generated/CertificateBasedAuthConfiguration/CertificateBasedAuthConfigurationRequestBuilder.cs +++ b/src/generated/CertificateBasedAuthConfiguration/CertificateBasedAuthConfigurationRequestBuilder.cs @@ -1,10 +1,11 @@ +using ApiSdk.CertificateBasedAuthConfiguration.Item; using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -20,11 +21,11 @@ public class CertificateBasedAuthConfigurationRequestBuilder { /// Url template to use to build the URL for the current request builder private string UrlTemplate { get; set; } public List BuildCommand() { - var builder = new CertificateBasedAuthConfigurationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCreateCommand(), - builder.BuildListCommand(), - }; + var builder = new CertificateBasedAuthConfigurationItemRequestBuilder(PathParameters, RequestAdapter); + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -38,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -97,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -108,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -171,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get entities from certificateBasedAuthConfiguration - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to certificateBasedAuthConfiguration - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.CertificateBasedAuthConfiguration model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from certificateBasedAuthConfiguration public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/CertificateBasedAuthConfiguration/Item/CertificateBasedAuthConfigurationItemRequestBuilder.cs b/src/generated/CertificateBasedAuthConfiguration/Item/CertificateBasedAuthConfigurationItemRequestBuilder.cs new file mode 100644 index 00000000000..8e7413b7be5 --- /dev/null +++ b/src/generated/CertificateBasedAuthConfiguration/Item/CertificateBasedAuthConfigurationItemRequestBuilder.cs @@ -0,0 +1,178 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.CertificateBasedAuthConfiguration.Item { + /// Builds and executes requests for operations under \certificateBasedAuthConfiguration\{certificateBasedAuthConfigurationItem-Id} + public class CertificateBasedAuthConfigurationItemRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Delete entity from certificateBasedAuthConfiguration + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Delete entity from certificateBasedAuthConfiguration"; + // Create options for all the parameters + var certificateBasedAuthConfigurationItemIdOption = new Option("--certificate-based-auth-configuration-item-id", description: "key: id of certificateBasedAuthConfiguration") { + }; + certificateBasedAuthConfigurationItemIdOption.IsRequired = true; + command.AddOption(certificateBasedAuthConfigurationItemIdOption); + command.SetHandler(async (string certificateBasedAuthConfigurationItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, certificateBasedAuthConfigurationItemIdOption); + return command; + } + /// + /// Get entity from certificateBasedAuthConfiguration by key + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Get entity from certificateBasedAuthConfiguration by key"; + // Create options for all the parameters + var certificateBasedAuthConfigurationItemIdOption = new Option("--certificate-based-auth-configuration-item-id", description: "key: id of certificateBasedAuthConfiguration") { + }; + certificateBasedAuthConfigurationItemIdOption.IsRequired = true; + command.AddOption(certificateBasedAuthConfigurationItemIdOption); + var selectOption = new Option("--select", description: "Select properties to be returned") { + Arity = ArgumentArity.ZeroOrMore + }; + selectOption.IsRequired = false; + command.AddOption(selectOption); + var expandOption = new Option("--expand", description: "Expand related entities") { + Arity = ArgumentArity.ZeroOrMore + }; + expandOption.IsRequired = false; + command.AddOption(expandOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string certificateBasedAuthConfigurationItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Select = select; + q.Expand = expand; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, certificateBasedAuthConfigurationItemIdOption, selectOption, expandOption, outputOption); + return command; + } + /// + /// Update entity in certificateBasedAuthConfiguration + /// + public Command BuildPatchCommand() { + var command = new Command("patch"); + command.Description = "Update entity in certificateBasedAuthConfiguration"; + // Create options for all the parameters + var certificateBasedAuthConfigurationItemIdOption = new Option("--certificate-based-auth-configuration-item-id", description: "key: id of certificateBasedAuthConfiguration") { + }; + certificateBasedAuthConfigurationItemIdOption.IsRequired = true; + command.AddOption(certificateBasedAuthConfigurationItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string certificateBasedAuthConfigurationItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePatchRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, certificateBasedAuthConfigurationItemIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new CertificateBasedAuthConfigurationItemRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public CertificateBasedAuthConfigurationItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/certificateBasedAuthConfiguration/{certificateBasedAuthConfigurationItem_Id}{?select,expand}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Delete entity from certificateBasedAuthConfiguration + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Get entity from certificateBasedAuthConfiguration by key + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Update entity in certificateBasedAuthConfiguration + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft.Graph.CertificateBasedAuthConfiguration body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PATCH, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Get entity from certificateBasedAuthConfiguration by key + public class GetQueryParameters : QueryParametersBase { + /// Expand related entities + public string[] Expand { get; set; } + /// Select properties to be returned + public string[] Select { get; set; } + } + } +} diff --git a/src/generated/CertificateBasedAuthConfiguration/Item/CertificateBasedAuthConfigurationRequestBuilder.cs b/src/generated/CertificateBasedAuthConfiguration/Item/CertificateBasedAuthConfigurationRequestBuilder.cs deleted file mode 100644 index d910048b341..00000000000 --- a/src/generated/CertificateBasedAuthConfiguration/Item/CertificateBasedAuthConfigurationRequestBuilder.cs +++ /dev/null @@ -1,217 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.CertificateBasedAuthConfiguration.Item { - /// Builds and executes requests for operations under \certificateBasedAuthConfiguration\{certificateBasedAuthConfiguration-id} - public class CertificateBasedAuthConfigurationRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Delete entity from certificateBasedAuthConfiguration - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Delete entity from certificateBasedAuthConfiguration"; - // Create options for all the parameters - var certificateBasedAuthConfigurationIdOption = new Option("--certificatebasedauthconfiguration-id", description: "key: id of certificateBasedAuthConfiguration") { - }; - certificateBasedAuthConfigurationIdOption.IsRequired = true; - command.AddOption(certificateBasedAuthConfigurationIdOption); - command.SetHandler(async (string certificateBasedAuthConfigurationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, certificateBasedAuthConfigurationIdOption); - return command; - } - /// - /// Get entity from certificateBasedAuthConfiguration by key - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Get entity from certificateBasedAuthConfiguration by key"; - // Create options for all the parameters - var certificateBasedAuthConfigurationIdOption = new Option("--certificatebasedauthconfiguration-id", description: "key: id of certificateBasedAuthConfiguration") { - }; - certificateBasedAuthConfigurationIdOption.IsRequired = true; - command.AddOption(certificateBasedAuthConfigurationIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string certificateBasedAuthConfigurationId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, certificateBasedAuthConfigurationIdOption, selectOption, expandOption); - return command; - } - /// - /// Update entity in certificateBasedAuthConfiguration - /// - public Command BuildPatchCommand() { - var command = new Command("patch"); - command.Description = "Update entity in certificateBasedAuthConfiguration"; - // Create options for all the parameters - var certificateBasedAuthConfigurationIdOption = new Option("--certificatebasedauthconfiguration-id", description: "key: id of certificateBasedAuthConfiguration") { - }; - certificateBasedAuthConfigurationIdOption.IsRequired = true; - command.AddOption(certificateBasedAuthConfigurationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string certificateBasedAuthConfigurationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePatchRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, certificateBasedAuthConfigurationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new CertificateBasedAuthConfigurationRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public CertificateBasedAuthConfigurationRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/certificateBasedAuthConfiguration/{certificateBasedAuthConfiguration_id}{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Delete entity from certificateBasedAuthConfiguration - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Get entity from certificateBasedAuthConfiguration by key - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Update entity in certificateBasedAuthConfiguration - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft.Graph.CertificateBasedAuthConfiguration body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PATCH, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Delete entity from certificateBasedAuthConfiguration - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from certificateBasedAuthConfiguration by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in certificateBasedAuthConfiguration - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.CertificateBasedAuthConfiguration model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// Get entity from certificateBasedAuthConfiguration by key - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/Chats/ChatsRequestBuilder.cs b/src/generated/Chats/ChatsRequestBuilder.cs index 1b5a6230bf5..7b0bda5e7ee 100644 --- a/src/generated/Chats/ChatsRequestBuilder.cs +++ b/src/generated/Chats/ChatsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,16 +23,15 @@ public class ChatsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ChatRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildInstalledAppsCommand(), - builder.BuildMembersCommand(), - builder.BuildMessagesCommand(), - builder.BuildPatchCommand(), - builder.BuildSendActivityNotificationCommand(), - builder.BuildTabsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInstalledAppsCommand()); + commands.Add(builder.BuildMembersCommand()); + commands.Add(builder.BuildMessagesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSendActivityNotificationCommand()); + commands.Add(builder.BuildTabsCommand()); return commands; } /// @@ -46,21 +45,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -105,7 +103,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -116,15 +118,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -185,31 +182,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G public GetAllMessagesRequestBuilder GetAllMessages() { return new GetAllMessagesRequestBuilder(PathParameters, RequestAdapter); } - /// - /// Get entities from chats - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to chats - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Chat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from chats public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Chats/GetAllMessages/GetAllMessagesRequestBuilder.cs b/src/generated/Chats/GetAllMessages/GetAllMessagesRequestBuilder.cs index 3d70c91e9ac..807e2d98d26 100644 --- a/src/generated/Chats/GetAllMessages/GetAllMessagesRequestBuilder.cs +++ b/src/generated/Chats/GetAllMessages/GetAllMessagesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function getAllMessages"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getAllMessages - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Chats/Item/ChatRequestBuilder.cs b/src/generated/Chats/Item/ChatRequestBuilder.cs index 1cedb91ab73..1bb9ae6bab9 100644 --- a/src/generated/Chats/Item/ChatRequestBuilder.cs +++ b/src/generated/Chats/Item/ChatRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,11 +35,10 @@ public Command BuildDeleteCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - command.SetHandler(async (string chatId) => { + command.SetHandler(async (string chatId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, chatIdOption); return command; @@ -65,25 +64,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string chatId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildInstalledAppsCommand() { var command = new Command("installed-apps"); var builder = new ApiSdk.Chats.Item.InstalledApps.InstalledAppsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -92,6 +93,9 @@ public Command BuildMembersCommand() { var command = new Command("members"); var builder = new ApiSdk.Chats.Item.Members.MembersRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -99,6 +103,9 @@ public Command BuildMembersCommand() { public Command BuildMessagesCommand() { var command = new Command("messages"); var builder = new ApiSdk.Chats.Item.Messages.MessagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -118,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string chatId, string body) => { + command.SetHandler(async (string chatId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, chatIdOption, bodyOption); return command; @@ -139,6 +145,9 @@ public Command BuildSendActivityNotificationCommand() { public Command BuildTabsCommand() { var command = new Command("tabs"); var builder = new ApiSdk.Chats.Item.Tabs.TabsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -210,42 +219,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from chats - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from chats by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in chats - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Chat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from chats by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Chats/Item/InstalledApps/InstalledAppsRequestBuilder.cs b/src/generated/Chats/Item/InstalledApps/InstalledAppsRequestBuilder.cs index d6606c78a04..fbc23402734 100644 --- a/src/generated/Chats/Item/InstalledApps/InstalledAppsRequestBuilder.cs +++ b/src/generated/Chats/Item/InstalledApps/InstalledAppsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class InstalledAppsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TeamsAppInstallationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildTeamsAppCommand(), - builder.BuildTeamsAppDefinitionCommand(), - builder.BuildUpgradeCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildTeamsAppCommand()); + commands.Add(builder.BuildTeamsAppDefinitionCommand()); + commands.Add(builder.BuildUpgradeCommand()); return commands; } /// @@ -47,21 +46,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string chatId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, bodyOption, outputOption); return command; } /// @@ -110,7 +108,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string chatId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(TeamsAppInstallation body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of all the apps in the chat. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of all the apps in the chat. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TeamsAppInstallation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of all the apps in the chat. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Chats/Item/InstalledApps/Item/TeamsApp/@Ref/@Ref.cs b/src/generated/Chats/Item/InstalledApps/Item/TeamsApp/@Ref/@Ref.cs deleted file mode 100644 index 1848c544f9f..00000000000 --- a/src/generated/Chats/Item/InstalledApps/Item/TeamsApp/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Chats.Item.InstalledApps.Item.TeamsApp.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Chats/Item/InstalledApps/Item/TeamsApp/@Ref/RefRequestBuilder.cs b/src/generated/Chats/Item/InstalledApps/Item/TeamsApp/@Ref/RefRequestBuilder.cs deleted file mode 100644 index ebc76e291cc..00000000000 --- a/src/generated/Chats/Item/InstalledApps/Item/TeamsApp/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Chats.Item.InstalledApps.Item.TeamsApp.@Ref { - /// Builds and executes requests for operations under \chats\{chat-id}\installedApps\{teamsAppInstallation-id}\teamsApp\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The app that is installed. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The app that is installed."; - // Create options for all the parameters - var chatIdOption = new Option("--chat-id", description: "key: id of chat") { - }; - chatIdOption.IsRequired = true; - command.AddOption(chatIdOption); - var teamsAppInstallationIdOption = new Option("--teamsappinstallation-id", description: "key: id of teamsAppInstallation") { - }; - teamsAppInstallationIdOption.IsRequired = true; - command.AddOption(teamsAppInstallationIdOption); - command.SetHandler(async (string chatId, string teamsAppInstallationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, chatIdOption, teamsAppInstallationIdOption); - return command; - } - /// - /// The app that is installed. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The app that is installed."; - // Create options for all the parameters - var chatIdOption = new Option("--chat-id", description: "key: id of chat") { - }; - chatIdOption.IsRequired = true; - command.AddOption(chatIdOption); - var teamsAppInstallationIdOption = new Option("--teamsappinstallation-id", description: "key: id of teamsAppInstallation") { - }; - teamsAppInstallationIdOption.IsRequired = true; - command.AddOption(teamsAppInstallationIdOption); - command.SetHandler(async (string chatId, string teamsAppInstallationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, teamsAppInstallationIdOption); - return command; - } - /// - /// The app that is installed. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The app that is installed."; - // Create options for all the parameters - var chatIdOption = new Option("--chat-id", description: "key: id of chat") { - }; - chatIdOption.IsRequired = true; - command.AddOption(chatIdOption); - var teamsAppInstallationIdOption = new Option("--teamsappinstallation-id", description: "key: id of teamsAppInstallation") { - }; - teamsAppInstallationIdOption.IsRequired = true; - command.AddOption(teamsAppInstallationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string chatId, string teamsAppInstallationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, chatIdOption, teamsAppInstallationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/chats/{chat_id}/installedApps/{teamsAppInstallation_id}/teamsApp/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The app that is installed. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The app that is installed. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The app that is installed. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Chats.Item.InstalledApps.Item.TeamsApp.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The app that is installed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The app that is installed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The app that is installed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Chats.Item.InstalledApps.Item.TeamsApp.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Chats/Item/InstalledApps/Item/TeamsApp/Ref/Ref.cs b/src/generated/Chats/Item/InstalledApps/Item/TeamsApp/Ref/Ref.cs new file mode 100644 index 00000000000..3f56f896c14 --- /dev/null +++ b/src/generated/Chats/Item/InstalledApps/Item/TeamsApp/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Chats.Item.InstalledApps.Item.TeamsApp.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Chats/Item/InstalledApps/Item/TeamsApp/Ref/RefRequestBuilder.cs b/src/generated/Chats/Item/InstalledApps/Item/TeamsApp/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..48cde1112ec --- /dev/null +++ b/src/generated/Chats/Item/InstalledApps/Item/TeamsApp/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Chats.Item.InstalledApps.Item.TeamsApp.Ref { + /// Builds and executes requests for operations under \chats\{chat-id}\installedApps\{teamsAppInstallation-id}\teamsApp\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The app that is installed. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The app that is installed."; + // Create options for all the parameters + var chatIdOption = new Option("--chat-id", description: "key: id of chat") { + }; + chatIdOption.IsRequired = true; + command.AddOption(chatIdOption); + var teamsAppInstallationIdOption = new Option("--teams-app-installation-id", description: "key: id of teamsAppInstallation") { + }; + teamsAppInstallationIdOption.IsRequired = true; + command.AddOption(teamsAppInstallationIdOption); + command.SetHandler(async (string chatId, string teamsAppInstallationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, chatIdOption, teamsAppInstallationIdOption); + return command; + } + /// + /// The app that is installed. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The app that is installed."; + // Create options for all the parameters + var chatIdOption = new Option("--chat-id", description: "key: id of chat") { + }; + chatIdOption.IsRequired = true; + command.AddOption(chatIdOption); + var teamsAppInstallationIdOption = new Option("--teams-app-installation-id", description: "key: id of teamsAppInstallation") { + }; + teamsAppInstallationIdOption.IsRequired = true; + command.AddOption(teamsAppInstallationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, string teamsAppInstallationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, teamsAppInstallationIdOption, outputOption); + return command; + } + /// + /// The app that is installed. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The app that is installed."; + // Create options for all the parameters + var chatIdOption = new Option("--chat-id", description: "key: id of chat") { + }; + chatIdOption.IsRequired = true; + command.AddOption(chatIdOption); + var teamsAppInstallationIdOption = new Option("--teams-app-installation-id", description: "key: id of teamsAppInstallation") { + }; + teamsAppInstallationIdOption.IsRequired = true; + command.AddOption(teamsAppInstallationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string chatId, string teamsAppInstallationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, chatIdOption, teamsAppInstallationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/chats/{chat_id}/installedApps/{teamsAppInstallation_id}/teamsApp/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The app that is installed. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The app that is installed. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The app that is installed. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Chats.Item.InstalledApps.Item.TeamsApp.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Chats/Item/InstalledApps/Item/TeamsApp/TeamsAppRequestBuilder.cs b/src/generated/Chats/Item/InstalledApps/Item/TeamsApp/TeamsAppRequestBuilder.cs index ef5932de5a8..b8d1e7b8f34 100644 --- a/src/generated/Chats/Item/InstalledApps/Item/TeamsApp/TeamsAppRequestBuilder.cs +++ b/src/generated/Chats/Item/InstalledApps/Item/TeamsApp/TeamsAppRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,7 +31,7 @@ public Command BuildGetCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - var teamsAppInstallationIdOption = new Option("--teamsappinstallation-id", description: "key: id of teamsAppInstallation") { + var teamsAppInstallationIdOption = new Option("--teams-app-installation-id", description: "key: id of teamsAppInstallation") { }; teamsAppInstallationIdOption.IsRequired = true; command.AddOption(teamsAppInstallationIdOption); @@ -45,25 +45,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string chatId, string teamsAppInstallationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, string teamsAppInstallationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, teamsAppInstallationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, teamsAppInstallationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Chats.Item.InstalledApps.Item.TeamsApp.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Chats.Item.InstalledApps.Item.TeamsApp.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -103,18 +102,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The app that is installed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The app that is installed. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Chats/Item/InstalledApps/Item/TeamsAppDefinition/@Ref/@Ref.cs b/src/generated/Chats/Item/InstalledApps/Item/TeamsAppDefinition/@Ref/@Ref.cs deleted file mode 100644 index f1887d169f8..00000000000 --- a/src/generated/Chats/Item/InstalledApps/Item/TeamsAppDefinition/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Chats.Item.InstalledApps.Item.TeamsAppDefinition.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Chats/Item/InstalledApps/Item/TeamsAppDefinition/@Ref/RefRequestBuilder.cs b/src/generated/Chats/Item/InstalledApps/Item/TeamsAppDefinition/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 27d17633767..00000000000 --- a/src/generated/Chats/Item/InstalledApps/Item/TeamsAppDefinition/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Chats.Item.InstalledApps.Item.TeamsAppDefinition.@Ref { - /// Builds and executes requests for operations under \chats\{chat-id}\installedApps\{teamsAppInstallation-id}\teamsAppDefinition\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The details of this version of the app. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The details of this version of the app."; - // Create options for all the parameters - var chatIdOption = new Option("--chat-id", description: "key: id of chat") { - }; - chatIdOption.IsRequired = true; - command.AddOption(chatIdOption); - var teamsAppInstallationIdOption = new Option("--teamsappinstallation-id", description: "key: id of teamsAppInstallation") { - }; - teamsAppInstallationIdOption.IsRequired = true; - command.AddOption(teamsAppInstallationIdOption); - command.SetHandler(async (string chatId, string teamsAppInstallationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, chatIdOption, teamsAppInstallationIdOption); - return command; - } - /// - /// The details of this version of the app. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The details of this version of the app."; - // Create options for all the parameters - var chatIdOption = new Option("--chat-id", description: "key: id of chat") { - }; - chatIdOption.IsRequired = true; - command.AddOption(chatIdOption); - var teamsAppInstallationIdOption = new Option("--teamsappinstallation-id", description: "key: id of teamsAppInstallation") { - }; - teamsAppInstallationIdOption.IsRequired = true; - command.AddOption(teamsAppInstallationIdOption); - command.SetHandler(async (string chatId, string teamsAppInstallationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, teamsAppInstallationIdOption); - return command; - } - /// - /// The details of this version of the app. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The details of this version of the app."; - // Create options for all the parameters - var chatIdOption = new Option("--chat-id", description: "key: id of chat") { - }; - chatIdOption.IsRequired = true; - command.AddOption(chatIdOption); - var teamsAppInstallationIdOption = new Option("--teamsappinstallation-id", description: "key: id of teamsAppInstallation") { - }; - teamsAppInstallationIdOption.IsRequired = true; - command.AddOption(teamsAppInstallationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string chatId, string teamsAppInstallationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, chatIdOption, teamsAppInstallationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/chats/{chat_id}/installedApps/{teamsAppInstallation_id}/teamsAppDefinition/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The details of this version of the app. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The details of this version of the app. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The details of this version of the app. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Chats.Item.InstalledApps.Item.TeamsAppDefinition.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The details of this version of the app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The details of this version of the app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The details of this version of the app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Chats.Item.InstalledApps.Item.TeamsAppDefinition.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Chats/Item/InstalledApps/Item/TeamsAppDefinition/Ref/Ref.cs b/src/generated/Chats/Item/InstalledApps/Item/TeamsAppDefinition/Ref/Ref.cs new file mode 100644 index 00000000000..89736d3192f --- /dev/null +++ b/src/generated/Chats/Item/InstalledApps/Item/TeamsAppDefinition/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Chats.Item.InstalledApps.Item.TeamsAppDefinition.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Chats/Item/InstalledApps/Item/TeamsAppDefinition/Ref/RefRequestBuilder.cs b/src/generated/Chats/Item/InstalledApps/Item/TeamsAppDefinition/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..d787e6aecbc --- /dev/null +++ b/src/generated/Chats/Item/InstalledApps/Item/TeamsAppDefinition/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Chats.Item.InstalledApps.Item.TeamsAppDefinition.Ref { + /// Builds and executes requests for operations under \chats\{chat-id}\installedApps\{teamsAppInstallation-id}\teamsAppDefinition\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The details of this version of the app. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The details of this version of the app."; + // Create options for all the parameters + var chatIdOption = new Option("--chat-id", description: "key: id of chat") { + }; + chatIdOption.IsRequired = true; + command.AddOption(chatIdOption); + var teamsAppInstallationIdOption = new Option("--teams-app-installation-id", description: "key: id of teamsAppInstallation") { + }; + teamsAppInstallationIdOption.IsRequired = true; + command.AddOption(teamsAppInstallationIdOption); + command.SetHandler(async (string chatId, string teamsAppInstallationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, chatIdOption, teamsAppInstallationIdOption); + return command; + } + /// + /// The details of this version of the app. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The details of this version of the app."; + // Create options for all the parameters + var chatIdOption = new Option("--chat-id", description: "key: id of chat") { + }; + chatIdOption.IsRequired = true; + command.AddOption(chatIdOption); + var teamsAppInstallationIdOption = new Option("--teams-app-installation-id", description: "key: id of teamsAppInstallation") { + }; + teamsAppInstallationIdOption.IsRequired = true; + command.AddOption(teamsAppInstallationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, string teamsAppInstallationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, teamsAppInstallationIdOption, outputOption); + return command; + } + /// + /// The details of this version of the app. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The details of this version of the app."; + // Create options for all the parameters + var chatIdOption = new Option("--chat-id", description: "key: id of chat") { + }; + chatIdOption.IsRequired = true; + command.AddOption(chatIdOption); + var teamsAppInstallationIdOption = new Option("--teams-app-installation-id", description: "key: id of teamsAppInstallation") { + }; + teamsAppInstallationIdOption.IsRequired = true; + command.AddOption(teamsAppInstallationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string chatId, string teamsAppInstallationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, chatIdOption, teamsAppInstallationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/chats/{chat_id}/installedApps/{teamsAppInstallation_id}/teamsAppDefinition/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The details of this version of the app. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The details of this version of the app. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The details of this version of the app. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Chats.Item.InstalledApps.Item.TeamsAppDefinition.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Chats/Item/InstalledApps/Item/TeamsAppDefinition/TeamsAppDefinitionRequestBuilder.cs b/src/generated/Chats/Item/InstalledApps/Item/TeamsAppDefinition/TeamsAppDefinitionRequestBuilder.cs index d8f82b51938..a043308fa0b 100644 --- a/src/generated/Chats/Item/InstalledApps/Item/TeamsAppDefinition/TeamsAppDefinitionRequestBuilder.cs +++ b/src/generated/Chats/Item/InstalledApps/Item/TeamsAppDefinition/TeamsAppDefinitionRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,7 +31,7 @@ public Command BuildGetCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - var teamsAppInstallationIdOption = new Option("--teamsappinstallation-id", description: "key: id of teamsAppInstallation") { + var teamsAppInstallationIdOption = new Option("--teams-app-installation-id", description: "key: id of teamsAppInstallation") { }; teamsAppInstallationIdOption.IsRequired = true; command.AddOption(teamsAppInstallationIdOption); @@ -45,25 +45,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string chatId, string teamsAppInstallationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, string teamsAppInstallationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, teamsAppInstallationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, teamsAppInstallationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Chats.Item.InstalledApps.Item.TeamsAppDefinition.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Chats.Item.InstalledApps.Item.TeamsAppDefinition.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -103,18 +102,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The details of this version of the app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The details of this version of the app. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Chats/Item/InstalledApps/Item/TeamsAppInstallationRequestBuilder.cs b/src/generated/Chats/Item/InstalledApps/Item/TeamsAppInstallationRequestBuilder.cs index 82cad3e8e76..345ee21a76b 100644 --- a/src/generated/Chats/Item/InstalledApps/Item/TeamsAppInstallationRequestBuilder.cs +++ b/src/generated/Chats/Item/InstalledApps/Item/TeamsAppInstallationRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,15 +33,14 @@ public Command BuildDeleteCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - var teamsAppInstallationIdOption = new Option("--teamsappinstallation-id", description: "key: id of teamsAppInstallation") { + var teamsAppInstallationIdOption = new Option("--teams-app-installation-id", description: "key: id of teamsAppInstallation") { }; teamsAppInstallationIdOption.IsRequired = true; command.AddOption(teamsAppInstallationIdOption); - command.SetHandler(async (string chatId, string teamsAppInstallationId) => { + command.SetHandler(async (string chatId, string teamsAppInstallationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, chatIdOption, teamsAppInstallationIdOption); return command; @@ -57,7 +56,7 @@ public Command BuildGetCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - var teamsAppInstallationIdOption = new Option("--teamsappinstallation-id", description: "key: id of teamsAppInstallation") { + var teamsAppInstallationIdOption = new Option("--teams-app-installation-id", description: "key: id of teamsAppInstallation") { }; teamsAppInstallationIdOption.IsRequired = true; command.AddOption(teamsAppInstallationIdOption); @@ -71,20 +70,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string chatId, string teamsAppInstallationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, string teamsAppInstallationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, teamsAppInstallationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, teamsAppInstallationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -98,7 +96,7 @@ public Command BuildPatchCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - var teamsAppInstallationIdOption = new Option("--teamsappinstallation-id", description: "key: id of teamsAppInstallation") { + var teamsAppInstallationIdOption = new Option("--teams-app-installation-id", description: "key: id of teamsAppInstallation") { }; teamsAppInstallationIdOption.IsRequired = true; command.AddOption(teamsAppInstallationIdOption); @@ -106,14 +104,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string chatId, string teamsAppInstallationId, string body) => { + command.SetHandler(async (string chatId, string teamsAppInstallationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, chatIdOption, teamsAppInstallationIdOption, bodyOption); return command; @@ -205,42 +202,6 @@ public RequestInformation CreatePatchRequestInformation(TeamsAppInstallation bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of all the apps in the chat. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of all the apps in the chat. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of all the apps in the chat. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(TeamsAppInstallation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of all the apps in the chat. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Chats/Item/InstalledApps/Item/Upgrade/UpgradeRequestBuilder.cs b/src/generated/Chats/Item/InstalledApps/Item/Upgrade/UpgradeRequestBuilder.cs index 4ab7e99a608..612c62592f5 100644 --- a/src/generated/Chats/Item/InstalledApps/Item/Upgrade/UpgradeRequestBuilder.cs +++ b/src/generated/Chats/Item/InstalledApps/Item/Upgrade/UpgradeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - var teamsAppInstallationIdOption = new Option("--teamsappinstallation-id", description: "key: id of teamsAppInstallation") { + var teamsAppInstallationIdOption = new Option("--teams-app-installation-id", description: "key: id of teamsAppInstallation") { }; teamsAppInstallationIdOption.IsRequired = true; command.AddOption(teamsAppInstallationIdOption); - command.SetHandler(async (string chatId, string teamsAppInstallationId) => { + command.SetHandler(async (string chatId, string teamsAppInstallationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, chatIdOption, teamsAppInstallationIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action upgrade - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Chats/Item/Members/@Add/@Add.cs b/src/generated/Chats/Item/Members/@Add/@Add.cs deleted file mode 100644 index d9a8bed4244..00000000000 --- a/src/generated/Chats/Item/Members/@Add/@Add.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Chats.Item.Members.@Add { - public class @Add : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Add and sets the default values. - /// - public @Add() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Chats/Item/Members/@Add/AddRequestBody.cs b/src/generated/Chats/Item/Members/@Add/AddRequestBody.cs deleted file mode 100644 index a24325470a8..00000000000 --- a/src/generated/Chats/Item/Members/@Add/AddRequestBody.cs +++ /dev/null @@ -1,36 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Chats.Item.Members.@Add { - public class AddRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public List Values { get; set; } - /// - /// Instantiates a new addRequestBody and sets the default values. - /// - public AddRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"values", (o,n) => { (o as AddRequestBody).Values = n.GetCollectionOfObjectValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteCollectionOfObjectValues("values", Values); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Chats/Item/Members/@Add/AddRequestBuilder.cs b/src/generated/Chats/Item/Members/@Add/AddRequestBuilder.cs deleted file mode 100644 index 8d9d9b8304b..00000000000 --- a/src/generated/Chats/Item/Members/@Add/AddRequestBuilder.cs +++ /dev/null @@ -1,98 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Chats.Item.Members.@Add { - /// Builds and executes requests for operations under \chats\{chat-id}\members\microsoft.graph.add - public class AddRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action add - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action add"; - // Create options for all the parameters - var chatIdOption = new Option("--chat-id", description: "key: id of chat") { - }; - chatIdOption.IsRequired = true; - command.AddOption(chatIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string chatId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AddRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/chats/{chat_id}/members/microsoft.graph.add"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action add - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action add - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(AddRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Chats/Item/Members/Add/Add.cs b/src/generated/Chats/Item/Members/Add/Add.cs new file mode 100644 index 00000000000..612db901096 --- /dev/null +++ b/src/generated/Chats/Item/Members/Add/Add.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Chats.Item.Members.Add { + public class Add : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new add and sets the default values. + /// + public Add() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Chats/Item/Members/Add/AddRequestBody.cs b/src/generated/Chats/Item/Members/Add/AddRequestBody.cs new file mode 100644 index 00000000000..d9590dc582b --- /dev/null +++ b/src/generated/Chats/Item/Members/Add/AddRequestBody.cs @@ -0,0 +1,36 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Chats.Item.Members.Add { + public class AddRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public List Values { get; set; } + /// + /// Instantiates a new addRequestBody and sets the default values. + /// + public AddRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"values", (o,n) => { (o as AddRequestBody).Values = n.GetCollectionOfObjectValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("values", Values); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Chats/Item/Members/Add/AddRequestBuilder.cs b/src/generated/Chats/Item/Members/Add/AddRequestBuilder.cs new file mode 100644 index 00000000000..7aec93a8aee --- /dev/null +++ b/src/generated/Chats/Item/Members/Add/AddRequestBuilder.cs @@ -0,0 +1,84 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Chats.Item.Members.Add { + /// Builds and executes requests for operations under \chats\{chat-id}\members\microsoft.graph.add + public class AddRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action add + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action add"; + // Create options for all the parameters + var chatIdOption = new Option("--chat-id", description: "key: id of chat") { + }; + chatIdOption.IsRequired = true; + command.AddOption(chatIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new AddRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/chats/{chat_id}/members/microsoft.graph.add"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action add + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Chats/Item/Members/Item/ConversationMemberRequestBuilder.cs b/src/generated/Chats/Item/Members/Item/ConversationMemberRequestBuilder.cs index be293cda91f..ff5e19ebb59 100644 --- a/src/generated/Chats/Item/Members/Item/ConversationMemberRequestBuilder.cs +++ b/src/generated/Chats/Item/Members/Item/ConversationMemberRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - var conversationMemberIdOption = new Option("--conversationmember-id", description: "key: id of conversationMember") { + var conversationMemberIdOption = new Option("--conversation-member-id", description: "key: id of conversationMember") { }; conversationMemberIdOption.IsRequired = true; command.AddOption(conversationMemberIdOption); - command.SetHandler(async (string chatId, string conversationMemberId) => { + command.SetHandler(async (string chatId, string conversationMemberId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, chatIdOption, conversationMemberIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - var conversationMemberIdOption = new Option("--conversationmember-id", description: "key: id of conversationMember") { + var conversationMemberIdOption = new Option("--conversation-member-id", description: "key: id of conversationMember") { }; conversationMemberIdOption.IsRequired = true; command.AddOption(conversationMemberIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string chatId, string conversationMemberId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, string conversationMemberId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, conversationMemberIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, conversationMemberIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - var conversationMemberIdOption = new Option("--conversationmember-id", description: "key: id of conversationMember") { + var conversationMemberIdOption = new Option("--conversation-member-id", description: "key: id of conversationMember") { }; conversationMemberIdOption.IsRequired = true; command.AddOption(conversationMemberIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string chatId, string conversationMemberId, string body) => { + command.SetHandler(async (string chatId, string conversationMemberId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, chatIdOption, conversationMemberIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ConversationMember body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of all the members in the chat. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of all the members in the chat. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of all the members in the chat. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ConversationMember model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of all the members in the chat. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Chats/Item/Members/MembersRequestBuilder.cs b/src/generated/Chats/Item/Members/MembersRequestBuilder.cs index b64858e737b..69244eb48d1 100644 --- a/src/generated/Chats/Item/Members/MembersRequestBuilder.cs +++ b/src/generated/Chats/Item/Members/MembersRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,17 +23,16 @@ public class MembersRequestBuilder { private string UrlTemplate { get; set; } public Command BuildAddCommand() { var command = new Command("add"); - var builder = new ApiSdk.Chats.Item.Members.@Add.AddRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Chats.Item.Members.Add.AddRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } public List BuildCommand() { var builder = new ConversationMemberRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -51,21 +50,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string chatId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, bodyOption, outputOption); return command; } /// @@ -114,7 +112,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string chatId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -125,15 +127,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -188,31 +185,6 @@ public RequestInformation CreatePostRequestInformation(ConversationMember body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of all the members in the chat. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of all the members in the chat. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ConversationMember model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of all the members in the chat. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Chats/Item/Messages/Delta/DeltaRequestBuilder.cs b/src/generated/Chats/Item/Messages/Delta/DeltaRequestBuilder.cs index 3ceb68b020b..3eb0ce4e2cd 100644 --- a/src/generated/Chats/Item/Messages/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Chats/Item/Messages/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +29,17 @@ public Command BuildGetCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - command.SetHandler(async (string chatId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Chats/Item/Messages/Item/ChatMessageRequestBuilder.cs b/src/generated/Chats/Item/Messages/Item/ChatMessageRequestBuilder.cs index 8d27e0afa8a..e2887b7e371 100644 --- a/src/generated/Chats/Item/Messages/Item/ChatMessageRequestBuilder.cs +++ b/src/generated/Chats/Item/Messages/Item/ChatMessageRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -32,15 +32,14 @@ public Command BuildDeleteCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); - command.SetHandler(async (string chatId, string chatMessageId) => { + command.SetHandler(async (string chatId, string chatMessageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, chatIdOption, chatMessageIdOption); return command; @@ -56,7 +55,7 @@ public Command BuildGetCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); @@ -70,25 +69,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string chatId, string chatMessageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, string chatMessageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, chatMessageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, chatMessageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildHostedContentsCommand() { var command = new Command("hosted-contents"); var builder = new ApiSdk.Chats.Item.Messages.Item.HostedContents.HostedContentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -104,7 +105,7 @@ public Command BuildPatchCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); @@ -112,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string chatId, string chatMessageId, string body) => { + command.SetHandler(async (string chatId, string chatMessageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, chatIdOption, chatMessageIdOption, bodyOption); return command; @@ -127,6 +127,9 @@ public Command BuildPatchCommand() { public Command BuildRepliesCommand() { var command = new Command("replies"); var builder = new ApiSdk.Chats.Item.Messages.Item.Replies.RepliesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -198,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(ChatMessage body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of all the messages in the chat. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of all the messages in the chat. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of all the messages in the chat. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ChatMessage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of all the messages in the chat. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Chats/Item/Messages/Item/HostedContents/HostedContentsRequestBuilder.cs b/src/generated/Chats/Item/Messages/Item/HostedContents/HostedContentsRequestBuilder.cs index cd505caa57f..7264535d87f 100644 --- a/src/generated/Chats/Item/Messages/Item/HostedContents/HostedContentsRequestBuilder.cs +++ b/src/generated/Chats/Item/Messages/Item/HostedContents/HostedContentsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class HostedContentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ChatMessageHostedContentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string chatId, string chatMessageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, string chatMessageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, chatMessageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, chatMessageIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string chatId, string chatMessageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, string chatMessageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, chatMessageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, chatMessageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(ChatMessageHostedContent requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Content in a message hosted by Microsoft Teams - for example, images or code snippets. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Content in a message hosted by Microsoft Teams - for example, images or code snippets. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ChatMessageHostedContent model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Content in a message hosted by Microsoft Teams - for example, images or code snippets. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Chats/Item/Messages/Item/HostedContents/Item/ChatMessageHostedContentRequestBuilder.cs b/src/generated/Chats/Item/Messages/Item/HostedContents/Item/ChatMessageHostedContentRequestBuilder.cs index 5256cc25c9e..1149bf8a6aa 100644 --- a/src/generated/Chats/Item/Messages/Item/HostedContents/Item/ChatMessageHostedContentRequestBuilder.cs +++ b/src/generated/Chats/Item/Messages/Item/HostedContents/Item/ChatMessageHostedContentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); - var chatMessageHostedContentIdOption = new Option("--chatmessagehostedcontent-id", description: "key: id of chatMessageHostedContent") { + var chatMessageHostedContentIdOption = new Option("--chat-message-hosted-content-id", description: "key: id of chatMessageHostedContent") { }; chatMessageHostedContentIdOption.IsRequired = true; command.AddOption(chatMessageHostedContentIdOption); - command.SetHandler(async (string chatId, string chatMessageId, string chatMessageHostedContentId) => { + command.SetHandler(async (string chatId, string chatMessageId, string chatMessageHostedContentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, chatIdOption, chatMessageIdOption, chatMessageHostedContentIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); - var chatMessageHostedContentIdOption = new Option("--chatmessagehostedcontent-id", description: "key: id of chatMessageHostedContent") { + var chatMessageHostedContentIdOption = new Option("--chat-message-hosted-content-id", description: "key: id of chatMessageHostedContent") { }; chatMessageHostedContentIdOption.IsRequired = true; command.AddOption(chatMessageHostedContentIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string chatId, string chatMessageId, string chatMessageHostedContentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, string chatMessageId, string chatMessageHostedContentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, chatMessageIdOption, chatMessageHostedContentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, chatMessageIdOption, chatMessageHostedContentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); - var chatMessageHostedContentIdOption = new Option("--chatmessagehostedcontent-id", description: "key: id of chatMessageHostedContent") { + var chatMessageHostedContentIdOption = new Option("--chat-message-hosted-content-id", description: "key: id of chatMessageHostedContent") { }; chatMessageHostedContentIdOption.IsRequired = true; command.AddOption(chatMessageHostedContentIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string chatId, string chatMessageId, string chatMessageHostedContentId, string body) => { + command.SetHandler(async (string chatId, string chatMessageId, string chatMessageHostedContentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, chatIdOption, chatMessageIdOption, chatMessageHostedContentIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(ChatMessageHostedContent requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Content in a message hosted by Microsoft Teams - for example, images or code snippets. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Content in a message hosted by Microsoft Teams - for example, images or code snippets. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Content in a message hosted by Microsoft Teams - for example, images or code snippets. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ChatMessageHostedContent model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Content in a message hosted by Microsoft Teams - for example, images or code snippets. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Chats/Item/Messages/Item/Replies/Delta/DeltaRequestBuilder.cs b/src/generated/Chats/Item/Messages/Item/Replies/Delta/DeltaRequestBuilder.cs index fe16d507788..159daa37260 100644 --- a/src/generated/Chats/Item/Messages/Item/Replies/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Chats/Item/Messages/Item/Replies/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,22 +29,21 @@ public Command BuildGetCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); - command.SetHandler(async (string chatId, string chatMessageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, string chatMessageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, chatMessageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, chatMessageIdOption, outputOption); return command; } /// @@ -75,16 +74,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Chats/Item/Messages/Item/Replies/Item/ChatMessageRequestBuilder.cs b/src/generated/Chats/Item/Messages/Item/Replies/Item/ChatMessageRequestBuilder.cs index 01a8fc69425..e3367903841 100644 --- a/src/generated/Chats/Item/Messages/Item/Replies/Item/ChatMessageRequestBuilder.cs +++ b/src/generated/Chats/Item/Messages/Item/Replies/Item/ChatMessageRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); - var chatMessageId1Option = new Option("--chatmessage-id1", description: "key: id of chatMessage") { + var chatMessageId1Option = new Option("--chat-message-id1", description: "key: id of chatMessage") { }; chatMessageId1Option.IsRequired = true; command.AddOption(chatMessageId1Option); - command.SetHandler(async (string chatId, string chatMessageId, string chatMessageId1) => { + command.SetHandler(async (string chatId, string chatMessageId, string chatMessageId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, chatIdOption, chatMessageIdOption, chatMessageId1Option); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); - var chatMessageId1Option = new Option("--chatmessage-id1", description: "key: id of chatMessage") { + var chatMessageId1Option = new Option("--chat-message-id1", description: "key: id of chatMessage") { }; chatMessageId1Option.IsRequired = true; command.AddOption(chatMessageId1Option); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string chatId, string chatMessageId, string chatMessageId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, string chatMessageId, string chatMessageId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, chatMessageIdOption, chatMessageId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, chatMessageIdOption, chatMessageId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); - var chatMessageId1Option = new Option("--chatmessage-id1", description: "key: id of chatMessage") { + var chatMessageId1Option = new Option("--chat-message-id1", description: "key: id of chatMessage") { }; chatMessageId1Option.IsRequired = true; command.AddOption(chatMessageId1Option); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string chatId, string chatMessageId, string chatMessageId1, string body) => { + command.SetHandler(async (string chatId, string chatMessageId, string chatMessageId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, chatIdOption, chatMessageIdOption, chatMessageId1Option, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(ChatMessage body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Replies for a specified message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Replies for a specified message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Replies for a specified message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ChatMessage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Replies for a specified message. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Chats/Item/Messages/Item/Replies/RepliesRequestBuilder.cs b/src/generated/Chats/Item/Messages/Item/Replies/RepliesRequestBuilder.cs index 9975c2d92f6..e4d72aa2ceb 100644 --- a/src/generated/Chats/Item/Messages/Item/Replies/RepliesRequestBuilder.cs +++ b/src/generated/Chats/Item/Messages/Item/Replies/RepliesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class RepliesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ChatMessageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,7 +40,7 @@ public Command BuildCreateCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string chatId, string chatMessageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, string chatMessageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, chatMessageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, chatMessageIdOption, bodyOption, outputOption); return command; } /// @@ -77,7 +75,7 @@ public Command BuildListCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); @@ -116,7 +114,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string chatId, string chatMessageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, string chatMessageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -127,15 +129,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, chatMessageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, chatMessageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -196,31 +193,6 @@ public RequestInformation CreatePostRequestInformation(ChatMessage body, Action< public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// Replies for a specified message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Replies for a specified message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ChatMessage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Replies for a specified message. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Chats/Item/Messages/MessagesRequestBuilder.cs b/src/generated/Chats/Item/Messages/MessagesRequestBuilder.cs index b3832e09d4d..242db8bb47e 100644 --- a/src/generated/Chats/Item/Messages/MessagesRequestBuilder.cs +++ b/src/generated/Chats/Item/Messages/MessagesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,13 +23,12 @@ public class MessagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ChatMessageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildHostedContentsCommand(), - builder.BuildPatchCommand(), - builder.BuildRepliesCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildHostedContentsCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRepliesCommand()); return commands; } /// @@ -47,21 +46,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string chatId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, bodyOption, outputOption); return command; } /// @@ -110,7 +108,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string chatId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -190,31 +187,6 @@ public RequestInformation CreatePostRequestInformation(ChatMessage body, Action< public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// A collection of all the messages in the chat. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of all the messages in the chat. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ChatMessage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of all the messages in the chat. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Chats/Item/SendActivityNotification/SendActivityNotificationRequestBuilder.cs b/src/generated/Chats/Item/SendActivityNotification/SendActivityNotificationRequestBuilder.cs index b2088943255..2e7c5a8273f 100644 --- a/src/generated/Chats/Item/SendActivityNotification/SendActivityNotificationRequestBuilder.cs +++ b/src/generated/Chats/Item/SendActivityNotification/SendActivityNotificationRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string chatId, string body) => { + command.SetHandler(async (string chatId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, chatIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(SendActivityNotificationR requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action sendActivityNotification - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SendActivityNotificationRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Chats/Item/Tabs/Item/TeamsApp/@Ref/@Ref.cs b/src/generated/Chats/Item/Tabs/Item/TeamsApp/@Ref/@Ref.cs deleted file mode 100644 index f581f4be512..00000000000 --- a/src/generated/Chats/Item/Tabs/Item/TeamsApp/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Chats.Item.Tabs.Item.TeamsApp.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Chats/Item/Tabs/Item/TeamsApp/@Ref/RefRequestBuilder.cs b/src/generated/Chats/Item/Tabs/Item/TeamsApp/@Ref/RefRequestBuilder.cs deleted file mode 100644 index b93c7494f83..00000000000 --- a/src/generated/Chats/Item/Tabs/Item/TeamsApp/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Chats.Item.Tabs.Item.TeamsApp.@Ref { - /// Builds and executes requests for operations under \chats\{chat-id}\tabs\{teamsTab-id}\teamsApp\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The application that is linked to the tab. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The application that is linked to the tab."; - // Create options for all the parameters - var chatIdOption = new Option("--chat-id", description: "key: id of chat") { - }; - chatIdOption.IsRequired = true; - command.AddOption(chatIdOption); - var teamsTabIdOption = new Option("--teamstab-id", description: "key: id of teamsTab") { - }; - teamsTabIdOption.IsRequired = true; - command.AddOption(teamsTabIdOption); - command.SetHandler(async (string chatId, string teamsTabId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, chatIdOption, teamsTabIdOption); - return command; - } - /// - /// The application that is linked to the tab. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The application that is linked to the tab."; - // Create options for all the parameters - var chatIdOption = new Option("--chat-id", description: "key: id of chat") { - }; - chatIdOption.IsRequired = true; - command.AddOption(chatIdOption); - var teamsTabIdOption = new Option("--teamstab-id", description: "key: id of teamsTab") { - }; - teamsTabIdOption.IsRequired = true; - command.AddOption(teamsTabIdOption); - command.SetHandler(async (string chatId, string teamsTabId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, teamsTabIdOption); - return command; - } - /// - /// The application that is linked to the tab. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The application that is linked to the tab."; - // Create options for all the parameters - var chatIdOption = new Option("--chat-id", description: "key: id of chat") { - }; - chatIdOption.IsRequired = true; - command.AddOption(chatIdOption); - var teamsTabIdOption = new Option("--teamstab-id", description: "key: id of teamsTab") { - }; - teamsTabIdOption.IsRequired = true; - command.AddOption(teamsTabIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string chatId, string teamsTabId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, chatIdOption, teamsTabIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/chats/{chat_id}/tabs/{teamsTab_id}/teamsApp/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The application that is linked to the tab. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The application that is linked to the tab. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The application that is linked to the tab. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Chats.Item.Tabs.Item.TeamsApp.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The application that is linked to the tab. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The application that is linked to the tab. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The application that is linked to the tab. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Chats.Item.Tabs.Item.TeamsApp.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Chats/Item/Tabs/Item/TeamsApp/Ref/Ref.cs b/src/generated/Chats/Item/Tabs/Item/TeamsApp/Ref/Ref.cs new file mode 100644 index 00000000000..514086dfd5a --- /dev/null +++ b/src/generated/Chats/Item/Tabs/Item/TeamsApp/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Chats.Item.Tabs.Item.TeamsApp.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Chats/Item/Tabs/Item/TeamsApp/Ref/RefRequestBuilder.cs b/src/generated/Chats/Item/Tabs/Item/TeamsApp/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..a777af96fff --- /dev/null +++ b/src/generated/Chats/Item/Tabs/Item/TeamsApp/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Chats.Item.Tabs.Item.TeamsApp.Ref { + /// Builds and executes requests for operations under \chats\{chat-id}\tabs\{teamsTab-id}\teamsApp\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The application that is linked to the tab. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The application that is linked to the tab."; + // Create options for all the parameters + var chatIdOption = new Option("--chat-id", description: "key: id of chat") { + }; + chatIdOption.IsRequired = true; + command.AddOption(chatIdOption); + var teamsTabIdOption = new Option("--teams-tab-id", description: "key: id of teamsTab") { + }; + teamsTabIdOption.IsRequired = true; + command.AddOption(teamsTabIdOption); + command.SetHandler(async (string chatId, string teamsTabId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, chatIdOption, teamsTabIdOption); + return command; + } + /// + /// The application that is linked to the tab. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The application that is linked to the tab."; + // Create options for all the parameters + var chatIdOption = new Option("--chat-id", description: "key: id of chat") { + }; + chatIdOption.IsRequired = true; + command.AddOption(chatIdOption); + var teamsTabIdOption = new Option("--teams-tab-id", description: "key: id of teamsTab") { + }; + teamsTabIdOption.IsRequired = true; + command.AddOption(teamsTabIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, string teamsTabId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, teamsTabIdOption, outputOption); + return command; + } + /// + /// The application that is linked to the tab. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The application that is linked to the tab."; + // Create options for all the parameters + var chatIdOption = new Option("--chat-id", description: "key: id of chat") { + }; + chatIdOption.IsRequired = true; + command.AddOption(chatIdOption); + var teamsTabIdOption = new Option("--teams-tab-id", description: "key: id of teamsTab") { + }; + teamsTabIdOption.IsRequired = true; + command.AddOption(teamsTabIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string chatId, string teamsTabId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, chatIdOption, teamsTabIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/chats/{chat_id}/tabs/{teamsTab_id}/teamsApp/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The application that is linked to the tab. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The application that is linked to the tab. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The application that is linked to the tab. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Chats.Item.Tabs.Item.TeamsApp.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Chats/Item/Tabs/Item/TeamsApp/TeamsAppRequestBuilder.cs b/src/generated/Chats/Item/Tabs/Item/TeamsApp/TeamsAppRequestBuilder.cs index 1c47c8f0a51..572290ad9e4 100644 --- a/src/generated/Chats/Item/Tabs/Item/TeamsApp/TeamsAppRequestBuilder.cs +++ b/src/generated/Chats/Item/Tabs/Item/TeamsApp/TeamsAppRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,7 +31,7 @@ public Command BuildGetCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - var teamsTabIdOption = new Option("--teamstab-id", description: "key: id of teamsTab") { + var teamsTabIdOption = new Option("--teams-tab-id", description: "key: id of teamsTab") { }; teamsTabIdOption.IsRequired = true; command.AddOption(teamsTabIdOption); @@ -45,25 +45,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string chatId, string teamsTabId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, string teamsTabId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, teamsTabIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, teamsTabIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Chats.Item.Tabs.Item.TeamsApp.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Chats.Item.Tabs.Item.TeamsApp.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -103,18 +102,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The application that is linked to the tab. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The application that is linked to the tab. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Chats/Item/Tabs/Item/TeamsTabRequestBuilder.cs b/src/generated/Chats/Item/Tabs/Item/TeamsTabRequestBuilder.cs index 1d8f9f08f07..fa242642ccc 100644 --- a/src/generated/Chats/Item/Tabs/Item/TeamsTabRequestBuilder.cs +++ b/src/generated/Chats/Item/Tabs/Item/TeamsTabRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,15 +31,14 @@ public Command BuildDeleteCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - var teamsTabIdOption = new Option("--teamstab-id", description: "key: id of teamsTab") { + var teamsTabIdOption = new Option("--teams-tab-id", description: "key: id of teamsTab") { }; teamsTabIdOption.IsRequired = true; command.AddOption(teamsTabIdOption); - command.SetHandler(async (string chatId, string teamsTabId) => { + command.SetHandler(async (string chatId, string teamsTabId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, chatIdOption, teamsTabIdOption); return command; @@ -55,7 +54,7 @@ public Command BuildGetCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - var teamsTabIdOption = new Option("--teamstab-id", description: "key: id of teamsTab") { + var teamsTabIdOption = new Option("--teams-tab-id", description: "key: id of teamsTab") { }; teamsTabIdOption.IsRequired = true; command.AddOption(teamsTabIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string chatId, string teamsTabId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, string teamsTabId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, teamsTabIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, teamsTabIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -96,7 +94,7 @@ public Command BuildPatchCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - var teamsTabIdOption = new Option("--teamstab-id", description: "key: id of teamsTab") { + var teamsTabIdOption = new Option("--teams-tab-id", description: "key: id of teamsTab") { }; teamsTabIdOption.IsRequired = true; command.AddOption(teamsTabIdOption); @@ -104,14 +102,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string chatId, string teamsTabId, string body) => { + command.SetHandler(async (string chatId, string teamsTabId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, chatIdOption, teamsTabIdOption, bodyOption); return command; @@ -190,42 +187,6 @@ public RequestInformation CreatePatchRequestInformation(TeamsTab body, Action - /// Delete navigation property tabs for chats - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get tabs from chats - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property tabs in chats - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(TeamsTab model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get tabs from chats public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Chats/Item/Tabs/TabsRequestBuilder.cs b/src/generated/Chats/Item/Tabs/TabsRequestBuilder.cs index 09187068192..51226513844 100644 --- a/src/generated/Chats/Item/Tabs/TabsRequestBuilder.cs +++ b/src/generated/Chats/Item/Tabs/TabsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class TabsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TeamsTabRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildTeamsAppCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildTeamsAppCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string chatId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, bodyOption, outputOption); return command; } /// @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string chatId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(TeamsTab body, Action - /// Get tabs from chats - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to tabs for chats - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TeamsTab model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get tabs from chats public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Communications/CallRecords/CallRecordsRequestBuilder.cs b/src/generated/Communications/CallRecords/CallRecordsRequestBuilder.cs index de8365654f6..a6ffb1dadb3 100644 --- a/src/generated/Communications/CallRecords/CallRecordsRequestBuilder.cs +++ b/src/generated/Communications/CallRecords/CallRecordsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph.CallRecords; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class CallRecordsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new CallRecordRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSessionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSessionsCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(CallRecord body, Action - /// Get callRecords from communications - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to callRecords for communications - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CallRecord model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get callRecords from communications public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Communications/CallRecords/Item/CallRecordRequestBuilder.cs b/src/generated/Communications/CallRecords/Item/CallRecordRequestBuilder.cs index d883f84f545..60012bf855e 100644 --- a/src/generated/Communications/CallRecords/Item/CallRecordRequestBuilder.cs +++ b/src/generated/Communications/CallRecords/Item/CallRecordRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph.CallRecords; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,15 +27,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property callRecords for communications"; // Create options for all the parameters - var callRecordIdOption = new Option("--callrecord-id", description: "key: id of callRecord") { + var callRecordIdOption = new Option("--call-record-id", description: "key: id of callRecord") { }; callRecordIdOption.IsRequired = true; command.AddOption(callRecordIdOption); - command.SetHandler(async (string callRecordId) => { + command.SetHandler(async (string callRecordId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, callRecordIdOption); return command; @@ -47,7 +46,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get callRecords from communications"; // Create options for all the parameters - var callRecordIdOption = new Option("--callrecord-id", description: "key: id of callRecord") { + var callRecordIdOption = new Option("--call-record-id", description: "key: id of callRecord") { }; callRecordIdOption.IsRequired = true; command.AddOption(callRecordIdOption); @@ -61,20 +60,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string callRecordId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callRecordId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callRecordIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callRecordIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property callRecords in communications"; // Create options for all the parameters - var callRecordIdOption = new Option("--callrecord-id", description: "key: id of callRecord") { + var callRecordIdOption = new Option("--call-record-id", description: "key: id of callRecord") { }; callRecordIdOption.IsRequired = true; command.AddOption(callRecordIdOption); @@ -92,14 +90,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callRecordId, string body) => { + command.SetHandler(async (string callRecordId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, callRecordIdOption, bodyOption); return command; @@ -107,6 +104,9 @@ public Command BuildPatchCommand() { public Command BuildSessionsCommand() { var command = new Command("sessions"); var builder = new ApiSdk.Communications.CallRecords.Item.Sessions.SessionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -178,42 +178,6 @@ public RequestInformation CreatePatchRequestInformation(CallRecord body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property callRecords for communications - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get callRecords from communications - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property callRecords in communications - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(CallRecord model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get callRecords from communications public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Communications/CallRecords/Item/Sessions/Item/Segments/Item/SegmentRequestBuilder.cs b/src/generated/Communications/CallRecords/Item/Sessions/Item/Segments/Item/SegmentRequestBuilder.cs index bba16eea0ed..ab7e3a597a3 100644 --- a/src/generated/Communications/CallRecords/Item/Sessions/Item/Segments/Item/SegmentRequestBuilder.cs +++ b/src/generated/Communications/CallRecords/Item/Sessions/Item/Segments/Item/SegmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph.CallRecords; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of segments involved in the session. Read-only. Nullable."; // Create options for all the parameters - var callRecordIdOption = new Option("--callrecord-id", description: "key: id of callRecord") { + var callRecordIdOption = new Option("--call-record-id", description: "key: id of callRecord") { }; callRecordIdOption.IsRequired = true; command.AddOption(callRecordIdOption); @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; segmentIdOption.IsRequired = true; command.AddOption(segmentIdOption); - command.SetHandler(async (string callRecordId, string sessionId, string segmentId) => { + command.SetHandler(async (string callRecordId, string sessionId, string segmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, callRecordIdOption, sessionIdOption, segmentIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of segments involved in the session. Read-only. Nullable."; // Create options for all the parameters - var callRecordIdOption = new Option("--callrecord-id", description: "key: id of callRecord") { + var callRecordIdOption = new Option("--call-record-id", description: "key: id of callRecord") { }; callRecordIdOption.IsRequired = true; command.AddOption(callRecordIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string callRecordId, string sessionId, string segmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callRecordId, string sessionId, string segmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callRecordIdOption, sessionIdOption, segmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callRecordIdOption, sessionIdOption, segmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,7 +97,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of segments involved in the session. Read-only. Nullable."; // Create options for all the parameters - var callRecordIdOption = new Option("--callrecord-id", description: "key: id of callRecord") { + var callRecordIdOption = new Option("--call-record-id", description: "key: id of callRecord") { }; callRecordIdOption.IsRequired = true; command.AddOption(callRecordIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callRecordId, string sessionId, string segmentId, string body) => { + command.SetHandler(async (string callRecordId, string sessionId, string segmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, callRecordIdOption, sessionIdOption, segmentIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Segment body, Action - /// The list of segments involved in the session. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of segments involved in the session. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of segments involved in the session. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Segment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of segments involved in the session. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Communications/CallRecords/Item/Sessions/Item/Segments/SegmentsRequestBuilder.cs b/src/generated/Communications/CallRecords/Item/Sessions/Item/Segments/SegmentsRequestBuilder.cs index 266a4e287c4..945b3a89ff3 100644 --- a/src/generated/Communications/CallRecords/Item/Sessions/Item/Segments/SegmentsRequestBuilder.cs +++ b/src/generated/Communications/CallRecords/Item/Sessions/Item/Segments/SegmentsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph.CallRecords; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SegmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SegmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The list of segments involved in the session. Read-only. Nullable."; // Create options for all the parameters - var callRecordIdOption = new Option("--callrecord-id", description: "key: id of callRecord") { + var callRecordIdOption = new Option("--call-record-id", description: "key: id of callRecord") { }; callRecordIdOption.IsRequired = true; command.AddOption(callRecordIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callRecordId, string sessionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callRecordId, string sessionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callRecordIdOption, sessionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callRecordIdOption, sessionIdOption, bodyOption, outputOption); return command; } /// @@ -72,7 +70,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The list of segments involved in the session. Read-only. Nullable."; // Create options for all the parameters - var callRecordIdOption = new Option("--callrecord-id", description: "key: id of callRecord") { + var callRecordIdOption = new Option("--call-record-id", description: "key: id of callRecord") { }; callRecordIdOption.IsRequired = true; command.AddOption(callRecordIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string callRecordId, string sessionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callRecordId, string sessionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callRecordIdOption, sessionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callRecordIdOption, sessionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(Segment body, Action - /// The list of segments involved in the session. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of segments involved in the session. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Segment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of segments involved in the session. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Communications/CallRecords/Item/Sessions/Item/SessionRequestBuilder.cs b/src/generated/Communications/CallRecords/Item/Sessions/Item/SessionRequestBuilder.cs index cb2c16114ad..d9e2214d3d4 100644 --- a/src/generated/Communications/CallRecords/Item/Sessions/Item/SessionRequestBuilder.cs +++ b/src/generated/Communications/CallRecords/Item/Sessions/Item/SessionRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph.CallRecords; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "List of sessions involved in the call. Peer-to-peer calls typically only have one session, whereas group calls typically have at least one session per participant. Read-only. Nullable."; // Create options for all the parameters - var callRecordIdOption = new Option("--callrecord-id", description: "key: id of callRecord") { + var callRecordIdOption = new Option("--call-record-id", description: "key: id of callRecord") { }; callRecordIdOption.IsRequired = true; command.AddOption(callRecordIdOption); @@ -35,11 +35,10 @@ public Command BuildDeleteCommand() { }; sessionIdOption.IsRequired = true; command.AddOption(sessionIdOption); - command.SetHandler(async (string callRecordId, string sessionId) => { + command.SetHandler(async (string callRecordId, string sessionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, callRecordIdOption, sessionIdOption); return command; @@ -51,7 +50,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "List of sessions involved in the call. Peer-to-peer calls typically only have one session, whereas group calls typically have at least one session per participant. Read-only. Nullable."; // Create options for all the parameters - var callRecordIdOption = new Option("--callrecord-id", description: "key: id of callRecord") { + var callRecordIdOption = new Option("--call-record-id", description: "key: id of callRecord") { }; callRecordIdOption.IsRequired = true; command.AddOption(callRecordIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string callRecordId, string sessionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callRecordId, string sessionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callRecordIdOption, sessionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callRecordIdOption, sessionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -92,7 +90,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "List of sessions involved in the call. Peer-to-peer calls typically only have one session, whereas group calls typically have at least one session per participant. Read-only. Nullable."; // Create options for all the parameters - var callRecordIdOption = new Option("--callrecord-id", description: "key: id of callRecord") { + var callRecordIdOption = new Option("--call-record-id", description: "key: id of callRecord") { }; callRecordIdOption.IsRequired = true; command.AddOption(callRecordIdOption); @@ -104,14 +102,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callRecordId, string sessionId, string body) => { + command.SetHandler(async (string callRecordId, string sessionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, callRecordIdOption, sessionIdOption, bodyOption); return command; @@ -119,6 +116,9 @@ public Command BuildPatchCommand() { public Command BuildSegmentsCommand() { var command = new Command("segments"); var builder = new ApiSdk.Communications.CallRecords.Item.Sessions.Item.Segments.SegmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -190,42 +190,6 @@ public RequestInformation CreatePatchRequestInformation(Session body, Action - /// List of sessions involved in the call. Peer-to-peer calls typically only have one session, whereas group calls typically have at least one session per participant. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of sessions involved in the call. Peer-to-peer calls typically only have one session, whereas group calls typically have at least one session per participant. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of sessions involved in the call. Peer-to-peer calls typically only have one session, whereas group calls typically have at least one session per participant. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Session model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// List of sessions involved in the call. Peer-to-peer calls typically only have one session, whereas group calls typically have at least one session per participant. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Communications/CallRecords/Item/Sessions/SessionsRequestBuilder.cs b/src/generated/Communications/CallRecords/Item/Sessions/SessionsRequestBuilder.cs index e248f3063cc..f7f06f5ea40 100644 --- a/src/generated/Communications/CallRecords/Item/Sessions/SessionsRequestBuilder.cs +++ b/src/generated/Communications/CallRecords/Item/Sessions/SessionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph.CallRecords; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class SessionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SessionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSegmentsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSegmentsCommand()); return commands; } /// @@ -37,7 +36,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "List of sessions involved in the call. Peer-to-peer calls typically only have one session, whereas group calls typically have at least one session per participant. Read-only. Nullable."; // Create options for all the parameters - var callRecordIdOption = new Option("--callrecord-id", description: "key: id of callRecord") { + var callRecordIdOption = new Option("--call-record-id", description: "key: id of callRecord") { }; callRecordIdOption.IsRequired = true; command.AddOption(callRecordIdOption); @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callRecordId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callRecordId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callRecordIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callRecordIdOption, bodyOption, outputOption); return command; } /// @@ -69,7 +67,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "List of sessions involved in the call. Peer-to-peer calls typically only have one session, whereas group calls typically have at least one session per participant. Read-only. Nullable."; // Create options for all the parameters - var callRecordIdOption = new Option("--callrecord-id", description: "key: id of callRecord") { + var callRecordIdOption = new Option("--call-record-id", description: "key: id of callRecord") { }; callRecordIdOption.IsRequired = true; command.AddOption(callRecordIdOption); @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string callRecordId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callRecordId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callRecordIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callRecordIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(Session body, Action - /// List of sessions involved in the call. Peer-to-peer calls typically only have one session, whereas group calls typically have at least one session per participant. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of sessions involved in the call. Peer-to-peer calls typically only have one session, whereas group calls typically have at least one session per participant. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Session model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// List of sessions involved in the call. Peer-to-peer calls typically only have one session, whereas group calls typically have at least one session per participant. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Communications/Calls/CallsRequestBuilder.cs b/src/generated/Communications/Calls/CallsRequestBuilder.cs index a56fbd7c4c6..1b7cf3beb61 100644 --- a/src/generated/Communications/Calls/CallsRequestBuilder.cs +++ b/src/generated/Communications/Calls/CallsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,27 +23,26 @@ public class CallsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new CallRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAnswerCommand(), - builder.BuildAudioRoutingGroupsCommand(), - builder.BuildCancelMediaProcessingCommand(), - builder.BuildChangeScreenSharingRoleCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildKeepAliveCommand(), - builder.BuildMuteCommand(), - builder.BuildOperationsCommand(), - builder.BuildParticipantsCommand(), - builder.BuildPatchCommand(), - builder.BuildPlayPromptCommand(), - builder.BuildRecordResponseCommand(), - builder.BuildRedirectCommand(), - builder.BuildRejectCommand(), - builder.BuildSubscribeToToneCommand(), - builder.BuildTransferCommand(), - builder.BuildUnmuteCommand(), - builder.BuildUpdateRecordingStatusCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAnswerCommand()); + commands.Add(builder.BuildAudioRoutingGroupsCommand()); + commands.Add(builder.BuildCancelMediaProcessingCommand()); + commands.Add(builder.BuildChangeScreenSharingRoleCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildKeepAliveCommand()); + commands.Add(builder.BuildMuteCommand()); + commands.Add(builder.BuildOperationsCommand()); + commands.Add(builder.BuildParticipantsCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPlayPromptCommand()); + commands.Add(builder.BuildRecordResponseCommand()); + commands.Add(builder.BuildRedirectCommand()); + commands.Add(builder.BuildRejectCommand()); + commands.Add(builder.BuildSubscribeToToneCommand()); + commands.Add(builder.BuildTransferCommand()); + commands.Add(builder.BuildUnmuteCommand()); + commands.Add(builder.BuildUpdateRecordingStatusCommand()); return commands; } /// @@ -57,21 +56,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -116,7 +114,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -127,15 +129,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildLogTeleconferenceDeviceQualityCommand() { @@ -196,31 +193,6 @@ public RequestInformation CreatePostRequestInformation(Call body, Action - /// Get calls from communications - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to calls for communications - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Call model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get calls from communications public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Communications/Calls/Item/Answer/AnswerRequestBuilder.cs b/src/generated/Communications/Calls/Item/Answer/AnswerRequestBuilder.cs index 35eca627839..daf836e4f1c 100644 --- a/src/generated/Communications/Calls/Item/Answer/AnswerRequestBuilder.cs +++ b/src/generated/Communications/Calls/Item/Answer/AnswerRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callId, string body) => { + command.SetHandler(async (string callId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, callIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(AnswerRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action answer - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AnswerRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Communications/Calls/Item/AudioRoutingGroups/AudioRoutingGroupsRequestBuilder.cs b/src/generated/Communications/Calls/Item/AudioRoutingGroups/AudioRoutingGroupsRequestBuilder.cs index 661c3d07bfc..28044d5b550 100644 --- a/src/generated/Communications/Calls/Item/AudioRoutingGroups/AudioRoutingGroupsRequestBuilder.cs +++ b/src/generated/Communications/Calls/Item/AudioRoutingGroups/AudioRoutingGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AudioRoutingGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AudioRoutingGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string callId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(AudioRoutingGroup body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AudioRoutingGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Communications/Calls/Item/AudioRoutingGroups/Item/AudioRoutingGroupRequestBuilder.cs b/src/generated/Communications/Calls/Item/AudioRoutingGroups/Item/AudioRoutingGroupRequestBuilder.cs index 4ade7585e34..e2ec3800708 100644 --- a/src/generated/Communications/Calls/Item/AudioRoutingGroups/Item/AudioRoutingGroupRequestBuilder.cs +++ b/src/generated/Communications/Calls/Item/AudioRoutingGroups/Item/AudioRoutingGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; callIdOption.IsRequired = true; command.AddOption(callIdOption); - var audioRoutingGroupIdOption = new Option("--audioroutinggroup-id", description: "key: id of audioRoutingGroup") { + var audioRoutingGroupIdOption = new Option("--audio-routing-group-id", description: "key: id of audioRoutingGroup") { }; audioRoutingGroupIdOption.IsRequired = true; command.AddOption(audioRoutingGroupIdOption); - command.SetHandler(async (string callId, string audioRoutingGroupId) => { + command.SetHandler(async (string callId, string audioRoutingGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, callIdOption, audioRoutingGroupIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; callIdOption.IsRequired = true; command.AddOption(callIdOption); - var audioRoutingGroupIdOption = new Option("--audioroutinggroup-id", description: "key: id of audioRoutingGroup") { + var audioRoutingGroupIdOption = new Option("--audio-routing-group-id", description: "key: id of audioRoutingGroup") { }; audioRoutingGroupIdOption.IsRequired = true; command.AddOption(audioRoutingGroupIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string callId, string audioRoutingGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callId, string audioRoutingGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callIdOption, audioRoutingGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callIdOption, audioRoutingGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; callIdOption.IsRequired = true; command.AddOption(callIdOption); - var audioRoutingGroupIdOption = new Option("--audioroutinggroup-id", description: "key: id of audioRoutingGroup") { + var audioRoutingGroupIdOption = new Option("--audio-routing-group-id", description: "key: id of audioRoutingGroup") { }; audioRoutingGroupIdOption.IsRequired = true; command.AddOption(audioRoutingGroupIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callId, string audioRoutingGroupId, string body) => { + command.SetHandler(async (string callId, string audioRoutingGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, callIdOption, audioRoutingGroupIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(AudioRoutingGroup body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AudioRoutingGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Communications/Calls/Item/CallRequestBuilder.cs b/src/generated/Communications/Calls/Item/CallRequestBuilder.cs index b2a32d831a3..d0ff7d0981c 100644 --- a/src/generated/Communications/Calls/Item/CallRequestBuilder.cs +++ b/src/generated/Communications/Calls/Item/CallRequestBuilder.cs @@ -17,10 +17,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,6 +44,9 @@ public Command BuildAnswerCommand() { public Command BuildAudioRoutingGroupsCommand() { var command = new Command("audio-routing-groups"); var builder = new ApiSdk.Communications.Calls.Item.AudioRoutingGroups.AudioRoutingGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -71,11 +74,10 @@ public Command BuildDeleteCommand() { }; callIdOption.IsRequired = true; command.AddOption(callIdOption); - command.SetHandler(async (string callId) => { + command.SetHandler(async (string callId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, callIdOption); return command; @@ -101,20 +103,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string callId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildKeepAliveCommand() { @@ -132,6 +133,9 @@ public Command BuildMuteCommand() { public Command BuildOperationsCommand() { var command = new Command("operations"); var builder = new ApiSdk.Communications.Calls.Item.Operations.OperationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -139,6 +143,9 @@ public Command BuildOperationsCommand() { public Command BuildParticipantsCommand() { var command = new Command("participants"); var builder = new ApiSdk.Communications.Calls.Item.Participants.ParticipantsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildInviteCommand()); command.AddCommand(builder.BuildListCommand()); @@ -159,14 +166,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callId, string body) => { + command.SetHandler(async (string callId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, callIdOption, bodyOption); return command; @@ -286,42 +292,6 @@ public RequestInformation CreatePatchRequestInformation(Call body, Action - /// Delete navigation property calls for communications - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get calls from communications - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property calls in communications - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Call model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get calls from communications public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Communications/Calls/Item/CancelMediaProcessing/CancelMediaProcessingRequestBuilder.cs b/src/generated/Communications/Calls/Item/CancelMediaProcessing/CancelMediaProcessingRequestBuilder.cs index ac935dae247..cbc76547b50 100644 --- a/src/generated/Communications/Calls/Item/CancelMediaProcessing/CancelMediaProcessingRequestBuilder.cs +++ b/src/generated/Communications/Calls/Item/CancelMediaProcessing/CancelMediaProcessingRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CancelMediaProcessingRequ requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancelMediaProcessing - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelMediaProcessingRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes cancelMediaProcessingOperation public class CancelMediaProcessingResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Communications/Calls/Item/ChangeScreenSharingRole/ChangeScreenSharingRoleRequestBuilder.cs b/src/generated/Communications/Calls/Item/ChangeScreenSharingRole/ChangeScreenSharingRoleRequestBuilder.cs index 4c385e6b44c..b3aa8ce25f5 100644 --- a/src/generated/Communications/Calls/Item/ChangeScreenSharingRole/ChangeScreenSharingRoleRequestBuilder.cs +++ b/src/generated/Communications/Calls/Item/ChangeScreenSharingRole/ChangeScreenSharingRoleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callId, string body) => { + command.SetHandler(async (string callId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, callIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ChangeScreenSharingRoleRe requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action changeScreenSharingRole - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ChangeScreenSharingRoleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Communications/Calls/Item/KeepAlive/KeepAliveRequestBuilder.cs b/src/generated/Communications/Calls/Item/KeepAlive/KeepAliveRequestBuilder.cs index e2e00231e6f..7e5bd8d11b5 100644 --- a/src/generated/Communications/Calls/Item/KeepAlive/KeepAliveRequestBuilder.cs +++ b/src/generated/Communications/Calls/Item/KeepAlive/KeepAliveRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,10 @@ public Command BuildPostCommand() { }; callIdOption.IsRequired = true; command.AddOption(callIdOption); - command.SetHandler(async (string callId) => { + command.SetHandler(async (string callId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, callIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action keepAlive - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Communications/Calls/Item/Mute/MuteRequestBuilder.cs b/src/generated/Communications/Calls/Item/Mute/MuteRequestBuilder.cs index 3228905d83e..596799a4f1c 100644 --- a/src/generated/Communications/Calls/Item/Mute/MuteRequestBuilder.cs +++ b/src/generated/Communications/Calls/Item/Mute/MuteRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(MuteRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action mute - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MuteRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes muteParticipantOperation public class MuteResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Communications/Calls/Item/Operations/Item/CommsOperationRequestBuilder.cs b/src/generated/Communications/Calls/Item/Operations/Item/CommsOperationRequestBuilder.cs index 079a606b191..5bf25f33095 100644 --- a/src/generated/Communications/Calls/Item/Operations/Item/CommsOperationRequestBuilder.cs +++ b/src/generated/Communications/Calls/Item/Operations/Item/CommsOperationRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; callIdOption.IsRequired = true; command.AddOption(callIdOption); - var commsOperationIdOption = new Option("--commsoperation-id", description: "key: id of commsOperation") { + var commsOperationIdOption = new Option("--comms-operation-id", description: "key: id of commsOperation") { }; commsOperationIdOption.IsRequired = true; command.AddOption(commsOperationIdOption); - command.SetHandler(async (string callId, string commsOperationId) => { + command.SetHandler(async (string callId, string commsOperationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, callIdOption, commsOperationIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; callIdOption.IsRequired = true; command.AddOption(callIdOption); - var commsOperationIdOption = new Option("--commsoperation-id", description: "key: id of commsOperation") { + var commsOperationIdOption = new Option("--comms-operation-id", description: "key: id of commsOperation") { }; commsOperationIdOption.IsRequired = true; command.AddOption(commsOperationIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string callId, string commsOperationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callId, string commsOperationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callIdOption, commsOperationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callIdOption, commsOperationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; callIdOption.IsRequired = true; command.AddOption(callIdOption); - var commsOperationIdOption = new Option("--commsoperation-id", description: "key: id of commsOperation") { + var commsOperationIdOption = new Option("--comms-operation-id", description: "key: id of commsOperation") { }; commsOperationIdOption.IsRequired = true; command.AddOption(commsOperationIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callId, string commsOperationId, string body) => { + command.SetHandler(async (string callId, string commsOperationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, callIdOption, commsOperationIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(CommsOperation body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(CommsOperation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Communications/Calls/Item/Operations/OperationsRequestBuilder.cs b/src/generated/Communications/Calls/Item/Operations/OperationsRequestBuilder.cs index 1b1a633657d..35058f6dcef 100644 --- a/src/generated/Communications/Calls/Item/Operations/OperationsRequestBuilder.cs +++ b/src/generated/Communications/Calls/Item/Operations/OperationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class OperationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new CommsOperationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string callId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(CommsOperation body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CommsOperation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Communications/Calls/Item/Participants/Invite/InviteRequestBuilder.cs b/src/generated/Communications/Calls/Item/Participants/Invite/InviteRequestBuilder.cs index 678ce3f85f6..cd334cdb168 100644 --- a/src/generated/Communications/Calls/Item/Participants/Invite/InviteRequestBuilder.cs +++ b/src/generated/Communications/Calls/Item/Participants/Invite/InviteRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(InviteRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action invite - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(InviteRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes inviteParticipantsOperation public class InviteResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Communications/Calls/Item/Participants/Item/Mute/MuteRequestBuilder.cs b/src/generated/Communications/Calls/Item/Participants/Item/Mute/MuteRequestBuilder.cs index c22d8e59bae..cb256f1a45d 100644 --- a/src/generated/Communications/Calls/Item/Participants/Item/Mute/MuteRequestBuilder.cs +++ b/src/generated/Communications/Calls/Item/Participants/Item/Mute/MuteRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callId, string participantId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callId, string participantId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callIdOption, participantIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callIdOption, participantIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(MuteRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action mute - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MuteRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes muteParticipantOperation public class MuteResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Communications/Calls/Item/Participants/Item/ParticipantRequestBuilder.cs b/src/generated/Communications/Calls/Item/Participants/Item/ParticipantRequestBuilder.cs index cb15c34fcce..15d9f941585 100644 --- a/src/generated/Communications/Calls/Item/Participants/Item/ParticipantRequestBuilder.cs +++ b/src/generated/Communications/Calls/Item/Participants/Item/ParticipantRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,11 +37,10 @@ public Command BuildDeleteCommand() { }; participantIdOption.IsRequired = true; command.AddOption(participantIdOption); - command.SetHandler(async (string callId, string participantId) => { + command.SetHandler(async (string callId, string participantId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, callIdOption, participantIdOption); return command; @@ -71,20 +70,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string callId, string participantId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callId, string participantId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callIdOption, participantIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callIdOption, participantIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildMuteCommand() { @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callId, string participantId, string body) => { + command.SetHandler(async (string callId, string participantId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, callIdOption, participantIdOption, bodyOption); return command; @@ -203,42 +200,6 @@ public RequestInformation CreatePatchRequestInformation(Participant body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Participant model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Communications/Calls/Item/Participants/Item/StartHoldMusic/StartHoldMusicRequestBuilder.cs b/src/generated/Communications/Calls/Item/Participants/Item/StartHoldMusic/StartHoldMusicRequestBuilder.cs index ff56fb043f4..44d152ff47b 100644 --- a/src/generated/Communications/Calls/Item/Participants/Item/StartHoldMusic/StartHoldMusicRequestBuilder.cs +++ b/src/generated/Communications/Calls/Item/Participants/Item/StartHoldMusic/StartHoldMusicRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callId, string participantId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callId, string participantId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callIdOption, participantIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callIdOption, participantIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(StartHoldMusicRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action startHoldMusic - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(StartHoldMusicRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes startHoldMusicOperation public class StartHoldMusicResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Communications/Calls/Item/Participants/Item/StopHoldMusic/StopHoldMusicRequestBuilder.cs b/src/generated/Communications/Calls/Item/Participants/Item/StopHoldMusic/StopHoldMusicRequestBuilder.cs index ec745ae56d4..05fa33bb92f 100644 --- a/src/generated/Communications/Calls/Item/Participants/Item/StopHoldMusic/StopHoldMusicRequestBuilder.cs +++ b/src/generated/Communications/Calls/Item/Participants/Item/StopHoldMusic/StopHoldMusicRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callId, string participantId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callId, string participantId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callIdOption, participantIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callIdOption, participantIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(StopHoldMusicRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action stopHoldMusic - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(StopHoldMusicRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes stopHoldMusicOperation public class StopHoldMusicResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Communications/Calls/Item/Participants/ParticipantsRequestBuilder.cs b/src/generated/Communications/Calls/Item/Participants/ParticipantsRequestBuilder.cs index e73d9e368c3..a50ab5454ac 100644 --- a/src/generated/Communications/Calls/Item/Participants/ParticipantsRequestBuilder.cs +++ b/src/generated/Communications/Calls/Item/Participants/ParticipantsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,14 +23,13 @@ public class ParticipantsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ParticipantRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildMuteCommand(), - builder.BuildPatchCommand(), - builder.BuildStartHoldMusicCommand(), - builder.BuildStopHoldMusicCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildMuteCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildStartHoldMusicCommand()); + commands.Add(builder.BuildStopHoldMusicCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callIdOption, bodyOption, outputOption); return command; } public Command BuildInviteCommand() { @@ -117,7 +115,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string callId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(Participant body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Participant model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Communications/Calls/Item/PlayPrompt/PlayPromptRequestBuilder.cs b/src/generated/Communications/Calls/Item/PlayPrompt/PlayPromptRequestBuilder.cs index 13a606fded5..c7e65fcfadd 100644 --- a/src/generated/Communications/Calls/Item/PlayPrompt/PlayPromptRequestBuilder.cs +++ b/src/generated/Communications/Calls/Item/PlayPrompt/PlayPromptRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(PlayPromptRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action playPrompt - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PlayPromptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes playPromptOperation public class PlayPromptResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Communications/Calls/Item/RecordResponse/RecordResponseRequestBuilder.cs b/src/generated/Communications/Calls/Item/RecordResponse/RecordResponseRequestBuilder.cs index aa7cff12d72..aa810613348 100644 --- a/src/generated/Communications/Calls/Item/RecordResponse/RecordResponseRequestBuilder.cs +++ b/src/generated/Communications/Calls/Item/RecordResponse/RecordResponseRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(RecordResponseRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action recordResponse - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RecordResponseRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes recordOperation public class RecordResponseResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Communications/Calls/Item/Redirect/RedirectRequestBuilder.cs b/src/generated/Communications/Calls/Item/Redirect/RedirectRequestBuilder.cs index 086da8df2a4..67593871d16 100644 --- a/src/generated/Communications/Calls/Item/Redirect/RedirectRequestBuilder.cs +++ b/src/generated/Communications/Calls/Item/Redirect/RedirectRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callId, string body) => { + command.SetHandler(async (string callId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, callIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(RedirectRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action redirect - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RedirectRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Communications/Calls/Item/Reject/RejectRequestBuilder.cs b/src/generated/Communications/Calls/Item/Reject/RejectRequestBuilder.cs index 7aecae205ce..5387713fb1d 100644 --- a/src/generated/Communications/Calls/Item/Reject/RejectRequestBuilder.cs +++ b/src/generated/Communications/Calls/Item/Reject/RejectRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callId, string body) => { + command.SetHandler(async (string callId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, callIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(RejectRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action reject - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RejectRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Communications/Calls/Item/SubscribeToTone/SubscribeToToneRequestBuilder.cs b/src/generated/Communications/Calls/Item/SubscribeToTone/SubscribeToToneRequestBuilder.cs index f6e397ff639..d1a30f80517 100644 --- a/src/generated/Communications/Calls/Item/SubscribeToTone/SubscribeToToneRequestBuilder.cs +++ b/src/generated/Communications/Calls/Item/SubscribeToTone/SubscribeToToneRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(SubscribeToToneRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action subscribeToTone - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SubscribeToToneRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes subscribeToToneOperation public class SubscribeToToneResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Communications/Calls/Item/Transfer/TransferRequestBuilder.cs b/src/generated/Communications/Calls/Item/Transfer/TransferRequestBuilder.cs index e3cc191a03a..28787e248a2 100644 --- a/src/generated/Communications/Calls/Item/Transfer/TransferRequestBuilder.cs +++ b/src/generated/Communications/Calls/Item/Transfer/TransferRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callId, string body) => { + command.SetHandler(async (string callId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, callIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(TransferRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action transfer - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TransferRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Communications/Calls/Item/Unmute/UnmuteRequestBuilder.cs b/src/generated/Communications/Calls/Item/Unmute/UnmuteRequestBuilder.cs index 04ec119b332..d3660ee253e 100644 --- a/src/generated/Communications/Calls/Item/Unmute/UnmuteRequestBuilder.cs +++ b/src/generated/Communications/Calls/Item/Unmute/UnmuteRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(UnmuteRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action unmute - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UnmuteRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes unmuteParticipantOperation public class UnmuteResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Communications/Calls/Item/UpdateRecordingStatus/UpdateRecordingStatusRequestBuilder.cs b/src/generated/Communications/Calls/Item/UpdateRecordingStatus/UpdateRecordingStatusRequestBuilder.cs index 4d35312c310..3afadb9b3f1 100644 --- a/src/generated/Communications/Calls/Item/UpdateRecordingStatus/UpdateRecordingStatusRequestBuilder.cs +++ b/src/generated/Communications/Calls/Item/UpdateRecordingStatus/UpdateRecordingStatusRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string callId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string callId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, callIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, callIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(UpdateRecordingStatusRequ requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action updateRecordingStatus - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UpdateRecordingStatusRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes updateRecordingStatusOperation public class UpdateRecordingStatusResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Communications/Calls/LogTeleconferenceDeviceQuality/LogTeleconferenceDeviceQualityRequestBuilder.cs b/src/generated/Communications/Calls/LogTeleconferenceDeviceQuality/LogTeleconferenceDeviceQualityRequestBuilder.cs index 45958f64c0d..077b79c7f47 100644 --- a/src/generated/Communications/Calls/LogTeleconferenceDeviceQuality/LogTeleconferenceDeviceQualityRequestBuilder.cs +++ b/src/generated/Communications/Calls/LogTeleconferenceDeviceQuality/LogTeleconferenceDeviceQualityRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,14 +29,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -72,18 +71,5 @@ public RequestInformation CreatePostRequestInformation(LogTeleconferenceDeviceQu requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action logTeleconferenceDeviceQuality - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(LogTeleconferenceDeviceQualityRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Communications/CommunicationsRequestBuilder.cs b/src/generated/Communications/CommunicationsRequestBuilder.cs index 2cab447e354..3b87bcbe915 100644 --- a/src/generated/Communications/CommunicationsRequestBuilder.cs +++ b/src/generated/Communications/CommunicationsRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,6 +27,9 @@ public class CommunicationsRequestBuilder { public Command BuildCallRecordsCommand() { var command = new Command("call-records"); var builder = new ApiSdk.Communications.CallRecords.CallRecordsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -34,6 +37,9 @@ public Command BuildCallRecordsCommand() { public Command BuildCallsCommand() { var command = new Command("calls"); var builder = new ApiSdk.Communications.Calls.CallsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); command.AddCommand(builder.BuildLogTeleconferenceDeviceQualityCommand()); @@ -56,20 +62,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } public Command BuildGetPresencesByUserIdCommand() { @@ -81,6 +86,9 @@ public Command BuildGetPresencesByUserIdCommand() { public Command BuildOnlineMeetingsCommand() { var command = new Command("online-meetings"); var builder = new ApiSdk.Communications.OnlineMeetings.OnlineMeetingsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateOrGetCommand()); command.AddCommand(builder.BuildListCommand()); @@ -97,14 +105,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -112,6 +119,9 @@ public Command BuildPatchCommand() { public Command BuildPresencesCommand() { var command = new Command("presences"); var builder = new ApiSdk.Communications.Presences.PresencesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -168,31 +178,6 @@ public RequestInformation CreatePatchRequestInformation(CloudCommunications body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get communications - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update communications - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(CloudCommunications model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get communications public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Communications/GetPresencesByUserId/GetPresencesByUserIdRequestBuilder.cs b/src/generated/Communications/GetPresencesByUserId/GetPresencesByUserIdRequestBuilder.cs index c1f51c49817..74449fefbba 100644 --- a/src/generated/Communications/GetPresencesByUserId/GetPresencesByUserIdRequestBuilder.cs +++ b/src/generated/Communications/GetPresencesByUserId/GetPresencesByUserIdRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +29,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +76,5 @@ public RequestInformation CreatePostRequestInformation(GetPresencesByUserIdReque requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getPresencesByUserId - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetPresencesByUserIdRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Communications/OnlineMeetings/CreateOrGet/CreateOrGetRequestBuilder.cs b/src/generated/Communications/OnlineMeetings/CreateOrGet/CreateOrGetRequestBuilder.cs index 26b139fa928..584f8fd3886 100644 --- a/src/generated/Communications/OnlineMeetings/CreateOrGet/CreateOrGetRequestBuilder.cs +++ b/src/generated/Communications/OnlineMeetings/CreateOrGet/CreateOrGetRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -78,19 +77,6 @@ public RequestInformation CreatePostRequestInformation(CreateOrGetRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createOrGet - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateOrGetRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onlineMeeting public class CreateOrGetResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Communications/OnlineMeetings/Item/AttendanceReports/AttendanceReportsRequestBuilder.cs b/src/generated/Communications/OnlineMeetings/Item/AttendanceReports/AttendanceReportsRequestBuilder.cs index ed7a8fff3e5..9f2f6cce626 100644 --- a/src/generated/Communications/OnlineMeetings/Item/AttendanceReports/AttendanceReportsRequestBuilder.cs +++ b/src/generated/Communications/OnlineMeetings/Item/AttendanceReports/AttendanceReportsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class AttendanceReportsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MeetingAttendanceReportRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAttendanceRecordsCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAttendanceRecordsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -37,7 +36,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The attendance reports of an online meeting. Read-only."; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onlineMeetingId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onlineMeetingId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onlineMeetingIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onlineMeetingIdOption, bodyOption, outputOption); return command; } /// @@ -69,7 +67,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The attendance reports of an online meeting. Read-only."; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onlineMeetingId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onlineMeetingId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onlineMeetingIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onlineMeetingIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(MeetingAttendanceReport b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The attendance reports of an online meeting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The attendance reports of an online meeting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MeetingAttendanceReport model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The attendance reports of an online meeting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Communications/OnlineMeetings/Item/AttendanceReports/Item/AttendanceRecords/AttendanceRecordsRequestBuilder.cs b/src/generated/Communications/OnlineMeetings/Item/AttendanceReports/Item/AttendanceRecords/AttendanceRecordsRequestBuilder.cs index 45bf208ed86..32ccb98f763 100644 --- a/src/generated/Communications/OnlineMeetings/Item/AttendanceReports/Item/AttendanceRecords/AttendanceRecordsRequestBuilder.cs +++ b/src/generated/Communications/OnlineMeetings/Item/AttendanceReports/Item/AttendanceRecords/AttendanceRecordsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AttendanceRecordsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttendanceRecordRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,11 +35,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "List of attendance records of an attendance report. Read-only."; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - var meetingAttendanceReportIdOption = new Option("--meetingattendancereport-id", description: "key: id of meetingAttendanceReport") { + var meetingAttendanceReportIdOption = new Option("--meeting-attendance-report-id", description: "key: id of meetingAttendanceReport") { }; meetingAttendanceReportIdOption.IsRequired = true; command.AddOption(meetingAttendanceReportIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onlineMeetingIdOption, meetingAttendanceReportIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onlineMeetingIdOption, meetingAttendanceReportIdOption, bodyOption, outputOption); return command; } /// @@ -72,11 +70,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "List of attendance records of an attendance report. Read-only."; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - var meetingAttendanceReportIdOption = new Option("--meetingattendancereport-id", description: "key: id of meetingAttendanceReport") { + var meetingAttendanceReportIdOption = new Option("--meeting-attendance-report-id", description: "key: id of meetingAttendanceReport") { }; meetingAttendanceReportIdOption.IsRequired = true; command.AddOption(meetingAttendanceReportIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onlineMeetingIdOption, meetingAttendanceReportIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onlineMeetingIdOption, meetingAttendanceReportIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(AttendanceRecord body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of attendance records of an attendance report. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of attendance records of an attendance report. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AttendanceRecord model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// List of attendance records of an attendance report. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Communications/OnlineMeetings/Item/AttendanceReports/Item/AttendanceRecords/Item/AttendanceRecordRequestBuilder.cs b/src/generated/Communications/OnlineMeetings/Item/AttendanceReports/Item/AttendanceRecords/Item/AttendanceRecordRequestBuilder.cs index e4cb0c52482..ac51596d272 100644 --- a/src/generated/Communications/OnlineMeetings/Item/AttendanceReports/Item/AttendanceRecords/Item/AttendanceRecordRequestBuilder.cs +++ b/src/generated/Communications/OnlineMeetings/Item/AttendanceReports/Item/AttendanceRecords/Item/AttendanceRecordRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "List of attendance records of an attendance report. Read-only."; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - var meetingAttendanceReportIdOption = new Option("--meetingattendancereport-id", description: "key: id of meetingAttendanceReport") { + var meetingAttendanceReportIdOption = new Option("--meeting-attendance-report-id", description: "key: id of meetingAttendanceReport") { }; meetingAttendanceReportIdOption.IsRequired = true; command.AddOption(meetingAttendanceReportIdOption); - var attendanceRecordIdOption = new Option("--attendancerecord-id", description: "key: id of attendanceRecord") { + var attendanceRecordIdOption = new Option("--attendance-record-id", description: "key: id of attendanceRecord") { }; attendanceRecordIdOption.IsRequired = true; command.AddOption(attendanceRecordIdOption); - command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, string attendanceRecordId) => { + command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, string attendanceRecordId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onlineMeetingIdOption, meetingAttendanceReportIdOption, attendanceRecordIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "List of attendance records of an attendance report. Read-only."; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - var meetingAttendanceReportIdOption = new Option("--meetingattendancereport-id", description: "key: id of meetingAttendanceReport") { + var meetingAttendanceReportIdOption = new Option("--meeting-attendance-report-id", description: "key: id of meetingAttendanceReport") { }; meetingAttendanceReportIdOption.IsRequired = true; command.AddOption(meetingAttendanceReportIdOption); - var attendanceRecordIdOption = new Option("--attendancerecord-id", description: "key: id of attendanceRecord") { + var attendanceRecordIdOption = new Option("--attendance-record-id", description: "key: id of attendanceRecord") { }; attendanceRecordIdOption.IsRequired = true; command.AddOption(attendanceRecordIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, string attendanceRecordId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, string attendanceRecordId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onlineMeetingIdOption, meetingAttendanceReportIdOption, attendanceRecordIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onlineMeetingIdOption, meetingAttendanceReportIdOption, attendanceRecordIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "List of attendance records of an attendance report. Read-only."; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - var meetingAttendanceReportIdOption = new Option("--meetingattendancereport-id", description: "key: id of meetingAttendanceReport") { + var meetingAttendanceReportIdOption = new Option("--meeting-attendance-report-id", description: "key: id of meetingAttendanceReport") { }; meetingAttendanceReportIdOption.IsRequired = true; command.AddOption(meetingAttendanceReportIdOption); - var attendanceRecordIdOption = new Option("--attendancerecord-id", description: "key: id of attendanceRecord") { + var attendanceRecordIdOption = new Option("--attendance-record-id", description: "key: id of attendanceRecord") { }; attendanceRecordIdOption.IsRequired = true; command.AddOption(attendanceRecordIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, string attendanceRecordId, string body) => { + command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, string attendanceRecordId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onlineMeetingIdOption, meetingAttendanceReportIdOption, attendanceRecordIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(AttendanceRecord body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of attendance records of an attendance report. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of attendance records of an attendance report. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of attendance records of an attendance report. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AttendanceRecord model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// List of attendance records of an attendance report. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Communications/OnlineMeetings/Item/AttendanceReports/Item/MeetingAttendanceReportRequestBuilder.cs b/src/generated/Communications/OnlineMeetings/Item/AttendanceReports/Item/MeetingAttendanceReportRequestBuilder.cs index 94b1724794f..bfaccb94a2e 100644 --- a/src/generated/Communications/OnlineMeetings/Item/AttendanceReports/Item/MeetingAttendanceReportRequestBuilder.cs +++ b/src/generated/Communications/OnlineMeetings/Item/AttendanceReports/Item/MeetingAttendanceReportRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,6 +23,9 @@ public class MeetingAttendanceReportRequestBuilder { public Command BuildAttendanceRecordsCommand() { var command = new Command("attendance-records"); var builder = new ApiSdk.Communications.OnlineMeetings.Item.AttendanceReports.Item.AttendanceRecords.AttendanceRecordsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -34,19 +37,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The attendance reports of an online meeting. Read-only."; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - var meetingAttendanceReportIdOption = new Option("--meetingattendancereport-id", description: "key: id of meetingAttendanceReport") { + var meetingAttendanceReportIdOption = new Option("--meeting-attendance-report-id", description: "key: id of meetingAttendanceReport") { }; meetingAttendanceReportIdOption.IsRequired = true; command.AddOption(meetingAttendanceReportIdOption); - command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId) => { + command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onlineMeetingIdOption, meetingAttendanceReportIdOption); return command; @@ -58,11 +60,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The attendance reports of an online meeting. Read-only."; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - var meetingAttendanceReportIdOption = new Option("--meetingattendancereport-id", description: "key: id of meetingAttendanceReport") { + var meetingAttendanceReportIdOption = new Option("--meeting-attendance-report-id", description: "key: id of meetingAttendanceReport") { }; meetingAttendanceReportIdOption.IsRequired = true; command.AddOption(meetingAttendanceReportIdOption); @@ -76,20 +78,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onlineMeetingIdOption, meetingAttendanceReportIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onlineMeetingIdOption, meetingAttendanceReportIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,11 +100,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The attendance reports of an online meeting. Read-only."; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - var meetingAttendanceReportIdOption = new Option("--meetingattendancereport-id", description: "key: id of meetingAttendanceReport") { + var meetingAttendanceReportIdOption = new Option("--meeting-attendance-report-id", description: "key: id of meetingAttendanceReport") { }; meetingAttendanceReportIdOption.IsRequired = true; command.AddOption(meetingAttendanceReportIdOption); @@ -111,14 +112,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, string body) => { + command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onlineMeetingIdOption, meetingAttendanceReportIdOption, bodyOption); return command; @@ -190,42 +190,6 @@ public RequestInformation CreatePatchRequestInformation(MeetingAttendanceReport requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The attendance reports of an online meeting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The attendance reports of an online meeting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The attendance reports of an online meeting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MeetingAttendanceReport model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The attendance reports of an online meeting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Communications/OnlineMeetings/Item/AttendeeReport/AttendeeReportRequestBuilder.cs b/src/generated/Communications/OnlineMeetings/Item/AttendeeReport/AttendeeReportRequestBuilder.cs index 77ba94667da..bfb6c7b6d95 100644 --- a/src/generated/Communications/OnlineMeetings/Item/AttendeeReport/AttendeeReportRequestBuilder.cs +++ b/src/generated/Communications/OnlineMeetings/Item/AttendeeReport/AttendeeReportRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,28 +25,30 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get media content for the navigation property onlineMeetings from communications"; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string onlineMeetingId, FileInfo output) => { + command.SetHandler(async (string onlineMeetingId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, onlineMeetingIdOption, outputOption); + }, onlineMeetingIdOption, fileOption, outputOption); return command; } /// @@ -56,7 +58,7 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "Update media content for the navigation property onlineMeetings in communications"; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); @@ -64,12 +66,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onlineMeetingId, FileInfo file) => { + command.SetHandler(async (string onlineMeetingId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onlineMeetingIdOption, bodyOption); return command; @@ -120,29 +121,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property onlineMeetings from communications - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property onlineMeetings in communications - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Communications/OnlineMeetings/Item/OnlineMeetingRequestBuilder.cs b/src/generated/Communications/OnlineMeetings/Item/OnlineMeetingRequestBuilder.cs index cca7b042c7c..901911bbbfe 100644 --- a/src/generated/Communications/OnlineMeetings/Item/OnlineMeetingRequestBuilder.cs +++ b/src/generated/Communications/OnlineMeetings/Item/OnlineMeetingRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -24,6 +24,9 @@ public class OnlineMeetingRequestBuilder { public Command BuildAttendanceReportsCommand() { var command = new Command("attendance-reports"); var builder = new ApiSdk.Communications.OnlineMeetings.Item.AttendanceReports.AttendanceReportsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -42,15 +45,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property onlineMeetings for communications"; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - command.SetHandler(async (string onlineMeetingId) => { + command.SetHandler(async (string onlineMeetingId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onlineMeetingIdOption); return command; @@ -62,7 +64,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get onlineMeetings from communications"; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); @@ -76,20 +78,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onlineMeetingId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onlineMeetingId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onlineMeetingIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onlineMeetingIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,7 +100,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property onlineMeetings in communications"; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); @@ -107,14 +108,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onlineMeetingId, string body) => { + command.SetHandler(async (string onlineMeetingId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onlineMeetingIdOption, bodyOption); return command; @@ -186,42 +186,6 @@ public RequestInformation CreatePatchRequestInformation(OnlineMeeting body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property onlineMeetings for communications - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get onlineMeetings from communications - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property onlineMeetings in communications - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnlineMeeting model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get onlineMeetings from communications public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Communications/OnlineMeetings/OnlineMeetingsRequestBuilder.cs b/src/generated/Communications/OnlineMeetings/OnlineMeetingsRequestBuilder.cs index e842f549a9a..9919a6b9c56 100644 --- a/src/generated/Communications/OnlineMeetings/OnlineMeetingsRequestBuilder.cs +++ b/src/generated/Communications/OnlineMeetings/OnlineMeetingsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,13 +23,12 @@ public class OnlineMeetingsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnlineMeetingRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAttendanceReportsCommand(), - builder.BuildAttendeeReportCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAttendanceReportsCommand()); + commands.Add(builder.BuildAttendeeReportCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -43,21 +42,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } public Command BuildCreateOrGetCommand() { @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(OnlineMeeting body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get onlineMeetings from communications - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to onlineMeetings for communications - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnlineMeeting model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get onlineMeetings from communications public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Communications/Presences/Item/ClearPresence/ClearPresenceRequestBuilder.cs b/src/generated/Communications/Presences/Item/ClearPresence/ClearPresenceRequestBuilder.cs index 62caa6dea6a..15a854d6d8f 100644 --- a/src/generated/Communications/Presences/Item/ClearPresence/ClearPresenceRequestBuilder.cs +++ b/src/generated/Communications/Presences/Item/ClearPresence/ClearPresenceRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string presenceId, string body) => { + command.SetHandler(async (string presenceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, presenceIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ClearPresenceRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action clearPresence - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ClearPresenceRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Communications/Presences/Item/PresenceRequestBuilder.cs b/src/generated/Communications/Presences/Item/PresenceRequestBuilder.cs index 51540caabdb..7ab71236f56 100644 --- a/src/generated/Communications/Presences/Item/PresenceRequestBuilder.cs +++ b/src/generated/Communications/Presences/Item/PresenceRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; presenceIdOption.IsRequired = true; command.AddOption(presenceIdOption); - command.SetHandler(async (string presenceId) => { + command.SetHandler(async (string presenceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, presenceIdOption); return command; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string presenceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string presenceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, presenceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, presenceIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,14 +97,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string presenceId, string body) => { + command.SetHandler(async (string presenceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, presenceIdOption, bodyOption); return command; @@ -184,42 +181,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property presences for communications - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get presences from communications - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property presences in communications - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Presence model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get presences from communications public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Communications/Presences/Item/SetPresence/SetPresenceRequestBody.cs b/src/generated/Communications/Presences/Item/SetPresence/SetPresenceRequestBody.cs index f986bca9918..e40062aab49 100644 --- a/src/generated/Communications/Presences/Item/SetPresence/SetPresenceRequestBody.cs +++ b/src/generated/Communications/Presences/Item/SetPresence/SetPresenceRequestBody.cs @@ -9,7 +9,7 @@ public class SetPresenceRequestBody : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string Availability { get; set; } - public string ExpirationDuration { get; set; } + public TimeSpan? ExpirationDuration { get; set; } public string SessionId { get; set; } /// /// Instantiates a new setPresenceRequestBody and sets the default values. @@ -24,7 +24,7 @@ public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"activity", (o,n) => { (o as SetPresenceRequestBody).Activity = n.GetStringValue(); } }, {"availability", (o,n) => { (o as SetPresenceRequestBody).Availability = n.GetStringValue(); } }, - {"expirationDuration", (o,n) => { (o as SetPresenceRequestBody).ExpirationDuration = n.GetStringValue(); } }, + {"expirationDuration", (o,n) => { (o as SetPresenceRequestBody).ExpirationDuration = n.GetTimeSpanValue(); } }, {"sessionId", (o,n) => { (o as SetPresenceRequestBody).SessionId = n.GetStringValue(); } }, }; } @@ -36,7 +36,7 @@ public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("activity", Activity); writer.WriteStringValue("availability", Availability); - writer.WriteStringValue("expirationDuration", ExpirationDuration); + writer.WriteTimeSpanValue("expirationDuration", ExpirationDuration); writer.WriteStringValue("sessionId", SessionId); writer.WriteAdditionalData(AdditionalData); } diff --git a/src/generated/Communications/Presences/Item/SetPresence/SetPresenceRequestBuilder.cs b/src/generated/Communications/Presences/Item/SetPresence/SetPresenceRequestBuilder.cs index da6a0454fb3..9d0d734abb0 100644 --- a/src/generated/Communications/Presences/Item/SetPresence/SetPresenceRequestBuilder.cs +++ b/src/generated/Communications/Presences/Item/SetPresence/SetPresenceRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string presenceId, string body) => { + command.SetHandler(async (string presenceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, presenceIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(SetPresenceRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setPresence - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetPresenceRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Communications/Presences/PresencesRequestBuilder.cs b/src/generated/Communications/Presences/PresencesRequestBuilder.cs index c42de4a2549..e86801f0f7b 100644 --- a/src/generated/Communications/Presences/PresencesRequestBuilder.cs +++ b/src/generated/Communications/Presences/PresencesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class PresencesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PresenceRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildClearPresenceCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSetPresenceCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildClearPresenceCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSetPresenceCommand()); return commands; } /// @@ -42,21 +41,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -101,7 +99,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -112,15 +114,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -175,31 +172,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get presences from communications - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to presences for communications - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Presence model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get presences from communications public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Compliance/ComplianceRequestBuilder.cs b/src/generated/Compliance/ComplianceRequestBuilder.cs index fa1f7bf8ec3..f31a35ed87e 100644 --- a/src/generated/Compliance/ComplianceRequestBuilder.cs +++ b/src/generated/Compliance/ComplianceRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -36,20 +36,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -63,14 +62,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -127,31 +125,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get compliance - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update compliance - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Compliance model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get compliance public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Connections/ConnectionsRequestBuilder.cs b/src/generated/Connections/ConnectionsRequestBuilder.cs index e265d61c032..29ce08b9083 100644 --- a/src/generated/Connections/ConnectionsRequestBuilder.cs +++ b/src/generated/Connections/ConnectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph.ExternalConnectors; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class ConnectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExternalConnectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildGroupsCommand(), - builder.BuildItemsCommand(), - builder.BuildOperationsCommand(), - builder.BuildPatchCommand(), - builder.BuildSchemaCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildGroupsCommand()); + commands.Add(builder.BuildItemsCommand()); + commands.Add(builder.BuildOperationsCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSchemaCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -103,7 +101,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -114,15 +116,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -177,31 +174,6 @@ public RequestInformation CreatePostRequestInformation(ExternalConnection body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get entities from connections - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to connections - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ExternalConnection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from connections public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Connections/Item/ExternalConnectionRequestBuilder.cs b/src/generated/Connections/Item/ExternalConnectionRequestBuilder.cs index 879541c1a45..866cc8549d8 100644 --- a/src/generated/Connections/Item/ExternalConnectionRequestBuilder.cs +++ b/src/generated/Connections/Item/ExternalConnectionRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph.ExternalConnectors; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete entity from connections"; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); - command.SetHandler(async (string externalConnectionId) => { + command.SetHandler(async (string externalConnectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, externalConnectionIdOption); return command; @@ -50,7 +49,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get entity from connections by key"; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); @@ -64,25 +63,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string externalConnectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string externalConnectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, externalConnectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, externalConnectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildGroupsCommand() { var command = new Command("groups"); var builder = new ApiSdk.Connections.Item.Groups.GroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -90,6 +91,9 @@ public Command BuildGroupsCommand() { public Command BuildItemsCommand() { var command = new Command("items"); var builder = new ApiSdk.Connections.Item.Items.ItemsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -97,6 +101,9 @@ public Command BuildItemsCommand() { public Command BuildOperationsCommand() { var command = new Command("operations"); var builder = new ApiSdk.Connections.Item.Operations.OperationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -108,7 +115,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update entity in connections"; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); @@ -116,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string externalConnectionId, string body) => { + command.SetHandler(async (string externalConnectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, externalConnectionIdOption, bodyOption); return command; @@ -203,42 +209,6 @@ public RequestInformation CreatePatchRequestInformation(ExternalConnection body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from connections - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from connections by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in connections - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ExternalConnection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from connections by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Connections/Item/Groups/GroupsRequestBuilder.cs b/src/generated/Connections/Item/Groups/GroupsRequestBuilder.cs index 985bfc5484a..0e6e8d0be8d 100644 --- a/src/generated/Connections/Item/Groups/GroupsRequestBuilder.cs +++ b/src/generated/Connections/Item/Groups/GroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph.ExternalConnectors; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class GroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExternalGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildMembersCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildMembersCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -37,7 +36,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string externalConnectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string externalConnectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, externalConnectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, externalConnectionIdOption, bodyOption, outputOption); return command; } /// @@ -69,7 +67,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string externalConnectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string externalConnectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, externalConnectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, externalConnectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(ExternalGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ExternalGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Connections/Item/Groups/Item/ExternalGroupRequestBuilder.cs b/src/generated/Connections/Item/Groups/Item/ExternalGroupRequestBuilder.cs index 62032fcaf33..fcf46edf07f 100644 --- a/src/generated/Connections/Item/Groups/Item/ExternalGroupRequestBuilder.cs +++ b/src/generated/Connections/Item/Groups/Item/ExternalGroupRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph.ExternalConnectors; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,19 +27,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); - var externalGroupIdOption = new Option("--externalgroup-id", description: "key: id of externalGroup") { + var externalGroupIdOption = new Option("--external-group-id", description: "key: id of externalGroup") { }; externalGroupIdOption.IsRequired = true; command.AddOption(externalGroupIdOption); - command.SetHandler(async (string externalConnectionId, string externalGroupId) => { + command.SetHandler(async (string externalConnectionId, string externalGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, externalConnectionIdOption, externalGroupIdOption); return command; @@ -51,11 +50,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); - var externalGroupIdOption = new Option("--externalgroup-id", description: "key: id of externalGroup") { + var externalGroupIdOption = new Option("--external-group-id", description: "key: id of externalGroup") { }; externalGroupIdOption.IsRequired = true; command.AddOption(externalGroupIdOption); @@ -69,25 +68,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string externalConnectionId, string externalGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string externalConnectionId, string externalGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, externalConnectionIdOption, externalGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, externalConnectionIdOption, externalGroupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildMembersCommand() { var command = new Command("members"); var builder = new ApiSdk.Connections.Item.Groups.Item.Members.MembersRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -99,11 +100,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); - var externalGroupIdOption = new Option("--externalgroup-id", description: "key: id of externalGroup") { + var externalGroupIdOption = new Option("--external-group-id", description: "key: id of externalGroup") { }; externalGroupIdOption.IsRequired = true; command.AddOption(externalGroupIdOption); @@ -111,14 +112,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string externalConnectionId, string externalGroupId, string body) => { + command.SetHandler(async (string externalConnectionId, string externalGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, externalConnectionIdOption, externalGroupIdOption, bodyOption); return command; @@ -190,42 +190,6 @@ public RequestInformation CreatePatchRequestInformation(ExternalGroup body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ExternalGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Connections/Item/Groups/Item/Members/Item/IdentityRequestBuilder.cs b/src/generated/Connections/Item/Groups/Item/Members/Item/IdentityRequestBuilder.cs index 81c6b4c735a..f92214d5171 100644 --- a/src/generated/Connections/Item/Groups/Item/Members/Item/IdentityRequestBuilder.cs +++ b/src/generated/Connections/Item/Groups/Item/Members/Item/IdentityRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "A member added to an externalGroup. You can add Azure Active Directory users, Azure Active Directory groups, or other externalGroups as members."; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); - var externalGroupIdOption = new Option("--externalgroup-id", description: "key: id of externalGroup") { + var externalGroupIdOption = new Option("--external-group-id", description: "key: id of externalGroup") { }; externalGroupIdOption.IsRequired = true; command.AddOption(externalGroupIdOption); @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; identityIdOption.IsRequired = true; command.AddOption(identityIdOption); - command.SetHandler(async (string externalConnectionId, string externalGroupId, string identityId) => { + command.SetHandler(async (string externalConnectionId, string externalGroupId, string identityId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, externalConnectionIdOption, externalGroupIdOption, identityIdOption); return command; @@ -54,11 +53,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "A member added to an externalGroup. You can add Azure Active Directory users, Azure Active Directory groups, or other externalGroups as members."; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); - var externalGroupIdOption = new Option("--externalgroup-id", description: "key: id of externalGroup") { + var externalGroupIdOption = new Option("--external-group-id", description: "key: id of externalGroup") { }; externalGroupIdOption.IsRequired = true; command.AddOption(externalGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string externalConnectionId, string externalGroupId, string identityId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string externalConnectionId, string externalGroupId, string identityId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, externalConnectionIdOption, externalGroupIdOption, identityIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, externalConnectionIdOption, externalGroupIdOption, identityIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,11 +97,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "A member added to an externalGroup. You can add Azure Active Directory users, Azure Active Directory groups, or other externalGroups as members."; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); - var externalGroupIdOption = new Option("--externalgroup-id", description: "key: id of externalGroup") { + var externalGroupIdOption = new Option("--external-group-id", description: "key: id of externalGroup") { }; externalGroupIdOption.IsRequired = true; command.AddOption(externalGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string externalConnectionId, string externalGroupId, string identityId, string body) => { + command.SetHandler(async (string externalConnectionId, string externalGroupId, string identityId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, externalConnectionIdOption, externalGroupIdOption, identityIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A member added to an externalGroup. You can add Azure Active Directory users, Azure Active Directory groups, or other externalGroups as members. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A member added to an externalGroup. You can add Azure Active Directory users, Azure Active Directory groups, or other externalGroups as members. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A member added to an externalGroup. You can add Azure Active Directory users, Azure Active Directory groups, or other externalGroups as members. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Identity model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A member added to an externalGroup. You can add Azure Active Directory users, Azure Active Directory groups, or other externalGroups as members. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Connections/Item/Groups/Item/Members/MembersRequestBuilder.cs b/src/generated/Connections/Item/Groups/Item/Members/MembersRequestBuilder.cs index 999fbfcb362..b014b938dfb 100644 --- a/src/generated/Connections/Item/Groups/Item/Members/MembersRequestBuilder.cs +++ b/src/generated/Connections/Item/Groups/Item/Members/MembersRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MembersRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new IdentityRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,11 +35,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "A member added to an externalGroup. You can add Azure Active Directory users, Azure Active Directory groups, or other externalGroups as members."; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); - var externalGroupIdOption = new Option("--externalgroup-id", description: "key: id of externalGroup") { + var externalGroupIdOption = new Option("--external-group-id", description: "key: id of externalGroup") { }; externalGroupIdOption.IsRequired = true; command.AddOption(externalGroupIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string externalConnectionId, string externalGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string externalConnectionId, string externalGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, externalConnectionIdOption, externalGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, externalConnectionIdOption, externalGroupIdOption, bodyOption, outputOption); return command; } /// @@ -72,11 +70,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "A member added to an externalGroup. You can add Azure Active Directory users, Azure Active Directory groups, or other externalGroups as members."; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); - var externalGroupIdOption = new Option("--externalgroup-id", description: "key: id of externalGroup") { + var externalGroupIdOption = new Option("--external-group-id", description: "key: id of externalGroup") { }; externalGroupIdOption.IsRequired = true; command.AddOption(externalGroupIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string externalConnectionId, string externalGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string externalConnectionId, string externalGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, externalConnectionIdOption, externalGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, externalConnectionIdOption, externalGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A member added to an externalGroup. You can add Azure Active Directory users, Azure Active Directory groups, or other externalGroups as members. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A member added to an externalGroup. You can add Azure Active Directory users, Azure Active Directory groups, or other externalGroups as members. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Identity model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A member added to an externalGroup. You can add Azure Active Directory users, Azure Active Directory groups, or other externalGroups as members. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Connections/Item/Groups/Item/Members/MembersResponse.cs b/src/generated/Connections/Item/Groups/Item/Members/MembersResponse.cs index 9588dd72260..a9bc6986bf0 100644 --- a/src/generated/Connections/Item/Groups/Item/Members/MembersResponse.cs +++ b/src/generated/Connections/Item/Groups/Item/Members/MembersResponse.cs @@ -1,4 +1,4 @@ -using ApiSdk.Models.Microsoft.Graph; +using ApiSdk.Models.Microsoft.Graph.ExternalConnectors; using Microsoft.Kiota.Abstractions.Serialization; using System; using System.Collections.Generic; @@ -9,7 +9,7 @@ public class MembersResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new membersResponse and sets the default values. /// @@ -22,7 +22,7 @@ public MembersResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as MembersResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as MembersResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, + {"value", (o,n) => { (o as MembersResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Connections/Item/Items/Item/ExternalItemRequestBuilder.cs b/src/generated/Connections/Item/Items/Item/ExternalItemRequestBuilder.cs index 0b95ab1210c..497652ee746 100644 --- a/src/generated/Connections/Item/Items/Item/ExternalItemRequestBuilder.cs +++ b/src/generated/Connections/Item/Items/Item/ExternalItemRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph.ExternalConnectors; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); - var externalItemIdOption = new Option("--externalitem-id", description: "key: id of externalItem") { + var externalItemIdOption = new Option("--external-item-id", description: "key: id of externalItem") { }; externalItemIdOption.IsRequired = true; command.AddOption(externalItemIdOption); - command.SetHandler(async (string externalConnectionId, string externalItemId) => { + command.SetHandler(async (string externalConnectionId, string externalItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, externalConnectionIdOption, externalItemIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); - var externalItemIdOption = new Option("--externalitem-id", description: "key: id of externalItem") { + var externalItemIdOption = new Option("--external-item-id", description: "key: id of externalItem") { }; externalItemIdOption.IsRequired = true; command.AddOption(externalItemIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string externalConnectionId, string externalItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string externalConnectionId, string externalItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, externalConnectionIdOption, externalItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, externalConnectionIdOption, externalItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); - var externalItemIdOption = new Option("--externalitem-id", description: "key: id of externalItem") { + var externalItemIdOption = new Option("--external-item-id", description: "key: id of externalItem") { }; externalItemIdOption.IsRequired = true; command.AddOption(externalItemIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string externalConnectionId, string externalItemId, string body) => { + command.SetHandler(async (string externalConnectionId, string externalItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, externalConnectionIdOption, externalItemIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ExternalItem body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ExternalItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Connections/Item/Items/ItemsRequestBuilder.cs b/src/generated/Connections/Item/Items/ItemsRequestBuilder.cs index 038ac6f3e7a..a444143ca40 100644 --- a/src/generated/Connections/Item/Items/ItemsRequestBuilder.cs +++ b/src/generated/Connections/Item/Items/ItemsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph.ExternalConnectors; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ItemsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExternalItemRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string externalConnectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string externalConnectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, externalConnectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, externalConnectionIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string externalConnectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string externalConnectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, externalConnectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, externalConnectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ExternalItem body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ExternalItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Connections/Item/Operations/Item/ConnectionOperationRequestBuilder.cs b/src/generated/Connections/Item/Operations/Item/ConnectionOperationRequestBuilder.cs index 01bb65ac420..2963e03b39e 100644 --- a/src/generated/Connections/Item/Operations/Item/ConnectionOperationRequestBuilder.cs +++ b/src/generated/Connections/Item/Operations/Item/ConnectionOperationRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph.ExternalConnectors; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); - var connectionOperationIdOption = new Option("--connectionoperation-id", description: "key: id of connectionOperation") { + var connectionOperationIdOption = new Option("--connection-operation-id", description: "key: id of connectionOperation") { }; connectionOperationIdOption.IsRequired = true; command.AddOption(connectionOperationIdOption); - command.SetHandler(async (string externalConnectionId, string connectionOperationId) => { + command.SetHandler(async (string externalConnectionId, string connectionOperationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, externalConnectionIdOption, connectionOperationIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); - var connectionOperationIdOption = new Option("--connectionoperation-id", description: "key: id of connectionOperation") { + var connectionOperationIdOption = new Option("--connection-operation-id", description: "key: id of connectionOperation") { }; connectionOperationIdOption.IsRequired = true; command.AddOption(connectionOperationIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string externalConnectionId, string connectionOperationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string externalConnectionId, string connectionOperationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, externalConnectionIdOption, connectionOperationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, externalConnectionIdOption, connectionOperationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); - var connectionOperationIdOption = new Option("--connectionoperation-id", description: "key: id of connectionOperation") { + var connectionOperationIdOption = new Option("--connection-operation-id", description: "key: id of connectionOperation") { }; connectionOperationIdOption.IsRequired = true; command.AddOption(connectionOperationIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string externalConnectionId, string connectionOperationId, string body) => { + command.SetHandler(async (string externalConnectionId, string connectionOperationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, externalConnectionIdOption, connectionOperationIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ConnectionOperation body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ConnectionOperation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Connections/Item/Operations/OperationsRequestBuilder.cs b/src/generated/Connections/Item/Operations/OperationsRequestBuilder.cs index a38f1958ea8..280a9afed50 100644 --- a/src/generated/Connections/Item/Operations/OperationsRequestBuilder.cs +++ b/src/generated/Connections/Item/Operations/OperationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph.ExternalConnectors; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class OperationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ConnectionOperationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string externalConnectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string externalConnectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, externalConnectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, externalConnectionIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string externalConnectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string externalConnectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, externalConnectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, externalConnectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ConnectionOperation body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ConnectionOperation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Connections/Item/Schema/SchemaRequestBuilder.cs b/src/generated/Connections/Item/Schema/SchemaRequestBuilder.cs index 4e478a26a83..ed2e8bf7dc0 100644 --- a/src/generated/Connections/Item/Schema/SchemaRequestBuilder.cs +++ b/src/generated/Connections/Item/Schema/SchemaRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph.ExternalConnectors; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); - command.SetHandler(async (string externalConnectionId) => { + command.SetHandler(async (string externalConnectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, externalConnectionIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string externalConnectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string externalConnectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, externalConnectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, externalConnectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string externalConnectionId, string body) => { + command.SetHandler(async (string externalConnectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, externalConnectionIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.ExternalConnectors.Schema model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Contacts/ContactsRequestBuilder.cs b/src/generated/Contacts/ContactsRequestBuilder.cs index f242960efbd..19bf20e14b3 100644 --- a/src/generated/Contacts/ContactsRequestBuilder.cs +++ b/src/generated/Contacts/ContactsRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,20 +26,19 @@ public class ContactsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OrgContactRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCheckMemberGroupsCommand(), - builder.BuildCheckMemberObjectsCommand(), - builder.BuildDeleteCommand(), - builder.BuildDirectReportsCommand(), - builder.BuildGetCommand(), - builder.BuildGetMemberGroupsCommand(), - builder.BuildGetMemberObjectsCommand(), - builder.BuildManagerCommand(), - builder.BuildMemberOfCommand(), - builder.BuildPatchCommand(), - builder.BuildRestoreCommand(), - builder.BuildTransitiveMemberOfCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCheckMemberGroupsCommand()); + commands.Add(builder.BuildCheckMemberObjectsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDirectReportsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildGetMemberGroupsCommand()); + commands.Add(builder.BuildGetMemberObjectsCommand()); + commands.Add(builder.BuildManagerCommand()); + commands.Add(builder.BuildMemberOfCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRestoreCommand()); + commands.Add(builder.BuildTransitiveMemberOfCommand()); return commands; } /// @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } public Command BuildGetAvailableExtensionPropertiesCommand() { @@ -124,7 +122,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -135,15 +137,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildValidatePropertiesCommand() { @@ -210,31 +207,6 @@ public RequestInformation CreatePostRequestInformation(OrgContact body, Action - /// Get entities from contacts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to contacts - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OrgContact model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from contacts public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Contacts/Delta/DeltaRequestBuilder.cs b/src/generated/Contacts/Delta/DeltaRequestBuilder.cs index 167f22904ae..c044f357b62 100644 --- a/src/generated/Contacts/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Contacts/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Contacts/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs b/src/generated/Contacts/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs deleted file mode 100644 index 5d853e4fef5..00000000000 --- a/src/generated/Contacts/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs +++ /dev/null @@ -1,45 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Contacts.GetAvailableExtensionProperties { - public class GetAvailableExtensionProperties : DirectoryObject, IParsable { - /// Display name of the application object on which this extension property is defined. Read-only. - public string AppDisplayName { get; set; } - /// Specifies the data type of the value the extension property can hold. Following values are supported. Not nullable. Binary - 256 bytes maximumBooleanDateTime - Must be specified in ISO 8601 format. Will be stored in UTC.Integer - 32-bit value.LargeInteger - 64-bit value.String - 256 characters maximum - public string DataType { get; set; } - /// Indicates if this extension property was sycned from onpremises directory using Azure AD Connect. Read-only. - public bool? IsSyncedFromOnPremises { get; set; } - /// Name of the extension property. Not nullable. - public string Name { get; set; } - /// Following values are supported. Not nullable. UserGroupOrganizationDeviceApplication - public List TargetObjects { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"appDisplayName", (o,n) => { (o as GetAvailableExtensionProperties).AppDisplayName = n.GetStringValue(); } }, - {"dataType", (o,n) => { (o as GetAvailableExtensionProperties).DataType = n.GetStringValue(); } }, - {"isSyncedFromOnPremises", (o,n) => { (o as GetAvailableExtensionProperties).IsSyncedFromOnPremises = n.GetBoolValue(); } }, - {"name", (o,n) => { (o as GetAvailableExtensionProperties).Name = n.GetStringValue(); } }, - {"targetObjects", (o,n) => { (o as GetAvailableExtensionProperties).TargetObjects = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteStringValue("appDisplayName", AppDisplayName); - writer.WriteStringValue("dataType", DataType); - writer.WriteBoolValue("isSyncedFromOnPremises", IsSyncedFromOnPremises); - writer.WriteStringValue("name", Name); - writer.WriteCollectionOfPrimitiveValues("targetObjects", TargetObjects); - } - } -} diff --git a/src/generated/Contacts/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs b/src/generated/Contacts/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs index ea4a6f2c9bf..c5ddfc7e03f 100644 --- a/src/generated/Contacts/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs +++ b/src/generated/Contacts/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(GetAvailableExtensionProp requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getAvailableExtensionProperties - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetAvailableExtensionPropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Contacts/GetByIds/GetByIds.cs b/src/generated/Contacts/GetByIds/GetByIds.cs deleted file mode 100644 index 5065c186943..00000000000 --- a/src/generated/Contacts/GetByIds/GetByIds.cs +++ /dev/null @@ -1,28 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Contacts.GetByIds { - public class GetByIds : Entity, IParsable { - public DateTimeOffset? DeletedDateTime { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"deletedDateTime", (o,n) => { (o as GetByIds).DeletedDateTime = n.GetDateTimeOffsetValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteDateTimeOffsetValue("deletedDateTime", DeletedDateTime); - } - } -} diff --git a/src/generated/Contacts/GetByIds/GetByIdsRequestBuilder.cs b/src/generated/Contacts/GetByIds/GetByIdsRequestBuilder.cs index bedbb90bf2f..eae40462953 100644 --- a/src/generated/Contacts/GetByIds/GetByIdsRequestBuilder.cs +++ b/src/generated/Contacts/GetByIds/GetByIdsRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(GetByIdsRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getByIds - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetByIdsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Contacts/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs b/src/generated/Contacts/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs index 8a3cd7917a3..aceedf29452 100644 --- a/src/generated/Contacts/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs +++ b/src/generated/Contacts/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action checkMemberGroups"; // Create options for all the parameters - var orgContactIdOption = new Option("--orgcontact-id", description: "key: id of orgContact") { + var orgContactIdOption = new Option("--org-contact-id", description: "key: id of orgContact") { }; orgContactIdOption.IsRequired = true; command.AddOption(orgContactIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string orgContactId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string orgContactId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, orgContactIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, orgContactIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberGroupsRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Contacts/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs b/src/generated/Contacts/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs index e08691960ef..3728e18ed90 100644 --- a/src/generated/Contacts/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs +++ b/src/generated/Contacts/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action checkMemberObjects"; // Create options for all the parameters - var orgContactIdOption = new Option("--orgcontact-id", description: "key: id of orgContact") { + var orgContactIdOption = new Option("--org-contact-id", description: "key: id of orgContact") { }; orgContactIdOption.IsRequired = true; command.AddOption(orgContactIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string orgContactId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string orgContactId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, orgContactIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, orgContactIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberObjectsRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Contacts/Item/DirectReports/@Ref/@Ref.cs b/src/generated/Contacts/Item/DirectReports/@Ref/@Ref.cs deleted file mode 100644 index e614650865a..00000000000 --- a/src/generated/Contacts/Item/DirectReports/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Contacts.Item.DirectReports.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Contacts/Item/DirectReports/@Ref/RefRequestBuilder.cs b/src/generated/Contacts/Item/DirectReports/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 25a6e66f765..00000000000 --- a/src/generated/Contacts/Item/DirectReports/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Contacts.Item.DirectReports.@Ref { - /// Builds and executes requests for operations under \contacts\{orgContact-id}\directReports\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The contact's direct reports. (The users and contacts that have their manager property set to this contact.) Read-only. Nullable. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The contact's direct reports. (The users and contacts that have their manager property set to this contact.) Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var orgContactIdOption = new Option("--orgcontact-id", description: "key: id of orgContact") { - }; - orgContactIdOption.IsRequired = true; - command.AddOption(orgContactIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string orgContactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, orgContactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The contact's direct reports. (The users and contacts that have their manager property set to this contact.) Read-only. Nullable. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The contact's direct reports. (The users and contacts that have their manager property set to this contact.) Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var orgContactIdOption = new Option("--orgcontact-id", description: "key: id of orgContact") { - }; - orgContactIdOption.IsRequired = true; - command.AddOption(orgContactIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string orgContactId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, orgContactIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/contacts/{orgContact_id}/directReports/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The contact's direct reports. (The users and contacts that have their manager property set to this contact.) Read-only. Nullable. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The contact's direct reports. (The users and contacts that have their manager property set to this contact.) Read-only. Nullable. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Contacts.Item.DirectReports.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The contact's direct reports. (The users and contacts that have their manager property set to this contact.) Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The contact's direct reports. (The users and contacts that have their manager property set to this contact.) Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Contacts.Item.DirectReports.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The contact's direct reports. (The users and contacts that have their manager property set to this contact.) Read-only. Nullable. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Contacts/Item/DirectReports/@Ref/RefResponse.cs b/src/generated/Contacts/Item/DirectReports/@Ref/RefResponse.cs deleted file mode 100644 index 736a711ad7c..00000000000 --- a/src/generated/Contacts/Item/DirectReports/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Contacts.Item.DirectReports.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Contacts/Item/DirectReports/DirectReportsRequestBuilder.cs b/src/generated/Contacts/Item/DirectReports/DirectReportsRequestBuilder.cs index 83829098f6f..02ddf5ee52a 100644 --- a/src/generated/Contacts/Item/DirectReports/DirectReportsRequestBuilder.cs +++ b/src/generated/Contacts/Item/DirectReports/DirectReportsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Contacts.Item.DirectReports.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The contact's direct reports. (The users and contacts that have their manager property set to this contact.) Read-only. Nullable. Supports $expand."; // Create options for all the parameters - var orgContactIdOption = new Option("--orgcontact-id", description: "key: id of orgContact") { + var orgContactIdOption = new Option("--org-contact-id", description: "key: id of orgContact") { }; orgContactIdOption.IsRequired = true; command.AddOption(orgContactIdOption); @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string orgContactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string orgContactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, orgContactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, orgContactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Contacts.Item.DirectReports.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Contacts.Item.DirectReports.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The contact's direct reports. (The users and contacts that have their manager property set to this contact.) Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The contact's direct reports. (The users and contacts that have their manager property set to this contact.) Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Contacts/Item/DirectReports/Ref/Ref.cs b/src/generated/Contacts/Item/DirectReports/Ref/Ref.cs new file mode 100644 index 00000000000..e7739d8cd1c --- /dev/null +++ b/src/generated/Contacts/Item/DirectReports/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Contacts.Item.DirectReports.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Contacts/Item/DirectReports/Ref/RefRequestBuilder.cs b/src/generated/Contacts/Item/DirectReports/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..362df092f43 --- /dev/null +++ b/src/generated/Contacts/Item/DirectReports/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Contacts.Item.DirectReports.Ref { + /// Builds and executes requests for operations under \contacts\{orgContact-id}\directReports\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The contact's direct reports. (The users and contacts that have their manager property set to this contact.) Read-only. Nullable. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The contact's direct reports. (The users and contacts that have their manager property set to this contact.) Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var orgContactIdOption = new Option("--org-contact-id", description: "key: id of orgContact") { + }; + orgContactIdOption.IsRequired = true; + command.AddOption(orgContactIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string orgContactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, orgContactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The contact's direct reports. (The users and contacts that have their manager property set to this contact.) Read-only. Nullable. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The contact's direct reports. (The users and contacts that have their manager property set to this contact.) Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var orgContactIdOption = new Option("--org-contact-id", description: "key: id of orgContact") { + }; + orgContactIdOption.IsRequired = true; + command.AddOption(orgContactIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string orgContactId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, orgContactIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/contacts/{orgContact_id}/directReports/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The contact's direct reports. (The users and contacts that have their manager property set to this contact.) Read-only. Nullable. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The contact's direct reports. (The users and contacts that have their manager property set to this contact.) Read-only. Nullable. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Contacts.Item.DirectReports.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The contact's direct reports. (The users and contacts that have their manager property set to this contact.) Read-only. Nullable. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Contacts/Item/DirectReports/Ref/RefResponse.cs b/src/generated/Contacts/Item/DirectReports/Ref/RefResponse.cs new file mode 100644 index 00000000000..3144f70db7f --- /dev/null +++ b/src/generated/Contacts/Item/DirectReports/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Contacts.Item.DirectReports.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Contacts/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs b/src/generated/Contacts/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs index cd4b921e8a2..c86424978e6 100644 --- a/src/generated/Contacts/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs +++ b/src/generated/Contacts/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action getMemberGroups"; // Create options for all the parameters - var orgContactIdOption = new Option("--orgcontact-id", description: "key: id of orgContact") { + var orgContactIdOption = new Option("--org-contact-id", description: "key: id of orgContact") { }; orgContactIdOption.IsRequired = true; command.AddOption(orgContactIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string orgContactId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string orgContactId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, orgContactIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, orgContactIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberGroupsRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Contacts/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs b/src/generated/Contacts/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs index 89980e98011..2c2be3a646b 100644 --- a/src/generated/Contacts/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs +++ b/src/generated/Contacts/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action getMemberObjects"; // Create options for all the parameters - var orgContactIdOption = new Option("--orgcontact-id", description: "key: id of orgContact") { + var orgContactIdOption = new Option("--org-contact-id", description: "key: id of orgContact") { }; orgContactIdOption.IsRequired = true; command.AddOption(orgContactIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string orgContactId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string orgContactId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, orgContactIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, orgContactIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberObjectsRequestBo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Contacts/Item/Manager/@Ref/@Ref.cs b/src/generated/Contacts/Item/Manager/@Ref/@Ref.cs deleted file mode 100644 index 8fbecf64ec0..00000000000 --- a/src/generated/Contacts/Item/Manager/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Contacts.Item.Manager.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Contacts/Item/Manager/@Ref/RefRequestBuilder.cs b/src/generated/Contacts/Item/Manager/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 6d60a1eea07..00000000000 --- a/src/generated/Contacts/Item/Manager/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Contacts.Item.Manager.@Ref { - /// Builds and executes requests for operations under \contacts\{orgContact-id}\manager\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The user or contact that is this contact's manager. Read-only. Supports $expand. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The user or contact that is this contact's manager. Read-only. Supports $expand."; - // Create options for all the parameters - var orgContactIdOption = new Option("--orgcontact-id", description: "key: id of orgContact") { - }; - orgContactIdOption.IsRequired = true; - command.AddOption(orgContactIdOption); - command.SetHandler(async (string orgContactId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, orgContactIdOption); - return command; - } - /// - /// The user or contact that is this contact's manager. Read-only. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The user or contact that is this contact's manager. Read-only. Supports $expand."; - // Create options for all the parameters - var orgContactIdOption = new Option("--orgcontact-id", description: "key: id of orgContact") { - }; - orgContactIdOption.IsRequired = true; - command.AddOption(orgContactIdOption); - command.SetHandler(async (string orgContactId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, orgContactIdOption); - return command; - } - /// - /// The user or contact that is this contact's manager. Read-only. Supports $expand. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The user or contact that is this contact's manager. Read-only. Supports $expand."; - // Create options for all the parameters - var orgContactIdOption = new Option("--orgcontact-id", description: "key: id of orgContact") { - }; - orgContactIdOption.IsRequired = true; - command.AddOption(orgContactIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string orgContactId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, orgContactIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/contacts/{orgContact_id}/manager/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The user or contact that is this contact's manager. Read-only. Supports $expand. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The user or contact that is this contact's manager. Read-only. Supports $expand. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The user or contact that is this contact's manager. Read-only. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Contacts.Item.Manager.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The user or contact that is this contact's manager. Read-only. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user or contact that is this contact's manager. Read-only. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user or contact that is this contact's manager. Read-only. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Contacts.Item.Manager.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Contacts/Item/Manager/ManagerRequestBuilder.cs b/src/generated/Contacts/Item/Manager/ManagerRequestBuilder.cs index 8f6153bb620..598ae211141 100644 --- a/src/generated/Contacts/Item/Manager/ManagerRequestBuilder.cs +++ b/src/generated/Contacts/Item/Manager/ManagerRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The user or contact that is this contact's manager. Read-only. Supports $expand."; // Create options for all the parameters - var orgContactIdOption = new Option("--orgcontact-id", description: "key: id of orgContact") { + var orgContactIdOption = new Option("--org-contact-id", description: "key: id of orgContact") { }; orgContactIdOption.IsRequired = true; command.AddOption(orgContactIdOption); @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string orgContactId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string orgContactId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, orgContactIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, orgContactIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Contacts.Item.Manager.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Contacts.Item.Manager.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user or contact that is this contact's manager. Read-only. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The user or contact that is this contact's manager. Read-only. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Contacts/Item/Manager/Ref/Ref.cs b/src/generated/Contacts/Item/Manager/Ref/Ref.cs new file mode 100644 index 00000000000..4f768ce156d --- /dev/null +++ b/src/generated/Contacts/Item/Manager/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Contacts.Item.Manager.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Contacts/Item/Manager/Ref/RefRequestBuilder.cs b/src/generated/Contacts/Item/Manager/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..ee4761caaab --- /dev/null +++ b/src/generated/Contacts/Item/Manager/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Contacts.Item.Manager.Ref { + /// Builds and executes requests for operations under \contacts\{orgContact-id}\manager\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The user or contact that is this contact's manager. Read-only. Supports $expand. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The user or contact that is this contact's manager. Read-only. Supports $expand."; + // Create options for all the parameters + var orgContactIdOption = new Option("--org-contact-id", description: "key: id of orgContact") { + }; + orgContactIdOption.IsRequired = true; + command.AddOption(orgContactIdOption); + command.SetHandler(async (string orgContactId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, orgContactIdOption); + return command; + } + /// + /// The user or contact that is this contact's manager. Read-only. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The user or contact that is this contact's manager. Read-only. Supports $expand."; + // Create options for all the parameters + var orgContactIdOption = new Option("--org-contact-id", description: "key: id of orgContact") { + }; + orgContactIdOption.IsRequired = true; + command.AddOption(orgContactIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string orgContactId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, orgContactIdOption, outputOption); + return command; + } + /// + /// The user or contact that is this contact's manager. Read-only. Supports $expand. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The user or contact that is this contact's manager. Read-only. Supports $expand."; + // Create options for all the parameters + var orgContactIdOption = new Option("--org-contact-id", description: "key: id of orgContact") { + }; + orgContactIdOption.IsRequired = true; + command.AddOption(orgContactIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string orgContactId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, orgContactIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/contacts/{orgContact_id}/manager/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The user or contact that is this contact's manager. Read-only. Supports $expand. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The user or contact that is this contact's manager. Read-only. Supports $expand. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The user or contact that is this contact's manager. Read-only. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Contacts.Item.Manager.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Contacts/Item/MemberOf/@Ref/@Ref.cs b/src/generated/Contacts/Item/MemberOf/@Ref/@Ref.cs deleted file mode 100644 index bc6b1802a0c..00000000000 --- a/src/generated/Contacts/Item/MemberOf/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Contacts.Item.MemberOf.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Contacts/Item/MemberOf/@Ref/RefRequestBuilder.cs b/src/generated/Contacts/Item/MemberOf/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 676acebe5db..00000000000 --- a/src/generated/Contacts/Item/MemberOf/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Contacts.Item.MemberOf.@Ref { - /// Builds and executes requests for operations under \contacts\{orgContact-id}\memberOf\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Groups that this contact is a member of. Read-only. Nullable. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Groups that this contact is a member of. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var orgContactIdOption = new Option("--orgcontact-id", description: "key: id of orgContact") { - }; - orgContactIdOption.IsRequired = true; - command.AddOption(orgContactIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string orgContactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, orgContactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Groups that this contact is a member of. Read-only. Nullable. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Groups that this contact is a member of. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var orgContactIdOption = new Option("--orgcontact-id", description: "key: id of orgContact") { - }; - orgContactIdOption.IsRequired = true; - command.AddOption(orgContactIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string orgContactId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, orgContactIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/contacts/{orgContact_id}/memberOf/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Groups that this contact is a member of. Read-only. Nullable. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Groups that this contact is a member of. Read-only. Nullable. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Contacts.Item.MemberOf.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Groups that this contact is a member of. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Groups that this contact is a member of. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Contacts.Item.MemberOf.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Groups that this contact is a member of. Read-only. Nullable. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Contacts/Item/MemberOf/@Ref/RefResponse.cs b/src/generated/Contacts/Item/MemberOf/@Ref/RefResponse.cs deleted file mode 100644 index 95f3a1aaabd..00000000000 --- a/src/generated/Contacts/Item/MemberOf/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Contacts.Item.MemberOf.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Contacts/Item/MemberOf/MemberOfRequestBuilder.cs b/src/generated/Contacts/Item/MemberOf/MemberOfRequestBuilder.cs index 50e06bdacfa..aa030f97279 100644 --- a/src/generated/Contacts/Item/MemberOf/MemberOfRequestBuilder.cs +++ b/src/generated/Contacts/Item/MemberOf/MemberOfRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Contacts.Item.MemberOf.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Groups that this contact is a member of. Read-only. Nullable. Supports $expand."; // Create options for all the parameters - var orgContactIdOption = new Option("--orgcontact-id", description: "key: id of orgContact") { + var orgContactIdOption = new Option("--org-contact-id", description: "key: id of orgContact") { }; orgContactIdOption.IsRequired = true; command.AddOption(orgContactIdOption); @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string orgContactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string orgContactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, orgContactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, orgContactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Contacts.Item.MemberOf.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Contacts.Item.MemberOf.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Groups that this contact is a member of. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Groups that this contact is a member of. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Contacts/Item/MemberOf/Ref/Ref.cs b/src/generated/Contacts/Item/MemberOf/Ref/Ref.cs new file mode 100644 index 00000000000..eb8aac4fd0d --- /dev/null +++ b/src/generated/Contacts/Item/MemberOf/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Contacts.Item.MemberOf.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Contacts/Item/MemberOf/Ref/RefRequestBuilder.cs b/src/generated/Contacts/Item/MemberOf/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..7b358034463 --- /dev/null +++ b/src/generated/Contacts/Item/MemberOf/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Contacts.Item.MemberOf.Ref { + /// Builds and executes requests for operations under \contacts\{orgContact-id}\memberOf\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Groups that this contact is a member of. Read-only. Nullable. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Groups that this contact is a member of. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var orgContactIdOption = new Option("--org-contact-id", description: "key: id of orgContact") { + }; + orgContactIdOption.IsRequired = true; + command.AddOption(orgContactIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string orgContactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, orgContactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Groups that this contact is a member of. Read-only. Nullable. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Groups that this contact is a member of. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var orgContactIdOption = new Option("--org-contact-id", description: "key: id of orgContact") { + }; + orgContactIdOption.IsRequired = true; + command.AddOption(orgContactIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string orgContactId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, orgContactIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/contacts/{orgContact_id}/memberOf/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Groups that this contact is a member of. Read-only. Nullable. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Groups that this contact is a member of. Read-only. Nullable. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Contacts.Item.MemberOf.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Groups that this contact is a member of. Read-only. Nullable. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Contacts/Item/MemberOf/Ref/RefResponse.cs b/src/generated/Contacts/Item/MemberOf/Ref/RefResponse.cs new file mode 100644 index 00000000000..2e6c80939b7 --- /dev/null +++ b/src/generated/Contacts/Item/MemberOf/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Contacts.Item.MemberOf.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Contacts/Item/OrgContactRequestBuilder.cs b/src/generated/Contacts/Item/OrgContactRequestBuilder.cs index 22d6870441c..412d4dbe33d 100644 --- a/src/generated/Contacts/Item/OrgContactRequestBuilder.cs +++ b/src/generated/Contacts/Item/OrgContactRequestBuilder.cs @@ -10,10 +10,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,15 +47,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete entity from contacts"; // Create options for all the parameters - var orgContactIdOption = new Option("--orgcontact-id", description: "key: id of orgContact") { + var orgContactIdOption = new Option("--org-contact-id", description: "key: id of orgContact") { }; orgContactIdOption.IsRequired = true; command.AddOption(orgContactIdOption); - command.SetHandler(async (string orgContactId) => { + command.SetHandler(async (string orgContactId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, orgContactIdOption); return command; @@ -74,7 +73,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get entity from contacts by key"; // Create options for all the parameters - var orgContactIdOption = new Option("--orgcontact-id", description: "key: id of orgContact") { + var orgContactIdOption = new Option("--org-contact-id", description: "key: id of orgContact") { }; orgContactIdOption.IsRequired = true; command.AddOption(orgContactIdOption); @@ -88,20 +87,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string orgContactId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string orgContactId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, orgContactIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, orgContactIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildGetMemberGroupsCommand() { @@ -137,7 +135,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update entity in contacts"; // Create options for all the parameters - var orgContactIdOption = new Option("--orgcontact-id", description: "key: id of orgContact") { + var orgContactIdOption = new Option("--org-contact-id", description: "key: id of orgContact") { }; orgContactIdOption.IsRequired = true; command.AddOption(orgContactIdOption); @@ -145,14 +143,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string orgContactId, string body) => { + command.SetHandler(async (string orgContactId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, orgContactIdOption, bodyOption); return command; @@ -237,42 +234,6 @@ public RequestInformation CreatePatchRequestInformation(OrgContact body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from contacts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from contacts by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in contacts - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OrgContact model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from contacts by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Contacts/Item/Restore/RestoreRequestBuilder.cs b/src/generated/Contacts/Item/Restore/RestoreRequestBuilder.cs index 56030fc8ec3..f8ba641653d 100644 --- a/src/generated/Contacts/Item/Restore/RestoreRequestBuilder.cs +++ b/src/generated/Contacts/Item/Restore/RestoreRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action restore"; // Create options for all the parameters - var orgContactIdOption = new Option("--orgcontact-id", description: "key: id of orgContact") { + var orgContactIdOption = new Option("--org-contact-id", description: "key: id of orgContact") { }; orgContactIdOption.IsRequired = true; command.AddOption(orgContactIdOption); - command.SetHandler(async (string orgContactId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string orgContactId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, orgContactIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, orgContactIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action restore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes directoryObject public class RestoreResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Contacts/Item/TransitiveMemberOf/@Ref/@Ref.cs b/src/generated/Contacts/Item/TransitiveMemberOf/@Ref/@Ref.cs deleted file mode 100644 index 88faa1648e8..00000000000 --- a/src/generated/Contacts/Item/TransitiveMemberOf/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Contacts.Item.TransitiveMemberOf.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Contacts/Item/TransitiveMemberOf/@Ref/RefRequestBuilder.cs b/src/generated/Contacts/Item/TransitiveMemberOf/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 8a6d4bab91c..00000000000 --- a/src/generated/Contacts/Item/TransitiveMemberOf/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Contacts.Item.TransitiveMemberOf.@Ref { - /// Builds and executes requests for operations under \contacts\{orgContact-id}\transitiveMemberOf\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Get ref of transitiveMemberOf from contacts - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Get ref of transitiveMemberOf from contacts"; - // Create options for all the parameters - var orgContactIdOption = new Option("--orgcontact-id", description: "key: id of orgContact") { - }; - orgContactIdOption.IsRequired = true; - command.AddOption(orgContactIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string orgContactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, orgContactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Create new navigation property ref to transitiveMemberOf for contacts - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Create new navigation property ref to transitiveMemberOf for contacts"; - // Create options for all the parameters - var orgContactIdOption = new Option("--orgcontact-id", description: "key: id of orgContact") { - }; - orgContactIdOption.IsRequired = true; - command.AddOption(orgContactIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string orgContactId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, orgContactIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/contacts/{orgContact_id}/transitiveMemberOf/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Get ref of transitiveMemberOf from contacts - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Create new navigation property ref to transitiveMemberOf for contacts - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Contacts.Item.TransitiveMemberOf.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Get ref of transitiveMemberOf from contacts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property ref to transitiveMemberOf for contacts - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Contacts.Item.TransitiveMemberOf.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Get ref of transitiveMemberOf from contacts - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Contacts/Item/TransitiveMemberOf/@Ref/RefResponse.cs b/src/generated/Contacts/Item/TransitiveMemberOf/@Ref/RefResponse.cs deleted file mode 100644 index f48ce261f51..00000000000 --- a/src/generated/Contacts/Item/TransitiveMemberOf/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Contacts.Item.TransitiveMemberOf.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Contacts/Item/TransitiveMemberOf/Ref/Ref.cs b/src/generated/Contacts/Item/TransitiveMemberOf/Ref/Ref.cs new file mode 100644 index 00000000000..cb2da80073c --- /dev/null +++ b/src/generated/Contacts/Item/TransitiveMemberOf/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Contacts.Item.TransitiveMemberOf.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Contacts/Item/TransitiveMemberOf/Ref/RefRequestBuilder.cs b/src/generated/Contacts/Item/TransitiveMemberOf/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..d60a73068d2 --- /dev/null +++ b/src/generated/Contacts/Item/TransitiveMemberOf/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Contacts.Item.TransitiveMemberOf.Ref { + /// Builds and executes requests for operations under \contacts\{orgContact-id}\transitiveMemberOf\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Get ref of transitiveMemberOf from contacts + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Get ref of transitiveMemberOf from contacts"; + // Create options for all the parameters + var orgContactIdOption = new Option("--org-contact-id", description: "key: id of orgContact") { + }; + orgContactIdOption.IsRequired = true; + command.AddOption(orgContactIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string orgContactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, orgContactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Create new navigation property ref to transitiveMemberOf for contacts + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Create new navigation property ref to transitiveMemberOf for contacts"; + // Create options for all the parameters + var orgContactIdOption = new Option("--org-contact-id", description: "key: id of orgContact") { + }; + orgContactIdOption.IsRequired = true; + command.AddOption(orgContactIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string orgContactId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, orgContactIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/contacts/{orgContact_id}/transitiveMemberOf/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Get ref of transitiveMemberOf from contacts + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Create new navigation property ref to transitiveMemberOf for contacts + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Contacts.Item.TransitiveMemberOf.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Get ref of transitiveMemberOf from contacts + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Contacts/Item/TransitiveMemberOf/Ref/RefResponse.cs b/src/generated/Contacts/Item/TransitiveMemberOf/Ref/RefResponse.cs new file mode 100644 index 00000000000..6b66a1d9d2b --- /dev/null +++ b/src/generated/Contacts/Item/TransitiveMemberOf/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Contacts.Item.TransitiveMemberOf.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Contacts/Item/TransitiveMemberOf/TransitiveMemberOfRequestBuilder.cs b/src/generated/Contacts/Item/TransitiveMemberOf/TransitiveMemberOfRequestBuilder.cs index cf9a782dfe3..f1232951661 100644 --- a/src/generated/Contacts/Item/TransitiveMemberOf/TransitiveMemberOfRequestBuilder.cs +++ b/src/generated/Contacts/Item/TransitiveMemberOf/TransitiveMemberOfRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Contacts.Item.TransitiveMemberOf.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get transitiveMemberOf from contacts"; // Create options for all the parameters - var orgContactIdOption = new Option("--orgcontact-id", description: "key: id of orgContact") { + var orgContactIdOption = new Option("--org-contact-id", description: "key: id of orgContact") { }; orgContactIdOption.IsRequired = true; command.AddOption(orgContactIdOption); @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string orgContactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string orgContactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, orgContactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, orgContactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Contacts.Item.TransitiveMemberOf.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Contacts.Item.TransitiveMemberOf.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get transitiveMemberOf from contacts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get transitiveMemberOf from contacts public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Contacts/ValidateProperties/ValidatePropertiesRequestBuilder.cs b/src/generated/Contacts/ValidateProperties/ValidatePropertiesRequestBuilder.cs index e7b35679e05..93107b3289b 100644 --- a/src/generated/Contacts/ValidateProperties/ValidatePropertiesRequestBuilder.cs +++ b/src/generated/Contacts/ValidateProperties/ValidatePropertiesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,14 +29,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -72,18 +71,5 @@ public RequestInformation CreatePostRequestInformation(ValidatePropertiesRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action validateProperties - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ValidatePropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Contracts/ContractsRequestBuilder.cs b/src/generated/Contracts/ContractsRequestBuilder.cs index fdbe0abf623..8c0ce532696 100644 --- a/src/generated/Contracts/ContractsRequestBuilder.cs +++ b/src/generated/Contracts/ContractsRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,16 +25,15 @@ public class ContractsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ContractRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCheckMemberGroupsCommand(), - builder.BuildCheckMemberObjectsCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildGetMemberGroupsCommand(), - builder.BuildGetMemberObjectsCommand(), - builder.BuildPatchCommand(), - builder.BuildRestoreCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCheckMemberGroupsCommand()); + commands.Add(builder.BuildCheckMemberObjectsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildGetMemberGroupsCommand()); + commands.Add(builder.BuildGetMemberObjectsCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRestoreCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } public Command BuildGetAvailableExtensionPropertiesCommand() { @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -130,15 +132,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildValidatePropertiesCommand() { @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(Contract body, Action - /// Get entities from contracts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to contracts - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Contract model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from contracts public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Contracts/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs b/src/generated/Contracts/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs deleted file mode 100644 index eca795df56d..00000000000 --- a/src/generated/Contracts/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs +++ /dev/null @@ -1,45 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Contracts.GetAvailableExtensionProperties { - public class GetAvailableExtensionProperties : DirectoryObject, IParsable { - /// Display name of the application object on which this extension property is defined. Read-only. - public string AppDisplayName { get; set; } - /// Specifies the data type of the value the extension property can hold. Following values are supported. Not nullable. Binary - 256 bytes maximumBooleanDateTime - Must be specified in ISO 8601 format. Will be stored in UTC.Integer - 32-bit value.LargeInteger - 64-bit value.String - 256 characters maximum - public string DataType { get; set; } - /// Indicates if this extension property was sycned from onpremises directory using Azure AD Connect. Read-only. - public bool? IsSyncedFromOnPremises { get; set; } - /// Name of the extension property. Not nullable. - public string Name { get; set; } - /// Following values are supported. Not nullable. UserGroupOrganizationDeviceApplication - public List TargetObjects { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"appDisplayName", (o,n) => { (o as GetAvailableExtensionProperties).AppDisplayName = n.GetStringValue(); } }, - {"dataType", (o,n) => { (o as GetAvailableExtensionProperties).DataType = n.GetStringValue(); } }, - {"isSyncedFromOnPremises", (o,n) => { (o as GetAvailableExtensionProperties).IsSyncedFromOnPremises = n.GetBoolValue(); } }, - {"name", (o,n) => { (o as GetAvailableExtensionProperties).Name = n.GetStringValue(); } }, - {"targetObjects", (o,n) => { (o as GetAvailableExtensionProperties).TargetObjects = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteStringValue("appDisplayName", AppDisplayName); - writer.WriteStringValue("dataType", DataType); - writer.WriteBoolValue("isSyncedFromOnPremises", IsSyncedFromOnPremises); - writer.WriteStringValue("name", Name); - writer.WriteCollectionOfPrimitiveValues("targetObjects", TargetObjects); - } - } -} diff --git a/src/generated/Contracts/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs b/src/generated/Contracts/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs index 6fbd3c5aae9..6123280c447 100644 --- a/src/generated/Contracts/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs +++ b/src/generated/Contracts/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(GetAvailableExtensionProp requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getAvailableExtensionProperties - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetAvailableExtensionPropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Contracts/GetByIds/GetByIds.cs b/src/generated/Contracts/GetByIds/GetByIds.cs deleted file mode 100644 index 7a7068a2659..00000000000 --- a/src/generated/Contracts/GetByIds/GetByIds.cs +++ /dev/null @@ -1,28 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Contracts.GetByIds { - public class GetByIds : Entity, IParsable { - public DateTimeOffset? DeletedDateTime { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"deletedDateTime", (o,n) => { (o as GetByIds).DeletedDateTime = n.GetDateTimeOffsetValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteDateTimeOffsetValue("deletedDateTime", DeletedDateTime); - } - } -} diff --git a/src/generated/Contracts/GetByIds/GetByIdsRequestBuilder.cs b/src/generated/Contracts/GetByIds/GetByIdsRequestBuilder.cs index db6b3e94db8..ca5c6174c5c 100644 --- a/src/generated/Contracts/GetByIds/GetByIdsRequestBuilder.cs +++ b/src/generated/Contracts/GetByIds/GetByIdsRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(GetByIdsRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getByIds - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetByIdsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Contracts/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs b/src/generated/Contracts/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs index 360185103c9..9c17d26a8fb 100644 --- a/src/generated/Contracts/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs +++ b/src/generated/Contracts/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contractId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contractId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contractIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contractIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberGroupsRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Contracts/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs b/src/generated/Contracts/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs index fe41b1d5ccc..cb6c926b191 100644 --- a/src/generated/Contracts/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs +++ b/src/generated/Contracts/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contractId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contractId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contractIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contractIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberObjectsRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Contracts/Item/ContractRequestBuilder.cs b/src/generated/Contracts/Item/ContractRequestBuilder.cs index 7a2640b04d7..6f2406a524f 100644 --- a/src/generated/Contracts/Item/ContractRequestBuilder.cs +++ b/src/generated/Contracts/Item/ContractRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,11 +47,10 @@ public Command BuildDeleteCommand() { }; contractIdOption.IsRequired = true; command.AddOption(contractIdOption); - command.SetHandler(async (string contractId) => { + command.SetHandler(async (string contractId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contractIdOption); return command; @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contractId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contractId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contractIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contractIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildGetMemberGroupsCommand() { @@ -120,14 +118,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contractId, string body) => { + command.SetHandler(async (string contractId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contractIdOption, bodyOption); return command; @@ -205,42 +202,6 @@ public RequestInformation CreatePatchRequestInformation(Contract body, Action - /// Delete entity from contracts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from contracts by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in contracts - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Contract model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from contracts by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Contracts/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs b/src/generated/Contracts/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs index 83e9b9c081c..b725f121ba4 100644 --- a/src/generated/Contracts/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs +++ b/src/generated/Contracts/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contractId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contractId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contractIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contractIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberGroupsRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Contracts/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs b/src/generated/Contracts/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs index f9d3fd5c559..ed65f40aef7 100644 --- a/src/generated/Contracts/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs +++ b/src/generated/Contracts/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contractId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contractId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contractIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contractIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberObjectsRequestBo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Contracts/Item/Restore/RestoreRequestBuilder.cs b/src/generated/Contracts/Item/Restore/RestoreRequestBuilder.cs index 0b041b85488..59bde18083d 100644 --- a/src/generated/Contracts/Item/Restore/RestoreRequestBuilder.cs +++ b/src/generated/Contracts/Item/Restore/RestoreRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildPostCommand() { }; contractIdOption.IsRequired = true; command.AddOption(contractIdOption); - command.SetHandler(async (string contractId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contractId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contractIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contractIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action restore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes directoryObject public class RestoreResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Contracts/ValidateProperties/ValidatePropertiesRequestBuilder.cs b/src/generated/Contracts/ValidateProperties/ValidatePropertiesRequestBuilder.cs index f5bd8ece2ee..7656ce22c3a 100644 --- a/src/generated/Contracts/ValidateProperties/ValidatePropertiesRequestBuilder.cs +++ b/src/generated/Contracts/ValidateProperties/ValidatePropertiesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,14 +29,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -72,18 +71,5 @@ public RequestInformation CreatePostRequestInformation(ValidatePropertiesRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action validateProperties - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ValidatePropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DataPolicyOperations/DataPolicyOperationsRequestBuilder.cs b/src/generated/DataPolicyOperations/DataPolicyOperationsRequestBuilder.cs index 7ae6cc7c0f9..515c40cbb77 100644 --- a/src/generated/DataPolicyOperations/DataPolicyOperationsRequestBuilder.cs +++ b/src/generated/DataPolicyOperations/DataPolicyOperationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DataPolicyOperationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DataPolicyOperationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(DataPolicyOperation body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get entities from dataPolicyOperations - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to dataPolicyOperations - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DataPolicyOperation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from dataPolicyOperations public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DataPolicyOperations/Item/DataPolicyOperationRequestBuilder.cs b/src/generated/DataPolicyOperations/Item/DataPolicyOperationRequestBuilder.cs index 5a00b666a6e..a41b522488b 100644 --- a/src/generated/DataPolicyOperations/Item/DataPolicyOperationRequestBuilder.cs +++ b/src/generated/DataPolicyOperations/Item/DataPolicyOperationRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete entity from dataPolicyOperations"; // Create options for all the parameters - var dataPolicyOperationIdOption = new Option("--datapolicyoperation-id", description: "key: id of dataPolicyOperation") { + var dataPolicyOperationIdOption = new Option("--data-policy-operation-id", description: "key: id of dataPolicyOperation") { }; dataPolicyOperationIdOption.IsRequired = true; command.AddOption(dataPolicyOperationIdOption); - command.SetHandler(async (string dataPolicyOperationId) => { + command.SetHandler(async (string dataPolicyOperationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, dataPolicyOperationIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get entity from dataPolicyOperations by key"; // Create options for all the parameters - var dataPolicyOperationIdOption = new Option("--datapolicyoperation-id", description: "key: id of dataPolicyOperation") { + var dataPolicyOperationIdOption = new Option("--data-policy-operation-id", description: "key: id of dataPolicyOperation") { }; dataPolicyOperationIdOption.IsRequired = true; command.AddOption(dataPolicyOperationIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string dataPolicyOperationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string dataPolicyOperationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, dataPolicyOperationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, dataPolicyOperationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update entity in dataPolicyOperations"; // Create options for all the parameters - var dataPolicyOperationIdOption = new Option("--datapolicyoperation-id", description: "key: id of dataPolicyOperation") { + var dataPolicyOperationIdOption = new Option("--data-policy-operation-id", description: "key: id of dataPolicyOperation") { }; dataPolicyOperationIdOption.IsRequired = true; command.AddOption(dataPolicyOperationIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string dataPolicyOperationId, string body) => { + command.SetHandler(async (string dataPolicyOperationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, dataPolicyOperationIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(DataPolicyOperation body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from dataPolicyOperations - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from dataPolicyOperations by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in dataPolicyOperations - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DataPolicyOperation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from dataPolicyOperations by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/AndroidManagedAppProtections/AndroidManagedAppProtectionsRequestBuilder.cs b/src/generated/DeviceAppManagement/AndroidManagedAppProtections/AndroidManagedAppProtectionsRequestBuilder.cs index b1b448444c3..79412999023 100644 --- a/src/generated/DeviceAppManagement/AndroidManagedAppProtections/AndroidManagedAppProtectionsRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/AndroidManagedAppProtections/AndroidManagedAppProtectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class AndroidManagedAppProtectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AndroidManagedAppProtectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAppsCommand(), - builder.BuildDeleteCommand(), - builder.BuildDeploymentSummaryCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAppsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDeploymentSummaryCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,21 +41,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -101,7 +99,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -112,15 +114,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -175,31 +172,6 @@ public RequestInformation CreatePostRequestInformation(AndroidManagedAppProtecti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Android managed app policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Android managed app policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AndroidManagedAppProtection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Android managed app policies. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/AndroidManagedAppProtections/Item/AndroidManagedAppProtectionRequestBuilder.cs b/src/generated/DeviceAppManagement/AndroidManagedAppProtections/Item/AndroidManagedAppProtectionRequestBuilder.cs index 60775ac80d2..cd91853a805 100644 --- a/src/generated/DeviceAppManagement/AndroidManagedAppProtections/Item/AndroidManagedAppProtectionRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/AndroidManagedAppProtections/Item/AndroidManagedAppProtectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -24,6 +24,9 @@ public class AndroidManagedAppProtectionRequestBuilder { public Command BuildAppsCommand() { var command = new Command("apps"); var builder = new ApiSdk.DeviceAppManagement.AndroidManagedAppProtections.Item.Apps.AppsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -35,15 +38,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Android managed app policies."; // Create options for all the parameters - var androidManagedAppProtectionIdOption = new Option("--androidmanagedappprotection-id", description: "key: id of androidManagedAppProtection") { + var androidManagedAppProtectionIdOption = new Option("--android-managed-app-protection-id", description: "key: id of androidManagedAppProtection") { }; androidManagedAppProtectionIdOption.IsRequired = true; command.AddOption(androidManagedAppProtectionIdOption); - command.SetHandler(async (string androidManagedAppProtectionId) => { + command.SetHandler(async (string androidManagedAppProtectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, androidManagedAppProtectionIdOption); return command; @@ -63,7 +65,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Android managed app policies."; // Create options for all the parameters - var androidManagedAppProtectionIdOption = new Option("--androidmanagedappprotection-id", description: "key: id of androidManagedAppProtection") { + var androidManagedAppProtectionIdOption = new Option("--android-managed-app-protection-id", description: "key: id of androidManagedAppProtection") { }; androidManagedAppProtectionIdOption.IsRequired = true; command.AddOption(androidManagedAppProtectionIdOption); @@ -77,20 +79,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string androidManagedAppProtectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string androidManagedAppProtectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, androidManagedAppProtectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, androidManagedAppProtectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -100,7 +101,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Android managed app policies."; // Create options for all the parameters - var androidManagedAppProtectionIdOption = new Option("--androidmanagedappprotection-id", description: "key: id of androidManagedAppProtection") { + var androidManagedAppProtectionIdOption = new Option("--android-managed-app-protection-id", description: "key: id of androidManagedAppProtection") { }; androidManagedAppProtectionIdOption.IsRequired = true; command.AddOption(androidManagedAppProtectionIdOption); @@ -108,14 +109,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string androidManagedAppProtectionId, string body) => { + command.SetHandler(async (string androidManagedAppProtectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, androidManagedAppProtectionIdOption, bodyOption); return command; @@ -187,42 +187,6 @@ public RequestInformation CreatePatchRequestInformation(AndroidManagedAppProtect requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Android managed app policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Android managed app policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Android managed app policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AndroidManagedAppProtection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Android managed app policies. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/AndroidManagedAppProtections/Item/Apps/AppsRequestBuilder.cs b/src/generated/DeviceAppManagement/AndroidManagedAppProtections/Item/Apps/AppsRequestBuilder.cs index 3b82d41b2a0..52eba2c7a24 100644 --- a/src/generated/DeviceAppManagement/AndroidManagedAppProtections/Item/Apps/AppsRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/AndroidManagedAppProtections/Item/Apps/AppsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AppsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ManagedMobileAppRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "List of apps to which the policy is deployed."; // Create options for all the parameters - var androidManagedAppProtectionIdOption = new Option("--androidmanagedappprotection-id", description: "key: id of androidManagedAppProtection") { + var androidManagedAppProtectionIdOption = new Option("--android-managed-app-protection-id", description: "key: id of androidManagedAppProtection") { }; androidManagedAppProtectionIdOption.IsRequired = true; command.AddOption(androidManagedAppProtectionIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string androidManagedAppProtectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string androidManagedAppProtectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, androidManagedAppProtectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, androidManagedAppProtectionIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "List of apps to which the policy is deployed."; // Create options for all the parameters - var androidManagedAppProtectionIdOption = new Option("--androidmanagedappprotection-id", description: "key: id of androidManagedAppProtection") { + var androidManagedAppProtectionIdOption = new Option("--android-managed-app-protection-id", description: "key: id of androidManagedAppProtection") { }; androidManagedAppProtectionIdOption.IsRequired = true; command.AddOption(androidManagedAppProtectionIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string androidManagedAppProtectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string androidManagedAppProtectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, androidManagedAppProtectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, androidManagedAppProtectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ManagedMobileApp body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of apps to which the policy is deployed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of apps to which the policy is deployed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ManagedMobileApp model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// List of apps to which the policy is deployed. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/AndroidManagedAppProtections/Item/Apps/Item/ManagedMobileAppRequestBuilder.cs b/src/generated/DeviceAppManagement/AndroidManagedAppProtections/Item/Apps/Item/ManagedMobileAppRequestBuilder.cs index 2bc252ade50..3ee24a66356 100644 --- a/src/generated/DeviceAppManagement/AndroidManagedAppProtections/Item/Apps/Item/ManagedMobileAppRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/AndroidManagedAppProtections/Item/Apps/Item/ManagedMobileAppRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "List of apps to which the policy is deployed."; // Create options for all the parameters - var androidManagedAppProtectionIdOption = new Option("--androidmanagedappprotection-id", description: "key: id of androidManagedAppProtection") { + var androidManagedAppProtectionIdOption = new Option("--android-managed-app-protection-id", description: "key: id of androidManagedAppProtection") { }; androidManagedAppProtectionIdOption.IsRequired = true; command.AddOption(androidManagedAppProtectionIdOption); - var managedMobileAppIdOption = new Option("--managedmobileapp-id", description: "key: id of managedMobileApp") { + var managedMobileAppIdOption = new Option("--managed-mobile-app-id", description: "key: id of managedMobileApp") { }; managedMobileAppIdOption.IsRequired = true; command.AddOption(managedMobileAppIdOption); - command.SetHandler(async (string androidManagedAppProtectionId, string managedMobileAppId) => { + command.SetHandler(async (string androidManagedAppProtectionId, string managedMobileAppId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, androidManagedAppProtectionIdOption, managedMobileAppIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "List of apps to which the policy is deployed."; // Create options for all the parameters - var androidManagedAppProtectionIdOption = new Option("--androidmanagedappprotection-id", description: "key: id of androidManagedAppProtection") { + var androidManagedAppProtectionIdOption = new Option("--android-managed-app-protection-id", description: "key: id of androidManagedAppProtection") { }; androidManagedAppProtectionIdOption.IsRequired = true; command.AddOption(androidManagedAppProtectionIdOption); - var managedMobileAppIdOption = new Option("--managedmobileapp-id", description: "key: id of managedMobileApp") { + var managedMobileAppIdOption = new Option("--managed-mobile-app-id", description: "key: id of managedMobileApp") { }; managedMobileAppIdOption.IsRequired = true; command.AddOption(managedMobileAppIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string androidManagedAppProtectionId, string managedMobileAppId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string androidManagedAppProtectionId, string managedMobileAppId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, androidManagedAppProtectionIdOption, managedMobileAppIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, androidManagedAppProtectionIdOption, managedMobileAppIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "List of apps to which the policy is deployed."; // Create options for all the parameters - var androidManagedAppProtectionIdOption = new Option("--androidmanagedappprotection-id", description: "key: id of androidManagedAppProtection") { + var androidManagedAppProtectionIdOption = new Option("--android-managed-app-protection-id", description: "key: id of androidManagedAppProtection") { }; androidManagedAppProtectionIdOption.IsRequired = true; command.AddOption(androidManagedAppProtectionIdOption); - var managedMobileAppIdOption = new Option("--managedmobileapp-id", description: "key: id of managedMobileApp") { + var managedMobileAppIdOption = new Option("--managed-mobile-app-id", description: "key: id of managedMobileApp") { }; managedMobileAppIdOption.IsRequired = true; command.AddOption(managedMobileAppIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string androidManagedAppProtectionId, string managedMobileAppId, string body) => { + command.SetHandler(async (string androidManagedAppProtectionId, string managedMobileAppId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, androidManagedAppProtectionIdOption, managedMobileAppIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ManagedMobileApp body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of apps to which the policy is deployed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of apps to which the policy is deployed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of apps to which the policy is deployed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ManagedMobileApp model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// List of apps to which the policy is deployed. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/AndroidManagedAppProtections/Item/DeploymentSummary/DeploymentSummaryRequestBuilder.cs b/src/generated/DeviceAppManagement/AndroidManagedAppProtections/Item/DeploymentSummary/DeploymentSummaryRequestBuilder.cs index e1f5d2c203a..cf3db258815 100644 --- a/src/generated/DeviceAppManagement/AndroidManagedAppProtections/Item/DeploymentSummary/DeploymentSummaryRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/AndroidManagedAppProtections/Item/DeploymentSummary/DeploymentSummaryRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Navigation property to deployment summary of the configuration."; // Create options for all the parameters - var androidManagedAppProtectionIdOption = new Option("--androidmanagedappprotection-id", description: "key: id of androidManagedAppProtection") { + var androidManagedAppProtectionIdOption = new Option("--android-managed-app-protection-id", description: "key: id of androidManagedAppProtection") { }; androidManagedAppProtectionIdOption.IsRequired = true; command.AddOption(androidManagedAppProtectionIdOption); - command.SetHandler(async (string androidManagedAppProtectionId) => { + command.SetHandler(async (string androidManagedAppProtectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, androidManagedAppProtectionIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Navigation property to deployment summary of the configuration."; // Create options for all the parameters - var androidManagedAppProtectionIdOption = new Option("--androidmanagedappprotection-id", description: "key: id of androidManagedAppProtection") { + var androidManagedAppProtectionIdOption = new Option("--android-managed-app-protection-id", description: "key: id of androidManagedAppProtection") { }; androidManagedAppProtectionIdOption.IsRequired = true; command.AddOption(androidManagedAppProtectionIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string androidManagedAppProtectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string androidManagedAppProtectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, androidManagedAppProtectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, androidManagedAppProtectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Navigation property to deployment summary of the configuration."; // Create options for all the parameters - var androidManagedAppProtectionIdOption = new Option("--androidmanagedappprotection-id", description: "key: id of androidManagedAppProtection") { + var androidManagedAppProtectionIdOption = new Option("--android-managed-app-protection-id", description: "key: id of androidManagedAppProtection") { }; androidManagedAppProtectionIdOption.IsRequired = true; command.AddOption(androidManagedAppProtectionIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string androidManagedAppProtectionId, string body) => { + command.SetHandler(async (string androidManagedAppProtectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, androidManagedAppProtectionIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ManagedAppPolicyDeployme requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Navigation property to deployment summary of the configuration. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Navigation property to deployment summary of the configuration. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Navigation property to deployment summary of the configuration. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ManagedAppPolicyDeploymentSummary model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Navigation property to deployment summary of the configuration. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/DefaultManagedAppProtections/DefaultManagedAppProtectionsRequestBuilder.cs b/src/generated/DeviceAppManagement/DefaultManagedAppProtections/DefaultManagedAppProtectionsRequestBuilder.cs index 627f34be5f7..b1182ecd853 100644 --- a/src/generated/DeviceAppManagement/DefaultManagedAppProtections/DefaultManagedAppProtectionsRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/DefaultManagedAppProtections/DefaultManagedAppProtectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class DefaultManagedAppProtectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DefaultManagedAppProtectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAppsCommand(), - builder.BuildDeleteCommand(), - builder.BuildDeploymentSummaryCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAppsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDeploymentSummaryCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,21 +41,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -101,7 +99,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -112,15 +114,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -175,31 +172,6 @@ public RequestInformation CreatePostRequestInformation(DefaultManagedAppProtecti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Default managed app policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Default managed app policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DefaultManagedAppProtection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Default managed app policies. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/DefaultManagedAppProtections/Item/Apps/AppsRequestBuilder.cs b/src/generated/DeviceAppManagement/DefaultManagedAppProtections/Item/Apps/AppsRequestBuilder.cs index 1d927a70d22..e63288fd553 100644 --- a/src/generated/DeviceAppManagement/DefaultManagedAppProtections/Item/Apps/AppsRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/DefaultManagedAppProtections/Item/Apps/AppsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AppsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ManagedMobileAppRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "List of apps to which the policy is deployed."; // Create options for all the parameters - var defaultManagedAppProtectionIdOption = new Option("--defaultmanagedappprotection-id", description: "key: id of defaultManagedAppProtection") { + var defaultManagedAppProtectionIdOption = new Option("--default-managed-app-protection-id", description: "key: id of defaultManagedAppProtection") { }; defaultManagedAppProtectionIdOption.IsRequired = true; command.AddOption(defaultManagedAppProtectionIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string defaultManagedAppProtectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string defaultManagedAppProtectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, defaultManagedAppProtectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, defaultManagedAppProtectionIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "List of apps to which the policy is deployed."; // Create options for all the parameters - var defaultManagedAppProtectionIdOption = new Option("--defaultmanagedappprotection-id", description: "key: id of defaultManagedAppProtection") { + var defaultManagedAppProtectionIdOption = new Option("--default-managed-app-protection-id", description: "key: id of defaultManagedAppProtection") { }; defaultManagedAppProtectionIdOption.IsRequired = true; command.AddOption(defaultManagedAppProtectionIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string defaultManagedAppProtectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string defaultManagedAppProtectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, defaultManagedAppProtectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, defaultManagedAppProtectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ManagedMobileApp body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of apps to which the policy is deployed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of apps to which the policy is deployed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ManagedMobileApp model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// List of apps to which the policy is deployed. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/DefaultManagedAppProtections/Item/Apps/Item/ManagedMobileAppRequestBuilder.cs b/src/generated/DeviceAppManagement/DefaultManagedAppProtections/Item/Apps/Item/ManagedMobileAppRequestBuilder.cs index bd5dba56f6b..e297e0ca90f 100644 --- a/src/generated/DeviceAppManagement/DefaultManagedAppProtections/Item/Apps/Item/ManagedMobileAppRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/DefaultManagedAppProtections/Item/Apps/Item/ManagedMobileAppRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "List of apps to which the policy is deployed."; // Create options for all the parameters - var defaultManagedAppProtectionIdOption = new Option("--defaultmanagedappprotection-id", description: "key: id of defaultManagedAppProtection") { + var defaultManagedAppProtectionIdOption = new Option("--default-managed-app-protection-id", description: "key: id of defaultManagedAppProtection") { }; defaultManagedAppProtectionIdOption.IsRequired = true; command.AddOption(defaultManagedAppProtectionIdOption); - var managedMobileAppIdOption = new Option("--managedmobileapp-id", description: "key: id of managedMobileApp") { + var managedMobileAppIdOption = new Option("--managed-mobile-app-id", description: "key: id of managedMobileApp") { }; managedMobileAppIdOption.IsRequired = true; command.AddOption(managedMobileAppIdOption); - command.SetHandler(async (string defaultManagedAppProtectionId, string managedMobileAppId) => { + command.SetHandler(async (string defaultManagedAppProtectionId, string managedMobileAppId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, defaultManagedAppProtectionIdOption, managedMobileAppIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "List of apps to which the policy is deployed."; // Create options for all the parameters - var defaultManagedAppProtectionIdOption = new Option("--defaultmanagedappprotection-id", description: "key: id of defaultManagedAppProtection") { + var defaultManagedAppProtectionIdOption = new Option("--default-managed-app-protection-id", description: "key: id of defaultManagedAppProtection") { }; defaultManagedAppProtectionIdOption.IsRequired = true; command.AddOption(defaultManagedAppProtectionIdOption); - var managedMobileAppIdOption = new Option("--managedmobileapp-id", description: "key: id of managedMobileApp") { + var managedMobileAppIdOption = new Option("--managed-mobile-app-id", description: "key: id of managedMobileApp") { }; managedMobileAppIdOption.IsRequired = true; command.AddOption(managedMobileAppIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string defaultManagedAppProtectionId, string managedMobileAppId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string defaultManagedAppProtectionId, string managedMobileAppId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, defaultManagedAppProtectionIdOption, managedMobileAppIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, defaultManagedAppProtectionIdOption, managedMobileAppIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "List of apps to which the policy is deployed."; // Create options for all the parameters - var defaultManagedAppProtectionIdOption = new Option("--defaultmanagedappprotection-id", description: "key: id of defaultManagedAppProtection") { + var defaultManagedAppProtectionIdOption = new Option("--default-managed-app-protection-id", description: "key: id of defaultManagedAppProtection") { }; defaultManagedAppProtectionIdOption.IsRequired = true; command.AddOption(defaultManagedAppProtectionIdOption); - var managedMobileAppIdOption = new Option("--managedmobileapp-id", description: "key: id of managedMobileApp") { + var managedMobileAppIdOption = new Option("--managed-mobile-app-id", description: "key: id of managedMobileApp") { }; managedMobileAppIdOption.IsRequired = true; command.AddOption(managedMobileAppIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string defaultManagedAppProtectionId, string managedMobileAppId, string body) => { + command.SetHandler(async (string defaultManagedAppProtectionId, string managedMobileAppId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, defaultManagedAppProtectionIdOption, managedMobileAppIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ManagedMobileApp body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of apps to which the policy is deployed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of apps to which the policy is deployed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of apps to which the policy is deployed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ManagedMobileApp model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// List of apps to which the policy is deployed. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/DefaultManagedAppProtections/Item/DefaultManagedAppProtectionRequestBuilder.cs b/src/generated/DeviceAppManagement/DefaultManagedAppProtections/Item/DefaultManagedAppProtectionRequestBuilder.cs index 4b198ffc51e..ae4c4cd2e80 100644 --- a/src/generated/DeviceAppManagement/DefaultManagedAppProtections/Item/DefaultManagedAppProtectionRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/DefaultManagedAppProtections/Item/DefaultManagedAppProtectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -24,6 +24,9 @@ public class DefaultManagedAppProtectionRequestBuilder { public Command BuildAppsCommand() { var command = new Command("apps"); var builder = new ApiSdk.DeviceAppManagement.DefaultManagedAppProtections.Item.Apps.AppsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -35,15 +38,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Default managed app policies."; // Create options for all the parameters - var defaultManagedAppProtectionIdOption = new Option("--defaultmanagedappprotection-id", description: "key: id of defaultManagedAppProtection") { + var defaultManagedAppProtectionIdOption = new Option("--default-managed-app-protection-id", description: "key: id of defaultManagedAppProtection") { }; defaultManagedAppProtectionIdOption.IsRequired = true; command.AddOption(defaultManagedAppProtectionIdOption); - command.SetHandler(async (string defaultManagedAppProtectionId) => { + command.SetHandler(async (string defaultManagedAppProtectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, defaultManagedAppProtectionIdOption); return command; @@ -63,7 +65,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Default managed app policies."; // Create options for all the parameters - var defaultManagedAppProtectionIdOption = new Option("--defaultmanagedappprotection-id", description: "key: id of defaultManagedAppProtection") { + var defaultManagedAppProtectionIdOption = new Option("--default-managed-app-protection-id", description: "key: id of defaultManagedAppProtection") { }; defaultManagedAppProtectionIdOption.IsRequired = true; command.AddOption(defaultManagedAppProtectionIdOption); @@ -77,20 +79,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string defaultManagedAppProtectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string defaultManagedAppProtectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, defaultManagedAppProtectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, defaultManagedAppProtectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -100,7 +101,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Default managed app policies."; // Create options for all the parameters - var defaultManagedAppProtectionIdOption = new Option("--defaultmanagedappprotection-id", description: "key: id of defaultManagedAppProtection") { + var defaultManagedAppProtectionIdOption = new Option("--default-managed-app-protection-id", description: "key: id of defaultManagedAppProtection") { }; defaultManagedAppProtectionIdOption.IsRequired = true; command.AddOption(defaultManagedAppProtectionIdOption); @@ -108,14 +109,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string defaultManagedAppProtectionId, string body) => { + command.SetHandler(async (string defaultManagedAppProtectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, defaultManagedAppProtectionIdOption, bodyOption); return command; @@ -187,42 +187,6 @@ public RequestInformation CreatePatchRequestInformation(DefaultManagedAppProtect requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Default managed app policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Default managed app policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Default managed app policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DefaultManagedAppProtection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Default managed app policies. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/DefaultManagedAppProtections/Item/DeploymentSummary/DeploymentSummaryRequestBuilder.cs b/src/generated/DeviceAppManagement/DefaultManagedAppProtections/Item/DeploymentSummary/DeploymentSummaryRequestBuilder.cs index 748a0f342ba..e347430c6bd 100644 --- a/src/generated/DeviceAppManagement/DefaultManagedAppProtections/Item/DeploymentSummary/DeploymentSummaryRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/DefaultManagedAppProtections/Item/DeploymentSummary/DeploymentSummaryRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Navigation property to deployment summary of the configuration."; // Create options for all the parameters - var defaultManagedAppProtectionIdOption = new Option("--defaultmanagedappprotection-id", description: "key: id of defaultManagedAppProtection") { + var defaultManagedAppProtectionIdOption = new Option("--default-managed-app-protection-id", description: "key: id of defaultManagedAppProtection") { }; defaultManagedAppProtectionIdOption.IsRequired = true; command.AddOption(defaultManagedAppProtectionIdOption); - command.SetHandler(async (string defaultManagedAppProtectionId) => { + command.SetHandler(async (string defaultManagedAppProtectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, defaultManagedAppProtectionIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Navigation property to deployment summary of the configuration."; // Create options for all the parameters - var defaultManagedAppProtectionIdOption = new Option("--defaultmanagedappprotection-id", description: "key: id of defaultManagedAppProtection") { + var defaultManagedAppProtectionIdOption = new Option("--default-managed-app-protection-id", description: "key: id of defaultManagedAppProtection") { }; defaultManagedAppProtectionIdOption.IsRequired = true; command.AddOption(defaultManagedAppProtectionIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string defaultManagedAppProtectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string defaultManagedAppProtectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, defaultManagedAppProtectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, defaultManagedAppProtectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Navigation property to deployment summary of the configuration."; // Create options for all the parameters - var defaultManagedAppProtectionIdOption = new Option("--defaultmanagedappprotection-id", description: "key: id of defaultManagedAppProtection") { + var defaultManagedAppProtectionIdOption = new Option("--default-managed-app-protection-id", description: "key: id of defaultManagedAppProtection") { }; defaultManagedAppProtectionIdOption.IsRequired = true; command.AddOption(defaultManagedAppProtectionIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string defaultManagedAppProtectionId, string body) => { + command.SetHandler(async (string defaultManagedAppProtectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, defaultManagedAppProtectionIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ManagedAppPolicyDeployme requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Navigation property to deployment summary of the configuration. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Navigation property to deployment summary of the configuration. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Navigation property to deployment summary of the configuration. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ManagedAppPolicyDeploymentSummary model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Navigation property to deployment summary of the configuration. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/DeviceAppManagementRequestBuilder.cs b/src/generated/DeviceAppManagement/DeviceAppManagementRequestBuilder.cs index 3fdf9089a1c..af51fae0b45 100644 --- a/src/generated/DeviceAppManagement/DeviceAppManagementRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/DeviceAppManagementRequestBuilder.cs @@ -16,10 +16,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,6 +37,9 @@ public class DeviceAppManagementRequestBuilder { public Command BuildAndroidManagedAppProtectionsCommand() { var command = new Command("android-managed-app-protections"); var builder = new ApiSdk.DeviceAppManagement.AndroidManagedAppProtections.AndroidManagedAppProtectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -44,6 +47,9 @@ public Command BuildAndroidManagedAppProtectionsCommand() { public Command BuildDefaultManagedAppProtectionsCommand() { var command = new Command("default-managed-app-protections"); var builder = new ApiSdk.DeviceAppManagement.DefaultManagedAppProtections.DefaultManagedAppProtectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -65,25 +71,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } public Command BuildIosManagedAppProtectionsCommand() { var command = new Command("ios-managed-app-protections"); var builder = new ApiSdk.DeviceAppManagement.IosManagedAppProtections.IosManagedAppProtectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -91,6 +99,9 @@ public Command BuildIosManagedAppProtectionsCommand() { public Command BuildManagedAppPoliciesCommand() { var command = new Command("managed-app-policies"); var builder = new ApiSdk.DeviceAppManagement.ManagedAppPolicies.ManagedAppPoliciesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -98,6 +109,9 @@ public Command BuildManagedAppPoliciesCommand() { public Command BuildManagedAppRegistrationsCommand() { var command = new Command("managed-app-registrations"); var builder = new ApiSdk.DeviceAppManagement.ManagedAppRegistrations.ManagedAppRegistrationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -105,6 +119,9 @@ public Command BuildManagedAppRegistrationsCommand() { public Command BuildManagedAppStatusesCommand() { var command = new Command("managed-app-statuses"); var builder = new ApiSdk.DeviceAppManagement.ManagedAppStatuses.ManagedAppStatusesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -112,6 +129,9 @@ public Command BuildManagedAppStatusesCommand() { public Command BuildManagedEBooksCommand() { var command = new Command("managed-e-books"); var builder = new ApiSdk.DeviceAppManagement.ManagedEBooks.ManagedEBooksRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -119,6 +139,9 @@ public Command BuildManagedEBooksCommand() { public Command BuildMdmWindowsInformationProtectionPoliciesCommand() { var command = new Command("mdm-windows-information-protection-policies"); var builder = new ApiSdk.DeviceAppManagement.MdmWindowsInformationProtectionPolicies.MdmWindowsInformationProtectionPoliciesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -126,6 +149,9 @@ public Command BuildMdmWindowsInformationProtectionPoliciesCommand() { public Command BuildMobileAppCategoriesCommand() { var command = new Command("mobile-app-categories"); var builder = new ApiSdk.DeviceAppManagement.MobileAppCategories.MobileAppCategoriesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -133,6 +159,9 @@ public Command BuildMobileAppCategoriesCommand() { public Command BuildMobileAppConfigurationsCommand() { var command = new Command("mobile-app-configurations"); var builder = new ApiSdk.DeviceAppManagement.MobileAppConfigurations.MobileAppConfigurationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -140,6 +169,9 @@ public Command BuildMobileAppConfigurationsCommand() { public Command BuildMobileAppsCommand() { var command = new Command("mobile-apps"); var builder = new ApiSdk.DeviceAppManagement.MobileApps.MobileAppsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -155,14 +187,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -176,6 +207,9 @@ public Command BuildSyncMicrosoftStoreForBusinessAppsCommand() { public Command BuildTargetedManagedAppConfigurationsCommand() { var command = new Command("targeted-managed-app-configurations"); var builder = new ApiSdk.DeviceAppManagement.TargetedManagedAppConfigurations.TargetedManagedAppConfigurationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -183,6 +217,9 @@ public Command BuildTargetedManagedAppConfigurationsCommand() { public Command BuildVppTokensCommand() { var command = new Command("vpp-tokens"); var builder = new ApiSdk.DeviceAppManagement.VppTokens.VppTokensRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -190,6 +227,9 @@ public Command BuildVppTokensCommand() { public Command BuildWindowsInformationProtectionPoliciesCommand() { var command = new Command("windows-information-protection-policies"); var builder = new ApiSdk.DeviceAppManagement.WindowsInformationProtectionPolicies.WindowsInformationProtectionPoliciesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -246,31 +286,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get deviceAppManagement - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update deviceAppManagement - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DeviceAppManagement model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get deviceAppManagement public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/IosManagedAppProtections/IosManagedAppProtectionsRequestBuilder.cs b/src/generated/DeviceAppManagement/IosManagedAppProtections/IosManagedAppProtectionsRequestBuilder.cs index 631db1cb9c2..4e1133567bf 100644 --- a/src/generated/DeviceAppManagement/IosManagedAppProtections/IosManagedAppProtectionsRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/IosManagedAppProtections/IosManagedAppProtectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class IosManagedAppProtectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new IosManagedAppProtectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAppsCommand(), - builder.BuildDeleteCommand(), - builder.BuildDeploymentSummaryCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAppsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDeploymentSummaryCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,21 +41,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -101,7 +99,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -112,15 +114,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -175,31 +172,6 @@ public RequestInformation CreatePostRequestInformation(IosManagedAppProtection b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// iOS managed app policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// iOS managed app policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(IosManagedAppProtection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// iOS managed app policies. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/IosManagedAppProtections/Item/Apps/AppsRequestBuilder.cs b/src/generated/DeviceAppManagement/IosManagedAppProtections/Item/Apps/AppsRequestBuilder.cs index fc21788052f..6f78dbd4e9f 100644 --- a/src/generated/DeviceAppManagement/IosManagedAppProtections/Item/Apps/AppsRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/IosManagedAppProtections/Item/Apps/AppsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AppsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ManagedMobileAppRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "List of apps to which the policy is deployed."; // Create options for all the parameters - var iosManagedAppProtectionIdOption = new Option("--iosmanagedappprotection-id", description: "key: id of iosManagedAppProtection") { + var iosManagedAppProtectionIdOption = new Option("--ios-managed-app-protection-id", description: "key: id of iosManagedAppProtection") { }; iosManagedAppProtectionIdOption.IsRequired = true; command.AddOption(iosManagedAppProtectionIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string iosManagedAppProtectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string iosManagedAppProtectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, iosManagedAppProtectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, iosManagedAppProtectionIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "List of apps to which the policy is deployed."; // Create options for all the parameters - var iosManagedAppProtectionIdOption = new Option("--iosmanagedappprotection-id", description: "key: id of iosManagedAppProtection") { + var iosManagedAppProtectionIdOption = new Option("--ios-managed-app-protection-id", description: "key: id of iosManagedAppProtection") { }; iosManagedAppProtectionIdOption.IsRequired = true; command.AddOption(iosManagedAppProtectionIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string iosManagedAppProtectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string iosManagedAppProtectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, iosManagedAppProtectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, iosManagedAppProtectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ManagedMobileApp body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of apps to which the policy is deployed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of apps to which the policy is deployed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ManagedMobileApp model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// List of apps to which the policy is deployed. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/IosManagedAppProtections/Item/Apps/Item/ManagedMobileAppRequestBuilder.cs b/src/generated/DeviceAppManagement/IosManagedAppProtections/Item/Apps/Item/ManagedMobileAppRequestBuilder.cs index 683ee471c1b..558e11278ce 100644 --- a/src/generated/DeviceAppManagement/IosManagedAppProtections/Item/Apps/Item/ManagedMobileAppRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/IosManagedAppProtections/Item/Apps/Item/ManagedMobileAppRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "List of apps to which the policy is deployed."; // Create options for all the parameters - var iosManagedAppProtectionIdOption = new Option("--iosmanagedappprotection-id", description: "key: id of iosManagedAppProtection") { + var iosManagedAppProtectionIdOption = new Option("--ios-managed-app-protection-id", description: "key: id of iosManagedAppProtection") { }; iosManagedAppProtectionIdOption.IsRequired = true; command.AddOption(iosManagedAppProtectionIdOption); - var managedMobileAppIdOption = new Option("--managedmobileapp-id", description: "key: id of managedMobileApp") { + var managedMobileAppIdOption = new Option("--managed-mobile-app-id", description: "key: id of managedMobileApp") { }; managedMobileAppIdOption.IsRequired = true; command.AddOption(managedMobileAppIdOption); - command.SetHandler(async (string iosManagedAppProtectionId, string managedMobileAppId) => { + command.SetHandler(async (string iosManagedAppProtectionId, string managedMobileAppId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, iosManagedAppProtectionIdOption, managedMobileAppIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "List of apps to which the policy is deployed."; // Create options for all the parameters - var iosManagedAppProtectionIdOption = new Option("--iosmanagedappprotection-id", description: "key: id of iosManagedAppProtection") { + var iosManagedAppProtectionIdOption = new Option("--ios-managed-app-protection-id", description: "key: id of iosManagedAppProtection") { }; iosManagedAppProtectionIdOption.IsRequired = true; command.AddOption(iosManagedAppProtectionIdOption); - var managedMobileAppIdOption = new Option("--managedmobileapp-id", description: "key: id of managedMobileApp") { + var managedMobileAppIdOption = new Option("--managed-mobile-app-id", description: "key: id of managedMobileApp") { }; managedMobileAppIdOption.IsRequired = true; command.AddOption(managedMobileAppIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string iosManagedAppProtectionId, string managedMobileAppId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string iosManagedAppProtectionId, string managedMobileAppId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, iosManagedAppProtectionIdOption, managedMobileAppIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, iosManagedAppProtectionIdOption, managedMobileAppIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "List of apps to which the policy is deployed."; // Create options for all the parameters - var iosManagedAppProtectionIdOption = new Option("--iosmanagedappprotection-id", description: "key: id of iosManagedAppProtection") { + var iosManagedAppProtectionIdOption = new Option("--ios-managed-app-protection-id", description: "key: id of iosManagedAppProtection") { }; iosManagedAppProtectionIdOption.IsRequired = true; command.AddOption(iosManagedAppProtectionIdOption); - var managedMobileAppIdOption = new Option("--managedmobileapp-id", description: "key: id of managedMobileApp") { + var managedMobileAppIdOption = new Option("--managed-mobile-app-id", description: "key: id of managedMobileApp") { }; managedMobileAppIdOption.IsRequired = true; command.AddOption(managedMobileAppIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string iosManagedAppProtectionId, string managedMobileAppId, string body) => { + command.SetHandler(async (string iosManagedAppProtectionId, string managedMobileAppId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, iosManagedAppProtectionIdOption, managedMobileAppIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ManagedMobileApp body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of apps to which the policy is deployed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of apps to which the policy is deployed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of apps to which the policy is deployed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ManagedMobileApp model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// List of apps to which the policy is deployed. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/IosManagedAppProtections/Item/DeploymentSummary/DeploymentSummaryRequestBuilder.cs b/src/generated/DeviceAppManagement/IosManagedAppProtections/Item/DeploymentSummary/DeploymentSummaryRequestBuilder.cs index f7dc5e225c4..da03218947d 100644 --- a/src/generated/DeviceAppManagement/IosManagedAppProtections/Item/DeploymentSummary/DeploymentSummaryRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/IosManagedAppProtections/Item/DeploymentSummary/DeploymentSummaryRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Navigation property to deployment summary of the configuration."; // Create options for all the parameters - var iosManagedAppProtectionIdOption = new Option("--iosmanagedappprotection-id", description: "key: id of iosManagedAppProtection") { + var iosManagedAppProtectionIdOption = new Option("--ios-managed-app-protection-id", description: "key: id of iosManagedAppProtection") { }; iosManagedAppProtectionIdOption.IsRequired = true; command.AddOption(iosManagedAppProtectionIdOption); - command.SetHandler(async (string iosManagedAppProtectionId) => { + command.SetHandler(async (string iosManagedAppProtectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, iosManagedAppProtectionIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Navigation property to deployment summary of the configuration."; // Create options for all the parameters - var iosManagedAppProtectionIdOption = new Option("--iosmanagedappprotection-id", description: "key: id of iosManagedAppProtection") { + var iosManagedAppProtectionIdOption = new Option("--ios-managed-app-protection-id", description: "key: id of iosManagedAppProtection") { }; iosManagedAppProtectionIdOption.IsRequired = true; command.AddOption(iosManagedAppProtectionIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string iosManagedAppProtectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string iosManagedAppProtectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, iosManagedAppProtectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, iosManagedAppProtectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Navigation property to deployment summary of the configuration."; // Create options for all the parameters - var iosManagedAppProtectionIdOption = new Option("--iosmanagedappprotection-id", description: "key: id of iosManagedAppProtection") { + var iosManagedAppProtectionIdOption = new Option("--ios-managed-app-protection-id", description: "key: id of iosManagedAppProtection") { }; iosManagedAppProtectionIdOption.IsRequired = true; command.AddOption(iosManagedAppProtectionIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string iosManagedAppProtectionId, string body) => { + command.SetHandler(async (string iosManagedAppProtectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, iosManagedAppProtectionIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ManagedAppPolicyDeployme requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Navigation property to deployment summary of the configuration. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Navigation property to deployment summary of the configuration. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Navigation property to deployment summary of the configuration. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ManagedAppPolicyDeploymentSummary model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Navigation property to deployment summary of the configuration. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/IosManagedAppProtections/Item/IosManagedAppProtectionRequestBuilder.cs b/src/generated/DeviceAppManagement/IosManagedAppProtections/Item/IosManagedAppProtectionRequestBuilder.cs index 413c848f195..f72dcc9e652 100644 --- a/src/generated/DeviceAppManagement/IosManagedAppProtections/Item/IosManagedAppProtectionRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/IosManagedAppProtections/Item/IosManagedAppProtectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -24,6 +24,9 @@ public class IosManagedAppProtectionRequestBuilder { public Command BuildAppsCommand() { var command = new Command("apps"); var builder = new ApiSdk.DeviceAppManagement.IosManagedAppProtections.Item.Apps.AppsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -35,15 +38,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "iOS managed app policies."; // Create options for all the parameters - var iosManagedAppProtectionIdOption = new Option("--iosmanagedappprotection-id", description: "key: id of iosManagedAppProtection") { + var iosManagedAppProtectionIdOption = new Option("--ios-managed-app-protection-id", description: "key: id of iosManagedAppProtection") { }; iosManagedAppProtectionIdOption.IsRequired = true; command.AddOption(iosManagedAppProtectionIdOption); - command.SetHandler(async (string iosManagedAppProtectionId) => { + command.SetHandler(async (string iosManagedAppProtectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, iosManagedAppProtectionIdOption); return command; @@ -63,7 +65,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "iOS managed app policies."; // Create options for all the parameters - var iosManagedAppProtectionIdOption = new Option("--iosmanagedappprotection-id", description: "key: id of iosManagedAppProtection") { + var iosManagedAppProtectionIdOption = new Option("--ios-managed-app-protection-id", description: "key: id of iosManagedAppProtection") { }; iosManagedAppProtectionIdOption.IsRequired = true; command.AddOption(iosManagedAppProtectionIdOption); @@ -77,20 +79,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string iosManagedAppProtectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string iosManagedAppProtectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, iosManagedAppProtectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, iosManagedAppProtectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -100,7 +101,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "iOS managed app policies."; // Create options for all the parameters - var iosManagedAppProtectionIdOption = new Option("--iosmanagedappprotection-id", description: "key: id of iosManagedAppProtection") { + var iosManagedAppProtectionIdOption = new Option("--ios-managed-app-protection-id", description: "key: id of iosManagedAppProtection") { }; iosManagedAppProtectionIdOption.IsRequired = true; command.AddOption(iosManagedAppProtectionIdOption); @@ -108,14 +109,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string iosManagedAppProtectionId, string body) => { + command.SetHandler(async (string iosManagedAppProtectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, iosManagedAppProtectionIdOption, bodyOption); return command; @@ -187,42 +187,6 @@ public RequestInformation CreatePatchRequestInformation(IosManagedAppProtection requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// iOS managed app policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// iOS managed app policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// iOS managed app policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(IosManagedAppProtection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// iOS managed app policies. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/ManagedAppPolicyRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/ManagedAppPolicyRequestBuilder.cs index fd20fd41e89..9c20d92540c 100644 --- a/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/ManagedAppPolicyRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/ManagedAppPolicyRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Managed app policies."; // Create options for all the parameters - var managedAppPolicyIdOption = new Option("--managedapppolicy-id", description: "key: id of managedAppPolicy") { + var managedAppPolicyIdOption = new Option("--managed-app-policy-id", description: "key: id of managedAppPolicy") { }; managedAppPolicyIdOption.IsRequired = true; command.AddOption(managedAppPolicyIdOption); - command.SetHandler(async (string managedAppPolicyId) => { + command.SetHandler(async (string managedAppPolicyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedAppPolicyIdOption); return command; @@ -50,7 +49,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Managed app policies."; // Create options for all the parameters - var managedAppPolicyIdOption = new Option("--managedapppolicy-id", description: "key: id of managedAppPolicy") { + var managedAppPolicyIdOption = new Option("--managed-app-policy-id", description: "key: id of managedAppPolicy") { }; managedAppPolicyIdOption.IsRequired = true; command.AddOption(managedAppPolicyIdOption); @@ -64,20 +63,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedAppPolicyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedAppPolicyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedAppPolicyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedAppPolicyIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildManagedAppProtectionCommand() { @@ -93,7 +91,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Managed app policies."; // Create options for all the parameters - var managedAppPolicyIdOption = new Option("--managedapppolicy-id", description: "key: id of managedAppPolicy") { + var managedAppPolicyIdOption = new Option("--managed-app-policy-id", description: "key: id of managedAppPolicy") { }; managedAppPolicyIdOption.IsRequired = true; command.AddOption(managedAppPolicyIdOption); @@ -101,14 +99,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedAppPolicyId, string body) => { + command.SetHandler(async (string managedAppPolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedAppPolicyIdOption, bodyOption); return command; @@ -199,42 +196,6 @@ public RequestInformation CreatePatchRequestInformation(ManagedAppPolicy body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Managed app policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Managed app policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Managed app policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ManagedAppPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Managed app policies. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs index 74a21299430..8fd7246d795 100644 --- a/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.DeviceAppManagement.ManagedAppPolicies.Item.ManagedAppProtection.TargetApps; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs index b86ab4e7bc8..01834762d00 100644 --- a/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action targetApps"; // Create options for all the parameters - var managedAppPolicyIdOption = new Option("--managedapppolicy-id", description: "key: id of managedAppPolicy") { + var managedAppPolicyIdOption = new Option("--managed-app-policy-id", description: "key: id of managedAppPolicy") { }; managedAppPolicyIdOption.IsRequired = true; command.AddOption(managedAppPolicyIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedAppPolicyId, string body) => { + command.SetHandler(async (string managedAppPolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedAppPolicyIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(TargetAppsRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action targetApps - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetAppsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/TargetApps/TargetAppsRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/TargetApps/TargetAppsRequestBuilder.cs index a55cd299457..12cd5a7e9b9 100644 --- a/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/TargetApps/TargetAppsRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/TargetApps/TargetAppsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action targetApps"; // Create options for all the parameters - var managedAppPolicyIdOption = new Option("--managedapppolicy-id", description: "key: id of managedAppPolicy") { + var managedAppPolicyIdOption = new Option("--managed-app-policy-id", description: "key: id of managedAppPolicy") { }; managedAppPolicyIdOption.IsRequired = true; command.AddOption(managedAppPolicyIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedAppPolicyId, string body) => { + command.SetHandler(async (string managedAppPolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedAppPolicyIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(TargetAppsRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action targetApps - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetAppsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs index 23e4cc46ff1..67ba6590e4b 100644 --- a/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action assign"; // Create options for all the parameters - var managedAppPolicyIdOption = new Option("--managedapppolicy-id", description: "key: id of managedAppPolicy") { + var managedAppPolicyIdOption = new Option("--managed-app-policy-id", description: "key: id of managedAppPolicy") { }; managedAppPolicyIdOption.IsRequired = true; command.AddOption(managedAppPolicyIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedAppPolicyId, string body) => { + command.SetHandler(async (string managedAppPolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedAppPolicyIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs index 82b4a4d7ab5..49cf085291a 100644 --- a/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action targetApps"; // Create options for all the parameters - var managedAppPolicyIdOption = new Option("--managedapppolicy-id", description: "key: id of managedAppPolicy") { + var managedAppPolicyIdOption = new Option("--managed-app-policy-id", description: "key: id of managedAppPolicy") { }; managedAppPolicyIdOption.IsRequired = true; command.AddOption(managedAppPolicyIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedAppPolicyId, string body) => { + command.SetHandler(async (string managedAppPolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedAppPolicyIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(TargetAppsRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action targetApps - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetAppsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs index ec17740f3ea..378840da5d3 100644 --- a/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.DeviceAppManagement.ManagedAppPolicies.Item.TargetedManagedAppProtection.Assign; using ApiSdk.DeviceAppManagement.ManagedAppPolicies.Item.TargetedManagedAppProtection.TargetApps; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/WindowsInformationProtection/Assign/AssignRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/WindowsInformationProtection/Assign/AssignRequestBuilder.cs index 1ebf08e4654..8eb1748f48d 100644 --- a/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/WindowsInformationProtection/Assign/AssignRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/WindowsInformationProtection/Assign/AssignRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action assign"; // Create options for all the parameters - var managedAppPolicyIdOption = new Option("--managedapppolicy-id", description: "key: id of managedAppPolicy") { + var managedAppPolicyIdOption = new Option("--managed-app-policy-id", description: "key: id of managedAppPolicy") { }; managedAppPolicyIdOption.IsRequired = true; command.AddOption(managedAppPolicyIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedAppPolicyId, string body) => { + command.SetHandler(async (string managedAppPolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedAppPolicyIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs index 106b7e2b638..ba2c2b93fec 100644 --- a/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppPolicies/Item/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.DeviceAppManagement.ManagedAppPolicies.Item.WindowsInformationProtection.Assign; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/DeviceAppManagement/ManagedAppPolicies/ManagedAppPoliciesRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppPolicies/ManagedAppPoliciesRequestBuilder.cs index ce22b218c35..560828baf46 100644 --- a/src/generated/DeviceAppManagement/ManagedAppPolicies/ManagedAppPoliciesRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppPolicies/ManagedAppPoliciesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class ManagedAppPoliciesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ManagedAppPolicyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildManagedAppProtectionCommand(), - builder.BuildPatchCommand(), - builder.BuildTargetAppsCommand(), - builder.BuildTargetedManagedAppProtectionCommand(), - builder.BuildWindowsInformationProtectionCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildManagedAppProtectionCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildTargetAppsCommand()); + commands.Add(builder.BuildTargetedManagedAppProtectionCommand()); + commands.Add(builder.BuildWindowsInformationProtectionCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -103,7 +101,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -114,15 +116,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -177,31 +174,6 @@ public RequestInformation CreatePostRequestInformation(ManagedAppPolicy body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Managed app policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Managed app policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ManagedAppPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Managed app policies. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/ManagedAppRegistrations/GetUserIdsWithFlaggedAppRegistration/GetUserIdsWithFlaggedAppRegistrationRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppRegistrations/GetUserIdsWithFlaggedAppRegistration/GetUserIdsWithFlaggedAppRegistrationRequestBuilder.cs index 7066eeb908d..63ee4f7b82f 100644 --- a/src/generated/DeviceAppManagement/ManagedAppRegistrations/GetUserIdsWithFlaggedAppRegistration/GetUserIdsWithFlaggedAppRegistrationRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppRegistrations/GetUserIdsWithFlaggedAppRegistration/GetUserIdsWithFlaggedAppRegistrationRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function getUserIdsWithFlaggedAppRegistration"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getUserIdsWithFlaggedAppRegistration - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/AppliedPoliciesRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/AppliedPoliciesRequestBuilder.cs index 1e252eb9531..f7bb1be043f 100644 --- a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/AppliedPoliciesRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/AppliedPoliciesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class AppliedPoliciesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ManagedAppPolicyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildManagedAppProtectionCommand(), - builder.BuildPatchCommand(), - builder.BuildTargetAppsCommand(), - builder.BuildTargetedManagedAppProtectionCommand(), - builder.BuildWindowsInformationProtectionCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildManagedAppProtectionCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildTargetAppsCommand()); + commands.Add(builder.BuildTargetedManagedAppProtectionCommand()); + commands.Add(builder.BuildWindowsInformationProtectionCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Zero or more policys already applied on the registered app when it last synchronized with managment service."; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedAppRegistrationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedAppRegistrationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedAppRegistrationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedAppRegistrationIdOption, bodyOption, outputOption); return command; } /// @@ -72,7 +70,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Zero or more policys already applied on the registered app when it last synchronized with managment service."; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedAppRegistrationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedAppRegistrationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -122,15 +124,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedAppRegistrationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedAppRegistrationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -185,31 +182,6 @@ public RequestInformation CreatePostRequestInformation(ManagedAppPolicy body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Zero or more policys already applied on the registered app when it last synchronized with managment service. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Zero or more policys already applied on the registered app when it last synchronized with managment service. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ManagedAppPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Zero or more policys already applied on the registered app when it last synchronized with managment service. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/ManagedAppPolicyRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/ManagedAppPolicyRequestBuilder.cs index efc7f9c1abe..f1ba2941d13 100644 --- a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/ManagedAppPolicyRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/ManagedAppPolicyRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Zero or more policys already applied on the registered app when it last synchronized with managment service."; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); - var managedAppPolicyIdOption = new Option("--managedapppolicy-id", description: "key: id of managedAppPolicy") { + var managedAppPolicyIdOption = new Option("--managed-app-policy-id", description: "key: id of managedAppPolicy") { }; managedAppPolicyIdOption.IsRequired = true; command.AddOption(managedAppPolicyIdOption); - command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId) => { + command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedAppRegistrationIdOption, managedAppPolicyIdOption); return command; @@ -54,11 +53,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Zero or more policys already applied on the registered app when it last synchronized with managment service."; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); - var managedAppPolicyIdOption = new Option("--managedapppolicy-id", description: "key: id of managedAppPolicy") { + var managedAppPolicyIdOption = new Option("--managed-app-policy-id", description: "key: id of managedAppPolicy") { }; managedAppPolicyIdOption.IsRequired = true; command.AddOption(managedAppPolicyIdOption); @@ -72,20 +71,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedAppRegistrationIdOption, managedAppPolicyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedAppRegistrationIdOption, managedAppPolicyIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildManagedAppProtectionCommand() { @@ -101,11 +99,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Zero or more policys already applied on the registered app when it last synchronized with managment service."; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); - var managedAppPolicyIdOption = new Option("--managedapppolicy-id", description: "key: id of managedAppPolicy") { + var managedAppPolicyIdOption = new Option("--managed-app-policy-id", description: "key: id of managedAppPolicy") { }; managedAppPolicyIdOption.IsRequired = true; command.AddOption(managedAppPolicyIdOption); @@ -113,14 +111,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string body) => { + command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedAppRegistrationIdOption, managedAppPolicyIdOption, bodyOption); return command; @@ -211,42 +208,6 @@ public RequestInformation CreatePatchRequestInformation(ManagedAppPolicy body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Zero or more policys already applied on the registered app when it last synchronized with managment service. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Zero or more policys already applied on the registered app when it last synchronized with managment service. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Zero or more policys already applied on the registered app when it last synchronized with managment service. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ManagedAppPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Zero or more policys already applied on the registered app when it last synchronized with managment service. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs index 4e556446452..07e0f745d15 100644 --- a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.DeviceAppManagement.ManagedAppRegistrations.Item.AppliedPolicies.Item.ManagedAppProtection.TargetApps; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs index 36915772a83..16b28d3bf2b 100644 --- a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,11 +25,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action targetApps"; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); - var managedAppPolicyIdOption = new Option("--managedapppolicy-id", description: "key: id of managedAppPolicy") { + var managedAppPolicyIdOption = new Option("--managed-app-policy-id", description: "key: id of managedAppPolicy") { }; managedAppPolicyIdOption.IsRequired = true; command.AddOption(managedAppPolicyIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string body) => { + command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedAppRegistrationIdOption, managedAppPolicyIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TargetAppsRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action targetApps - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetAppsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/TargetApps/TargetAppsRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/TargetApps/TargetAppsRequestBuilder.cs index a7af94e839a..91df33a31bf 100644 --- a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/TargetApps/TargetAppsRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/TargetApps/TargetAppsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,11 +25,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action targetApps"; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); - var managedAppPolicyIdOption = new Option("--managedapppolicy-id", description: "key: id of managedAppPolicy") { + var managedAppPolicyIdOption = new Option("--managed-app-policy-id", description: "key: id of managedAppPolicy") { }; managedAppPolicyIdOption.IsRequired = true; command.AddOption(managedAppPolicyIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string body) => { + command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedAppRegistrationIdOption, managedAppPolicyIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TargetAppsRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action targetApps - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetAppsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs index c084794bdfa..7b79d3c793d 100644 --- a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,11 +25,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action assign"; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); - var managedAppPolicyIdOption = new Option("--managedapppolicy-id", description: "key: id of managedAppPolicy") { + var managedAppPolicyIdOption = new Option("--managed-app-policy-id", description: "key: id of managedAppPolicy") { }; managedAppPolicyIdOption.IsRequired = true; command.AddOption(managedAppPolicyIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string body) => { + command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedAppRegistrationIdOption, managedAppPolicyIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs index 623cc483004..211d6501489 100644 --- a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,11 +25,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action targetApps"; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); - var managedAppPolicyIdOption = new Option("--managedapppolicy-id", description: "key: id of managedAppPolicy") { + var managedAppPolicyIdOption = new Option("--managed-app-policy-id", description: "key: id of managedAppPolicy") { }; managedAppPolicyIdOption.IsRequired = true; command.AddOption(managedAppPolicyIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string body) => { + command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedAppRegistrationIdOption, managedAppPolicyIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TargetAppsRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action targetApps - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetAppsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs index 03d1abbd5cb..bd3ea611c4d 100644 --- a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.DeviceAppManagement.ManagedAppRegistrations.Item.AppliedPolicies.Item.TargetedManagedAppProtection.Assign; using ApiSdk.DeviceAppManagement.ManagedAppRegistrations.Item.AppliedPolicies.Item.TargetedManagedAppProtection.TargetApps; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/WindowsInformationProtection/Assign/AssignRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/WindowsInformationProtection/Assign/AssignRequestBuilder.cs index 532e2b87661..5c703d36085 100644 --- a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/WindowsInformationProtection/Assign/AssignRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/WindowsInformationProtection/Assign/AssignRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,11 +25,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action assign"; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); - var managedAppPolicyIdOption = new Option("--managedapppolicy-id", description: "key: id of managedAppPolicy") { + var managedAppPolicyIdOption = new Option("--managed-app-policy-id", description: "key: id of managedAppPolicy") { }; managedAppPolicyIdOption.IsRequired = true; command.AddOption(managedAppPolicyIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string body) => { + command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedAppRegistrationIdOption, managedAppPolicyIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs index 278fdb65b1d..3b209e597c7 100644 --- a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/AppliedPolicies/Item/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.DeviceAppManagement.ManagedAppRegistrations.Item.AppliedPolicies.Item.WindowsInformationProtection.Assign; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/IntendedPoliciesRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/IntendedPoliciesRequestBuilder.cs index 9243e4cb010..4831c546bf6 100644 --- a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/IntendedPoliciesRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/IntendedPoliciesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class IntendedPoliciesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ManagedAppPolicyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildManagedAppProtectionCommand(), - builder.BuildPatchCommand(), - builder.BuildTargetAppsCommand(), - builder.BuildTargetedManagedAppProtectionCommand(), - builder.BuildWindowsInformationProtectionCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildManagedAppProtectionCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildTargetAppsCommand()); + commands.Add(builder.BuildTargetedManagedAppProtectionCommand()); + commands.Add(builder.BuildWindowsInformationProtectionCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Zero or more policies admin intended for the app as of now."; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedAppRegistrationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedAppRegistrationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedAppRegistrationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedAppRegistrationIdOption, bodyOption, outputOption); return command; } /// @@ -72,7 +70,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Zero or more policies admin intended for the app as of now."; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedAppRegistrationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedAppRegistrationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -122,15 +124,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedAppRegistrationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedAppRegistrationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -185,31 +182,6 @@ public RequestInformation CreatePostRequestInformation(ManagedAppPolicy body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Zero or more policies admin intended for the app as of now. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Zero or more policies admin intended for the app as of now. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ManagedAppPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Zero or more policies admin intended for the app as of now. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/ManagedAppPolicyRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/ManagedAppPolicyRequestBuilder.cs index 0cbdc01baba..eb38d583742 100644 --- a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/ManagedAppPolicyRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/ManagedAppPolicyRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Zero or more policies admin intended for the app as of now."; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); - var managedAppPolicyIdOption = new Option("--managedapppolicy-id", description: "key: id of managedAppPolicy") { + var managedAppPolicyIdOption = new Option("--managed-app-policy-id", description: "key: id of managedAppPolicy") { }; managedAppPolicyIdOption.IsRequired = true; command.AddOption(managedAppPolicyIdOption); - command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId) => { + command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedAppRegistrationIdOption, managedAppPolicyIdOption); return command; @@ -54,11 +53,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Zero or more policies admin intended for the app as of now."; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); - var managedAppPolicyIdOption = new Option("--managedapppolicy-id", description: "key: id of managedAppPolicy") { + var managedAppPolicyIdOption = new Option("--managed-app-policy-id", description: "key: id of managedAppPolicy") { }; managedAppPolicyIdOption.IsRequired = true; command.AddOption(managedAppPolicyIdOption); @@ -72,20 +71,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedAppRegistrationIdOption, managedAppPolicyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedAppRegistrationIdOption, managedAppPolicyIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildManagedAppProtectionCommand() { @@ -101,11 +99,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Zero or more policies admin intended for the app as of now."; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); - var managedAppPolicyIdOption = new Option("--managedapppolicy-id", description: "key: id of managedAppPolicy") { + var managedAppPolicyIdOption = new Option("--managed-app-policy-id", description: "key: id of managedAppPolicy") { }; managedAppPolicyIdOption.IsRequired = true; command.AddOption(managedAppPolicyIdOption); @@ -113,14 +111,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string body) => { + command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedAppRegistrationIdOption, managedAppPolicyIdOption, bodyOption); return command; @@ -211,42 +208,6 @@ public RequestInformation CreatePatchRequestInformation(ManagedAppPolicy body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Zero or more policies admin intended for the app as of now. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Zero or more policies admin intended for the app as of now. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Zero or more policies admin intended for the app as of now. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ManagedAppPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Zero or more policies admin intended for the app as of now. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs index 9cadab33cfc..5f3267645a5 100644 --- a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.DeviceAppManagement.ManagedAppRegistrations.Item.IntendedPolicies.Item.ManagedAppProtection.TargetApps; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs index 833915afef7..9b22c4dbc3e 100644 --- a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,11 +25,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action targetApps"; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); - var managedAppPolicyIdOption = new Option("--managedapppolicy-id", description: "key: id of managedAppPolicy") { + var managedAppPolicyIdOption = new Option("--managed-app-policy-id", description: "key: id of managedAppPolicy") { }; managedAppPolicyIdOption.IsRequired = true; command.AddOption(managedAppPolicyIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string body) => { + command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedAppRegistrationIdOption, managedAppPolicyIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TargetAppsRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action targetApps - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetAppsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/TargetApps/TargetAppsRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/TargetApps/TargetAppsRequestBuilder.cs index f04295dda31..ea5e3964abc 100644 --- a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/TargetApps/TargetAppsRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/TargetApps/TargetAppsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,11 +25,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action targetApps"; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); - var managedAppPolicyIdOption = new Option("--managedapppolicy-id", description: "key: id of managedAppPolicy") { + var managedAppPolicyIdOption = new Option("--managed-app-policy-id", description: "key: id of managedAppPolicy") { }; managedAppPolicyIdOption.IsRequired = true; command.AddOption(managedAppPolicyIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string body) => { + command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedAppRegistrationIdOption, managedAppPolicyIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TargetAppsRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action targetApps - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetAppsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs index 84abe903054..fe11eb86361 100644 --- a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,11 +25,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action assign"; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); - var managedAppPolicyIdOption = new Option("--managedapppolicy-id", description: "key: id of managedAppPolicy") { + var managedAppPolicyIdOption = new Option("--managed-app-policy-id", description: "key: id of managedAppPolicy") { }; managedAppPolicyIdOption.IsRequired = true; command.AddOption(managedAppPolicyIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string body) => { + command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedAppRegistrationIdOption, managedAppPolicyIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs index 6094dce5470..cadda3b6ab6 100644 --- a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,11 +25,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action targetApps"; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); - var managedAppPolicyIdOption = new Option("--managedapppolicy-id", description: "key: id of managedAppPolicy") { + var managedAppPolicyIdOption = new Option("--managed-app-policy-id", description: "key: id of managedAppPolicy") { }; managedAppPolicyIdOption.IsRequired = true; command.AddOption(managedAppPolicyIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string body) => { + command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedAppRegistrationIdOption, managedAppPolicyIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TargetAppsRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action targetApps - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetAppsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs index 33ed786530f..791cace61f1 100644 --- a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.DeviceAppManagement.ManagedAppRegistrations.Item.IntendedPolicies.Item.TargetedManagedAppProtection.Assign; using ApiSdk.DeviceAppManagement.ManagedAppRegistrations.Item.IntendedPolicies.Item.TargetedManagedAppProtection.TargetApps; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/WindowsInformationProtection/Assign/AssignRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/WindowsInformationProtection/Assign/AssignRequestBuilder.cs index a11383933e2..75351d01ff2 100644 --- a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/WindowsInformationProtection/Assign/AssignRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/WindowsInformationProtection/Assign/AssignRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,11 +25,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action assign"; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); - var managedAppPolicyIdOption = new Option("--managedapppolicy-id", description: "key: id of managedAppPolicy") { + var managedAppPolicyIdOption = new Option("--managed-app-policy-id", description: "key: id of managedAppPolicy") { }; managedAppPolicyIdOption.IsRequired = true; command.AddOption(managedAppPolicyIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string body) => { + command.SetHandler(async (string managedAppRegistrationId, string managedAppPolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedAppRegistrationIdOption, managedAppPolicyIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs index 4d4a3b0deae..af5ad4bdba1 100644 --- a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/IntendedPolicies/Item/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.DeviceAppManagement.ManagedAppRegistrations.Item.IntendedPolicies.Item.WindowsInformationProtection.Assign; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/ManagedAppRegistrationRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/ManagedAppRegistrationRequestBuilder.cs index fe2451e803d..3bbe7a651cc 100644 --- a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/ManagedAppRegistrationRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/ManagedAppRegistrationRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,6 +25,9 @@ public class ManagedAppRegistrationRequestBuilder { public Command BuildAppliedPoliciesCommand() { var command = new Command("applied-policies"); var builder = new ApiSdk.DeviceAppManagement.ManagedAppRegistrations.Item.AppliedPolicies.AppliedPoliciesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -36,15 +39,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The managed app registrations."; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); - command.SetHandler(async (string managedAppRegistrationId) => { + command.SetHandler(async (string managedAppRegistrationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedAppRegistrationIdOption); return command; @@ -56,7 +58,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The managed app registrations."; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); @@ -70,25 +72,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedAppRegistrationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedAppRegistrationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedAppRegistrationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedAppRegistrationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildIntendedPoliciesCommand() { var command = new Command("intended-policies"); var builder = new ApiSdk.DeviceAppManagement.ManagedAppRegistrations.Item.IntendedPolicies.IntendedPoliciesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -96,6 +100,9 @@ public Command BuildIntendedPoliciesCommand() { public Command BuildOperationsCommand() { var command = new Command("operations"); var builder = new ApiSdk.DeviceAppManagement.ManagedAppRegistrations.Item.Operations.OperationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -107,7 +114,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The managed app registrations."; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); @@ -115,14 +122,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedAppRegistrationId, string body) => { + command.SetHandler(async (string managedAppRegistrationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedAppRegistrationIdOption, bodyOption); return command; @@ -194,42 +200,6 @@ public RequestInformation CreatePatchRequestInformation(ManagedAppRegistration b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The managed app registrations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The managed app registrations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The managed app registrations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ManagedAppRegistration model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The managed app registrations. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/Operations/Item/ManagedAppOperationRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/Operations/Item/ManagedAppOperationRequestBuilder.cs index ae99477b829..33e4e0bcd6b 100644 --- a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/Operations/Item/ManagedAppOperationRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/Operations/Item/ManagedAppOperationRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Zero or more long running operations triggered on the app registration."; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); - var managedAppOperationIdOption = new Option("--managedappoperation-id", description: "key: id of managedAppOperation") { + var managedAppOperationIdOption = new Option("--managed-app-operation-id", description: "key: id of managedAppOperation") { }; managedAppOperationIdOption.IsRequired = true; command.AddOption(managedAppOperationIdOption); - command.SetHandler(async (string managedAppRegistrationId, string managedAppOperationId) => { + command.SetHandler(async (string managedAppRegistrationId, string managedAppOperationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedAppRegistrationIdOption, managedAppOperationIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Zero or more long running operations triggered on the app registration."; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); - var managedAppOperationIdOption = new Option("--managedappoperation-id", description: "key: id of managedAppOperation") { + var managedAppOperationIdOption = new Option("--managed-app-operation-id", description: "key: id of managedAppOperation") { }; managedAppOperationIdOption.IsRequired = true; command.AddOption(managedAppOperationIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedAppRegistrationId, string managedAppOperationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedAppRegistrationId, string managedAppOperationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedAppRegistrationIdOption, managedAppOperationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedAppRegistrationIdOption, managedAppOperationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Zero or more long running operations triggered on the app registration."; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); - var managedAppOperationIdOption = new Option("--managedappoperation-id", description: "key: id of managedAppOperation") { + var managedAppOperationIdOption = new Option("--managed-app-operation-id", description: "key: id of managedAppOperation") { }; managedAppOperationIdOption.IsRequired = true; command.AddOption(managedAppOperationIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedAppRegistrationId, string managedAppOperationId, string body) => { + command.SetHandler(async (string managedAppRegistrationId, string managedAppOperationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedAppRegistrationIdOption, managedAppOperationIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ManagedAppOperation body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Zero or more long running operations triggered on the app registration. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Zero or more long running operations triggered on the app registration. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Zero or more long running operations triggered on the app registration. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ManagedAppOperation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Zero or more long running operations triggered on the app registration. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/Operations/OperationsRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/Operations/OperationsRequestBuilder.cs index c39ac03f3ac..aa1c8ac3871 100644 --- a/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/Operations/OperationsRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppRegistrations/Item/Operations/OperationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class OperationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ManagedAppOperationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Zero or more long running operations triggered on the app registration."; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedAppRegistrationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedAppRegistrationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedAppRegistrationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedAppRegistrationIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Zero or more long running operations triggered on the app registration."; // Create options for all the parameters - var managedAppRegistrationIdOption = new Option("--managedappregistration-id", description: "key: id of managedAppRegistration") { + var managedAppRegistrationIdOption = new Option("--managed-app-registration-id", description: "key: id of managedAppRegistration") { }; managedAppRegistrationIdOption.IsRequired = true; command.AddOption(managedAppRegistrationIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedAppRegistrationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedAppRegistrationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedAppRegistrationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedAppRegistrationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ManagedAppOperation body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Zero or more long running operations triggered on the app registration. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Zero or more long running operations triggered on the app registration. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ManagedAppOperation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Zero or more long running operations triggered on the app registration. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/ManagedAppRegistrations/ManagedAppRegistrationsRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppRegistrations/ManagedAppRegistrationsRequestBuilder.cs index 9b006f6abfc..6b8cd192f56 100644 --- a/src/generated/DeviceAppManagement/ManagedAppRegistrations/ManagedAppRegistrationsRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppRegistrations/ManagedAppRegistrationsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,14 +23,13 @@ public class ManagedAppRegistrationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ManagedAppRegistrationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAppliedPoliciesCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildIntendedPoliciesCommand(), - builder.BuildOperationsCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAppliedPoliciesCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildIntendedPoliciesCommand()); + commands.Add(builder.BuildOperationsCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -103,7 +101,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -114,15 +116,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -178,36 +175,11 @@ public RequestInformation CreatePostRequestInformation(ManagedAppRegistration bo return requestInfo; } /// - /// The managed app registrations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \deviceAppManagement\managedAppRegistrations\microsoft.graph.getUserIdsWithFlaggedAppRegistration() /// public GetUserIdsWithFlaggedAppRegistrationRequestBuilder GetUserIdsWithFlaggedAppRegistration() { return new GetUserIdsWithFlaggedAppRegistrationRequestBuilder(PathParameters, RequestAdapter); } - /// - /// The managed app registrations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ManagedAppRegistration model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The managed app registrations. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/ManagedAppStatuses/Item/ManagedAppStatusRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppStatuses/Item/ManagedAppStatusRequestBuilder.cs index 8bef11d7b4c..56c0af8acf9 100644 --- a/src/generated/DeviceAppManagement/ManagedAppStatuses/Item/ManagedAppStatusRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppStatuses/Item/ManagedAppStatusRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The managed app statuses."; // Create options for all the parameters - var managedAppStatusIdOption = new Option("--managedappstatus-id", description: "key: id of managedAppStatus") { + var managedAppStatusIdOption = new Option("--managed-app-status-id", description: "key: id of managedAppStatus") { }; managedAppStatusIdOption.IsRequired = true; command.AddOption(managedAppStatusIdOption); - command.SetHandler(async (string managedAppStatusId) => { + command.SetHandler(async (string managedAppStatusId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedAppStatusIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The managed app statuses."; // Create options for all the parameters - var managedAppStatusIdOption = new Option("--managedappstatus-id", description: "key: id of managedAppStatus") { + var managedAppStatusIdOption = new Option("--managed-app-status-id", description: "key: id of managedAppStatus") { }; managedAppStatusIdOption.IsRequired = true; command.AddOption(managedAppStatusIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedAppStatusId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedAppStatusId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedAppStatusIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedAppStatusIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The managed app statuses."; // Create options for all the parameters - var managedAppStatusIdOption = new Option("--managedappstatus-id", description: "key: id of managedAppStatus") { + var managedAppStatusIdOption = new Option("--managed-app-status-id", description: "key: id of managedAppStatus") { }; managedAppStatusIdOption.IsRequired = true; command.AddOption(managedAppStatusIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedAppStatusId, string body) => { + command.SetHandler(async (string managedAppStatusId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedAppStatusIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ManagedAppStatus body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The managed app statuses. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The managed app statuses. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The managed app statuses. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ManagedAppStatus model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The managed app statuses. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/ManagedAppStatuses/ManagedAppStatusesRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedAppStatuses/ManagedAppStatusesRequestBuilder.cs index 752c8c50e2b..812e5342500 100644 --- a/src/generated/DeviceAppManagement/ManagedAppStatuses/ManagedAppStatusesRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedAppStatuses/ManagedAppStatusesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ManagedAppStatusesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ManagedAppStatusRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(ManagedAppStatus body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The managed app statuses. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The managed app statuses. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ManagedAppStatus model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The managed app statuses. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/ManagedEBooks/Item/Assign/AssignRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedEBooks/Item/Assign/AssignRequestBuilder.cs index 75d33ca9df9..00ac4f6e6b5 100644 --- a/src/generated/DeviceAppManagement/ManagedEBooks/Item/Assign/AssignRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedEBooks/Item/Assign/AssignRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action assign"; // Create options for all the parameters - var managedEBookIdOption = new Option("--managedebook-id", description: "key: id of managedEBook") { + var managedEBookIdOption = new Option("--managed-ebook-id", description: "key: id of managedEBook") { }; managedEBookIdOption.IsRequired = true; command.AddOption(managedEBookIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedEBookId, string body) => { + command.SetHandler(async (string managedEBookId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedEBookIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceAppManagement/ManagedEBooks/Item/Assignments/AssignmentsRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedEBooks/Item/Assignments/AssignmentsRequestBuilder.cs index 95ae2d12368..0ae8bb253c4 100644 --- a/src/generated/DeviceAppManagement/ManagedEBooks/Item/Assignments/AssignmentsRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedEBooks/Item/Assignments/AssignmentsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AssignmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ManagedEBookAssignmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The list of assignments for this eBook."; // Create options for all the parameters - var managedEBookIdOption = new Option("--managedebook-id", description: "key: id of managedEBook") { + var managedEBookIdOption = new Option("--managed-ebook-id", description: "key: id of managedEBook") { }; managedEBookIdOption.IsRequired = true; command.AddOption(managedEBookIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedEBookId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedEBookId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedEBookIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedEBookIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The list of assignments for this eBook."; // Create options for all the parameters - var managedEBookIdOption = new Option("--managedebook-id", description: "key: id of managedEBook") { + var managedEBookIdOption = new Option("--managed-ebook-id", description: "key: id of managedEBook") { }; managedEBookIdOption.IsRequired = true; command.AddOption(managedEBookIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedEBookId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedEBookId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedEBookIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedEBookIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ManagedEBookAssignment bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of assignments for this eBook. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of assignments for this eBook. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ManagedEBookAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of assignments for this eBook. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/ManagedEBooks/Item/Assignments/Item/ManagedEBookAssignmentRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedEBooks/Item/Assignments/Item/ManagedEBookAssignmentRequestBuilder.cs index a37b4cb2bfd..01e2496b69b 100644 --- a/src/generated/DeviceAppManagement/ManagedEBooks/Item/Assignments/Item/ManagedEBookAssignmentRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedEBooks/Item/Assignments/Item/ManagedEBookAssignmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of assignments for this eBook."; // Create options for all the parameters - var managedEBookIdOption = new Option("--managedebook-id", description: "key: id of managedEBook") { + var managedEBookIdOption = new Option("--managed-ebook-id", description: "key: id of managedEBook") { }; managedEBookIdOption.IsRequired = true; command.AddOption(managedEBookIdOption); - var managedEBookAssignmentIdOption = new Option("--managedebookassignment-id", description: "key: id of managedEBookAssignment") { + var managedEBookAssignmentIdOption = new Option("--managed-ebook-assignment-id", description: "key: id of managedEBookAssignment") { }; managedEBookAssignmentIdOption.IsRequired = true; command.AddOption(managedEBookAssignmentIdOption); - command.SetHandler(async (string managedEBookId, string managedEBookAssignmentId) => { + command.SetHandler(async (string managedEBookId, string managedEBookAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedEBookIdOption, managedEBookAssignmentIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of assignments for this eBook."; // Create options for all the parameters - var managedEBookIdOption = new Option("--managedebook-id", description: "key: id of managedEBook") { + var managedEBookIdOption = new Option("--managed-ebook-id", description: "key: id of managedEBook") { }; managedEBookIdOption.IsRequired = true; command.AddOption(managedEBookIdOption); - var managedEBookAssignmentIdOption = new Option("--managedebookassignment-id", description: "key: id of managedEBookAssignment") { + var managedEBookAssignmentIdOption = new Option("--managed-ebook-assignment-id", description: "key: id of managedEBookAssignment") { }; managedEBookAssignmentIdOption.IsRequired = true; command.AddOption(managedEBookAssignmentIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedEBookId, string managedEBookAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedEBookId, string managedEBookAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedEBookIdOption, managedEBookAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedEBookIdOption, managedEBookAssignmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of assignments for this eBook."; // Create options for all the parameters - var managedEBookIdOption = new Option("--managedebook-id", description: "key: id of managedEBook") { + var managedEBookIdOption = new Option("--managed-ebook-id", description: "key: id of managedEBook") { }; managedEBookIdOption.IsRequired = true; command.AddOption(managedEBookIdOption); - var managedEBookAssignmentIdOption = new Option("--managedebookassignment-id", description: "key: id of managedEBookAssignment") { + var managedEBookAssignmentIdOption = new Option("--managed-ebook-assignment-id", description: "key: id of managedEBookAssignment") { }; managedEBookAssignmentIdOption.IsRequired = true; command.AddOption(managedEBookAssignmentIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedEBookId, string managedEBookAssignmentId, string body) => { + command.SetHandler(async (string managedEBookId, string managedEBookAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedEBookIdOption, managedEBookAssignmentIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ManagedEBookAssignment b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of assignments for this eBook. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of assignments for this eBook. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of assignments for this eBook. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ManagedEBookAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of assignments for this eBook. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/ManagedEBooks/Item/DeviceStates/DeviceStatesRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedEBooks/Item/DeviceStates/DeviceStatesRequestBuilder.cs index aa3016c35f6..0a205c51945 100644 --- a/src/generated/DeviceAppManagement/ManagedEBooks/Item/DeviceStates/DeviceStatesRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedEBooks/Item/DeviceStates/DeviceStatesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DeviceStatesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceInstallStateRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The list of installation states for this eBook."; // Create options for all the parameters - var managedEBookIdOption = new Option("--managedebook-id", description: "key: id of managedEBook") { + var managedEBookIdOption = new Option("--managed-ebook-id", description: "key: id of managedEBook") { }; managedEBookIdOption.IsRequired = true; command.AddOption(managedEBookIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedEBookId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedEBookId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedEBookIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedEBookIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The list of installation states for this eBook."; // Create options for all the parameters - var managedEBookIdOption = new Option("--managedebook-id", description: "key: id of managedEBook") { + var managedEBookIdOption = new Option("--managed-ebook-id", description: "key: id of managedEBook") { }; managedEBookIdOption.IsRequired = true; command.AddOption(managedEBookIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedEBookId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedEBookId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedEBookIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedEBookIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(DeviceInstallState body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of installation states for this eBook. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of installation states for this eBook. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceInstallState model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of installation states for this eBook. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/ManagedEBooks/Item/DeviceStates/Item/DeviceInstallStateRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedEBooks/Item/DeviceStates/Item/DeviceInstallStateRequestBuilder.cs index 28445338376..3a373a65513 100644 --- a/src/generated/DeviceAppManagement/ManagedEBooks/Item/DeviceStates/Item/DeviceInstallStateRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedEBooks/Item/DeviceStates/Item/DeviceInstallStateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of installation states for this eBook."; // Create options for all the parameters - var managedEBookIdOption = new Option("--managedebook-id", description: "key: id of managedEBook") { + var managedEBookIdOption = new Option("--managed-ebook-id", description: "key: id of managedEBook") { }; managedEBookIdOption.IsRequired = true; command.AddOption(managedEBookIdOption); - var deviceInstallStateIdOption = new Option("--deviceinstallstate-id", description: "key: id of deviceInstallState") { + var deviceInstallStateIdOption = new Option("--device-install-state-id", description: "key: id of deviceInstallState") { }; deviceInstallStateIdOption.IsRequired = true; command.AddOption(deviceInstallStateIdOption); - command.SetHandler(async (string managedEBookId, string deviceInstallStateId) => { + command.SetHandler(async (string managedEBookId, string deviceInstallStateId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedEBookIdOption, deviceInstallStateIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of installation states for this eBook."; // Create options for all the parameters - var managedEBookIdOption = new Option("--managedebook-id", description: "key: id of managedEBook") { + var managedEBookIdOption = new Option("--managed-ebook-id", description: "key: id of managedEBook") { }; managedEBookIdOption.IsRequired = true; command.AddOption(managedEBookIdOption); - var deviceInstallStateIdOption = new Option("--deviceinstallstate-id", description: "key: id of deviceInstallState") { + var deviceInstallStateIdOption = new Option("--device-install-state-id", description: "key: id of deviceInstallState") { }; deviceInstallStateIdOption.IsRequired = true; command.AddOption(deviceInstallStateIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedEBookId, string deviceInstallStateId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedEBookId, string deviceInstallStateId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedEBookIdOption, deviceInstallStateIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedEBookIdOption, deviceInstallStateIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of installation states for this eBook."; // Create options for all the parameters - var managedEBookIdOption = new Option("--managedebook-id", description: "key: id of managedEBook") { + var managedEBookIdOption = new Option("--managed-ebook-id", description: "key: id of managedEBook") { }; managedEBookIdOption.IsRequired = true; command.AddOption(managedEBookIdOption); - var deviceInstallStateIdOption = new Option("--deviceinstallstate-id", description: "key: id of deviceInstallState") { + var deviceInstallStateIdOption = new Option("--device-install-state-id", description: "key: id of deviceInstallState") { }; deviceInstallStateIdOption.IsRequired = true; command.AddOption(deviceInstallStateIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedEBookId, string deviceInstallStateId, string body) => { + command.SetHandler(async (string managedEBookId, string deviceInstallStateId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedEBookIdOption, deviceInstallStateIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceInstallState body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of installation states for this eBook. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of installation states for this eBook. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of installation states for this eBook. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceInstallState model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of installation states for this eBook. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/ManagedEBooks/Item/InstallSummary/InstallSummaryRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedEBooks/Item/InstallSummary/InstallSummaryRequestBuilder.cs index f5a4eaaa517..6ab1c5618c0 100644 --- a/src/generated/DeviceAppManagement/ManagedEBooks/Item/InstallSummary/InstallSummaryRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedEBooks/Item/InstallSummary/InstallSummaryRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Mobile App Install Summary."; // Create options for all the parameters - var managedEBookIdOption = new Option("--managedebook-id", description: "key: id of managedEBook") { + var managedEBookIdOption = new Option("--managed-ebook-id", description: "key: id of managedEBook") { }; managedEBookIdOption.IsRequired = true; command.AddOption(managedEBookIdOption); - command.SetHandler(async (string managedEBookId) => { + command.SetHandler(async (string managedEBookId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedEBookIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Mobile App Install Summary."; // Create options for all the parameters - var managedEBookIdOption = new Option("--managedebook-id", description: "key: id of managedEBook") { + var managedEBookIdOption = new Option("--managed-ebook-id", description: "key: id of managedEBook") { }; managedEBookIdOption.IsRequired = true; command.AddOption(managedEBookIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedEBookId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedEBookId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedEBookIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedEBookIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Mobile App Install Summary."; // Create options for all the parameters - var managedEBookIdOption = new Option("--managedebook-id", description: "key: id of managedEBook") { + var managedEBookIdOption = new Option("--managed-ebook-id", description: "key: id of managedEBook") { }; managedEBookIdOption.IsRequired = true; command.AddOption(managedEBookIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedEBookId, string body) => { + command.SetHandler(async (string managedEBookId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedEBookIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(EBookInstallSummary body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Mobile App Install Summary. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Mobile App Install Summary. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Mobile App Install Summary. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EBookInstallSummary model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Mobile App Install Summary. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/ManagedEBooks/Item/ManagedEBookRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedEBooks/Item/ManagedEBookRequestBuilder.cs index fc2d515b6d3..ca041f68af9 100644 --- a/src/generated/DeviceAppManagement/ManagedEBooks/Item/ManagedEBookRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedEBooks/Item/ManagedEBookRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,6 +33,9 @@ public Command BuildAssignCommand() { public Command BuildAssignmentsCommand() { var command = new Command("assignments"); var builder = new ApiSdk.DeviceAppManagement.ManagedEBooks.Item.Assignments.AssignmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -44,15 +47,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The Managed eBook."; // Create options for all the parameters - var managedEBookIdOption = new Option("--managedebook-id", description: "key: id of managedEBook") { + var managedEBookIdOption = new Option("--managed-ebook-id", description: "key: id of managedEBook") { }; managedEBookIdOption.IsRequired = true; command.AddOption(managedEBookIdOption); - command.SetHandler(async (string managedEBookId) => { + command.SetHandler(async (string managedEBookId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedEBookIdOption); return command; @@ -60,6 +62,9 @@ public Command BuildDeleteCommand() { public Command BuildDeviceStatesCommand() { var command = new Command("device-states"); var builder = new ApiSdk.DeviceAppManagement.ManagedEBooks.Item.DeviceStates.DeviceStatesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -71,7 +76,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The Managed eBook."; // Create options for all the parameters - var managedEBookIdOption = new Option("--managedebook-id", description: "key: id of managedEBook") { + var managedEBookIdOption = new Option("--managed-ebook-id", description: "key: id of managedEBook") { }; managedEBookIdOption.IsRequired = true; command.AddOption(managedEBookIdOption); @@ -85,20 +90,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedEBookId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedEBookId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedEBookIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedEBookIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildInstallSummaryCommand() { @@ -116,7 +120,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The Managed eBook."; // Create options for all the parameters - var managedEBookIdOption = new Option("--managedebook-id", description: "key: id of managedEBook") { + var managedEBookIdOption = new Option("--managed-ebook-id", description: "key: id of managedEBook") { }; managedEBookIdOption.IsRequired = true; command.AddOption(managedEBookIdOption); @@ -124,14 +128,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedEBookId, string body) => { + command.SetHandler(async (string managedEBookId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedEBookIdOption, bodyOption); return command; @@ -139,6 +142,9 @@ public Command BuildPatchCommand() { public Command BuildUserStateSummaryCommand() { var command = new Command("user-state-summary"); var builder = new ApiSdk.DeviceAppManagement.ManagedEBooks.Item.UserStateSummary.UserStateSummaryRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -210,42 +216,6 @@ public RequestInformation CreatePatchRequestInformation(ManagedEBook body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The Managed eBook. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Managed eBook. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Managed eBook. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ManagedEBook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The Managed eBook. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/ManagedEBooks/Item/UserStateSummary/Item/DeviceStates/DeviceStatesRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedEBooks/Item/UserStateSummary/Item/DeviceStates/DeviceStatesRequestBuilder.cs index a2e5ad53922..e5ba8c340e6 100644 --- a/src/generated/DeviceAppManagement/ManagedEBooks/Item/UserStateSummary/Item/DeviceStates/DeviceStatesRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedEBooks/Item/UserStateSummary/Item/DeviceStates/DeviceStatesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DeviceStatesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceInstallStateRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,11 +35,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The install state of the eBook."; // Create options for all the parameters - var managedEBookIdOption = new Option("--managedebook-id", description: "key: id of managedEBook") { + var managedEBookIdOption = new Option("--managed-ebook-id", description: "key: id of managedEBook") { }; managedEBookIdOption.IsRequired = true; command.AddOption(managedEBookIdOption); - var userInstallStateSummaryIdOption = new Option("--userinstallstatesummary-id", description: "key: id of userInstallStateSummary") { + var userInstallStateSummaryIdOption = new Option("--user-install-state-summary-id", description: "key: id of userInstallStateSummary") { }; userInstallStateSummaryIdOption.IsRequired = true; command.AddOption(userInstallStateSummaryIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedEBookId, string userInstallStateSummaryId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedEBookId, string userInstallStateSummaryId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedEBookIdOption, userInstallStateSummaryIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedEBookIdOption, userInstallStateSummaryIdOption, bodyOption, outputOption); return command; } /// @@ -72,11 +70,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The install state of the eBook."; // Create options for all the parameters - var managedEBookIdOption = new Option("--managedebook-id", description: "key: id of managedEBook") { + var managedEBookIdOption = new Option("--managed-ebook-id", description: "key: id of managedEBook") { }; managedEBookIdOption.IsRequired = true; command.AddOption(managedEBookIdOption); - var userInstallStateSummaryIdOption = new Option("--userinstallstatesummary-id", description: "key: id of userInstallStateSummary") { + var userInstallStateSummaryIdOption = new Option("--user-install-state-summary-id", description: "key: id of userInstallStateSummary") { }; userInstallStateSummaryIdOption.IsRequired = true; command.AddOption(userInstallStateSummaryIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedEBookId, string userInstallStateSummaryId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedEBookId, string userInstallStateSummaryId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedEBookIdOption, userInstallStateSummaryIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedEBookIdOption, userInstallStateSummaryIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(DeviceInstallState body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The install state of the eBook. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The install state of the eBook. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceInstallState model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The install state of the eBook. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/ManagedEBooks/Item/UserStateSummary/Item/DeviceStates/Item/DeviceInstallStateRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedEBooks/Item/UserStateSummary/Item/DeviceStates/Item/DeviceInstallStateRequestBuilder.cs index 5b0574d4e8f..90a528883f9 100644 --- a/src/generated/DeviceAppManagement/ManagedEBooks/Item/UserStateSummary/Item/DeviceStates/Item/DeviceInstallStateRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedEBooks/Item/UserStateSummary/Item/DeviceStates/Item/DeviceInstallStateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The install state of the eBook."; // Create options for all the parameters - var managedEBookIdOption = new Option("--managedebook-id", description: "key: id of managedEBook") { + var managedEBookIdOption = new Option("--managed-ebook-id", description: "key: id of managedEBook") { }; managedEBookIdOption.IsRequired = true; command.AddOption(managedEBookIdOption); - var userInstallStateSummaryIdOption = new Option("--userinstallstatesummary-id", description: "key: id of userInstallStateSummary") { + var userInstallStateSummaryIdOption = new Option("--user-install-state-summary-id", description: "key: id of userInstallStateSummary") { }; userInstallStateSummaryIdOption.IsRequired = true; command.AddOption(userInstallStateSummaryIdOption); - var deviceInstallStateIdOption = new Option("--deviceinstallstate-id", description: "key: id of deviceInstallState") { + var deviceInstallStateIdOption = new Option("--device-install-state-id", description: "key: id of deviceInstallState") { }; deviceInstallStateIdOption.IsRequired = true; command.AddOption(deviceInstallStateIdOption); - command.SetHandler(async (string managedEBookId, string userInstallStateSummaryId, string deviceInstallStateId) => { + command.SetHandler(async (string managedEBookId, string userInstallStateSummaryId, string deviceInstallStateId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedEBookIdOption, userInstallStateSummaryIdOption, deviceInstallStateIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The install state of the eBook."; // Create options for all the parameters - var managedEBookIdOption = new Option("--managedebook-id", description: "key: id of managedEBook") { + var managedEBookIdOption = new Option("--managed-ebook-id", description: "key: id of managedEBook") { }; managedEBookIdOption.IsRequired = true; command.AddOption(managedEBookIdOption); - var userInstallStateSummaryIdOption = new Option("--userinstallstatesummary-id", description: "key: id of userInstallStateSummary") { + var userInstallStateSummaryIdOption = new Option("--user-install-state-summary-id", description: "key: id of userInstallStateSummary") { }; userInstallStateSummaryIdOption.IsRequired = true; command.AddOption(userInstallStateSummaryIdOption); - var deviceInstallStateIdOption = new Option("--deviceinstallstate-id", description: "key: id of deviceInstallState") { + var deviceInstallStateIdOption = new Option("--device-install-state-id", description: "key: id of deviceInstallState") { }; deviceInstallStateIdOption.IsRequired = true; command.AddOption(deviceInstallStateIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedEBookId, string userInstallStateSummaryId, string deviceInstallStateId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedEBookId, string userInstallStateSummaryId, string deviceInstallStateId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedEBookIdOption, userInstallStateSummaryIdOption, deviceInstallStateIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedEBookIdOption, userInstallStateSummaryIdOption, deviceInstallStateIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The install state of the eBook."; // Create options for all the parameters - var managedEBookIdOption = new Option("--managedebook-id", description: "key: id of managedEBook") { + var managedEBookIdOption = new Option("--managed-ebook-id", description: "key: id of managedEBook") { }; managedEBookIdOption.IsRequired = true; command.AddOption(managedEBookIdOption); - var userInstallStateSummaryIdOption = new Option("--userinstallstatesummary-id", description: "key: id of userInstallStateSummary") { + var userInstallStateSummaryIdOption = new Option("--user-install-state-summary-id", description: "key: id of userInstallStateSummary") { }; userInstallStateSummaryIdOption.IsRequired = true; command.AddOption(userInstallStateSummaryIdOption); - var deviceInstallStateIdOption = new Option("--deviceinstallstate-id", description: "key: id of deviceInstallState") { + var deviceInstallStateIdOption = new Option("--device-install-state-id", description: "key: id of deviceInstallState") { }; deviceInstallStateIdOption.IsRequired = true; command.AddOption(deviceInstallStateIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedEBookId, string userInstallStateSummaryId, string deviceInstallStateId, string body) => { + command.SetHandler(async (string managedEBookId, string userInstallStateSummaryId, string deviceInstallStateId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedEBookIdOption, userInstallStateSummaryIdOption, deviceInstallStateIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceInstallState body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The install state of the eBook. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The install state of the eBook. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The install state of the eBook. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceInstallState model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The install state of the eBook. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/ManagedEBooks/Item/UserStateSummary/Item/UserInstallStateSummaryRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedEBooks/Item/UserStateSummary/Item/UserInstallStateSummaryRequestBuilder.cs index 7316d743652..5de12588186 100644 --- a/src/generated/DeviceAppManagement/ManagedEBooks/Item/UserStateSummary/Item/UserInstallStateSummaryRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedEBooks/Item/UserStateSummary/Item/UserInstallStateSummaryRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,19 +27,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of installation states for this eBook."; // Create options for all the parameters - var managedEBookIdOption = new Option("--managedebook-id", description: "key: id of managedEBook") { + var managedEBookIdOption = new Option("--managed-ebook-id", description: "key: id of managedEBook") { }; managedEBookIdOption.IsRequired = true; command.AddOption(managedEBookIdOption); - var userInstallStateSummaryIdOption = new Option("--userinstallstatesummary-id", description: "key: id of userInstallStateSummary") { + var userInstallStateSummaryIdOption = new Option("--user-install-state-summary-id", description: "key: id of userInstallStateSummary") { }; userInstallStateSummaryIdOption.IsRequired = true; command.AddOption(userInstallStateSummaryIdOption); - command.SetHandler(async (string managedEBookId, string userInstallStateSummaryId) => { + command.SetHandler(async (string managedEBookId, string userInstallStateSummaryId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedEBookIdOption, userInstallStateSummaryIdOption); return command; @@ -47,6 +46,9 @@ public Command BuildDeleteCommand() { public Command BuildDeviceStatesCommand() { var command = new Command("device-states"); var builder = new ApiSdk.DeviceAppManagement.ManagedEBooks.Item.UserStateSummary.Item.DeviceStates.DeviceStatesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -58,11 +60,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of installation states for this eBook."; // Create options for all the parameters - var managedEBookIdOption = new Option("--managedebook-id", description: "key: id of managedEBook") { + var managedEBookIdOption = new Option("--managed-ebook-id", description: "key: id of managedEBook") { }; managedEBookIdOption.IsRequired = true; command.AddOption(managedEBookIdOption); - var userInstallStateSummaryIdOption = new Option("--userinstallstatesummary-id", description: "key: id of userInstallStateSummary") { + var userInstallStateSummaryIdOption = new Option("--user-install-state-summary-id", description: "key: id of userInstallStateSummary") { }; userInstallStateSummaryIdOption.IsRequired = true; command.AddOption(userInstallStateSummaryIdOption); @@ -76,20 +78,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedEBookId, string userInstallStateSummaryId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedEBookId, string userInstallStateSummaryId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedEBookIdOption, userInstallStateSummaryIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedEBookIdOption, userInstallStateSummaryIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,11 +100,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of installation states for this eBook."; // Create options for all the parameters - var managedEBookIdOption = new Option("--managedebook-id", description: "key: id of managedEBook") { + var managedEBookIdOption = new Option("--managed-ebook-id", description: "key: id of managedEBook") { }; managedEBookIdOption.IsRequired = true; command.AddOption(managedEBookIdOption); - var userInstallStateSummaryIdOption = new Option("--userinstallstatesummary-id", description: "key: id of userInstallStateSummary") { + var userInstallStateSummaryIdOption = new Option("--user-install-state-summary-id", description: "key: id of userInstallStateSummary") { }; userInstallStateSummaryIdOption.IsRequired = true; command.AddOption(userInstallStateSummaryIdOption); @@ -111,14 +112,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedEBookId, string userInstallStateSummaryId, string body) => { + command.SetHandler(async (string managedEBookId, string userInstallStateSummaryId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedEBookIdOption, userInstallStateSummaryIdOption, bodyOption); return command; @@ -190,42 +190,6 @@ public RequestInformation CreatePatchRequestInformation(UserInstallStateSummary requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of installation states for this eBook. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of installation states for this eBook. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of installation states for this eBook. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(UserInstallStateSummary model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of installation states for this eBook. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/ManagedEBooks/Item/UserStateSummary/UserStateSummaryRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedEBooks/Item/UserStateSummary/UserStateSummaryRequestBuilder.cs index e0b78735fb5..e7c3cfe093c 100644 --- a/src/generated/DeviceAppManagement/ManagedEBooks/Item/UserStateSummary/UserStateSummaryRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedEBooks/Item/UserStateSummary/UserStateSummaryRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class UserStateSummaryRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new UserInstallStateSummaryRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildDeviceStatesCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDeviceStatesCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -37,7 +36,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The list of installation states for this eBook."; // Create options for all the parameters - var managedEBookIdOption = new Option("--managedebook-id", description: "key: id of managedEBook") { + var managedEBookIdOption = new Option("--managed-ebook-id", description: "key: id of managedEBook") { }; managedEBookIdOption.IsRequired = true; command.AddOption(managedEBookIdOption); @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedEBookId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedEBookId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedEBookIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedEBookIdOption, bodyOption, outputOption); return command; } /// @@ -69,7 +67,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The list of installation states for this eBook."; // Create options for all the parameters - var managedEBookIdOption = new Option("--managedebook-id", description: "key: id of managedEBook") { + var managedEBookIdOption = new Option("--managed-ebook-id", description: "key: id of managedEBook") { }; managedEBookIdOption.IsRequired = true; command.AddOption(managedEBookIdOption); @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedEBookId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedEBookId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedEBookIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedEBookIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(UserInstallStateSummary b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of installation states for this eBook. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of installation states for this eBook. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UserInstallStateSummary model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of installation states for this eBook. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/ManagedEBooks/ManagedEBooksRequestBuilder.cs b/src/generated/DeviceAppManagement/ManagedEBooks/ManagedEBooksRequestBuilder.cs index ed7b884ebf6..3439bd7a278 100644 --- a/src/generated/DeviceAppManagement/ManagedEBooks/ManagedEBooksRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/ManagedEBooks/ManagedEBooksRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class ManagedEBooksRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ManagedEBookRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAssignCommand(), - builder.BuildAssignmentsCommand(), - builder.BuildDeleteCommand(), - builder.BuildDeviceStatesCommand(), - builder.BuildGetCommand(), - builder.BuildInstallSummaryCommand(), - builder.BuildPatchCommand(), - builder.BuildUserStateSummaryCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAssignCommand()); + commands.Add(builder.BuildAssignmentsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDeviceStatesCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInstallSummaryCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildUserStateSummaryCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -104,7 +102,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -115,15 +117,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -178,31 +175,6 @@ public RequestInformation CreatePostRequestInformation(ManagedEBook body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The Managed eBook. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Managed eBook. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ManagedEBook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The Managed eBook. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/MdmWindowsInformationProtectionPolicies/Item/MdmWindowsInformationProtectionPolicyRequestBuilder.cs b/src/generated/DeviceAppManagement/MdmWindowsInformationProtectionPolicies/Item/MdmWindowsInformationProtectionPolicyRequestBuilder.cs index 071c15d25e4..4bc1348e6f2 100644 --- a/src/generated/DeviceAppManagement/MdmWindowsInformationProtectionPolicies/Item/MdmWindowsInformationProtectionPolicyRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/MdmWindowsInformationProtectionPolicies/Item/MdmWindowsInformationProtectionPolicyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Windows information protection for apps running on devices which are MDM enrolled."; // Create options for all the parameters - var mdmWindowsInformationProtectionPolicyIdOption = new Option("--mdmwindowsinformationprotectionpolicy-id", description: "key: id of mdmWindowsInformationProtectionPolicy") { + var mdmWindowsInformationProtectionPolicyIdOption = new Option("--mdm-windows-information-protection-policy-id", description: "key: id of mdmWindowsInformationProtectionPolicy") { }; mdmWindowsInformationProtectionPolicyIdOption.IsRequired = true; command.AddOption(mdmWindowsInformationProtectionPolicyIdOption); - command.SetHandler(async (string mdmWindowsInformationProtectionPolicyId) => { + command.SetHandler(async (string mdmWindowsInformationProtectionPolicyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mdmWindowsInformationProtectionPolicyIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Windows information protection for apps running on devices which are MDM enrolled."; // Create options for all the parameters - var mdmWindowsInformationProtectionPolicyIdOption = new Option("--mdmwindowsinformationprotectionpolicy-id", description: "key: id of mdmWindowsInformationProtectionPolicy") { + var mdmWindowsInformationProtectionPolicyIdOption = new Option("--mdm-windows-information-protection-policy-id", description: "key: id of mdmWindowsInformationProtectionPolicy") { }; mdmWindowsInformationProtectionPolicyIdOption.IsRequired = true; command.AddOption(mdmWindowsInformationProtectionPolicyIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string mdmWindowsInformationProtectionPolicyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mdmWindowsInformationProtectionPolicyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mdmWindowsInformationProtectionPolicyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mdmWindowsInformationProtectionPolicyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Windows information protection for apps running on devices which are MDM enrolled."; // Create options for all the parameters - var mdmWindowsInformationProtectionPolicyIdOption = new Option("--mdmwindowsinformationprotectionpolicy-id", description: "key: id of mdmWindowsInformationProtectionPolicy") { + var mdmWindowsInformationProtectionPolicyIdOption = new Option("--mdm-windows-information-protection-policy-id", description: "key: id of mdmWindowsInformationProtectionPolicy") { }; mdmWindowsInformationProtectionPolicyIdOption.IsRequired = true; command.AddOption(mdmWindowsInformationProtectionPolicyIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mdmWindowsInformationProtectionPolicyId, string body) => { + command.SetHandler(async (string mdmWindowsInformationProtectionPolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mdmWindowsInformationProtectionPolicyIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(MdmWindowsInformationPro requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Windows information protection for apps running on devices which are MDM enrolled. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Windows information protection for apps running on devices which are MDM enrolled. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Windows information protection for apps running on devices which are MDM enrolled. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MdmWindowsInformationProtectionPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Windows information protection for apps running on devices which are MDM enrolled. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/MdmWindowsInformationProtectionPolicies/MdmWindowsInformationProtectionPoliciesRequestBuilder.cs b/src/generated/DeviceAppManagement/MdmWindowsInformationProtectionPolicies/MdmWindowsInformationProtectionPoliciesRequestBuilder.cs index 1a0f176c171..147cf8e90c5 100644 --- a/src/generated/DeviceAppManagement/MdmWindowsInformationProtectionPolicies/MdmWindowsInformationProtectionPoliciesRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/MdmWindowsInformationProtectionPolicies/MdmWindowsInformationProtectionPoliciesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MdmWindowsInformationProtectionPoliciesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MdmWindowsInformationProtectionPolicyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(MdmWindowsInformationProt requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Windows information protection for apps running on devices which are MDM enrolled. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Windows information protection for apps running on devices which are MDM enrolled. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MdmWindowsInformationProtectionPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Windows information protection for apps running on devices which are MDM enrolled. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/MobileAppCategories/Item/MobileAppCategoryRequestBuilder.cs b/src/generated/DeviceAppManagement/MobileAppCategories/Item/MobileAppCategoryRequestBuilder.cs index 9efd639ecd7..f5c1576b271 100644 --- a/src/generated/DeviceAppManagement/MobileAppCategories/Item/MobileAppCategoryRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/MobileAppCategories/Item/MobileAppCategoryRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The mobile app categories."; // Create options for all the parameters - var mobileAppCategoryIdOption = new Option("--mobileappcategory-id", description: "key: id of mobileAppCategory") { + var mobileAppCategoryIdOption = new Option("--mobile-app-category-id", description: "key: id of mobileAppCategory") { }; mobileAppCategoryIdOption.IsRequired = true; command.AddOption(mobileAppCategoryIdOption); - command.SetHandler(async (string mobileAppCategoryId) => { + command.SetHandler(async (string mobileAppCategoryId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mobileAppCategoryIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The mobile app categories."; // Create options for all the parameters - var mobileAppCategoryIdOption = new Option("--mobileappcategory-id", description: "key: id of mobileAppCategory") { + var mobileAppCategoryIdOption = new Option("--mobile-app-category-id", description: "key: id of mobileAppCategory") { }; mobileAppCategoryIdOption.IsRequired = true; command.AddOption(mobileAppCategoryIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string mobileAppCategoryId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mobileAppCategoryId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mobileAppCategoryIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mobileAppCategoryIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The mobile app categories."; // Create options for all the parameters - var mobileAppCategoryIdOption = new Option("--mobileappcategory-id", description: "key: id of mobileAppCategory") { + var mobileAppCategoryIdOption = new Option("--mobile-app-category-id", description: "key: id of mobileAppCategory") { }; mobileAppCategoryIdOption.IsRequired = true; command.AddOption(mobileAppCategoryIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mobileAppCategoryId, string body) => { + command.SetHandler(async (string mobileAppCategoryId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mobileAppCategoryIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(MobileAppCategory body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The mobile app categories. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The mobile app categories. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The mobile app categories. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MobileAppCategory model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The mobile app categories. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/MobileAppCategories/MobileAppCategoriesRequestBuilder.cs b/src/generated/DeviceAppManagement/MobileAppCategories/MobileAppCategoriesRequestBuilder.cs index c91d0df938e..d95e762a35d 100644 --- a/src/generated/DeviceAppManagement/MobileAppCategories/MobileAppCategoriesRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/MobileAppCategories/MobileAppCategoriesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MobileAppCategoriesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MobileAppCategoryRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(MobileAppCategory body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The mobile app categories. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The mobile app categories. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MobileAppCategory model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The mobile app categories. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/Assign/AssignRequestBuilder.cs b/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/Assign/AssignRequestBuilder.cs index 6929f67df7e..38415d0e097 100644 --- a/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/Assign/AssignRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/Assign/AssignRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action assign"; // Create options for all the parameters - var managedDeviceMobileAppConfigurationIdOption = new Option("--manageddevicemobileappconfiguration-id", description: "key: id of managedDeviceMobileAppConfiguration") { + var managedDeviceMobileAppConfigurationIdOption = new Option("--managed-device-mobile-app-configuration-id", description: "key: id of managedDeviceMobileAppConfiguration") { }; managedDeviceMobileAppConfigurationIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string body) => { + command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceMobileAppConfigurationIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/Assignments/AssignmentsRequestBuilder.cs b/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/Assignments/AssignmentsRequestBuilder.cs index a186c1e4192..d3cf36e0d56 100644 --- a/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/Assignments/AssignmentsRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/Assignments/AssignmentsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AssignmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ManagedDeviceMobileAppConfigurationAssignmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The list of group assignemenets for app configration."; // Create options for all the parameters - var managedDeviceMobileAppConfigurationIdOption = new Option("--manageddevicemobileappconfiguration-id", description: "key: id of managedDeviceMobileAppConfiguration") { + var managedDeviceMobileAppConfigurationIdOption = new Option("--managed-device-mobile-app-configuration-id", description: "key: id of managedDeviceMobileAppConfiguration") { }; managedDeviceMobileAppConfigurationIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceMobileAppConfigurationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceMobileAppConfigurationIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The list of group assignemenets for app configration."; // Create options for all the parameters - var managedDeviceMobileAppConfigurationIdOption = new Option("--manageddevicemobileappconfiguration-id", description: "key: id of managedDeviceMobileAppConfiguration") { + var managedDeviceMobileAppConfigurationIdOption = new Option("--managed-device-mobile-app-configuration-id", description: "key: id of managedDeviceMobileAppConfiguration") { }; managedDeviceMobileAppConfigurationIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedDeviceMobileAppConfigurationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceMobileAppConfigurationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceMobileAppConfigurationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceMobileAppConfigurationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ManagedDeviceMobileAppCon requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of group assignemenets for app configration. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of group assignemenets for app configration. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ManagedDeviceMobileAppConfigurationAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of group assignemenets for app configration. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/Assignments/Item/ManagedDeviceMobileAppConfigurationAssignmentRequestBuilder.cs b/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/Assignments/Item/ManagedDeviceMobileAppConfigurationAssignmentRequestBuilder.cs index 6cda4358c08..1cdfa9bfc1a 100644 --- a/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/Assignments/Item/ManagedDeviceMobileAppConfigurationAssignmentRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/Assignments/Item/ManagedDeviceMobileAppConfigurationAssignmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of group assignemenets for app configration."; // Create options for all the parameters - var managedDeviceMobileAppConfigurationIdOption = new Option("--manageddevicemobileappconfiguration-id", description: "key: id of managedDeviceMobileAppConfiguration") { + var managedDeviceMobileAppConfigurationIdOption = new Option("--managed-device-mobile-app-configuration-id", description: "key: id of managedDeviceMobileAppConfiguration") { }; managedDeviceMobileAppConfigurationIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationIdOption); - var managedDeviceMobileAppConfigurationAssignmentIdOption = new Option("--manageddevicemobileappconfigurationassignment-id", description: "key: id of managedDeviceMobileAppConfigurationAssignment") { + var managedDeviceMobileAppConfigurationAssignmentIdOption = new Option("--managed-device-mobile-app-configuration-assignment-id", description: "key: id of managedDeviceMobileAppConfigurationAssignment") { }; managedDeviceMobileAppConfigurationAssignmentIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationAssignmentIdOption); - command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string managedDeviceMobileAppConfigurationAssignmentId) => { + command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string managedDeviceMobileAppConfigurationAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceMobileAppConfigurationIdOption, managedDeviceMobileAppConfigurationAssignmentIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of group assignemenets for app configration."; // Create options for all the parameters - var managedDeviceMobileAppConfigurationIdOption = new Option("--manageddevicemobileappconfiguration-id", description: "key: id of managedDeviceMobileAppConfiguration") { + var managedDeviceMobileAppConfigurationIdOption = new Option("--managed-device-mobile-app-configuration-id", description: "key: id of managedDeviceMobileAppConfiguration") { }; managedDeviceMobileAppConfigurationIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationIdOption); - var managedDeviceMobileAppConfigurationAssignmentIdOption = new Option("--manageddevicemobileappconfigurationassignment-id", description: "key: id of managedDeviceMobileAppConfigurationAssignment") { + var managedDeviceMobileAppConfigurationAssignmentIdOption = new Option("--managed-device-mobile-app-configuration-assignment-id", description: "key: id of managedDeviceMobileAppConfigurationAssignment") { }; managedDeviceMobileAppConfigurationAssignmentIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationAssignmentIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string managedDeviceMobileAppConfigurationAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string managedDeviceMobileAppConfigurationAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceMobileAppConfigurationIdOption, managedDeviceMobileAppConfigurationAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceMobileAppConfigurationIdOption, managedDeviceMobileAppConfigurationAssignmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of group assignemenets for app configration."; // Create options for all the parameters - var managedDeviceMobileAppConfigurationIdOption = new Option("--manageddevicemobileappconfiguration-id", description: "key: id of managedDeviceMobileAppConfiguration") { + var managedDeviceMobileAppConfigurationIdOption = new Option("--managed-device-mobile-app-configuration-id", description: "key: id of managedDeviceMobileAppConfiguration") { }; managedDeviceMobileAppConfigurationIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationIdOption); - var managedDeviceMobileAppConfigurationAssignmentIdOption = new Option("--manageddevicemobileappconfigurationassignment-id", description: "key: id of managedDeviceMobileAppConfigurationAssignment") { + var managedDeviceMobileAppConfigurationAssignmentIdOption = new Option("--managed-device-mobile-app-configuration-assignment-id", description: "key: id of managedDeviceMobileAppConfigurationAssignment") { }; managedDeviceMobileAppConfigurationAssignmentIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationAssignmentIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string managedDeviceMobileAppConfigurationAssignmentId, string body) => { + command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string managedDeviceMobileAppConfigurationAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceMobileAppConfigurationIdOption, managedDeviceMobileAppConfigurationAssignmentIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ManagedDeviceMobileAppCo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of group assignemenets for app configration. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of group assignemenets for app configration. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of group assignemenets for app configration. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ManagedDeviceMobileAppConfigurationAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of group assignemenets for app configration. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/DeviceStatusSummary/DeviceStatusSummaryRequestBuilder.cs b/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/DeviceStatusSummary/DeviceStatusSummaryRequestBuilder.cs index 198166c2693..2969f952ecb 100644 --- a/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/DeviceStatusSummary/DeviceStatusSummaryRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/DeviceStatusSummary/DeviceStatusSummaryRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "App configuration device status summary."; // Create options for all the parameters - var managedDeviceMobileAppConfigurationIdOption = new Option("--manageddevicemobileappconfiguration-id", description: "key: id of managedDeviceMobileAppConfiguration") { + var managedDeviceMobileAppConfigurationIdOption = new Option("--managed-device-mobile-app-configuration-id", description: "key: id of managedDeviceMobileAppConfiguration") { }; managedDeviceMobileAppConfigurationIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationIdOption); - command.SetHandler(async (string managedDeviceMobileAppConfigurationId) => { + command.SetHandler(async (string managedDeviceMobileAppConfigurationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceMobileAppConfigurationIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "App configuration device status summary."; // Create options for all the parameters - var managedDeviceMobileAppConfigurationIdOption = new Option("--manageddevicemobileappconfiguration-id", description: "key: id of managedDeviceMobileAppConfiguration") { + var managedDeviceMobileAppConfigurationIdOption = new Option("--managed-device-mobile-app-configuration-id", description: "key: id of managedDeviceMobileAppConfiguration") { }; managedDeviceMobileAppConfigurationIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceMobileAppConfigurationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceMobileAppConfigurationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "App configuration device status summary."; // Create options for all the parameters - var managedDeviceMobileAppConfigurationIdOption = new Option("--manageddevicemobileappconfiguration-id", description: "key: id of managedDeviceMobileAppConfiguration") { + var managedDeviceMobileAppConfigurationIdOption = new Option("--managed-device-mobile-app-configuration-id", description: "key: id of managedDeviceMobileAppConfiguration") { }; managedDeviceMobileAppConfigurationIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string body) => { + command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceMobileAppConfigurationIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ManagedDeviceMobileAppCo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// App configuration device status summary. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// App configuration device status summary. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// App configuration device status summary. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ManagedDeviceMobileAppConfigurationDeviceSummary model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// App configuration device status summary. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/DeviceStatuses/DeviceStatusesRequestBuilder.cs b/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/DeviceStatuses/DeviceStatusesRequestBuilder.cs index 4082d6b89b8..923be4002c7 100644 --- a/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/DeviceStatuses/DeviceStatusesRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/DeviceStatuses/DeviceStatusesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DeviceStatusesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ManagedDeviceMobileAppConfigurationDeviceStatusRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "List of ManagedDeviceMobileAppConfigurationDeviceStatus."; // Create options for all the parameters - var managedDeviceMobileAppConfigurationIdOption = new Option("--manageddevicemobileappconfiguration-id", description: "key: id of managedDeviceMobileAppConfiguration") { + var managedDeviceMobileAppConfigurationIdOption = new Option("--managed-device-mobile-app-configuration-id", description: "key: id of managedDeviceMobileAppConfiguration") { }; managedDeviceMobileAppConfigurationIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceMobileAppConfigurationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceMobileAppConfigurationIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "List of ManagedDeviceMobileAppConfigurationDeviceStatus."; // Create options for all the parameters - var managedDeviceMobileAppConfigurationIdOption = new Option("--manageddevicemobileappconfiguration-id", description: "key: id of managedDeviceMobileAppConfiguration") { + var managedDeviceMobileAppConfigurationIdOption = new Option("--managed-device-mobile-app-configuration-id", description: "key: id of managedDeviceMobileAppConfiguration") { }; managedDeviceMobileAppConfigurationIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedDeviceMobileAppConfigurationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceMobileAppConfigurationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceMobileAppConfigurationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceMobileAppConfigurationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ManagedDeviceMobileAppCon requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of ManagedDeviceMobileAppConfigurationDeviceStatus. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of ManagedDeviceMobileAppConfigurationDeviceStatus. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ManagedDeviceMobileAppConfigurationDeviceStatus model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// List of ManagedDeviceMobileAppConfigurationDeviceStatus. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/DeviceStatuses/Item/ManagedDeviceMobileAppConfigurationDeviceStatusRequestBuilder.cs b/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/DeviceStatuses/Item/ManagedDeviceMobileAppConfigurationDeviceStatusRequestBuilder.cs index 714db06144e..9891a21c84d 100644 --- a/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/DeviceStatuses/Item/ManagedDeviceMobileAppConfigurationDeviceStatusRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/DeviceStatuses/Item/ManagedDeviceMobileAppConfigurationDeviceStatusRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "List of ManagedDeviceMobileAppConfigurationDeviceStatus."; // Create options for all the parameters - var managedDeviceMobileAppConfigurationIdOption = new Option("--manageddevicemobileappconfiguration-id", description: "key: id of managedDeviceMobileAppConfiguration") { + var managedDeviceMobileAppConfigurationIdOption = new Option("--managed-device-mobile-app-configuration-id", description: "key: id of managedDeviceMobileAppConfiguration") { }; managedDeviceMobileAppConfigurationIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationIdOption); - var managedDeviceMobileAppConfigurationDeviceStatusIdOption = new Option("--manageddevicemobileappconfigurationdevicestatus-id", description: "key: id of managedDeviceMobileAppConfigurationDeviceStatus") { + var managedDeviceMobileAppConfigurationDeviceStatusIdOption = new Option("--managed-device-mobile-app-configuration-device-status-id", description: "key: id of managedDeviceMobileAppConfigurationDeviceStatus") { }; managedDeviceMobileAppConfigurationDeviceStatusIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationDeviceStatusIdOption); - command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string managedDeviceMobileAppConfigurationDeviceStatusId) => { + command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string managedDeviceMobileAppConfigurationDeviceStatusId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceMobileAppConfigurationIdOption, managedDeviceMobileAppConfigurationDeviceStatusIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "List of ManagedDeviceMobileAppConfigurationDeviceStatus."; // Create options for all the parameters - var managedDeviceMobileAppConfigurationIdOption = new Option("--manageddevicemobileappconfiguration-id", description: "key: id of managedDeviceMobileAppConfiguration") { + var managedDeviceMobileAppConfigurationIdOption = new Option("--managed-device-mobile-app-configuration-id", description: "key: id of managedDeviceMobileAppConfiguration") { }; managedDeviceMobileAppConfigurationIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationIdOption); - var managedDeviceMobileAppConfigurationDeviceStatusIdOption = new Option("--manageddevicemobileappconfigurationdevicestatus-id", description: "key: id of managedDeviceMobileAppConfigurationDeviceStatus") { + var managedDeviceMobileAppConfigurationDeviceStatusIdOption = new Option("--managed-device-mobile-app-configuration-device-status-id", description: "key: id of managedDeviceMobileAppConfigurationDeviceStatus") { }; managedDeviceMobileAppConfigurationDeviceStatusIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationDeviceStatusIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string managedDeviceMobileAppConfigurationDeviceStatusId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string managedDeviceMobileAppConfigurationDeviceStatusId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceMobileAppConfigurationIdOption, managedDeviceMobileAppConfigurationDeviceStatusIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceMobileAppConfigurationIdOption, managedDeviceMobileAppConfigurationDeviceStatusIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "List of ManagedDeviceMobileAppConfigurationDeviceStatus."; // Create options for all the parameters - var managedDeviceMobileAppConfigurationIdOption = new Option("--manageddevicemobileappconfiguration-id", description: "key: id of managedDeviceMobileAppConfiguration") { + var managedDeviceMobileAppConfigurationIdOption = new Option("--managed-device-mobile-app-configuration-id", description: "key: id of managedDeviceMobileAppConfiguration") { }; managedDeviceMobileAppConfigurationIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationIdOption); - var managedDeviceMobileAppConfigurationDeviceStatusIdOption = new Option("--manageddevicemobileappconfigurationdevicestatus-id", description: "key: id of managedDeviceMobileAppConfigurationDeviceStatus") { + var managedDeviceMobileAppConfigurationDeviceStatusIdOption = new Option("--managed-device-mobile-app-configuration-device-status-id", description: "key: id of managedDeviceMobileAppConfigurationDeviceStatus") { }; managedDeviceMobileAppConfigurationDeviceStatusIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationDeviceStatusIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string managedDeviceMobileAppConfigurationDeviceStatusId, string body) => { + command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string managedDeviceMobileAppConfigurationDeviceStatusId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceMobileAppConfigurationIdOption, managedDeviceMobileAppConfigurationDeviceStatusIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ManagedDeviceMobileAppCo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of ManagedDeviceMobileAppConfigurationDeviceStatus. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of ManagedDeviceMobileAppConfigurationDeviceStatus. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of ManagedDeviceMobileAppConfigurationDeviceStatus. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ManagedDeviceMobileAppConfigurationDeviceStatus model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// List of ManagedDeviceMobileAppConfigurationDeviceStatus. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/ManagedDeviceMobileAppConfigurationRequestBuilder.cs b/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/ManagedDeviceMobileAppConfigurationRequestBuilder.cs index 855ea867b63..0058601a15a 100644 --- a/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/ManagedDeviceMobileAppConfigurationRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/ManagedDeviceMobileAppConfigurationRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,6 +34,9 @@ public Command BuildAssignCommand() { public Command BuildAssignmentsCommand() { var command = new Command("assignments"); var builder = new ApiSdk.DeviceAppManagement.MobileAppConfigurations.Item.Assignments.AssignmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -45,15 +48,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The Managed Device Mobile Application Configurations."; // Create options for all the parameters - var managedDeviceMobileAppConfigurationIdOption = new Option("--manageddevicemobileappconfiguration-id", description: "key: id of managedDeviceMobileAppConfiguration") { + var managedDeviceMobileAppConfigurationIdOption = new Option("--managed-device-mobile-app-configuration-id", description: "key: id of managedDeviceMobileAppConfiguration") { }; managedDeviceMobileAppConfigurationIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationIdOption); - command.SetHandler(async (string managedDeviceMobileAppConfigurationId) => { + command.SetHandler(async (string managedDeviceMobileAppConfigurationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceMobileAppConfigurationIdOption); return command; @@ -61,6 +63,9 @@ public Command BuildDeleteCommand() { public Command BuildDeviceStatusesCommand() { var command = new Command("device-statuses"); var builder = new ApiSdk.DeviceAppManagement.MobileAppConfigurations.Item.DeviceStatuses.DeviceStatusesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -80,7 +85,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The Managed Device Mobile Application Configurations."; // Create options for all the parameters - var managedDeviceMobileAppConfigurationIdOption = new Option("--manageddevicemobileappconfiguration-id", description: "key: id of managedDeviceMobileAppConfiguration") { + var managedDeviceMobileAppConfigurationIdOption = new Option("--managed-device-mobile-app-configuration-id", description: "key: id of managedDeviceMobileAppConfiguration") { }; managedDeviceMobileAppConfigurationIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationIdOption); @@ -94,20 +99,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceMobileAppConfigurationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceMobileAppConfigurationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -117,7 +121,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The Managed Device Mobile Application Configurations."; // Create options for all the parameters - var managedDeviceMobileAppConfigurationIdOption = new Option("--manageddevicemobileappconfiguration-id", description: "key: id of managedDeviceMobileAppConfiguration") { + var managedDeviceMobileAppConfigurationIdOption = new Option("--managed-device-mobile-app-configuration-id", description: "key: id of managedDeviceMobileAppConfiguration") { }; managedDeviceMobileAppConfigurationIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationIdOption); @@ -125,14 +129,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string body) => { + command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceMobileAppConfigurationIdOption, bodyOption); return command; @@ -140,6 +143,9 @@ public Command BuildPatchCommand() { public Command BuildUserStatusesCommand() { var command = new Command("user-statuses"); var builder = new ApiSdk.DeviceAppManagement.MobileAppConfigurations.Item.UserStatuses.UserStatusesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -219,42 +225,6 @@ public RequestInformation CreatePatchRequestInformation(ManagedDeviceMobileAppCo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The Managed Device Mobile Application Configurations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Managed Device Mobile Application Configurations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Managed Device Mobile Application Configurations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ManagedDeviceMobileAppConfiguration model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The Managed Device Mobile Application Configurations. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/UserStatusSummary/UserStatusSummaryRequestBuilder.cs b/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/UserStatusSummary/UserStatusSummaryRequestBuilder.cs index f8a3dd8b727..e89bba44399 100644 --- a/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/UserStatusSummary/UserStatusSummaryRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/UserStatusSummary/UserStatusSummaryRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "App configuration user status summary."; // Create options for all the parameters - var managedDeviceMobileAppConfigurationIdOption = new Option("--manageddevicemobileappconfiguration-id", description: "key: id of managedDeviceMobileAppConfiguration") { + var managedDeviceMobileAppConfigurationIdOption = new Option("--managed-device-mobile-app-configuration-id", description: "key: id of managedDeviceMobileAppConfiguration") { }; managedDeviceMobileAppConfigurationIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationIdOption); - command.SetHandler(async (string managedDeviceMobileAppConfigurationId) => { + command.SetHandler(async (string managedDeviceMobileAppConfigurationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceMobileAppConfigurationIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "App configuration user status summary."; // Create options for all the parameters - var managedDeviceMobileAppConfigurationIdOption = new Option("--manageddevicemobileappconfiguration-id", description: "key: id of managedDeviceMobileAppConfiguration") { + var managedDeviceMobileAppConfigurationIdOption = new Option("--managed-device-mobile-app-configuration-id", description: "key: id of managedDeviceMobileAppConfiguration") { }; managedDeviceMobileAppConfigurationIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceMobileAppConfigurationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceMobileAppConfigurationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "App configuration user status summary."; // Create options for all the parameters - var managedDeviceMobileAppConfigurationIdOption = new Option("--manageddevicemobileappconfiguration-id", description: "key: id of managedDeviceMobileAppConfiguration") { + var managedDeviceMobileAppConfigurationIdOption = new Option("--managed-device-mobile-app-configuration-id", description: "key: id of managedDeviceMobileAppConfiguration") { }; managedDeviceMobileAppConfigurationIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string body) => { + command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceMobileAppConfigurationIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ManagedDeviceMobileAppCo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// App configuration user status summary. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// App configuration user status summary. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// App configuration user status summary. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ManagedDeviceMobileAppConfigurationUserSummary model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// App configuration user status summary. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/UserStatuses/Item/ManagedDeviceMobileAppConfigurationUserStatusRequestBuilder.cs b/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/UserStatuses/Item/ManagedDeviceMobileAppConfigurationUserStatusRequestBuilder.cs index 0687fa82bce..e71ba50b657 100644 --- a/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/UserStatuses/Item/ManagedDeviceMobileAppConfigurationUserStatusRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/UserStatuses/Item/ManagedDeviceMobileAppConfigurationUserStatusRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "List of ManagedDeviceMobileAppConfigurationUserStatus."; // Create options for all the parameters - var managedDeviceMobileAppConfigurationIdOption = new Option("--manageddevicemobileappconfiguration-id", description: "key: id of managedDeviceMobileAppConfiguration") { + var managedDeviceMobileAppConfigurationIdOption = new Option("--managed-device-mobile-app-configuration-id", description: "key: id of managedDeviceMobileAppConfiguration") { }; managedDeviceMobileAppConfigurationIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationIdOption); - var managedDeviceMobileAppConfigurationUserStatusIdOption = new Option("--manageddevicemobileappconfigurationuserstatus-id", description: "key: id of managedDeviceMobileAppConfigurationUserStatus") { + var managedDeviceMobileAppConfigurationUserStatusIdOption = new Option("--managed-device-mobile-app-configuration-user-status-id", description: "key: id of managedDeviceMobileAppConfigurationUserStatus") { }; managedDeviceMobileAppConfigurationUserStatusIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationUserStatusIdOption); - command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string managedDeviceMobileAppConfigurationUserStatusId) => { + command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string managedDeviceMobileAppConfigurationUserStatusId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceMobileAppConfigurationIdOption, managedDeviceMobileAppConfigurationUserStatusIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "List of ManagedDeviceMobileAppConfigurationUserStatus."; // Create options for all the parameters - var managedDeviceMobileAppConfigurationIdOption = new Option("--manageddevicemobileappconfiguration-id", description: "key: id of managedDeviceMobileAppConfiguration") { + var managedDeviceMobileAppConfigurationIdOption = new Option("--managed-device-mobile-app-configuration-id", description: "key: id of managedDeviceMobileAppConfiguration") { }; managedDeviceMobileAppConfigurationIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationIdOption); - var managedDeviceMobileAppConfigurationUserStatusIdOption = new Option("--manageddevicemobileappconfigurationuserstatus-id", description: "key: id of managedDeviceMobileAppConfigurationUserStatus") { + var managedDeviceMobileAppConfigurationUserStatusIdOption = new Option("--managed-device-mobile-app-configuration-user-status-id", description: "key: id of managedDeviceMobileAppConfigurationUserStatus") { }; managedDeviceMobileAppConfigurationUserStatusIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationUserStatusIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string managedDeviceMobileAppConfigurationUserStatusId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string managedDeviceMobileAppConfigurationUserStatusId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceMobileAppConfigurationIdOption, managedDeviceMobileAppConfigurationUserStatusIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceMobileAppConfigurationIdOption, managedDeviceMobileAppConfigurationUserStatusIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "List of ManagedDeviceMobileAppConfigurationUserStatus."; // Create options for all the parameters - var managedDeviceMobileAppConfigurationIdOption = new Option("--manageddevicemobileappconfiguration-id", description: "key: id of managedDeviceMobileAppConfiguration") { + var managedDeviceMobileAppConfigurationIdOption = new Option("--managed-device-mobile-app-configuration-id", description: "key: id of managedDeviceMobileAppConfiguration") { }; managedDeviceMobileAppConfigurationIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationIdOption); - var managedDeviceMobileAppConfigurationUserStatusIdOption = new Option("--manageddevicemobileappconfigurationuserstatus-id", description: "key: id of managedDeviceMobileAppConfigurationUserStatus") { + var managedDeviceMobileAppConfigurationUserStatusIdOption = new Option("--managed-device-mobile-app-configuration-user-status-id", description: "key: id of managedDeviceMobileAppConfigurationUserStatus") { }; managedDeviceMobileAppConfigurationUserStatusIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationUserStatusIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string managedDeviceMobileAppConfigurationUserStatusId, string body) => { + command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string managedDeviceMobileAppConfigurationUserStatusId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceMobileAppConfigurationIdOption, managedDeviceMobileAppConfigurationUserStatusIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ManagedDeviceMobileAppCo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of ManagedDeviceMobileAppConfigurationUserStatus. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of ManagedDeviceMobileAppConfigurationUserStatus. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of ManagedDeviceMobileAppConfigurationUserStatus. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ManagedDeviceMobileAppConfigurationUserStatus model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// List of ManagedDeviceMobileAppConfigurationUserStatus. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/UserStatuses/UserStatusesRequestBuilder.cs b/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/UserStatuses/UserStatusesRequestBuilder.cs index 2410012f289..bcd983db372 100644 --- a/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/UserStatuses/UserStatusesRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/MobileAppConfigurations/Item/UserStatuses/UserStatusesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class UserStatusesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ManagedDeviceMobileAppConfigurationUserStatusRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "List of ManagedDeviceMobileAppConfigurationUserStatus."; // Create options for all the parameters - var managedDeviceMobileAppConfigurationIdOption = new Option("--manageddevicemobileappconfiguration-id", description: "key: id of managedDeviceMobileAppConfiguration") { + var managedDeviceMobileAppConfigurationIdOption = new Option("--managed-device-mobile-app-configuration-id", description: "key: id of managedDeviceMobileAppConfiguration") { }; managedDeviceMobileAppConfigurationIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceMobileAppConfigurationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceMobileAppConfigurationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceMobileAppConfigurationIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "List of ManagedDeviceMobileAppConfigurationUserStatus."; // Create options for all the parameters - var managedDeviceMobileAppConfigurationIdOption = new Option("--manageddevicemobileappconfiguration-id", description: "key: id of managedDeviceMobileAppConfiguration") { + var managedDeviceMobileAppConfigurationIdOption = new Option("--managed-device-mobile-app-configuration-id", description: "key: id of managedDeviceMobileAppConfiguration") { }; managedDeviceMobileAppConfigurationIdOption.IsRequired = true; command.AddOption(managedDeviceMobileAppConfigurationIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedDeviceMobileAppConfigurationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceMobileAppConfigurationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceMobileAppConfigurationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceMobileAppConfigurationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ManagedDeviceMobileAppCon requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of ManagedDeviceMobileAppConfigurationUserStatus. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of ManagedDeviceMobileAppConfigurationUserStatus. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ManagedDeviceMobileAppConfigurationUserStatus model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// List of ManagedDeviceMobileAppConfigurationUserStatus. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/MobileAppConfigurations/MobileAppConfigurationsRequestBuilder.cs b/src/generated/DeviceAppManagement/MobileAppConfigurations/MobileAppConfigurationsRequestBuilder.cs index 479743319d6..bac65d98e5a 100644 --- a/src/generated/DeviceAppManagement/MobileAppConfigurations/MobileAppConfigurationsRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/MobileAppConfigurations/MobileAppConfigurationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,17 +22,16 @@ public class MobileAppConfigurationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ManagedDeviceMobileAppConfigurationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAssignCommand(), - builder.BuildAssignmentsCommand(), - builder.BuildDeleteCommand(), - builder.BuildDeviceStatusesCommand(), - builder.BuildDeviceStatusSummaryCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildUserStatusesCommand(), - builder.BuildUserStatusSummaryCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAssignCommand()); + commands.Add(builder.BuildAssignmentsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDeviceStatusesCommand()); + commands.Add(builder.BuildDeviceStatusSummaryCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildUserStatusesCommand()); + commands.Add(builder.BuildUserStatusSummaryCommand()); return commands; } /// @@ -46,21 +45,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -105,7 +103,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -116,15 +118,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -179,31 +176,6 @@ public RequestInformation CreatePostRequestInformation(ManagedDeviceMobileAppCon requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The Managed Device Mobile Application Configurations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Managed Device Mobile Application Configurations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ManagedDeviceMobileAppConfiguration model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The Managed Device Mobile Application Configurations. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/MobileApps/Item/Assign/AssignRequestBuilder.cs b/src/generated/DeviceAppManagement/MobileApps/Item/Assign/AssignRequestBuilder.cs index 4f58a9920a4..d8f8fc78e21 100644 --- a/src/generated/DeviceAppManagement/MobileApps/Item/Assign/AssignRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/MobileApps/Item/Assign/AssignRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action assign"; // Create options for all the parameters - var mobileAppIdOption = new Option("--mobileapp-id", description: "key: id of mobileApp") { + var mobileAppIdOption = new Option("--mobile-app-id", description: "key: id of mobileApp") { }; mobileAppIdOption.IsRequired = true; command.AddOption(mobileAppIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mobileAppId, string body) => { + command.SetHandler(async (string mobileAppId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mobileAppIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceAppManagement/MobileApps/Item/Assignments/AssignmentsRequestBuilder.cs b/src/generated/DeviceAppManagement/MobileApps/Item/Assignments/AssignmentsRequestBuilder.cs index 89a54cfc84b..e7da74d3bae 100644 --- a/src/generated/DeviceAppManagement/MobileApps/Item/Assignments/AssignmentsRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/MobileApps/Item/Assignments/AssignmentsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AssignmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MobileAppAssignmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The list of group assignments for this mobile app."; // Create options for all the parameters - var mobileAppIdOption = new Option("--mobileapp-id", description: "key: id of mobileApp") { + var mobileAppIdOption = new Option("--mobile-app-id", description: "key: id of mobileApp") { }; mobileAppIdOption.IsRequired = true; command.AddOption(mobileAppIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mobileAppId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mobileAppId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mobileAppIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mobileAppIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The list of group assignments for this mobile app."; // Create options for all the parameters - var mobileAppIdOption = new Option("--mobileapp-id", description: "key: id of mobileApp") { + var mobileAppIdOption = new Option("--mobile-app-id", description: "key: id of mobileApp") { }; mobileAppIdOption.IsRequired = true; command.AddOption(mobileAppIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string mobileAppId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mobileAppId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mobileAppIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mobileAppIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(MobileAppAssignment body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of group assignments for this mobile app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of group assignments for this mobile app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MobileAppAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of group assignments for this mobile app. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/MobileApps/Item/Assignments/Item/MobileAppAssignmentRequestBuilder.cs b/src/generated/DeviceAppManagement/MobileApps/Item/Assignments/Item/MobileAppAssignmentRequestBuilder.cs index 8c1df991a30..ced0b348753 100644 --- a/src/generated/DeviceAppManagement/MobileApps/Item/Assignments/Item/MobileAppAssignmentRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/MobileApps/Item/Assignments/Item/MobileAppAssignmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of group assignments for this mobile app."; // Create options for all the parameters - var mobileAppIdOption = new Option("--mobileapp-id", description: "key: id of mobileApp") { + var mobileAppIdOption = new Option("--mobile-app-id", description: "key: id of mobileApp") { }; mobileAppIdOption.IsRequired = true; command.AddOption(mobileAppIdOption); - var mobileAppAssignmentIdOption = new Option("--mobileappassignment-id", description: "key: id of mobileAppAssignment") { + var mobileAppAssignmentIdOption = new Option("--mobile-app-assignment-id", description: "key: id of mobileAppAssignment") { }; mobileAppAssignmentIdOption.IsRequired = true; command.AddOption(mobileAppAssignmentIdOption); - command.SetHandler(async (string mobileAppId, string mobileAppAssignmentId) => { + command.SetHandler(async (string mobileAppId, string mobileAppAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mobileAppIdOption, mobileAppAssignmentIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of group assignments for this mobile app."; // Create options for all the parameters - var mobileAppIdOption = new Option("--mobileapp-id", description: "key: id of mobileApp") { + var mobileAppIdOption = new Option("--mobile-app-id", description: "key: id of mobileApp") { }; mobileAppIdOption.IsRequired = true; command.AddOption(mobileAppIdOption); - var mobileAppAssignmentIdOption = new Option("--mobileappassignment-id", description: "key: id of mobileAppAssignment") { + var mobileAppAssignmentIdOption = new Option("--mobile-app-assignment-id", description: "key: id of mobileAppAssignment") { }; mobileAppAssignmentIdOption.IsRequired = true; command.AddOption(mobileAppAssignmentIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string mobileAppId, string mobileAppAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mobileAppId, string mobileAppAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mobileAppIdOption, mobileAppAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mobileAppIdOption, mobileAppAssignmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of group assignments for this mobile app."; // Create options for all the parameters - var mobileAppIdOption = new Option("--mobileapp-id", description: "key: id of mobileApp") { + var mobileAppIdOption = new Option("--mobile-app-id", description: "key: id of mobileApp") { }; mobileAppIdOption.IsRequired = true; command.AddOption(mobileAppIdOption); - var mobileAppAssignmentIdOption = new Option("--mobileappassignment-id", description: "key: id of mobileAppAssignment") { + var mobileAppAssignmentIdOption = new Option("--mobile-app-assignment-id", description: "key: id of mobileAppAssignment") { }; mobileAppAssignmentIdOption.IsRequired = true; command.AddOption(mobileAppAssignmentIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mobileAppId, string mobileAppAssignmentId, string body) => { + command.SetHandler(async (string mobileAppId, string mobileAppAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mobileAppIdOption, mobileAppAssignmentIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(MobileAppAssignment body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of group assignments for this mobile app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of group assignments for this mobile app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of group assignments for this mobile app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MobileAppAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of group assignments for this mobile app. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/MobileApps/Item/Categories/@Ref/@Ref.cs b/src/generated/DeviceAppManagement/MobileApps/Item/Categories/@Ref/@Ref.cs deleted file mode 100644 index 821fd872d92..00000000000 --- a/src/generated/DeviceAppManagement/MobileApps/Item/Categories/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.DeviceAppManagement.MobileApps.Item.Categories.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/DeviceAppManagement/MobileApps/Item/Categories/@Ref/RefRequestBuilder.cs b/src/generated/DeviceAppManagement/MobileApps/Item/Categories/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 2f9a023090f..00000000000 --- a/src/generated/DeviceAppManagement/MobileApps/Item/Categories/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.DeviceAppManagement.MobileApps.Item.Categories.@Ref { - /// Builds and executes requests for operations under \deviceAppManagement\mobileApps\{mobileApp-id}\categories\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The list of categories for this app. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The list of categories for this app."; - // Create options for all the parameters - var mobileAppIdOption = new Option("--mobileapp-id", description: "key: id of mobileApp") { - }; - mobileAppIdOption.IsRequired = true; - command.AddOption(mobileAppIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string mobileAppId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mobileAppIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The list of categories for this app. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The list of categories for this app."; - // Create options for all the parameters - var mobileAppIdOption = new Option("--mobileapp-id", description: "key: id of mobileApp") { - }; - mobileAppIdOption.IsRequired = true; - command.AddOption(mobileAppIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string mobileAppId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mobileAppIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/deviceAppManagement/mobileApps/{mobileApp_id}/categories/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The list of categories for this app. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The list of categories for this app. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.DeviceAppManagement.MobileApps.Item.Categories.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The list of categories for this app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of categories for this app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.DeviceAppManagement.MobileApps.Item.Categories.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The list of categories for this app. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/DeviceAppManagement/MobileApps/Item/Categories/@Ref/RefResponse.cs b/src/generated/DeviceAppManagement/MobileApps/Item/Categories/@Ref/RefResponse.cs deleted file mode 100644 index c6e33b556f1..00000000000 --- a/src/generated/DeviceAppManagement/MobileApps/Item/Categories/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.DeviceAppManagement.MobileApps.Item.Categories.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/DeviceAppManagement/MobileApps/Item/Categories/CategoriesRequestBuilder.cs b/src/generated/DeviceAppManagement/MobileApps/Item/Categories/CategoriesRequestBuilder.cs index 75ef68317c4..fd65f63de6d 100644 --- a/src/generated/DeviceAppManagement/MobileApps/Item/Categories/CategoriesRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/MobileApps/Item/Categories/CategoriesRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.DeviceAppManagement.MobileApps.Item.Categories.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of categories for this app."; // Create options for all the parameters - var mobileAppIdOption = new Option("--mobileapp-id", description: "key: id of mobileApp") { + var mobileAppIdOption = new Option("--mobile-app-id", description: "key: id of mobileApp") { }; mobileAppIdOption.IsRequired = true; command.AddOption(mobileAppIdOption); @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string mobileAppId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mobileAppId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mobileAppIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mobileAppIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.DeviceAppManagement.MobileApps.Item.Categories.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.DeviceAppManagement.MobileApps.Item.Categories.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of categories for this app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of categories for this app. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/MobileApps/Item/Categories/Ref/Ref.cs b/src/generated/DeviceAppManagement/MobileApps/Item/Categories/Ref/Ref.cs new file mode 100644 index 00000000000..74e94eef565 --- /dev/null +++ b/src/generated/DeviceAppManagement/MobileApps/Item/Categories/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.DeviceAppManagement.MobileApps.Item.Categories.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/DeviceAppManagement/MobileApps/Item/Categories/Ref/RefRequestBuilder.cs b/src/generated/DeviceAppManagement/MobileApps/Item/Categories/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..d7b3ecaa9e4 --- /dev/null +++ b/src/generated/DeviceAppManagement/MobileApps/Item/Categories/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.DeviceAppManagement.MobileApps.Item.Categories.Ref { + /// Builds and executes requests for operations under \deviceAppManagement\mobileApps\{mobileApp-id}\categories\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The list of categories for this app. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The list of categories for this app."; + // Create options for all the parameters + var mobileAppIdOption = new Option("--mobile-app-id", description: "key: id of mobileApp") { + }; + mobileAppIdOption.IsRequired = true; + command.AddOption(mobileAppIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mobileAppId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mobileAppIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The list of categories for this app. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The list of categories for this app."; + // Create options for all the parameters + var mobileAppIdOption = new Option("--mobile-app-id", description: "key: id of mobileApp") { + }; + mobileAppIdOption.IsRequired = true; + command.AddOption(mobileAppIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mobileAppId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mobileAppIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/deviceAppManagement/mobileApps/{mobileApp_id}/categories/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The list of categories for this app. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The list of categories for this app. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.DeviceAppManagement.MobileApps.Item.Categories.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The list of categories for this app. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/DeviceAppManagement/MobileApps/Item/Categories/Ref/RefResponse.cs b/src/generated/DeviceAppManagement/MobileApps/Item/Categories/Ref/RefResponse.cs new file mode 100644 index 00000000000..260a7bdfb87 --- /dev/null +++ b/src/generated/DeviceAppManagement/MobileApps/Item/Categories/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.DeviceAppManagement.MobileApps.Item.Categories.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/DeviceAppManagement/MobileApps/Item/MobileAppRequestBuilder.cs b/src/generated/DeviceAppManagement/MobileApps/Item/MobileAppRequestBuilder.cs index 29f509dade2..f56e8848028 100644 --- a/src/generated/DeviceAppManagement/MobileApps/Item/MobileAppRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/MobileApps/Item/MobileAppRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,6 +31,9 @@ public Command BuildAssignCommand() { public Command BuildAssignmentsCommand() { var command = new Command("assignments"); var builder = new ApiSdk.DeviceAppManagement.MobileApps.Item.Assignments.AssignmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -49,15 +52,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The mobile apps."; // Create options for all the parameters - var mobileAppIdOption = new Option("--mobileapp-id", description: "key: id of mobileApp") { + var mobileAppIdOption = new Option("--mobile-app-id", description: "key: id of mobileApp") { }; mobileAppIdOption.IsRequired = true; command.AddOption(mobileAppIdOption); - command.SetHandler(async (string mobileAppId) => { + command.SetHandler(async (string mobileAppId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mobileAppIdOption); return command; @@ -69,7 +71,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The mobile apps."; // Create options for all the parameters - var mobileAppIdOption = new Option("--mobileapp-id", description: "key: id of mobileApp") { + var mobileAppIdOption = new Option("--mobile-app-id", description: "key: id of mobileApp") { }; mobileAppIdOption.IsRequired = true; command.AddOption(mobileAppIdOption); @@ -83,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string mobileAppId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mobileAppId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mobileAppIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mobileAppIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,7 +107,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The mobile apps."; // Create options for all the parameters - var mobileAppIdOption = new Option("--mobileapp-id", description: "key: id of mobileApp") { + var mobileAppIdOption = new Option("--mobile-app-id", description: "key: id of mobileApp") { }; mobileAppIdOption.IsRequired = true; command.AddOption(mobileAppIdOption); @@ -114,14 +115,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mobileAppId, string body) => { + command.SetHandler(async (string mobileAppId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mobileAppIdOption, bodyOption); return command; @@ -193,42 +193,6 @@ public RequestInformation CreatePatchRequestInformation(MobileApp body, Action - /// The mobile apps. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The mobile apps. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The mobile apps. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MobileApp model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The mobile apps. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/MobileApps/MobileAppsRequestBuilder.cs b/src/generated/DeviceAppManagement/MobileApps/MobileAppsRequestBuilder.cs index 15ce05a529f..afbb0410614 100644 --- a/src/generated/DeviceAppManagement/MobileApps/MobileAppsRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/MobileApps/MobileAppsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class MobileAppsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MobileAppRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAssignCommand(), - builder.BuildAssignmentsCommand(), - builder.BuildCategoriesCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAssignCommand()); + commands.Add(builder.BuildAssignmentsCommand()); + commands.Add(builder.BuildCategoriesCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -43,21 +42,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -102,7 +100,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -113,15 +115,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -176,31 +173,6 @@ public RequestInformation CreatePostRequestInformation(MobileApp body, Action - /// The mobile apps. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The mobile apps. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MobileApp model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The mobile apps. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/SyncMicrosoftStoreForBusinessApps/SyncMicrosoftStoreForBusinessAppsRequestBuilder.cs b/src/generated/DeviceAppManagement/SyncMicrosoftStoreForBusinessApps/SyncMicrosoftStoreForBusinessAppsRequestBuilder.cs index 5ee1864f6b7..7ea7f7cd2f5 100644 --- a/src/generated/DeviceAppManagement/SyncMicrosoftStoreForBusinessApps/SyncMicrosoftStoreForBusinessAppsRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/SyncMicrosoftStoreForBusinessApps/SyncMicrosoftStoreForBusinessAppsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,11 +25,10 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Syncs Intune account with Microsoft Store For Business"; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -62,16 +61,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Syncs Intune account with Microsoft Store For Business - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/Apps/AppsRequestBuilder.cs b/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/Apps/AppsRequestBuilder.cs index 8ee4fa50b53..871a7182927 100644 --- a/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/Apps/AppsRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/Apps/AppsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AppsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ManagedMobileAppRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "List of apps to which the policy is deployed."; // Create options for all the parameters - var targetedManagedAppConfigurationIdOption = new Option("--targetedmanagedappconfiguration-id", description: "key: id of targetedManagedAppConfiguration") { + var targetedManagedAppConfigurationIdOption = new Option("--targeted-managed-app-configuration-id", description: "key: id of targetedManagedAppConfiguration") { }; targetedManagedAppConfigurationIdOption.IsRequired = true; command.AddOption(targetedManagedAppConfigurationIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string targetedManagedAppConfigurationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string targetedManagedAppConfigurationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, targetedManagedAppConfigurationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, targetedManagedAppConfigurationIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "List of apps to which the policy is deployed."; // Create options for all the parameters - var targetedManagedAppConfigurationIdOption = new Option("--targetedmanagedappconfiguration-id", description: "key: id of targetedManagedAppConfiguration") { + var targetedManagedAppConfigurationIdOption = new Option("--targeted-managed-app-configuration-id", description: "key: id of targetedManagedAppConfiguration") { }; targetedManagedAppConfigurationIdOption.IsRequired = true; command.AddOption(targetedManagedAppConfigurationIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string targetedManagedAppConfigurationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string targetedManagedAppConfigurationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, targetedManagedAppConfigurationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, targetedManagedAppConfigurationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ManagedMobileApp body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of apps to which the policy is deployed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of apps to which the policy is deployed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ManagedMobileApp model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// List of apps to which the policy is deployed. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/Apps/Item/ManagedMobileAppRequestBuilder.cs b/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/Apps/Item/ManagedMobileAppRequestBuilder.cs index 42b2b80729b..423102d2f9e 100644 --- a/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/Apps/Item/ManagedMobileAppRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/Apps/Item/ManagedMobileAppRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "List of apps to which the policy is deployed."; // Create options for all the parameters - var targetedManagedAppConfigurationIdOption = new Option("--targetedmanagedappconfiguration-id", description: "key: id of targetedManagedAppConfiguration") { + var targetedManagedAppConfigurationIdOption = new Option("--targeted-managed-app-configuration-id", description: "key: id of targetedManagedAppConfiguration") { }; targetedManagedAppConfigurationIdOption.IsRequired = true; command.AddOption(targetedManagedAppConfigurationIdOption); - var managedMobileAppIdOption = new Option("--managedmobileapp-id", description: "key: id of managedMobileApp") { + var managedMobileAppIdOption = new Option("--managed-mobile-app-id", description: "key: id of managedMobileApp") { }; managedMobileAppIdOption.IsRequired = true; command.AddOption(managedMobileAppIdOption); - command.SetHandler(async (string targetedManagedAppConfigurationId, string managedMobileAppId) => { + command.SetHandler(async (string targetedManagedAppConfigurationId, string managedMobileAppId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, targetedManagedAppConfigurationIdOption, managedMobileAppIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "List of apps to which the policy is deployed."; // Create options for all the parameters - var targetedManagedAppConfigurationIdOption = new Option("--targetedmanagedappconfiguration-id", description: "key: id of targetedManagedAppConfiguration") { + var targetedManagedAppConfigurationIdOption = new Option("--targeted-managed-app-configuration-id", description: "key: id of targetedManagedAppConfiguration") { }; targetedManagedAppConfigurationIdOption.IsRequired = true; command.AddOption(targetedManagedAppConfigurationIdOption); - var managedMobileAppIdOption = new Option("--managedmobileapp-id", description: "key: id of managedMobileApp") { + var managedMobileAppIdOption = new Option("--managed-mobile-app-id", description: "key: id of managedMobileApp") { }; managedMobileAppIdOption.IsRequired = true; command.AddOption(managedMobileAppIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string targetedManagedAppConfigurationId, string managedMobileAppId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string targetedManagedAppConfigurationId, string managedMobileAppId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, targetedManagedAppConfigurationIdOption, managedMobileAppIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, targetedManagedAppConfigurationIdOption, managedMobileAppIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "List of apps to which the policy is deployed."; // Create options for all the parameters - var targetedManagedAppConfigurationIdOption = new Option("--targetedmanagedappconfiguration-id", description: "key: id of targetedManagedAppConfiguration") { + var targetedManagedAppConfigurationIdOption = new Option("--targeted-managed-app-configuration-id", description: "key: id of targetedManagedAppConfiguration") { }; targetedManagedAppConfigurationIdOption.IsRequired = true; command.AddOption(targetedManagedAppConfigurationIdOption); - var managedMobileAppIdOption = new Option("--managedmobileapp-id", description: "key: id of managedMobileApp") { + var managedMobileAppIdOption = new Option("--managed-mobile-app-id", description: "key: id of managedMobileApp") { }; managedMobileAppIdOption.IsRequired = true; command.AddOption(managedMobileAppIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string targetedManagedAppConfigurationId, string managedMobileAppId, string body) => { + command.SetHandler(async (string targetedManagedAppConfigurationId, string managedMobileAppId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, targetedManagedAppConfigurationIdOption, managedMobileAppIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ManagedMobileApp body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of apps to which the policy is deployed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of apps to which the policy is deployed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of apps to which the policy is deployed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ManagedMobileApp model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// List of apps to which the policy is deployed. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/Assign/AssignRequestBuilder.cs b/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/Assign/AssignRequestBuilder.cs index ad8b9feb871..f63f0b51a29 100644 --- a/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/Assign/AssignRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/Assign/AssignRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action assign"; // Create options for all the parameters - var targetedManagedAppConfigurationIdOption = new Option("--targetedmanagedappconfiguration-id", description: "key: id of targetedManagedAppConfiguration") { + var targetedManagedAppConfigurationIdOption = new Option("--targeted-managed-app-configuration-id", description: "key: id of targetedManagedAppConfiguration") { }; targetedManagedAppConfigurationIdOption.IsRequired = true; command.AddOption(targetedManagedAppConfigurationIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string targetedManagedAppConfigurationId, string body) => { + command.SetHandler(async (string targetedManagedAppConfigurationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, targetedManagedAppConfigurationIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/Assignments/AssignmentsRequestBuilder.cs b/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/Assignments/AssignmentsRequestBuilder.cs index dcbb532c28a..16d35b9f621 100644 --- a/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/Assignments/AssignmentsRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/Assignments/AssignmentsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AssignmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TargetedManagedAppPolicyAssignmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Navigation property to list of inclusion and exclusion groups to which the policy is deployed."; // Create options for all the parameters - var targetedManagedAppConfigurationIdOption = new Option("--targetedmanagedappconfiguration-id", description: "key: id of targetedManagedAppConfiguration") { + var targetedManagedAppConfigurationIdOption = new Option("--targeted-managed-app-configuration-id", description: "key: id of targetedManagedAppConfiguration") { }; targetedManagedAppConfigurationIdOption.IsRequired = true; command.AddOption(targetedManagedAppConfigurationIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string targetedManagedAppConfigurationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string targetedManagedAppConfigurationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, targetedManagedAppConfigurationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, targetedManagedAppConfigurationIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Navigation property to list of inclusion and exclusion groups to which the policy is deployed."; // Create options for all the parameters - var targetedManagedAppConfigurationIdOption = new Option("--targetedmanagedappconfiguration-id", description: "key: id of targetedManagedAppConfiguration") { + var targetedManagedAppConfigurationIdOption = new Option("--targeted-managed-app-configuration-id", description: "key: id of targetedManagedAppConfiguration") { }; targetedManagedAppConfigurationIdOption.IsRequired = true; command.AddOption(targetedManagedAppConfigurationIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string targetedManagedAppConfigurationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string targetedManagedAppConfigurationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, targetedManagedAppConfigurationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, targetedManagedAppConfigurationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(TargetedManagedAppPolicyA requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Navigation property to list of inclusion and exclusion groups to which the policy is deployed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Navigation property to list of inclusion and exclusion groups to which the policy is deployed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetedManagedAppPolicyAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Navigation property to list of inclusion and exclusion groups to which the policy is deployed. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/Assignments/Item/TargetedManagedAppPolicyAssignmentRequestBuilder.cs b/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/Assignments/Item/TargetedManagedAppPolicyAssignmentRequestBuilder.cs index 6bb6e292fca..fca26995010 100644 --- a/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/Assignments/Item/TargetedManagedAppPolicyAssignmentRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/Assignments/Item/TargetedManagedAppPolicyAssignmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Navigation property to list of inclusion and exclusion groups to which the policy is deployed."; // Create options for all the parameters - var targetedManagedAppConfigurationIdOption = new Option("--targetedmanagedappconfiguration-id", description: "key: id of targetedManagedAppConfiguration") { + var targetedManagedAppConfigurationIdOption = new Option("--targeted-managed-app-configuration-id", description: "key: id of targetedManagedAppConfiguration") { }; targetedManagedAppConfigurationIdOption.IsRequired = true; command.AddOption(targetedManagedAppConfigurationIdOption); - var targetedManagedAppPolicyAssignmentIdOption = new Option("--targetedmanagedapppolicyassignment-id", description: "key: id of targetedManagedAppPolicyAssignment") { + var targetedManagedAppPolicyAssignmentIdOption = new Option("--targeted-managed-app-policy-assignment-id", description: "key: id of targetedManagedAppPolicyAssignment") { }; targetedManagedAppPolicyAssignmentIdOption.IsRequired = true; command.AddOption(targetedManagedAppPolicyAssignmentIdOption); - command.SetHandler(async (string targetedManagedAppConfigurationId, string targetedManagedAppPolicyAssignmentId) => { + command.SetHandler(async (string targetedManagedAppConfigurationId, string targetedManagedAppPolicyAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, targetedManagedAppConfigurationIdOption, targetedManagedAppPolicyAssignmentIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Navigation property to list of inclusion and exclusion groups to which the policy is deployed."; // Create options for all the parameters - var targetedManagedAppConfigurationIdOption = new Option("--targetedmanagedappconfiguration-id", description: "key: id of targetedManagedAppConfiguration") { + var targetedManagedAppConfigurationIdOption = new Option("--targeted-managed-app-configuration-id", description: "key: id of targetedManagedAppConfiguration") { }; targetedManagedAppConfigurationIdOption.IsRequired = true; command.AddOption(targetedManagedAppConfigurationIdOption); - var targetedManagedAppPolicyAssignmentIdOption = new Option("--targetedmanagedapppolicyassignment-id", description: "key: id of targetedManagedAppPolicyAssignment") { + var targetedManagedAppPolicyAssignmentIdOption = new Option("--targeted-managed-app-policy-assignment-id", description: "key: id of targetedManagedAppPolicyAssignment") { }; targetedManagedAppPolicyAssignmentIdOption.IsRequired = true; command.AddOption(targetedManagedAppPolicyAssignmentIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string targetedManagedAppConfigurationId, string targetedManagedAppPolicyAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string targetedManagedAppConfigurationId, string targetedManagedAppPolicyAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, targetedManagedAppConfigurationIdOption, targetedManagedAppPolicyAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, targetedManagedAppConfigurationIdOption, targetedManagedAppPolicyAssignmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Navigation property to list of inclusion and exclusion groups to which the policy is deployed."; // Create options for all the parameters - var targetedManagedAppConfigurationIdOption = new Option("--targetedmanagedappconfiguration-id", description: "key: id of targetedManagedAppConfiguration") { + var targetedManagedAppConfigurationIdOption = new Option("--targeted-managed-app-configuration-id", description: "key: id of targetedManagedAppConfiguration") { }; targetedManagedAppConfigurationIdOption.IsRequired = true; command.AddOption(targetedManagedAppConfigurationIdOption); - var targetedManagedAppPolicyAssignmentIdOption = new Option("--targetedmanagedapppolicyassignment-id", description: "key: id of targetedManagedAppPolicyAssignment") { + var targetedManagedAppPolicyAssignmentIdOption = new Option("--targeted-managed-app-policy-assignment-id", description: "key: id of targetedManagedAppPolicyAssignment") { }; targetedManagedAppPolicyAssignmentIdOption.IsRequired = true; command.AddOption(targetedManagedAppPolicyAssignmentIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string targetedManagedAppConfigurationId, string targetedManagedAppPolicyAssignmentId, string body) => { + command.SetHandler(async (string targetedManagedAppConfigurationId, string targetedManagedAppPolicyAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, targetedManagedAppConfigurationIdOption, targetedManagedAppPolicyAssignmentIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(TargetedManagedAppPolicy requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Navigation property to list of inclusion and exclusion groups to which the policy is deployed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Navigation property to list of inclusion and exclusion groups to which the policy is deployed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Navigation property to list of inclusion and exclusion groups to which the policy is deployed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(TargetedManagedAppPolicyAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Navigation property to list of inclusion and exclusion groups to which the policy is deployed. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/DeploymentSummary/DeploymentSummaryRequestBuilder.cs b/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/DeploymentSummary/DeploymentSummaryRequestBuilder.cs index dbe0f24eb33..9dd4d008c19 100644 --- a/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/DeploymentSummary/DeploymentSummaryRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/DeploymentSummary/DeploymentSummaryRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Navigation property to deployment summary of the configuration."; // Create options for all the parameters - var targetedManagedAppConfigurationIdOption = new Option("--targetedmanagedappconfiguration-id", description: "key: id of targetedManagedAppConfiguration") { + var targetedManagedAppConfigurationIdOption = new Option("--targeted-managed-app-configuration-id", description: "key: id of targetedManagedAppConfiguration") { }; targetedManagedAppConfigurationIdOption.IsRequired = true; command.AddOption(targetedManagedAppConfigurationIdOption); - command.SetHandler(async (string targetedManagedAppConfigurationId) => { + command.SetHandler(async (string targetedManagedAppConfigurationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, targetedManagedAppConfigurationIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Navigation property to deployment summary of the configuration."; // Create options for all the parameters - var targetedManagedAppConfigurationIdOption = new Option("--targetedmanagedappconfiguration-id", description: "key: id of targetedManagedAppConfiguration") { + var targetedManagedAppConfigurationIdOption = new Option("--targeted-managed-app-configuration-id", description: "key: id of targetedManagedAppConfiguration") { }; targetedManagedAppConfigurationIdOption.IsRequired = true; command.AddOption(targetedManagedAppConfigurationIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string targetedManagedAppConfigurationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string targetedManagedAppConfigurationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, targetedManagedAppConfigurationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, targetedManagedAppConfigurationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Navigation property to deployment summary of the configuration."; // Create options for all the parameters - var targetedManagedAppConfigurationIdOption = new Option("--targetedmanagedappconfiguration-id", description: "key: id of targetedManagedAppConfiguration") { + var targetedManagedAppConfigurationIdOption = new Option("--targeted-managed-app-configuration-id", description: "key: id of targetedManagedAppConfiguration") { }; targetedManagedAppConfigurationIdOption.IsRequired = true; command.AddOption(targetedManagedAppConfigurationIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string targetedManagedAppConfigurationId, string body) => { + command.SetHandler(async (string targetedManagedAppConfigurationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, targetedManagedAppConfigurationIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ManagedAppPolicyDeployme requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Navigation property to deployment summary of the configuration. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Navigation property to deployment summary of the configuration. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Navigation property to deployment summary of the configuration. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ManagedAppPolicyDeploymentSummary model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Navigation property to deployment summary of the configuration. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/TargetApps/TargetAppsRequestBuilder.cs b/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/TargetApps/TargetAppsRequestBuilder.cs index e2ca589f152..09dd14c824d 100644 --- a/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/TargetApps/TargetAppsRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/TargetApps/TargetAppsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action targetApps"; // Create options for all the parameters - var targetedManagedAppConfigurationIdOption = new Option("--targetedmanagedappconfiguration-id", description: "key: id of targetedManagedAppConfiguration") { + var targetedManagedAppConfigurationIdOption = new Option("--targeted-managed-app-configuration-id", description: "key: id of targetedManagedAppConfiguration") { }; targetedManagedAppConfigurationIdOption.IsRequired = true; command.AddOption(targetedManagedAppConfigurationIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string targetedManagedAppConfigurationId, string body) => { + command.SetHandler(async (string targetedManagedAppConfigurationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, targetedManagedAppConfigurationIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(TargetAppsRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action targetApps - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetAppsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/TargetedManagedAppConfigurationRequestBuilder.cs b/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/TargetedManagedAppConfigurationRequestBuilder.cs index f52946d6caf..d34a3ee56c7 100644 --- a/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/TargetedManagedAppConfigurationRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/Item/TargetedManagedAppConfigurationRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,6 +27,9 @@ public class TargetedManagedAppConfigurationRequestBuilder { public Command BuildAppsCommand() { var command = new Command("apps"); var builder = new ApiSdk.DeviceAppManagement.TargetedManagedAppConfigurations.Item.Apps.AppsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -40,6 +43,9 @@ public Command BuildAssignCommand() { public Command BuildAssignmentsCommand() { var command = new Command("assignments"); var builder = new ApiSdk.DeviceAppManagement.TargetedManagedAppConfigurations.Item.Assignments.AssignmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -51,15 +57,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Targeted managed app configurations."; // Create options for all the parameters - var targetedManagedAppConfigurationIdOption = new Option("--targetedmanagedappconfiguration-id", description: "key: id of targetedManagedAppConfiguration") { + var targetedManagedAppConfigurationIdOption = new Option("--targeted-managed-app-configuration-id", description: "key: id of targetedManagedAppConfiguration") { }; targetedManagedAppConfigurationIdOption.IsRequired = true; command.AddOption(targetedManagedAppConfigurationIdOption); - command.SetHandler(async (string targetedManagedAppConfigurationId) => { + command.SetHandler(async (string targetedManagedAppConfigurationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, targetedManagedAppConfigurationIdOption); return command; @@ -79,7 +84,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Targeted managed app configurations."; // Create options for all the parameters - var targetedManagedAppConfigurationIdOption = new Option("--targetedmanagedappconfiguration-id", description: "key: id of targetedManagedAppConfiguration") { + var targetedManagedAppConfigurationIdOption = new Option("--targeted-managed-app-configuration-id", description: "key: id of targetedManagedAppConfiguration") { }; targetedManagedAppConfigurationIdOption.IsRequired = true; command.AddOption(targetedManagedAppConfigurationIdOption); @@ -93,20 +98,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string targetedManagedAppConfigurationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string targetedManagedAppConfigurationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, targetedManagedAppConfigurationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, targetedManagedAppConfigurationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -116,7 +120,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Targeted managed app configurations."; // Create options for all the parameters - var targetedManagedAppConfigurationIdOption = new Option("--targetedmanagedappconfiguration-id", description: "key: id of targetedManagedAppConfiguration") { + var targetedManagedAppConfigurationIdOption = new Option("--targeted-managed-app-configuration-id", description: "key: id of targetedManagedAppConfiguration") { }; targetedManagedAppConfigurationIdOption.IsRequired = true; command.AddOption(targetedManagedAppConfigurationIdOption); @@ -124,14 +128,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string targetedManagedAppConfigurationId, string body) => { + command.SetHandler(async (string targetedManagedAppConfigurationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, targetedManagedAppConfigurationIdOption, bodyOption); return command; @@ -209,42 +212,6 @@ public RequestInformation CreatePatchRequestInformation(TargetedManagedAppConfig requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Targeted managed app configurations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Targeted managed app configurations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Targeted managed app configurations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(TargetedManagedAppConfiguration model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Targeted managed app configurations. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/TargetedManagedAppConfigurationsRequestBuilder.cs b/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/TargetedManagedAppConfigurationsRequestBuilder.cs index d550f9df168..dd4f2854705 100644 --- a/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/TargetedManagedAppConfigurationsRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/TargetedManagedAppConfigurations/TargetedManagedAppConfigurationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class TargetedManagedAppConfigurationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TargetedManagedAppConfigurationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAppsCommand(), - builder.BuildAssignCommand(), - builder.BuildAssignmentsCommand(), - builder.BuildDeleteCommand(), - builder.BuildDeploymentSummaryCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildTargetAppsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAppsCommand()); + commands.Add(builder.BuildAssignCommand()); + commands.Add(builder.BuildAssignmentsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDeploymentSummaryCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildTargetAppsCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -104,7 +102,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -115,15 +117,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -178,31 +175,6 @@ public RequestInformation CreatePostRequestInformation(TargetedManagedAppConfigu requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Targeted managed app configurations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Targeted managed app configurations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetedManagedAppConfiguration model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Targeted managed app configurations. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/VppTokens/Item/SyncLicenses/SyncLicensesRequestBuilder.cs b/src/generated/DeviceAppManagement/VppTokens/Item/SyncLicenses/SyncLicensesRequestBuilder.cs index ae2ea05b096..b31d7206b78 100644 --- a/src/generated/DeviceAppManagement/VppTokens/Item/SyncLicenses/SyncLicensesRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/VppTokens/Item/SyncLicenses/SyncLicensesRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Syncs licenses associated with a specific appleVolumePurchaseProgramToken"; // Create options for all the parameters - var vppTokenIdOption = new Option("--vpptoken-id", description: "key: id of vppToken") { + var vppTokenIdOption = new Option("--vpp-token-id", description: "key: id of vppToken") { }; vppTokenIdOption.IsRequired = true; command.AddOption(vppTokenIdOption); - command.SetHandler(async (string vppTokenId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string vppTokenId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, vppTokenIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, vppTokenIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Syncs licenses associated with a specific appleVolumePurchaseProgramToken - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes vppToken public class SyncLicensesResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/DeviceAppManagement/VppTokens/Item/VppTokenRequestBuilder.cs b/src/generated/DeviceAppManagement/VppTokens/Item/VppTokenRequestBuilder.cs index ee4116be08d..4697b065e34 100644 --- a/src/generated/DeviceAppManagement/VppTokens/Item/VppTokenRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/VppTokens/Item/VppTokenRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,15 +27,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "List of Vpp tokens for this organization."; // Create options for all the parameters - var vppTokenIdOption = new Option("--vpptoken-id", description: "key: id of vppToken") { + var vppTokenIdOption = new Option("--vpp-token-id", description: "key: id of vppToken") { }; vppTokenIdOption.IsRequired = true; command.AddOption(vppTokenIdOption); - command.SetHandler(async (string vppTokenId) => { + command.SetHandler(async (string vppTokenId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, vppTokenIdOption); return command; @@ -47,7 +46,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "List of Vpp tokens for this organization."; // Create options for all the parameters - var vppTokenIdOption = new Option("--vpptoken-id", description: "key: id of vppToken") { + var vppTokenIdOption = new Option("--vpp-token-id", description: "key: id of vppToken") { }; vppTokenIdOption.IsRequired = true; command.AddOption(vppTokenIdOption); @@ -61,20 +60,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string vppTokenId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string vppTokenId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, vppTokenIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, vppTokenIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "List of Vpp tokens for this organization."; // Create options for all the parameters - var vppTokenIdOption = new Option("--vpptoken-id", description: "key: id of vppToken") { + var vppTokenIdOption = new Option("--vpp-token-id", description: "key: id of vppToken") { }; vppTokenIdOption.IsRequired = true; command.AddOption(vppTokenIdOption); @@ -92,14 +90,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string vppTokenId, string body) => { + command.SetHandler(async (string vppTokenId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, vppTokenIdOption, bodyOption); return command; @@ -177,42 +174,6 @@ public RequestInformation CreatePatchRequestInformation(VppToken body, Action - /// List of Vpp tokens for this organization. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of Vpp tokens for this organization. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of Vpp tokens for this organization. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(VppToken model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// List of Vpp tokens for this organization. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/VppTokens/VppTokensRequestBuilder.cs b/src/generated/DeviceAppManagement/VppTokens/VppTokensRequestBuilder.cs index 39c59898523..455c93d1dfd 100644 --- a/src/generated/DeviceAppManagement/VppTokens/VppTokensRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/VppTokens/VppTokensRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class VppTokensRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new VppTokenRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSyncLicensesCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSyncLicensesCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(VppToken body, Action - /// List of Vpp tokens for this organization. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of Vpp tokens for this organization. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(VppToken model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// List of Vpp tokens for this organization. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceAppManagement/WindowsInformationProtectionPolicies/Item/WindowsInformationProtectionPolicyRequestBuilder.cs b/src/generated/DeviceAppManagement/WindowsInformationProtectionPolicies/Item/WindowsInformationProtectionPolicyRequestBuilder.cs index 4a3d1cc0de1..a687f97c8e9 100644 --- a/src/generated/DeviceAppManagement/WindowsInformationProtectionPolicies/Item/WindowsInformationProtectionPolicyRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/WindowsInformationProtectionPolicies/Item/WindowsInformationProtectionPolicyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Windows information protection for apps running on devices which are not MDM enrolled."; // Create options for all the parameters - var windowsInformationProtectionPolicyIdOption = new Option("--windowsinformationprotectionpolicy-id", description: "key: id of windowsInformationProtectionPolicy") { + var windowsInformationProtectionPolicyIdOption = new Option("--windows-information-protection-policy-id", description: "key: id of windowsInformationProtectionPolicy") { }; windowsInformationProtectionPolicyIdOption.IsRequired = true; command.AddOption(windowsInformationProtectionPolicyIdOption); - command.SetHandler(async (string windowsInformationProtectionPolicyId) => { + command.SetHandler(async (string windowsInformationProtectionPolicyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, windowsInformationProtectionPolicyIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Windows information protection for apps running on devices which are not MDM enrolled."; // Create options for all the parameters - var windowsInformationProtectionPolicyIdOption = new Option("--windowsinformationprotectionpolicy-id", description: "key: id of windowsInformationProtectionPolicy") { + var windowsInformationProtectionPolicyIdOption = new Option("--windows-information-protection-policy-id", description: "key: id of windowsInformationProtectionPolicy") { }; windowsInformationProtectionPolicyIdOption.IsRequired = true; command.AddOption(windowsInformationProtectionPolicyIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string windowsInformationProtectionPolicyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string windowsInformationProtectionPolicyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, windowsInformationProtectionPolicyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, windowsInformationProtectionPolicyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Windows information protection for apps running on devices which are not MDM enrolled."; // Create options for all the parameters - var windowsInformationProtectionPolicyIdOption = new Option("--windowsinformationprotectionpolicy-id", description: "key: id of windowsInformationProtectionPolicy") { + var windowsInformationProtectionPolicyIdOption = new Option("--windows-information-protection-policy-id", description: "key: id of windowsInformationProtectionPolicy") { }; windowsInformationProtectionPolicyIdOption.IsRequired = true; command.AddOption(windowsInformationProtectionPolicyIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string windowsInformationProtectionPolicyId, string body) => { + command.SetHandler(async (string windowsInformationProtectionPolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, windowsInformationProtectionPolicyIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(WindowsInformationProtec requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Windows information protection for apps running on devices which are not MDM enrolled. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Windows information protection for apps running on devices which are not MDM enrolled. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Windows information protection for apps running on devices which are not MDM enrolled. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WindowsInformationProtectionPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Windows information protection for apps running on devices which are not MDM enrolled. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceAppManagement/WindowsInformationProtectionPolicies/WindowsInformationProtectionPoliciesRequestBuilder.cs b/src/generated/DeviceAppManagement/WindowsInformationProtectionPolicies/WindowsInformationProtectionPoliciesRequestBuilder.cs index e2238aec2db..e4e22ce9f32 100644 --- a/src/generated/DeviceAppManagement/WindowsInformationProtectionPolicies/WindowsInformationProtectionPoliciesRequestBuilder.cs +++ b/src/generated/DeviceAppManagement/WindowsInformationProtectionPolicies/WindowsInformationProtectionPoliciesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class WindowsInformationProtectionPoliciesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new WindowsInformationProtectionPolicyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(WindowsInformationProtect requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Windows information protection for apps running on devices which are not MDM enrolled. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Windows information protection for apps running on devices which are not MDM enrolled. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WindowsInformationProtectionPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Windows information protection for apps running on devices which are not MDM enrolled. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/ApplePushNotificationCertificate/ApplePushNotificationCertificateRequestBuilder.cs b/src/generated/DeviceManagement/ApplePushNotificationCertificate/ApplePushNotificationCertificateRequestBuilder.cs index 0763c862497..e19f8ababcb 100644 --- a/src/generated/DeviceManagement/ApplePushNotificationCertificate/ApplePushNotificationCertificateRequestBuilder.cs +++ b/src/generated/DeviceManagement/ApplePushNotificationCertificate/ApplePushNotificationCertificateRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,11 +27,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Apple push notification certificate."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -53,20 +52,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -80,14 +78,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -160,47 +157,11 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. return requestInfo; } /// - /// Apple push notification certificate. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \deviceManagement\applePushNotificationCertificate\microsoft.graph.downloadApplePushNotificationCertificateSigningRequest() /// public DownloadApplePushNotificationCertificateSigningRequestRequestBuilder DownloadApplePushNotificationCertificateSigningRequest() { return new DownloadApplePushNotificationCertificateSigningRequestRequestBuilder(PathParameters, RequestAdapter); } - /// - /// Apple push notification certificate. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Apple push notification certificate. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.ApplePushNotificationCertificate model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Apple push notification certificate. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/ApplePushNotificationCertificate/DownloadApplePushNotificationCertificateSigningRequest/DownloadApplePushNotificationCertificateSigningRequestRequestBuilder.cs b/src/generated/DeviceManagement/ApplePushNotificationCertificate/DownloadApplePushNotificationCertificateSigningRequest/DownloadApplePushNotificationCertificateSigningRequestRequestBuilder.cs index 9563d3dfaf7..256a7b9425f 100644 --- a/src/generated/DeviceManagement/ApplePushNotificationCertificate/DownloadApplePushNotificationCertificateSigningRequest/DownloadApplePushNotificationCertificateSigningRequestRequestBuilder.cs +++ b/src/generated/DeviceManagement/ApplePushNotificationCertificate/DownloadApplePushNotificationCertificateSigningRequest/DownloadApplePushNotificationCertificateSigningRequestRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Download Apple push notification certificate signing request"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Download Apple push notification certificate signing request - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/ComplianceManagementPartners/ComplianceManagementPartnersRequestBuilder.cs b/src/generated/DeviceManagement/ComplianceManagementPartners/ComplianceManagementPartnersRequestBuilder.cs index a270763497e..73e7a3e7b3c 100644 --- a/src/generated/DeviceManagement/ComplianceManagementPartners/ComplianceManagementPartnersRequestBuilder.cs +++ b/src/generated/DeviceManagement/ComplianceManagementPartners/ComplianceManagementPartnersRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ComplianceManagementPartnersRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ComplianceManagementPartnerRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(ComplianceManagementPartn requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of Compliance Management Partners configured by the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of Compliance Management Partners configured by the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ComplianceManagementPartner model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of Compliance Management Partners configured by the tenant. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/ComplianceManagementPartners/Item/ComplianceManagementPartnerRequestBuilder.cs b/src/generated/DeviceManagement/ComplianceManagementPartners/Item/ComplianceManagementPartnerRequestBuilder.cs index 91924397646..d4497dd26fa 100644 --- a/src/generated/DeviceManagement/ComplianceManagementPartners/Item/ComplianceManagementPartnerRequestBuilder.cs +++ b/src/generated/DeviceManagement/ComplianceManagementPartners/Item/ComplianceManagementPartnerRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of Compliance Management Partners configured by the tenant."; // Create options for all the parameters - var complianceManagementPartnerIdOption = new Option("--compliancemanagementpartner-id", description: "key: id of complianceManagementPartner") { + var complianceManagementPartnerIdOption = new Option("--compliance-management-partner-id", description: "key: id of complianceManagementPartner") { }; complianceManagementPartnerIdOption.IsRequired = true; command.AddOption(complianceManagementPartnerIdOption); - command.SetHandler(async (string complianceManagementPartnerId) => { + command.SetHandler(async (string complianceManagementPartnerId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, complianceManagementPartnerIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of Compliance Management Partners configured by the tenant."; // Create options for all the parameters - var complianceManagementPartnerIdOption = new Option("--compliancemanagementpartner-id", description: "key: id of complianceManagementPartner") { + var complianceManagementPartnerIdOption = new Option("--compliance-management-partner-id", description: "key: id of complianceManagementPartner") { }; complianceManagementPartnerIdOption.IsRequired = true; command.AddOption(complianceManagementPartnerIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string complianceManagementPartnerId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string complianceManagementPartnerId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, complianceManagementPartnerIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, complianceManagementPartnerIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of Compliance Management Partners configured by the tenant."; // Create options for all the parameters - var complianceManagementPartnerIdOption = new Option("--compliancemanagementpartner-id", description: "key: id of complianceManagementPartner") { + var complianceManagementPartnerIdOption = new Option("--compliance-management-partner-id", description: "key: id of complianceManagementPartner") { }; complianceManagementPartnerIdOption.IsRequired = true; command.AddOption(complianceManagementPartnerIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string complianceManagementPartnerId, string body) => { + command.SetHandler(async (string complianceManagementPartnerId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, complianceManagementPartnerIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ComplianceManagementPart requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of Compliance Management Partners configured by the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of Compliance Management Partners configured by the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of Compliance Management Partners configured by the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ComplianceManagementPartner model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of Compliance Management Partners configured by the tenant. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/ConditionalAccessSettings/ConditionalAccessSettingsRequestBuilder.cs b/src/generated/DeviceManagement/ConditionalAccessSettings/ConditionalAccessSettingsRequestBuilder.cs index b91a0a32957..f39f806eac1 100644 --- a/src/generated/DeviceManagement/ConditionalAccessSettings/ConditionalAccessSettingsRequestBuilder.cs +++ b/src/generated/DeviceManagement/ConditionalAccessSettings/ConditionalAccessSettingsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The Exchange on premises conditional access settings. On premises conditional access will require devices to be both enrolled and compliant for mail access"; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -52,20 +51,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -79,14 +77,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -158,42 +155,6 @@ public RequestInformation CreatePatchRequestInformation(OnPremisesConditionalAcc requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The Exchange on premises conditional access settings. On premises conditional access will require devices to be both enrolled and compliant for mail access - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Exchange on premises conditional access settings. On premises conditional access will require devices to be both enrolled and compliant for mail access - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Exchange on premises conditional access settings. On premises conditional access will require devices to be both enrolled and compliant for mail access - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnPremisesConditionalAccessSettings model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The Exchange on premises conditional access settings. On premises conditional access will require devices to be both enrolled and compliant for mail access public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/DetectedApps/DetectedAppsRequestBuilder.cs b/src/generated/DeviceManagement/DetectedApps/DetectedAppsRequestBuilder.cs index e2a29b15996..cee2fedbde7 100644 --- a/src/generated/DeviceManagement/DetectedApps/DetectedAppsRequestBuilder.cs +++ b/src/generated/DeviceManagement/DetectedApps/DetectedAppsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class DetectedAppsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DetectedAppRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildManagedDevicesCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildManagedDevicesCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(DetectedApp body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of detected apps associated with a device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of detected apps associated with a device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DetectedApp model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of detected apps associated with a device. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/DetectedApps/Item/DetectedAppRequestBuilder.cs b/src/generated/DeviceManagement/DetectedApps/Item/DetectedAppRequestBuilder.cs index cab3f5bdf46..454528482dd 100644 --- a/src/generated/DeviceManagement/DetectedApps/Item/DetectedAppRequestBuilder.cs +++ b/src/generated/DeviceManagement/DetectedApps/Item/DetectedAppRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,15 +27,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of detected apps associated with a device."; // Create options for all the parameters - var detectedAppIdOption = new Option("--detectedapp-id", description: "key: id of detectedApp") { + var detectedAppIdOption = new Option("--detected-app-id", description: "key: id of detectedApp") { }; detectedAppIdOption.IsRequired = true; command.AddOption(detectedAppIdOption); - command.SetHandler(async (string detectedAppId) => { + command.SetHandler(async (string detectedAppId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, detectedAppIdOption); return command; @@ -47,7 +46,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of detected apps associated with a device."; // Create options for all the parameters - var detectedAppIdOption = new Option("--detectedapp-id", description: "key: id of detectedApp") { + var detectedAppIdOption = new Option("--detected-app-id", description: "key: id of detectedApp") { }; detectedAppIdOption.IsRequired = true; command.AddOption(detectedAppIdOption); @@ -61,20 +60,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string detectedAppId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string detectedAppId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, detectedAppIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, detectedAppIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildManagedDevicesCommand() { @@ -91,7 +89,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of detected apps associated with a device."; // Create options for all the parameters - var detectedAppIdOption = new Option("--detectedapp-id", description: "key: id of detectedApp") { + var detectedAppIdOption = new Option("--detected-app-id", description: "key: id of detectedApp") { }; detectedAppIdOption.IsRequired = true; command.AddOption(detectedAppIdOption); @@ -99,14 +97,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string detectedAppId, string body) => { + command.SetHandler(async (string detectedAppId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, detectedAppIdOption, bodyOption); return command; @@ -178,42 +175,6 @@ public RequestInformation CreatePatchRequestInformation(DetectedApp body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of detected apps associated with a device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of detected apps associated with a device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of detected apps associated with a device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DetectedApp model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of detected apps associated with a device. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/DetectedApps/Item/ManagedDevices/@Ref/@Ref.cs b/src/generated/DeviceManagement/DetectedApps/Item/ManagedDevices/@Ref/@Ref.cs deleted file mode 100644 index b81f635c318..00000000000 --- a/src/generated/DeviceManagement/DetectedApps/Item/ManagedDevices/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.DeviceManagement.DetectedApps.Item.ManagedDevices.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/DeviceManagement/DetectedApps/Item/ManagedDevices/@Ref/RefRequestBuilder.cs b/src/generated/DeviceManagement/DetectedApps/Item/ManagedDevices/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 7e969d4a410..00000000000 --- a/src/generated/DeviceManagement/DetectedApps/Item/ManagedDevices/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.DeviceManagement.DetectedApps.Item.ManagedDevices.@Ref { - /// Builds and executes requests for operations under \deviceManagement\detectedApps\{detectedApp-id}\managedDevices\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The devices that have the discovered application installed - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The devices that have the discovered application installed"; - // Create options for all the parameters - var detectedAppIdOption = new Option("--detectedapp-id", description: "key: id of detectedApp") { - }; - detectedAppIdOption.IsRequired = true; - command.AddOption(detectedAppIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string detectedAppId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, detectedAppIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The devices that have the discovered application installed - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The devices that have the discovered application installed"; - // Create options for all the parameters - var detectedAppIdOption = new Option("--detectedapp-id", description: "key: id of detectedApp") { - }; - detectedAppIdOption.IsRequired = true; - command.AddOption(detectedAppIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string detectedAppId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, detectedAppIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/deviceManagement/detectedApps/{detectedApp_id}/managedDevices/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The devices that have the discovered application installed - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The devices that have the discovered application installed - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.DeviceManagement.DetectedApps.Item.ManagedDevices.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The devices that have the discovered application installed - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The devices that have the discovered application installed - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.DeviceManagement.DetectedApps.Item.ManagedDevices.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The devices that have the discovered application installed - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/DeviceManagement/DetectedApps/Item/ManagedDevices/@Ref/RefResponse.cs b/src/generated/DeviceManagement/DetectedApps/Item/ManagedDevices/@Ref/RefResponse.cs deleted file mode 100644 index c1107d0de1f..00000000000 --- a/src/generated/DeviceManagement/DetectedApps/Item/ManagedDevices/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.DeviceManagement.DetectedApps.Item.ManagedDevices.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/DeviceManagement/DetectedApps/Item/ManagedDevices/ManagedDevicesRequestBuilder.cs b/src/generated/DeviceManagement/DetectedApps/Item/ManagedDevices/ManagedDevicesRequestBuilder.cs index d4990359e44..2248f7fd800 100644 --- a/src/generated/DeviceManagement/DetectedApps/Item/ManagedDevices/ManagedDevicesRequestBuilder.cs +++ b/src/generated/DeviceManagement/DetectedApps/Item/ManagedDevices/ManagedDevicesRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.DeviceManagement.DetectedApps.Item.ManagedDevices.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The devices that have the discovered application installed"; // Create options for all the parameters - var detectedAppIdOption = new Option("--detectedapp-id", description: "key: id of detectedApp") { + var detectedAppIdOption = new Option("--detected-app-id", description: "key: id of detectedApp") { }; detectedAppIdOption.IsRequired = true; command.AddOption(detectedAppIdOption); @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string detectedAppId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string detectedAppId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, detectedAppIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, detectedAppIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.DeviceManagement.DetectedApps.Item.ManagedDevices.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.DeviceManagement.DetectedApps.Item.ManagedDevices.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The devices that have the discovered application installed - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The devices that have the discovered application installed public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/DetectedApps/Item/ManagedDevices/Ref/Ref.cs b/src/generated/DeviceManagement/DetectedApps/Item/ManagedDevices/Ref/Ref.cs new file mode 100644 index 00000000000..e928ba22dc8 --- /dev/null +++ b/src/generated/DeviceManagement/DetectedApps/Item/ManagedDevices/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.DeviceManagement.DetectedApps.Item.ManagedDevices.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/DeviceManagement/DetectedApps/Item/ManagedDevices/Ref/RefRequestBuilder.cs b/src/generated/DeviceManagement/DetectedApps/Item/ManagedDevices/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..e7c7bc3970d --- /dev/null +++ b/src/generated/DeviceManagement/DetectedApps/Item/ManagedDevices/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.DeviceManagement.DetectedApps.Item.ManagedDevices.Ref { + /// Builds and executes requests for operations under \deviceManagement\detectedApps\{detectedApp-id}\managedDevices\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The devices that have the discovered application installed + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The devices that have the discovered application installed"; + // Create options for all the parameters + var detectedAppIdOption = new Option("--detected-app-id", description: "key: id of detectedApp") { + }; + detectedAppIdOption.IsRequired = true; + command.AddOption(detectedAppIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string detectedAppId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, detectedAppIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The devices that have the discovered application installed + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The devices that have the discovered application installed"; + // Create options for all the parameters + var detectedAppIdOption = new Option("--detected-app-id", description: "key: id of detectedApp") { + }; + detectedAppIdOption.IsRequired = true; + command.AddOption(detectedAppIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string detectedAppId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, detectedAppIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/deviceManagement/detectedApps/{detectedApp_id}/managedDevices/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The devices that have the discovered application installed + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The devices that have the discovered application installed + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.DeviceManagement.DetectedApps.Item.ManagedDevices.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The devices that have the discovered application installed + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/DeviceManagement/DetectedApps/Item/ManagedDevices/Ref/RefResponse.cs b/src/generated/DeviceManagement/DetectedApps/Item/ManagedDevices/Ref/RefResponse.cs new file mode 100644 index 00000000000..8145cfd72a2 --- /dev/null +++ b/src/generated/DeviceManagement/DetectedApps/Item/ManagedDevices/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.DeviceManagement.DetectedApps.Item.ManagedDevices.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/DeviceManagement/DeviceCategories/DeviceCategoriesRequestBuilder.cs b/src/generated/DeviceManagement/DeviceCategories/DeviceCategoriesRequestBuilder.cs index 012fc860532..33b94d3959f 100644 --- a/src/generated/DeviceManagement/DeviceCategories/DeviceCategoriesRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceCategories/DeviceCategoriesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DeviceCategoriesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceCategoryRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of device categories with the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of device categories with the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.DeviceCategory model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of device categories with the tenant. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/DeviceCategories/Item/DeviceCategoryRequestBuilder.cs b/src/generated/DeviceManagement/DeviceCategories/Item/DeviceCategoryRequestBuilder.cs index 3dd391e88dc..c641371af56 100644 --- a/src/generated/DeviceManagement/DeviceCategories/Item/DeviceCategoryRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceCategories/Item/DeviceCategoryRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of device categories with the tenant."; // Create options for all the parameters - var deviceCategoryIdOption = new Option("--devicecategory-id", description: "key: id of deviceCategory") { + var deviceCategoryIdOption = new Option("--device-category-id", description: "key: id of deviceCategory") { }; deviceCategoryIdOption.IsRequired = true; command.AddOption(deviceCategoryIdOption); - command.SetHandler(async (string deviceCategoryId) => { + command.SetHandler(async (string deviceCategoryId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceCategoryIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of device categories with the tenant."; // Create options for all the parameters - var deviceCategoryIdOption = new Option("--devicecategory-id", description: "key: id of deviceCategory") { + var deviceCategoryIdOption = new Option("--device-category-id", description: "key: id of deviceCategory") { }; deviceCategoryIdOption.IsRequired = true; command.AddOption(deviceCategoryIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceCategoryId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceCategoryId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceCategoryIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceCategoryIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of device categories with the tenant."; // Create options for all the parameters - var deviceCategoryIdOption = new Option("--devicecategory-id", description: "key: id of deviceCategory") { + var deviceCategoryIdOption = new Option("--device-category-id", description: "key: id of deviceCategory") { }; deviceCategoryIdOption.IsRequired = true; command.AddOption(deviceCategoryIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceCategoryId, string body) => { + command.SetHandler(async (string deviceCategoryId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceCategoryIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of device categories with the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of device categories with the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of device categories with the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DeviceCategory model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of device categories with the tenant. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/DeviceCompliancePolicies/DeviceCompliancePoliciesRequestBuilder.cs b/src/generated/DeviceManagement/DeviceCompliancePolicies/DeviceCompliancePoliciesRequestBuilder.cs index a0184d0b53c..b28c3312c13 100644 --- a/src/generated/DeviceManagement/DeviceCompliancePolicies/DeviceCompliancePoliciesRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceCompliancePolicies/DeviceCompliancePoliciesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,20 +22,19 @@ public class DeviceCompliancePoliciesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceCompliancePolicyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAssignCommand(), - builder.BuildAssignmentsCommand(), - builder.BuildDeleteCommand(), - builder.BuildDeviceSettingStateSummariesCommand(), - builder.BuildDeviceStatusesCommand(), - builder.BuildDeviceStatusOverviewCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildScheduleActionsForRulesCommand(), - builder.BuildScheduledActionsForRuleCommand(), - builder.BuildUserStatusesCommand(), - builder.BuildUserStatusOverviewCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAssignCommand()); + commands.Add(builder.BuildAssignmentsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDeviceSettingStateSummariesCommand()); + commands.Add(builder.BuildDeviceStatusesCommand()); + commands.Add(builder.BuildDeviceStatusOverviewCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildScheduleActionsForRulesCommand()); + commands.Add(builder.BuildScheduledActionsForRuleCommand()); + commands.Add(builder.BuildUserStatusesCommand()); + commands.Add(builder.BuildUserStatusOverviewCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(DeviceCompliancePolicy bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The device compliance policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The device compliance policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceCompliancePolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The device compliance policies. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/Assign/AssignRequestBuilder.cs b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/Assign/AssignRequestBuilder.cs index dfe3cfd8fc7..89a23eef7c4 100644 --- a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/Assign/AssignRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/Assign/AssignRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action assign"; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceCompliancePolicyId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceCompliancePolicyId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceCompliancePolicyIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceCompliancePolicyIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/Assignments/AssignmentsRequestBuilder.cs b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/Assignments/AssignmentsRequestBuilder.cs index f480ed0efd4..97c56e0a289 100644 --- a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/Assignments/AssignmentsRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/Assignments/AssignmentsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AssignmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceCompliancePolicyAssignmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of assignments for this compliance policy."; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceCompliancePolicyId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceCompliancePolicyId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceCompliancePolicyIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceCompliancePolicyIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of assignments for this compliance policy."; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceCompliancePolicyId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceCompliancePolicyId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceCompliancePolicyIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceCompliancePolicyIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(DeviceCompliancePolicyAss requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of assignments for this compliance policy. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of assignments for this compliance policy. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceCompliancePolicyAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of assignments for this compliance policy. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/Assignments/Item/DeviceCompliancePolicyAssignmentRequestBuilder.cs b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/Assignments/Item/DeviceCompliancePolicyAssignmentRequestBuilder.cs index e15b028ce2e..f4d68affa73 100644 --- a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/Assignments/Item/DeviceCompliancePolicyAssignmentRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/Assignments/Item/DeviceCompliancePolicyAssignmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of assignments for this compliance policy."; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); - var deviceCompliancePolicyAssignmentIdOption = new Option("--devicecompliancepolicyassignment-id", description: "key: id of deviceCompliancePolicyAssignment") { + var deviceCompliancePolicyAssignmentIdOption = new Option("--device-compliance-policy-assignment-id", description: "key: id of deviceCompliancePolicyAssignment") { }; deviceCompliancePolicyAssignmentIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyAssignmentIdOption); - command.SetHandler(async (string deviceCompliancePolicyId, string deviceCompliancePolicyAssignmentId) => { + command.SetHandler(async (string deviceCompliancePolicyId, string deviceCompliancePolicyAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceCompliancePolicyIdOption, deviceCompliancePolicyAssignmentIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of assignments for this compliance policy."; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); - var deviceCompliancePolicyAssignmentIdOption = new Option("--devicecompliancepolicyassignment-id", description: "key: id of deviceCompliancePolicyAssignment") { + var deviceCompliancePolicyAssignmentIdOption = new Option("--device-compliance-policy-assignment-id", description: "key: id of deviceCompliancePolicyAssignment") { }; deviceCompliancePolicyAssignmentIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyAssignmentIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceCompliancePolicyId, string deviceCompliancePolicyAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceCompliancePolicyId, string deviceCompliancePolicyAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceCompliancePolicyIdOption, deviceCompliancePolicyAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceCompliancePolicyIdOption, deviceCompliancePolicyAssignmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of assignments for this compliance policy."; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); - var deviceCompliancePolicyAssignmentIdOption = new Option("--devicecompliancepolicyassignment-id", description: "key: id of deviceCompliancePolicyAssignment") { + var deviceCompliancePolicyAssignmentIdOption = new Option("--device-compliance-policy-assignment-id", description: "key: id of deviceCompliancePolicyAssignment") { }; deviceCompliancePolicyAssignmentIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyAssignmentIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceCompliancePolicyId, string deviceCompliancePolicyAssignmentId, string body) => { + command.SetHandler(async (string deviceCompliancePolicyId, string deviceCompliancePolicyAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceCompliancePolicyIdOption, deviceCompliancePolicyAssignmentIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceCompliancePolicyAs requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of assignments for this compliance policy. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of assignments for this compliance policy. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of assignments for this compliance policy. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceCompliancePolicyAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of assignments for this compliance policy. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/DeviceCompliancePolicyRequestBuilder.cs b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/DeviceCompliancePolicyRequestBuilder.cs index 2c50a3bb86c..29c2efc7ba9 100644 --- a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/DeviceCompliancePolicyRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/DeviceCompliancePolicyRequestBuilder.cs @@ -10,10 +10,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,6 +37,9 @@ public Command BuildAssignCommand() { public Command BuildAssignmentsCommand() { var command = new Command("assignments"); var builder = new ApiSdk.DeviceManagement.DeviceCompliancePolicies.Item.Assignments.AssignmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -48,15 +51,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The device compliance policies."; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); - command.SetHandler(async (string deviceCompliancePolicyId) => { + command.SetHandler(async (string deviceCompliancePolicyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceCompliancePolicyIdOption); return command; @@ -64,6 +66,9 @@ public Command BuildDeleteCommand() { public Command BuildDeviceSettingStateSummariesCommand() { var command = new Command("device-setting-state-summaries"); var builder = new ApiSdk.DeviceManagement.DeviceCompliancePolicies.Item.DeviceSettingStateSummaries.DeviceSettingStateSummariesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -71,6 +76,9 @@ public Command BuildDeviceSettingStateSummariesCommand() { public Command BuildDeviceStatusesCommand() { var command = new Command("device-statuses"); var builder = new ApiSdk.DeviceManagement.DeviceCompliancePolicies.Item.DeviceStatuses.DeviceStatusesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -90,7 +98,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The device compliance policies."; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); @@ -104,20 +112,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceCompliancePolicyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceCompliancePolicyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceCompliancePolicyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceCompliancePolicyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -127,7 +134,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The device compliance policies."; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); @@ -135,14 +142,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceCompliancePolicyId, string body) => { + command.SetHandler(async (string deviceCompliancePolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceCompliancePolicyIdOption, bodyOption); return command; @@ -156,6 +162,9 @@ public Command BuildScheduleActionsForRulesCommand() { public Command BuildScheduledActionsForRuleCommand() { var command = new Command("scheduled-actions-for-rule"); var builder = new ApiSdk.DeviceManagement.DeviceCompliancePolicies.Item.ScheduledActionsForRule.ScheduledActionsForRuleRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -163,6 +172,9 @@ public Command BuildScheduledActionsForRuleCommand() { public Command BuildUserStatusesCommand() { var command = new Command("user-statuses"); var builder = new ApiSdk.DeviceManagement.DeviceCompliancePolicies.Item.UserStatuses.UserStatusesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -242,42 +254,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceCompliancePolicy b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The device compliance policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The device compliance policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The device compliance policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceCompliancePolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The device compliance policies. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/DeviceSettingStateSummaries/DeviceSettingStateSummariesRequestBuilder.cs b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/DeviceSettingStateSummaries/DeviceSettingStateSummariesRequestBuilder.cs index 2585e8ed071..cf13becb53f 100644 --- a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/DeviceSettingStateSummaries/DeviceSettingStateSummariesRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/DeviceSettingStateSummaries/DeviceSettingStateSummariesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DeviceSettingStateSummariesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SettingStateDeviceSummaryRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Compliance Setting State Device Summary"; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceCompliancePolicyId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceCompliancePolicyId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceCompliancePolicyIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceCompliancePolicyIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Compliance Setting State Device Summary"; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceCompliancePolicyId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceCompliancePolicyId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceCompliancePolicyIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceCompliancePolicyIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(SettingStateDeviceSummary requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Compliance Setting State Device Summary - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Compliance Setting State Device Summary - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SettingStateDeviceSummary model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Compliance Setting State Device Summary public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/DeviceSettingStateSummaries/Item/SettingStateDeviceSummaryRequestBuilder.cs b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/DeviceSettingStateSummaries/Item/SettingStateDeviceSummaryRequestBuilder.cs index 135b1207dfa..eaa2877a0c9 100644 --- a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/DeviceSettingStateSummaries/Item/SettingStateDeviceSummaryRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/DeviceSettingStateSummaries/Item/SettingStateDeviceSummaryRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Compliance Setting State Device Summary"; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); - var settingStateDeviceSummaryIdOption = new Option("--settingstatedevicesummary-id", description: "key: id of settingStateDeviceSummary") { + var settingStateDeviceSummaryIdOption = new Option("--setting-state-device-summary-id", description: "key: id of settingStateDeviceSummary") { }; settingStateDeviceSummaryIdOption.IsRequired = true; command.AddOption(settingStateDeviceSummaryIdOption); - command.SetHandler(async (string deviceCompliancePolicyId, string settingStateDeviceSummaryId) => { + command.SetHandler(async (string deviceCompliancePolicyId, string settingStateDeviceSummaryId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceCompliancePolicyIdOption, settingStateDeviceSummaryIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Compliance Setting State Device Summary"; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); - var settingStateDeviceSummaryIdOption = new Option("--settingstatedevicesummary-id", description: "key: id of settingStateDeviceSummary") { + var settingStateDeviceSummaryIdOption = new Option("--setting-state-device-summary-id", description: "key: id of settingStateDeviceSummary") { }; settingStateDeviceSummaryIdOption.IsRequired = true; command.AddOption(settingStateDeviceSummaryIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceCompliancePolicyId, string settingStateDeviceSummaryId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceCompliancePolicyId, string settingStateDeviceSummaryId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceCompliancePolicyIdOption, settingStateDeviceSummaryIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceCompliancePolicyIdOption, settingStateDeviceSummaryIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Compliance Setting State Device Summary"; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); - var settingStateDeviceSummaryIdOption = new Option("--settingstatedevicesummary-id", description: "key: id of settingStateDeviceSummary") { + var settingStateDeviceSummaryIdOption = new Option("--setting-state-device-summary-id", description: "key: id of settingStateDeviceSummary") { }; settingStateDeviceSummaryIdOption.IsRequired = true; command.AddOption(settingStateDeviceSummaryIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceCompliancePolicyId, string settingStateDeviceSummaryId, string body) => { + command.SetHandler(async (string deviceCompliancePolicyId, string settingStateDeviceSummaryId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceCompliancePolicyIdOption, settingStateDeviceSummaryIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SettingStateDeviceSummar requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Compliance Setting State Device Summary - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Compliance Setting State Device Summary - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Compliance Setting State Device Summary - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SettingStateDeviceSummary model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Compliance Setting State Device Summary public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/DeviceStatusOverview/DeviceStatusOverviewRequestBuilder.cs b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/DeviceStatusOverview/DeviceStatusOverviewRequestBuilder.cs index 2da93cd9d3a..c4addf9cf06 100644 --- a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/DeviceStatusOverview/DeviceStatusOverviewRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/DeviceStatusOverview/DeviceStatusOverviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Device compliance devices status overview"; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); - command.SetHandler(async (string deviceCompliancePolicyId) => { + command.SetHandler(async (string deviceCompliancePolicyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceCompliancePolicyIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Device compliance devices status overview"; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceCompliancePolicyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceCompliancePolicyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceCompliancePolicyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceCompliancePolicyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Device compliance devices status overview"; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceCompliancePolicyId, string body) => { + command.SetHandler(async (string deviceCompliancePolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceCompliancePolicyIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceComplianceDeviceOv requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Device compliance devices status overview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device compliance devices status overview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device compliance devices status overview - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceComplianceDeviceOverview model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Device compliance devices status overview public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/DeviceStatuses/DeviceStatusesRequestBuilder.cs b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/DeviceStatuses/DeviceStatusesRequestBuilder.cs index 844f05cc215..852692e941d 100644 --- a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/DeviceStatuses/DeviceStatusesRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/DeviceStatuses/DeviceStatusesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DeviceStatusesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceComplianceDeviceStatusRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "List of DeviceComplianceDeviceStatus."; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceCompliancePolicyId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceCompliancePolicyId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceCompliancePolicyIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceCompliancePolicyIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "List of DeviceComplianceDeviceStatus."; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceCompliancePolicyId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceCompliancePolicyId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceCompliancePolicyIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceCompliancePolicyIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(DeviceComplianceDeviceSta requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of DeviceComplianceDeviceStatus. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of DeviceComplianceDeviceStatus. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceComplianceDeviceStatus model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// List of DeviceComplianceDeviceStatus. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/DeviceStatuses/Item/DeviceComplianceDeviceStatusRequestBuilder.cs b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/DeviceStatuses/Item/DeviceComplianceDeviceStatusRequestBuilder.cs index 82dc95e23c3..3edb61d0a00 100644 --- a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/DeviceStatuses/Item/DeviceComplianceDeviceStatusRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/DeviceStatuses/Item/DeviceComplianceDeviceStatusRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "List of DeviceComplianceDeviceStatus."; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); - var deviceComplianceDeviceStatusIdOption = new Option("--devicecompliancedevicestatus-id", description: "key: id of deviceComplianceDeviceStatus") { + var deviceComplianceDeviceStatusIdOption = new Option("--device-compliance-device-status-id", description: "key: id of deviceComplianceDeviceStatus") { }; deviceComplianceDeviceStatusIdOption.IsRequired = true; command.AddOption(deviceComplianceDeviceStatusIdOption); - command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceDeviceStatusId) => { + command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceDeviceStatusId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceCompliancePolicyIdOption, deviceComplianceDeviceStatusIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "List of DeviceComplianceDeviceStatus."; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); - var deviceComplianceDeviceStatusIdOption = new Option("--devicecompliancedevicestatus-id", description: "key: id of deviceComplianceDeviceStatus") { + var deviceComplianceDeviceStatusIdOption = new Option("--device-compliance-device-status-id", description: "key: id of deviceComplianceDeviceStatus") { }; deviceComplianceDeviceStatusIdOption.IsRequired = true; command.AddOption(deviceComplianceDeviceStatusIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceDeviceStatusId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceDeviceStatusId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceCompliancePolicyIdOption, deviceComplianceDeviceStatusIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceCompliancePolicyIdOption, deviceComplianceDeviceStatusIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "List of DeviceComplianceDeviceStatus."; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); - var deviceComplianceDeviceStatusIdOption = new Option("--devicecompliancedevicestatus-id", description: "key: id of deviceComplianceDeviceStatus") { + var deviceComplianceDeviceStatusIdOption = new Option("--device-compliance-device-status-id", description: "key: id of deviceComplianceDeviceStatus") { }; deviceComplianceDeviceStatusIdOption.IsRequired = true; command.AddOption(deviceComplianceDeviceStatusIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceDeviceStatusId, string body) => { + command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceDeviceStatusId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceCompliancePolicyIdOption, deviceComplianceDeviceStatusIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceComplianceDeviceSt requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of DeviceComplianceDeviceStatus. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of DeviceComplianceDeviceStatus. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of DeviceComplianceDeviceStatus. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceComplianceDeviceStatus model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// List of DeviceComplianceDeviceStatus. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/ScheduleActionsForRules/ScheduleActionsForRulesRequestBuilder.cs b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/ScheduleActionsForRules/ScheduleActionsForRulesRequestBuilder.cs index 5d6ef4d6727..ba01cfec19b 100644 --- a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/ScheduleActionsForRules/ScheduleActionsForRulesRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/ScheduleActionsForRules/ScheduleActionsForRulesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action scheduleActionsForRules"; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceCompliancePolicyId, string body) => { + command.SetHandler(async (string deviceCompliancePolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceCompliancePolicyIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ScheduleActionsForRulesRe requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action scheduleActionsForRules - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ScheduleActionsForRulesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/ScheduledActionsForRule/Item/DeviceComplianceScheduledActionForRuleRequestBuilder.cs b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/ScheduledActionsForRule/Item/DeviceComplianceScheduledActionForRuleRequestBuilder.cs index ee9c7f9d573..42ba084fdc1 100644 --- a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/ScheduledActionsForRule/Item/DeviceComplianceScheduledActionForRuleRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/ScheduledActionsForRule/Item/DeviceComplianceScheduledActionForRuleRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,19 +27,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of scheduled action for this rule"; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); - var deviceComplianceScheduledActionForRuleIdOption = new Option("--devicecompliancescheduledactionforrule-id", description: "key: id of deviceComplianceScheduledActionForRule") { + var deviceComplianceScheduledActionForRuleIdOption = new Option("--device-compliance-scheduled-action-for-rule-id", description: "key: id of deviceComplianceScheduledActionForRule") { }; deviceComplianceScheduledActionForRuleIdOption.IsRequired = true; command.AddOption(deviceComplianceScheduledActionForRuleIdOption); - command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceScheduledActionForRuleId) => { + command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceScheduledActionForRuleId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceCompliancePolicyIdOption, deviceComplianceScheduledActionForRuleIdOption); return command; @@ -51,11 +50,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of scheduled action for this rule"; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); - var deviceComplianceScheduledActionForRuleIdOption = new Option("--devicecompliancescheduledactionforrule-id", description: "key: id of deviceComplianceScheduledActionForRule") { + var deviceComplianceScheduledActionForRuleIdOption = new Option("--device-compliance-scheduled-action-for-rule-id", description: "key: id of deviceComplianceScheduledActionForRule") { }; deviceComplianceScheduledActionForRuleIdOption.IsRequired = true; command.AddOption(deviceComplianceScheduledActionForRuleIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceScheduledActionForRuleId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceScheduledActionForRuleId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceCompliancePolicyIdOption, deviceComplianceScheduledActionForRuleIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceCompliancePolicyIdOption, deviceComplianceScheduledActionForRuleIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -92,11 +90,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of scheduled action for this rule"; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); - var deviceComplianceScheduledActionForRuleIdOption = new Option("--devicecompliancescheduledactionforrule-id", description: "key: id of deviceComplianceScheduledActionForRule") { + var deviceComplianceScheduledActionForRuleIdOption = new Option("--device-compliance-scheduled-action-for-rule-id", description: "key: id of deviceComplianceScheduledActionForRule") { }; deviceComplianceScheduledActionForRuleIdOption.IsRequired = true; command.AddOption(deviceComplianceScheduledActionForRuleIdOption); @@ -104,14 +102,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceScheduledActionForRuleId, string body) => { + command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceScheduledActionForRuleId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceCompliancePolicyIdOption, deviceComplianceScheduledActionForRuleIdOption, bodyOption); return command; @@ -119,6 +116,9 @@ public Command BuildPatchCommand() { public Command BuildScheduledActionConfigurationsCommand() { var command = new Command("scheduled-action-configurations"); var builder = new ApiSdk.DeviceManagement.DeviceCompliancePolicies.Item.ScheduledActionsForRule.Item.ScheduledActionConfigurations.ScheduledActionConfigurationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -190,42 +190,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceComplianceSchedule requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of scheduled action for this rule - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of scheduled action for this rule - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of scheduled action for this rule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceComplianceScheduledActionForRule model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of scheduled action for this rule public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/ScheduledActionsForRule/Item/ScheduledActionConfigurations/Item/DeviceComplianceActionItemRequestBuilder.cs b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/ScheduledActionsForRule/Item/ScheduledActionConfigurations/Item/DeviceComplianceActionItemRequestBuilder.cs index dab76403953..a9831ed93dc 100644 --- a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/ScheduledActionsForRule/Item/ScheduledActionConfigurations/Item/DeviceComplianceActionItemRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/ScheduledActionsForRule/Item/ScheduledActionConfigurations/Item/DeviceComplianceActionItemRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of scheduled action configurations for this compliance policy. Compliance policy must have one and only one block scheduled action."; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); - var deviceComplianceScheduledActionForRuleIdOption = new Option("--devicecompliancescheduledactionforrule-id", description: "key: id of deviceComplianceScheduledActionForRule") { + var deviceComplianceScheduledActionForRuleIdOption = new Option("--device-compliance-scheduled-action-for-rule-id", description: "key: id of deviceComplianceScheduledActionForRule") { }; deviceComplianceScheduledActionForRuleIdOption.IsRequired = true; command.AddOption(deviceComplianceScheduledActionForRuleIdOption); - var deviceComplianceActionItemIdOption = new Option("--devicecomplianceactionitem-id", description: "key: id of deviceComplianceActionItem") { + var deviceComplianceActionItemIdOption = new Option("--device-compliance-action-item-id", description: "key: id of deviceComplianceActionItem") { }; deviceComplianceActionItemIdOption.IsRequired = true; command.AddOption(deviceComplianceActionItemIdOption); - command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceScheduledActionForRuleId, string deviceComplianceActionItemId) => { + command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceScheduledActionForRuleId, string deviceComplianceActionItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceCompliancePolicyIdOption, deviceComplianceScheduledActionForRuleIdOption, deviceComplianceActionItemIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of scheduled action configurations for this compliance policy. Compliance policy must have one and only one block scheduled action."; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); - var deviceComplianceScheduledActionForRuleIdOption = new Option("--devicecompliancescheduledactionforrule-id", description: "key: id of deviceComplianceScheduledActionForRule") { + var deviceComplianceScheduledActionForRuleIdOption = new Option("--device-compliance-scheduled-action-for-rule-id", description: "key: id of deviceComplianceScheduledActionForRule") { }; deviceComplianceScheduledActionForRuleIdOption.IsRequired = true; command.AddOption(deviceComplianceScheduledActionForRuleIdOption); - var deviceComplianceActionItemIdOption = new Option("--devicecomplianceactionitem-id", description: "key: id of deviceComplianceActionItem") { + var deviceComplianceActionItemIdOption = new Option("--device-compliance-action-item-id", description: "key: id of deviceComplianceActionItem") { }; deviceComplianceActionItemIdOption.IsRequired = true; command.AddOption(deviceComplianceActionItemIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceScheduledActionForRuleId, string deviceComplianceActionItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceScheduledActionForRuleId, string deviceComplianceActionItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceCompliancePolicyIdOption, deviceComplianceScheduledActionForRuleIdOption, deviceComplianceActionItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceCompliancePolicyIdOption, deviceComplianceScheduledActionForRuleIdOption, deviceComplianceActionItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of scheduled action configurations for this compliance policy. Compliance policy must have one and only one block scheduled action."; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); - var deviceComplianceScheduledActionForRuleIdOption = new Option("--devicecompliancescheduledactionforrule-id", description: "key: id of deviceComplianceScheduledActionForRule") { + var deviceComplianceScheduledActionForRuleIdOption = new Option("--device-compliance-scheduled-action-for-rule-id", description: "key: id of deviceComplianceScheduledActionForRule") { }; deviceComplianceScheduledActionForRuleIdOption.IsRequired = true; command.AddOption(deviceComplianceScheduledActionForRuleIdOption); - var deviceComplianceActionItemIdOption = new Option("--devicecomplianceactionitem-id", description: "key: id of deviceComplianceActionItem") { + var deviceComplianceActionItemIdOption = new Option("--device-compliance-action-item-id", description: "key: id of deviceComplianceActionItem") { }; deviceComplianceActionItemIdOption.IsRequired = true; command.AddOption(deviceComplianceActionItemIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceScheduledActionForRuleId, string deviceComplianceActionItemId, string body) => { + command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceScheduledActionForRuleId, string deviceComplianceActionItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceCompliancePolicyIdOption, deviceComplianceScheduledActionForRuleIdOption, deviceComplianceActionItemIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceComplianceActionIt requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of scheduled action configurations for this compliance policy. Compliance policy must have one and only one block scheduled action. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of scheduled action configurations for this compliance policy. Compliance policy must have one and only one block scheduled action. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of scheduled action configurations for this compliance policy. Compliance policy must have one and only one block scheduled action. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceComplianceActionItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of scheduled action configurations for this compliance policy. Compliance policy must have one and only one block scheduled action. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/ScheduledActionsForRule/Item/ScheduledActionConfigurations/ScheduledActionConfigurationsRequestBuilder.cs b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/ScheduledActionsForRule/Item/ScheduledActionConfigurations/ScheduledActionConfigurationsRequestBuilder.cs index 1010da4ea24..5754165a0f1 100644 --- a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/ScheduledActionsForRule/Item/ScheduledActionConfigurations/ScheduledActionConfigurationsRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/ScheduledActionsForRule/Item/ScheduledActionConfigurations/ScheduledActionConfigurationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ScheduledActionConfigurationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceComplianceActionItemRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,11 +35,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The list of scheduled action configurations for this compliance policy. Compliance policy must have one and only one block scheduled action."; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); - var deviceComplianceScheduledActionForRuleIdOption = new Option("--devicecompliancescheduledactionforrule-id", description: "key: id of deviceComplianceScheduledActionForRule") { + var deviceComplianceScheduledActionForRuleIdOption = new Option("--device-compliance-scheduled-action-for-rule-id", description: "key: id of deviceComplianceScheduledActionForRule") { }; deviceComplianceScheduledActionForRuleIdOption.IsRequired = true; command.AddOption(deviceComplianceScheduledActionForRuleIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceScheduledActionForRuleId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceScheduledActionForRuleId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceCompliancePolicyIdOption, deviceComplianceScheduledActionForRuleIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceCompliancePolicyIdOption, deviceComplianceScheduledActionForRuleIdOption, bodyOption, outputOption); return command; } /// @@ -72,11 +70,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The list of scheduled action configurations for this compliance policy. Compliance policy must have one and only one block scheduled action."; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); - var deviceComplianceScheduledActionForRuleIdOption = new Option("--devicecompliancescheduledactionforrule-id", description: "key: id of deviceComplianceScheduledActionForRule") { + var deviceComplianceScheduledActionForRuleIdOption = new Option("--device-compliance-scheduled-action-for-rule-id", description: "key: id of deviceComplianceScheduledActionForRule") { }; deviceComplianceScheduledActionForRuleIdOption.IsRequired = true; command.AddOption(deviceComplianceScheduledActionForRuleIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceScheduledActionForRuleId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceScheduledActionForRuleId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceCompliancePolicyIdOption, deviceComplianceScheduledActionForRuleIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceCompliancePolicyIdOption, deviceComplianceScheduledActionForRuleIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(DeviceComplianceActionIte requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of scheduled action configurations for this compliance policy. Compliance policy must have one and only one block scheduled action. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of scheduled action configurations for this compliance policy. Compliance policy must have one and only one block scheduled action. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceComplianceActionItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of scheduled action configurations for this compliance policy. Compliance policy must have one and only one block scheduled action. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/ScheduledActionsForRule/ScheduledActionsForRuleRequestBuilder.cs b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/ScheduledActionsForRule/ScheduledActionsForRuleRequestBuilder.cs index 1144981bced..ee7383156d2 100644 --- a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/ScheduledActionsForRule/ScheduledActionsForRuleRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/ScheduledActionsForRule/ScheduledActionsForRuleRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class ScheduledActionsForRuleRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceComplianceScheduledActionForRuleRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildScheduledActionConfigurationsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildScheduledActionConfigurationsCommand()); return commands; } /// @@ -37,7 +36,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The list of scheduled action for this rule"; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceCompliancePolicyId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceCompliancePolicyId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceCompliancePolicyIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceCompliancePolicyIdOption, bodyOption, outputOption); return command; } /// @@ -69,7 +67,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The list of scheduled action for this rule"; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceCompliancePolicyId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceCompliancePolicyId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceCompliancePolicyIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceCompliancePolicyIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(DeviceComplianceScheduled requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of scheduled action for this rule - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of scheduled action for this rule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceComplianceScheduledActionForRule model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of scheduled action for this rule public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/UserStatusOverview/UserStatusOverviewRequestBuilder.cs b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/UserStatusOverview/UserStatusOverviewRequestBuilder.cs index 3384337b227..e682c0e10d2 100644 --- a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/UserStatusOverview/UserStatusOverviewRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/UserStatusOverview/UserStatusOverviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Device compliance users status overview"; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); - command.SetHandler(async (string deviceCompliancePolicyId) => { + command.SetHandler(async (string deviceCompliancePolicyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceCompliancePolicyIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Device compliance users status overview"; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceCompliancePolicyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceCompliancePolicyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceCompliancePolicyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceCompliancePolicyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Device compliance users status overview"; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceCompliancePolicyId, string body) => { + command.SetHandler(async (string deviceCompliancePolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceCompliancePolicyIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceComplianceUserOver requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Device compliance users status overview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device compliance users status overview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device compliance users status overview - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceComplianceUserOverview model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Device compliance users status overview public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/UserStatuses/Item/DeviceComplianceUserStatusRequestBuilder.cs b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/UserStatuses/Item/DeviceComplianceUserStatusRequestBuilder.cs index e4f10496ff4..64c361519ce 100644 --- a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/UserStatuses/Item/DeviceComplianceUserStatusRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/UserStatuses/Item/DeviceComplianceUserStatusRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "List of DeviceComplianceUserStatus."; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); - var deviceComplianceUserStatusIdOption = new Option("--devicecomplianceuserstatus-id", description: "key: id of deviceComplianceUserStatus") { + var deviceComplianceUserStatusIdOption = new Option("--device-compliance-user-status-id", description: "key: id of deviceComplianceUserStatus") { }; deviceComplianceUserStatusIdOption.IsRequired = true; command.AddOption(deviceComplianceUserStatusIdOption); - command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceUserStatusId) => { + command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceUserStatusId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceCompliancePolicyIdOption, deviceComplianceUserStatusIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "List of DeviceComplianceUserStatus."; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); - var deviceComplianceUserStatusIdOption = new Option("--devicecomplianceuserstatus-id", description: "key: id of deviceComplianceUserStatus") { + var deviceComplianceUserStatusIdOption = new Option("--device-compliance-user-status-id", description: "key: id of deviceComplianceUserStatus") { }; deviceComplianceUserStatusIdOption.IsRequired = true; command.AddOption(deviceComplianceUserStatusIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceUserStatusId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceUserStatusId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceCompliancePolicyIdOption, deviceComplianceUserStatusIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceCompliancePolicyIdOption, deviceComplianceUserStatusIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "List of DeviceComplianceUserStatus."; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); - var deviceComplianceUserStatusIdOption = new Option("--devicecomplianceuserstatus-id", description: "key: id of deviceComplianceUserStatus") { + var deviceComplianceUserStatusIdOption = new Option("--device-compliance-user-status-id", description: "key: id of deviceComplianceUserStatus") { }; deviceComplianceUserStatusIdOption.IsRequired = true; command.AddOption(deviceComplianceUserStatusIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceUserStatusId, string body) => { + command.SetHandler(async (string deviceCompliancePolicyId, string deviceComplianceUserStatusId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceCompliancePolicyIdOption, deviceComplianceUserStatusIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceComplianceUserStat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of DeviceComplianceUserStatus. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of DeviceComplianceUserStatus. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of DeviceComplianceUserStatus. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceComplianceUserStatus model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// List of DeviceComplianceUserStatus. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/UserStatuses/UserStatusesRequestBuilder.cs b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/UserStatuses/UserStatusesRequestBuilder.cs index d50253b9524..154b6665d85 100644 --- a/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/UserStatuses/UserStatusesRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceCompliancePolicies/Item/UserStatuses/UserStatusesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class UserStatusesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceComplianceUserStatusRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "List of DeviceComplianceUserStatus."; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceCompliancePolicyId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceCompliancePolicyId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceCompliancePolicyIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceCompliancePolicyIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "List of DeviceComplianceUserStatus."; // Create options for all the parameters - var deviceCompliancePolicyIdOption = new Option("--devicecompliancepolicy-id", description: "key: id of deviceCompliancePolicy") { + var deviceCompliancePolicyIdOption = new Option("--device-compliance-policy-id", description: "key: id of deviceCompliancePolicy") { }; deviceCompliancePolicyIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceCompliancePolicyId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceCompliancePolicyId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceCompliancePolicyIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceCompliancePolicyIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(DeviceComplianceUserStatu requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of DeviceComplianceUserStatus. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of DeviceComplianceUserStatus. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceComplianceUserStatus model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// List of DeviceComplianceUserStatus. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/DeviceCompliancePolicyDeviceStateSummary/DeviceCompliancePolicyDeviceStateSummaryRequestBuilder.cs b/src/generated/DeviceManagement/DeviceCompliancePolicyDeviceStateSummary/DeviceCompliancePolicyDeviceStateSummaryRequestBuilder.cs index a0b0c852aa6..c0a1e1e37ca 100644 --- a/src/generated/DeviceManagement/DeviceCompliancePolicyDeviceStateSummary/DeviceCompliancePolicyDeviceStateSummaryRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceCompliancePolicyDeviceStateSummary/DeviceCompliancePolicyDeviceStateSummaryRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The device compliance state summary for this account."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -52,20 +51,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -79,14 +77,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -158,42 +155,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The device compliance state summary for this account. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The device compliance state summary for this account. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The device compliance state summary for this account. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DeviceCompliancePolicyDeviceStateSummary model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The device compliance state summary for this account. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/DeviceCompliancePolicySettingStateSummaries/DeviceCompliancePolicySettingStateSummariesRequestBuilder.cs b/src/generated/DeviceManagement/DeviceCompliancePolicySettingStateSummaries/DeviceCompliancePolicySettingStateSummariesRequestBuilder.cs index 277aeb2fcf3..2c3238573e7 100644 --- a/src/generated/DeviceManagement/DeviceCompliancePolicySettingStateSummaries/DeviceCompliancePolicySettingStateSummariesRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceCompliancePolicySettingStateSummaries/DeviceCompliancePolicySettingStateSummariesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class DeviceCompliancePolicySettingStateSummariesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceCompliancePolicySettingStateSummaryRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildDeviceComplianceSettingStatesCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDeviceComplianceSettingStatesCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(DeviceCompliancePolicySet requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The summary states of compliance policy settings for this account. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The summary states of compliance policy settings for this account. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceCompliancePolicySettingStateSummary model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The summary states of compliance policy settings for this account. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/DeviceCompliancePolicySettingStateSummaries/Item/DeviceCompliancePolicySettingStateSummaryRequestBuilder.cs b/src/generated/DeviceManagement/DeviceCompliancePolicySettingStateSummaries/Item/DeviceCompliancePolicySettingStateSummaryRequestBuilder.cs index de877dc5f34..17118230f2d 100644 --- a/src/generated/DeviceManagement/DeviceCompliancePolicySettingStateSummaries/Item/DeviceCompliancePolicySettingStateSummaryRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceCompliancePolicySettingStateSummaries/Item/DeviceCompliancePolicySettingStateSummaryRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,15 +27,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The summary states of compliance policy settings for this account."; // Create options for all the parameters - var deviceCompliancePolicySettingStateSummaryIdOption = new Option("--devicecompliancepolicysettingstatesummary-id", description: "key: id of deviceCompliancePolicySettingStateSummary") { + var deviceCompliancePolicySettingStateSummaryIdOption = new Option("--device-compliance-policy-setting-state-summary-id", description: "key: id of deviceCompliancePolicySettingStateSummary") { }; deviceCompliancePolicySettingStateSummaryIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicySettingStateSummaryIdOption); - command.SetHandler(async (string deviceCompliancePolicySettingStateSummaryId) => { + command.SetHandler(async (string deviceCompliancePolicySettingStateSummaryId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceCompliancePolicySettingStateSummaryIdOption); return command; @@ -43,6 +42,9 @@ public Command BuildDeleteCommand() { public Command BuildDeviceComplianceSettingStatesCommand() { var command = new Command("device-compliance-setting-states"); var builder = new ApiSdk.DeviceManagement.DeviceCompliancePolicySettingStateSummaries.Item.DeviceComplianceSettingStates.DeviceComplianceSettingStatesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -54,7 +56,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The summary states of compliance policy settings for this account."; // Create options for all the parameters - var deviceCompliancePolicySettingStateSummaryIdOption = new Option("--devicecompliancepolicysettingstatesummary-id", description: "key: id of deviceCompliancePolicySettingStateSummary") { + var deviceCompliancePolicySettingStateSummaryIdOption = new Option("--device-compliance-policy-setting-state-summary-id", description: "key: id of deviceCompliancePolicySettingStateSummary") { }; deviceCompliancePolicySettingStateSummaryIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicySettingStateSummaryIdOption); @@ -68,20 +70,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceCompliancePolicySettingStateSummaryId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceCompliancePolicySettingStateSummaryId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceCompliancePolicySettingStateSummaryIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceCompliancePolicySettingStateSummaryIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,7 +92,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The summary states of compliance policy settings for this account."; // Create options for all the parameters - var deviceCompliancePolicySettingStateSummaryIdOption = new Option("--devicecompliancepolicysettingstatesummary-id", description: "key: id of deviceCompliancePolicySettingStateSummary") { + var deviceCompliancePolicySettingStateSummaryIdOption = new Option("--device-compliance-policy-setting-state-summary-id", description: "key: id of deviceCompliancePolicySettingStateSummary") { }; deviceCompliancePolicySettingStateSummaryIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicySettingStateSummaryIdOption); @@ -99,14 +100,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceCompliancePolicySettingStateSummaryId, string body) => { + command.SetHandler(async (string deviceCompliancePolicySettingStateSummaryId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceCompliancePolicySettingStateSummaryIdOption, bodyOption); return command; @@ -178,42 +178,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceCompliancePolicySe requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The summary states of compliance policy settings for this account. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The summary states of compliance policy settings for this account. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The summary states of compliance policy settings for this account. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceCompliancePolicySettingStateSummary model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The summary states of compliance policy settings for this account. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/DeviceCompliancePolicySettingStateSummaries/Item/DeviceComplianceSettingStates/DeviceComplianceSettingStatesRequestBuilder.cs b/src/generated/DeviceManagement/DeviceCompliancePolicySettingStateSummaries/Item/DeviceComplianceSettingStates/DeviceComplianceSettingStatesRequestBuilder.cs index 23f8db1e798..dff6553a8c5 100644 --- a/src/generated/DeviceManagement/DeviceCompliancePolicySettingStateSummaries/Item/DeviceComplianceSettingStates/DeviceComplianceSettingStatesRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceCompliancePolicySettingStateSummaries/Item/DeviceComplianceSettingStates/DeviceComplianceSettingStatesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DeviceComplianceSettingStatesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceComplianceSettingStateRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Not yet documented"; // Create options for all the parameters - var deviceCompliancePolicySettingStateSummaryIdOption = new Option("--devicecompliancepolicysettingstatesummary-id", description: "key: id of deviceCompliancePolicySettingStateSummary") { + var deviceCompliancePolicySettingStateSummaryIdOption = new Option("--device-compliance-policy-setting-state-summary-id", description: "key: id of deviceCompliancePolicySettingStateSummary") { }; deviceCompliancePolicySettingStateSummaryIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicySettingStateSummaryIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceCompliancePolicySettingStateSummaryId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceCompliancePolicySettingStateSummaryId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceCompliancePolicySettingStateSummaryIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceCompliancePolicySettingStateSummaryIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Not yet documented"; // Create options for all the parameters - var deviceCompliancePolicySettingStateSummaryIdOption = new Option("--devicecompliancepolicysettingstatesummary-id", description: "key: id of deviceCompliancePolicySettingStateSummary") { + var deviceCompliancePolicySettingStateSummaryIdOption = new Option("--device-compliance-policy-setting-state-summary-id", description: "key: id of deviceCompliancePolicySettingStateSummary") { }; deviceCompliancePolicySettingStateSummaryIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicySettingStateSummaryIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceCompliancePolicySettingStateSummaryId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceCompliancePolicySettingStateSummaryId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceCompliancePolicySettingStateSummaryIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceCompliancePolicySettingStateSummaryIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(DeviceComplianceSettingSt requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Not yet documented - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Not yet documented - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceComplianceSettingState model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Not yet documented public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/DeviceCompliancePolicySettingStateSummaries/Item/DeviceComplianceSettingStates/Item/DeviceComplianceSettingStateRequestBuilder.cs b/src/generated/DeviceManagement/DeviceCompliancePolicySettingStateSummaries/Item/DeviceComplianceSettingStates/Item/DeviceComplianceSettingStateRequestBuilder.cs index 0006674a0b4..970be4b204c 100644 --- a/src/generated/DeviceManagement/DeviceCompliancePolicySettingStateSummaries/Item/DeviceComplianceSettingStates/Item/DeviceComplianceSettingStateRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceCompliancePolicySettingStateSummaries/Item/DeviceComplianceSettingStates/Item/DeviceComplianceSettingStateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Not yet documented"; // Create options for all the parameters - var deviceCompliancePolicySettingStateSummaryIdOption = new Option("--devicecompliancepolicysettingstatesummary-id", description: "key: id of deviceCompliancePolicySettingStateSummary") { + var deviceCompliancePolicySettingStateSummaryIdOption = new Option("--device-compliance-policy-setting-state-summary-id", description: "key: id of deviceCompliancePolicySettingStateSummary") { }; deviceCompliancePolicySettingStateSummaryIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicySettingStateSummaryIdOption); - var deviceComplianceSettingStateIdOption = new Option("--devicecompliancesettingstate-id", description: "key: id of deviceComplianceSettingState") { + var deviceComplianceSettingStateIdOption = new Option("--device-compliance-setting-state-id", description: "key: id of deviceComplianceSettingState") { }; deviceComplianceSettingStateIdOption.IsRequired = true; command.AddOption(deviceComplianceSettingStateIdOption); - command.SetHandler(async (string deviceCompliancePolicySettingStateSummaryId, string deviceComplianceSettingStateId) => { + command.SetHandler(async (string deviceCompliancePolicySettingStateSummaryId, string deviceComplianceSettingStateId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceCompliancePolicySettingStateSummaryIdOption, deviceComplianceSettingStateIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Not yet documented"; // Create options for all the parameters - var deviceCompliancePolicySettingStateSummaryIdOption = new Option("--devicecompliancepolicysettingstatesummary-id", description: "key: id of deviceCompliancePolicySettingStateSummary") { + var deviceCompliancePolicySettingStateSummaryIdOption = new Option("--device-compliance-policy-setting-state-summary-id", description: "key: id of deviceCompliancePolicySettingStateSummary") { }; deviceCompliancePolicySettingStateSummaryIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicySettingStateSummaryIdOption); - var deviceComplianceSettingStateIdOption = new Option("--devicecompliancesettingstate-id", description: "key: id of deviceComplianceSettingState") { + var deviceComplianceSettingStateIdOption = new Option("--device-compliance-setting-state-id", description: "key: id of deviceComplianceSettingState") { }; deviceComplianceSettingStateIdOption.IsRequired = true; command.AddOption(deviceComplianceSettingStateIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceCompliancePolicySettingStateSummaryId, string deviceComplianceSettingStateId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceCompliancePolicySettingStateSummaryId, string deviceComplianceSettingStateId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceCompliancePolicySettingStateSummaryIdOption, deviceComplianceSettingStateIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceCompliancePolicySettingStateSummaryIdOption, deviceComplianceSettingStateIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Not yet documented"; // Create options for all the parameters - var deviceCompliancePolicySettingStateSummaryIdOption = new Option("--devicecompliancepolicysettingstatesummary-id", description: "key: id of deviceCompliancePolicySettingStateSummary") { + var deviceCompliancePolicySettingStateSummaryIdOption = new Option("--device-compliance-policy-setting-state-summary-id", description: "key: id of deviceCompliancePolicySettingStateSummary") { }; deviceCompliancePolicySettingStateSummaryIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicySettingStateSummaryIdOption); - var deviceComplianceSettingStateIdOption = new Option("--devicecompliancesettingstate-id", description: "key: id of deviceComplianceSettingState") { + var deviceComplianceSettingStateIdOption = new Option("--device-compliance-setting-state-id", description: "key: id of deviceComplianceSettingState") { }; deviceComplianceSettingStateIdOption.IsRequired = true; command.AddOption(deviceComplianceSettingStateIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceCompliancePolicySettingStateSummaryId, string deviceComplianceSettingStateId, string body) => { + command.SetHandler(async (string deviceCompliancePolicySettingStateSummaryId, string deviceComplianceSettingStateId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceCompliancePolicySettingStateSummaryIdOption, deviceComplianceSettingStateIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceComplianceSettingS requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Not yet documented - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Not yet documented - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Not yet documented - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceComplianceSettingState model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Not yet documented public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/DeviceConfigurationDeviceStateSummaries/DeviceConfigurationDeviceStateSummariesRequestBuilder.cs b/src/generated/DeviceManagement/DeviceConfigurationDeviceStateSummaries/DeviceConfigurationDeviceStateSummariesRequestBuilder.cs index cec1ea6857e..78e09be49d8 100644 --- a/src/generated/DeviceManagement/DeviceConfigurationDeviceStateSummaries/DeviceConfigurationDeviceStateSummariesRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceConfigurationDeviceStateSummaries/DeviceConfigurationDeviceStateSummariesRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The device configuration device state summary for this account."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -52,20 +51,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -79,14 +77,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -158,42 +155,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceConfigurationDevic requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The device configuration device state summary for this account. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The device configuration device state summary for this account. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The device configuration device state summary for this account. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceConfigurationDeviceStateSummary model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The device configuration device state summary for this account. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/DeviceConfigurations/DeviceConfigurationsRequestBuilder.cs b/src/generated/DeviceManagement/DeviceConfigurations/DeviceConfigurationsRequestBuilder.cs index 875adbd53f6..4cb6b8762f5 100644 --- a/src/generated/DeviceManagement/DeviceConfigurations/DeviceConfigurationsRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceConfigurations/DeviceConfigurationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,18 +22,17 @@ public class DeviceConfigurationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceConfigurationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAssignCommand(), - builder.BuildAssignmentsCommand(), - builder.BuildDeleteCommand(), - builder.BuildDeviceSettingStateSummariesCommand(), - builder.BuildDeviceStatusesCommand(), - builder.BuildDeviceStatusOverviewCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildUserStatusesCommand(), - builder.BuildUserStatusOverviewCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAssignCommand()); + commands.Add(builder.BuildAssignmentsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDeviceSettingStateSummariesCommand()); + commands.Add(builder.BuildDeviceStatusesCommand()); + commands.Add(builder.BuildDeviceStatusOverviewCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildUserStatusesCommand()); + commands.Add(builder.BuildUserStatusOverviewCommand()); return commands; } /// @@ -47,21 +46,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -106,7 +104,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -117,15 +119,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -180,31 +177,6 @@ public RequestInformation CreatePostRequestInformation(DeviceConfiguration body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The device configurations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The device configurations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceConfiguration model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The device configurations. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/DeviceConfigurations/Item/Assign/AssignRequestBuilder.cs b/src/generated/DeviceManagement/DeviceConfigurations/Item/Assign/AssignRequestBuilder.cs index c6907ba5fc2..d5d7219eb85 100644 --- a/src/generated/DeviceManagement/DeviceConfigurations/Item/Assign/AssignRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceConfigurations/Item/Assign/AssignRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action assign"; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceConfigurationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceConfigurationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceConfigurationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceConfigurationIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/DeviceConfigurations/Item/Assignments/AssignmentsRequestBuilder.cs b/src/generated/DeviceManagement/DeviceConfigurations/Item/Assignments/AssignmentsRequestBuilder.cs index 11216785776..1e44357255a 100644 --- a/src/generated/DeviceManagement/DeviceConfigurations/Item/Assignments/AssignmentsRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceConfigurations/Item/Assignments/AssignmentsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AssignmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceConfigurationAssignmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The list of assignments for the device configuration profile."; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceConfigurationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceConfigurationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceConfigurationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceConfigurationIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The list of assignments for the device configuration profile."; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceConfigurationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceConfigurationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceConfigurationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceConfigurationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(DeviceConfigurationAssign requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of assignments for the device configuration profile. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of assignments for the device configuration profile. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceConfigurationAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of assignments for the device configuration profile. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/DeviceConfigurations/Item/Assignments/Item/DeviceConfigurationAssignmentRequestBuilder.cs b/src/generated/DeviceManagement/DeviceConfigurations/Item/Assignments/Item/DeviceConfigurationAssignmentRequestBuilder.cs index e21b35914a8..bc5110849d9 100644 --- a/src/generated/DeviceManagement/DeviceConfigurations/Item/Assignments/Item/DeviceConfigurationAssignmentRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceConfigurations/Item/Assignments/Item/DeviceConfigurationAssignmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of assignments for the device configuration profile."; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); - var deviceConfigurationAssignmentIdOption = new Option("--deviceconfigurationassignment-id", description: "key: id of deviceConfigurationAssignment") { + var deviceConfigurationAssignmentIdOption = new Option("--device-configuration-assignment-id", description: "key: id of deviceConfigurationAssignment") { }; deviceConfigurationAssignmentIdOption.IsRequired = true; command.AddOption(deviceConfigurationAssignmentIdOption); - command.SetHandler(async (string deviceConfigurationId, string deviceConfigurationAssignmentId) => { + command.SetHandler(async (string deviceConfigurationId, string deviceConfigurationAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceConfigurationIdOption, deviceConfigurationAssignmentIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of assignments for the device configuration profile."; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); - var deviceConfigurationAssignmentIdOption = new Option("--deviceconfigurationassignment-id", description: "key: id of deviceConfigurationAssignment") { + var deviceConfigurationAssignmentIdOption = new Option("--device-configuration-assignment-id", description: "key: id of deviceConfigurationAssignment") { }; deviceConfigurationAssignmentIdOption.IsRequired = true; command.AddOption(deviceConfigurationAssignmentIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceConfigurationId, string deviceConfigurationAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceConfigurationId, string deviceConfigurationAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceConfigurationIdOption, deviceConfigurationAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceConfigurationIdOption, deviceConfigurationAssignmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of assignments for the device configuration profile."; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); - var deviceConfigurationAssignmentIdOption = new Option("--deviceconfigurationassignment-id", description: "key: id of deviceConfigurationAssignment") { + var deviceConfigurationAssignmentIdOption = new Option("--device-configuration-assignment-id", description: "key: id of deviceConfigurationAssignment") { }; deviceConfigurationAssignmentIdOption.IsRequired = true; command.AddOption(deviceConfigurationAssignmentIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceConfigurationId, string deviceConfigurationAssignmentId, string body) => { + command.SetHandler(async (string deviceConfigurationId, string deviceConfigurationAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceConfigurationIdOption, deviceConfigurationAssignmentIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceConfigurationAssig requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of assignments for the device configuration profile. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of assignments for the device configuration profile. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of assignments for the device configuration profile. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceConfigurationAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of assignments for the device configuration profile. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/DeviceConfigurations/Item/DeviceConfigurationRequestBuilder.cs b/src/generated/DeviceManagement/DeviceConfigurations/Item/DeviceConfigurationRequestBuilder.cs index 4154f151ec5..f3118a4bb8f 100644 --- a/src/generated/DeviceManagement/DeviceConfigurations/Item/DeviceConfigurationRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceConfigurations/Item/DeviceConfigurationRequestBuilder.cs @@ -9,10 +9,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -36,6 +36,9 @@ public Command BuildAssignCommand() { public Command BuildAssignmentsCommand() { var command = new Command("assignments"); var builder = new ApiSdk.DeviceManagement.DeviceConfigurations.Item.Assignments.AssignmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -47,15 +50,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The device configurations."; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); - command.SetHandler(async (string deviceConfigurationId) => { + command.SetHandler(async (string deviceConfigurationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceConfigurationIdOption); return command; @@ -63,6 +65,9 @@ public Command BuildDeleteCommand() { public Command BuildDeviceSettingStateSummariesCommand() { var command = new Command("device-setting-state-summaries"); var builder = new ApiSdk.DeviceManagement.DeviceConfigurations.Item.DeviceSettingStateSummaries.DeviceSettingStateSummariesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -70,6 +75,9 @@ public Command BuildDeviceSettingStateSummariesCommand() { public Command BuildDeviceStatusesCommand() { var command = new Command("device-statuses"); var builder = new ApiSdk.DeviceManagement.DeviceConfigurations.Item.DeviceStatuses.DeviceStatusesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -89,7 +97,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The device configurations."; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); @@ -103,20 +111,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceConfigurationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceConfigurationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceConfigurationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceConfigurationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -126,7 +133,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The device configurations."; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); @@ -134,14 +141,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceConfigurationId, string body) => { + command.SetHandler(async (string deviceConfigurationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceConfigurationIdOption, bodyOption); return command; @@ -149,6 +155,9 @@ public Command BuildPatchCommand() { public Command BuildUserStatusesCommand() { var command = new Command("user-statuses"); var builder = new ApiSdk.DeviceManagement.DeviceConfigurations.Item.UserStatuses.UserStatusesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -229,29 +238,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceConfiguration body return requestInfo; } /// - /// The device configurations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The device configurations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \deviceManagement\deviceConfigurations\{deviceConfiguration-id}\microsoft.graph.getOmaSettingPlainTextValue(secretReferenceValueId='{secretReferenceValueId}') /// Usage: secretReferenceValueId={secretReferenceValueId} /// @@ -259,19 +245,6 @@ public GetOmaSettingPlainTextValueWithSecretReferenceValueIdRequestBuilder GetOm if(string.IsNullOrEmpty(secretReferenceValueId)) throw new ArgumentNullException(nameof(secretReferenceValueId)); return new GetOmaSettingPlainTextValueWithSecretReferenceValueIdRequestBuilder(PathParameters, RequestAdapter, secretReferenceValueId); } - /// - /// The device configurations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceConfiguration model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The device configurations. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/DeviceConfigurations/Item/DeviceSettingStateSummaries/DeviceSettingStateSummariesRequestBuilder.cs b/src/generated/DeviceManagement/DeviceConfigurations/Item/DeviceSettingStateSummaries/DeviceSettingStateSummariesRequestBuilder.cs index 9cbf235913d..849d5faf97c 100644 --- a/src/generated/DeviceManagement/DeviceConfigurations/Item/DeviceSettingStateSummaries/DeviceSettingStateSummariesRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceConfigurations/Item/DeviceSettingStateSummaries/DeviceSettingStateSummariesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DeviceSettingStateSummariesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SettingStateDeviceSummaryRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Device Configuration Setting State Device Summary"; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceConfigurationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceConfigurationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceConfigurationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceConfigurationIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Device Configuration Setting State Device Summary"; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceConfigurationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceConfigurationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceConfigurationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceConfigurationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(SettingStateDeviceSummary requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Device Configuration Setting State Device Summary - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device Configuration Setting State Device Summary - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SettingStateDeviceSummary model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Device Configuration Setting State Device Summary public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/DeviceConfigurations/Item/DeviceSettingStateSummaries/Item/SettingStateDeviceSummaryRequestBuilder.cs b/src/generated/DeviceManagement/DeviceConfigurations/Item/DeviceSettingStateSummaries/Item/SettingStateDeviceSummaryRequestBuilder.cs index d4ef2c26dd2..0c489b303b7 100644 --- a/src/generated/DeviceManagement/DeviceConfigurations/Item/DeviceSettingStateSummaries/Item/SettingStateDeviceSummaryRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceConfigurations/Item/DeviceSettingStateSummaries/Item/SettingStateDeviceSummaryRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Device Configuration Setting State Device Summary"; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); - var settingStateDeviceSummaryIdOption = new Option("--settingstatedevicesummary-id", description: "key: id of settingStateDeviceSummary") { + var settingStateDeviceSummaryIdOption = new Option("--setting-state-device-summary-id", description: "key: id of settingStateDeviceSummary") { }; settingStateDeviceSummaryIdOption.IsRequired = true; command.AddOption(settingStateDeviceSummaryIdOption); - command.SetHandler(async (string deviceConfigurationId, string settingStateDeviceSummaryId) => { + command.SetHandler(async (string deviceConfigurationId, string settingStateDeviceSummaryId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceConfigurationIdOption, settingStateDeviceSummaryIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Device Configuration Setting State Device Summary"; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); - var settingStateDeviceSummaryIdOption = new Option("--settingstatedevicesummary-id", description: "key: id of settingStateDeviceSummary") { + var settingStateDeviceSummaryIdOption = new Option("--setting-state-device-summary-id", description: "key: id of settingStateDeviceSummary") { }; settingStateDeviceSummaryIdOption.IsRequired = true; command.AddOption(settingStateDeviceSummaryIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceConfigurationId, string settingStateDeviceSummaryId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceConfigurationId, string settingStateDeviceSummaryId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceConfigurationIdOption, settingStateDeviceSummaryIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceConfigurationIdOption, settingStateDeviceSummaryIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Device Configuration Setting State Device Summary"; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); - var settingStateDeviceSummaryIdOption = new Option("--settingstatedevicesummary-id", description: "key: id of settingStateDeviceSummary") { + var settingStateDeviceSummaryIdOption = new Option("--setting-state-device-summary-id", description: "key: id of settingStateDeviceSummary") { }; settingStateDeviceSummaryIdOption.IsRequired = true; command.AddOption(settingStateDeviceSummaryIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceConfigurationId, string settingStateDeviceSummaryId, string body) => { + command.SetHandler(async (string deviceConfigurationId, string settingStateDeviceSummaryId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceConfigurationIdOption, settingStateDeviceSummaryIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SettingStateDeviceSummar requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Device Configuration Setting State Device Summary - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device Configuration Setting State Device Summary - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device Configuration Setting State Device Summary - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SettingStateDeviceSummary model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Device Configuration Setting State Device Summary public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/DeviceConfigurations/Item/DeviceStatusOverview/DeviceStatusOverviewRequestBuilder.cs b/src/generated/DeviceManagement/DeviceConfigurations/Item/DeviceStatusOverview/DeviceStatusOverviewRequestBuilder.cs index 586f5e0caa8..3def4057ddc 100644 --- a/src/generated/DeviceManagement/DeviceConfigurations/Item/DeviceStatusOverview/DeviceStatusOverviewRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceConfigurations/Item/DeviceStatusOverview/DeviceStatusOverviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Device Configuration devices status overview"; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); - command.SetHandler(async (string deviceConfigurationId) => { + command.SetHandler(async (string deviceConfigurationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceConfigurationIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Device Configuration devices status overview"; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceConfigurationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceConfigurationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceConfigurationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceConfigurationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Device Configuration devices status overview"; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceConfigurationId, string body) => { + command.SetHandler(async (string deviceConfigurationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceConfigurationIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceConfigurationDevic requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Device Configuration devices status overview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device Configuration devices status overview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device Configuration devices status overview - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceConfigurationDeviceOverview model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Device Configuration devices status overview public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/DeviceConfigurations/Item/DeviceStatuses/DeviceStatusesRequestBuilder.cs b/src/generated/DeviceManagement/DeviceConfigurations/Item/DeviceStatuses/DeviceStatusesRequestBuilder.cs index 9a9ed6648ea..9eaed5bf4e5 100644 --- a/src/generated/DeviceManagement/DeviceConfigurations/Item/DeviceStatuses/DeviceStatusesRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceConfigurations/Item/DeviceStatuses/DeviceStatusesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DeviceStatusesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceConfigurationDeviceStatusRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Device configuration installation status by device."; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceConfigurationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceConfigurationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceConfigurationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceConfigurationIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Device configuration installation status by device."; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceConfigurationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceConfigurationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceConfigurationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceConfigurationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(DeviceConfigurationDevice requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Device configuration installation status by device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device configuration installation status by device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceConfigurationDeviceStatus model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Device configuration installation status by device. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/DeviceConfigurations/Item/DeviceStatuses/Item/DeviceConfigurationDeviceStatusRequestBuilder.cs b/src/generated/DeviceManagement/DeviceConfigurations/Item/DeviceStatuses/Item/DeviceConfigurationDeviceStatusRequestBuilder.cs index 63a86c644d2..ee99af1f741 100644 --- a/src/generated/DeviceManagement/DeviceConfigurations/Item/DeviceStatuses/Item/DeviceConfigurationDeviceStatusRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceConfigurations/Item/DeviceStatuses/Item/DeviceConfigurationDeviceStatusRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Device configuration installation status by device."; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); - var deviceConfigurationDeviceStatusIdOption = new Option("--deviceconfigurationdevicestatus-id", description: "key: id of deviceConfigurationDeviceStatus") { + var deviceConfigurationDeviceStatusIdOption = new Option("--device-configuration-device-status-id", description: "key: id of deviceConfigurationDeviceStatus") { }; deviceConfigurationDeviceStatusIdOption.IsRequired = true; command.AddOption(deviceConfigurationDeviceStatusIdOption); - command.SetHandler(async (string deviceConfigurationId, string deviceConfigurationDeviceStatusId) => { + command.SetHandler(async (string deviceConfigurationId, string deviceConfigurationDeviceStatusId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceConfigurationIdOption, deviceConfigurationDeviceStatusIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Device configuration installation status by device."; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); - var deviceConfigurationDeviceStatusIdOption = new Option("--deviceconfigurationdevicestatus-id", description: "key: id of deviceConfigurationDeviceStatus") { + var deviceConfigurationDeviceStatusIdOption = new Option("--device-configuration-device-status-id", description: "key: id of deviceConfigurationDeviceStatus") { }; deviceConfigurationDeviceStatusIdOption.IsRequired = true; command.AddOption(deviceConfigurationDeviceStatusIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceConfigurationId, string deviceConfigurationDeviceStatusId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceConfigurationId, string deviceConfigurationDeviceStatusId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceConfigurationIdOption, deviceConfigurationDeviceStatusIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceConfigurationIdOption, deviceConfigurationDeviceStatusIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Device configuration installation status by device."; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); - var deviceConfigurationDeviceStatusIdOption = new Option("--deviceconfigurationdevicestatus-id", description: "key: id of deviceConfigurationDeviceStatus") { + var deviceConfigurationDeviceStatusIdOption = new Option("--device-configuration-device-status-id", description: "key: id of deviceConfigurationDeviceStatus") { }; deviceConfigurationDeviceStatusIdOption.IsRequired = true; command.AddOption(deviceConfigurationDeviceStatusIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceConfigurationId, string deviceConfigurationDeviceStatusId, string body) => { + command.SetHandler(async (string deviceConfigurationId, string deviceConfigurationDeviceStatusId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceConfigurationIdOption, deviceConfigurationDeviceStatusIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceConfigurationDevic requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Device configuration installation status by device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device configuration installation status by device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device configuration installation status by device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceConfigurationDeviceStatus model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Device configuration installation status by device. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/DeviceConfigurations/Item/GetOmaSettingPlainTextValueWithSecretReferenceValueId/GetOmaSettingPlainTextValueWithSecretReferenceValueIdRequestBuilder.cs b/src/generated/DeviceManagement/DeviceConfigurations/Item/GetOmaSettingPlainTextValueWithSecretReferenceValueId/GetOmaSettingPlainTextValueWithSecretReferenceValueIdRequestBuilder.cs index 44b6e2cc95d..aabbb3a0080 100644 --- a/src/generated/DeviceManagement/DeviceConfigurations/Item/GetOmaSettingPlainTextValueWithSecretReferenceValueId/GetOmaSettingPlainTextValueWithSecretReferenceValueIdRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceConfigurations/Item/GetOmaSettingPlainTextValueWithSecretReferenceValueId/GetOmaSettingPlainTextValueWithSecretReferenceValueIdRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,26 +25,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function getOmaSettingPlainTextValue"; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); - var secretReferenceValueIdOption = new Option("--secretreferencevalueid", description: "Usage: secretReferenceValueId={secretReferenceValueId}") { + var secretReferenceValueIdOption = new Option("--secret-reference-value-id", description: "Usage: secretReferenceValueId={secretReferenceValueId}") { }; secretReferenceValueIdOption.IsRequired = true; command.AddOption(secretReferenceValueIdOption); - command.SetHandler(async (string deviceConfigurationId, string secretReferenceValueId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceConfigurationId, string secretReferenceValueId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceConfigurationIdOption, secretReferenceValueIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceConfigurationIdOption, secretReferenceValueIdOption, outputOption); return command; } /// @@ -77,16 +76,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getOmaSettingPlainTextValue - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/DeviceConfigurations/Item/UserStatusOverview/UserStatusOverviewRequestBuilder.cs b/src/generated/DeviceManagement/DeviceConfigurations/Item/UserStatusOverview/UserStatusOverviewRequestBuilder.cs index 8cc77a1bbc8..e8820e60106 100644 --- a/src/generated/DeviceManagement/DeviceConfigurations/Item/UserStatusOverview/UserStatusOverviewRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceConfigurations/Item/UserStatusOverview/UserStatusOverviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Device Configuration users status overview"; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); - command.SetHandler(async (string deviceConfigurationId) => { + command.SetHandler(async (string deviceConfigurationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceConfigurationIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Device Configuration users status overview"; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceConfigurationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceConfigurationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceConfigurationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceConfigurationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Device Configuration users status overview"; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceConfigurationId, string body) => { + command.SetHandler(async (string deviceConfigurationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceConfigurationIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceConfigurationUserO requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Device Configuration users status overview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device Configuration users status overview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device Configuration users status overview - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceConfigurationUserOverview model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Device Configuration users status overview public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/DeviceConfigurations/Item/UserStatuses/Item/DeviceConfigurationUserStatusRequestBuilder.cs b/src/generated/DeviceManagement/DeviceConfigurations/Item/UserStatuses/Item/DeviceConfigurationUserStatusRequestBuilder.cs index a6fdc1bc25e..b85c1011680 100644 --- a/src/generated/DeviceManagement/DeviceConfigurations/Item/UserStatuses/Item/DeviceConfigurationUserStatusRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceConfigurations/Item/UserStatuses/Item/DeviceConfigurationUserStatusRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Device configuration installation status by user."; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); - var deviceConfigurationUserStatusIdOption = new Option("--deviceconfigurationuserstatus-id", description: "key: id of deviceConfigurationUserStatus") { + var deviceConfigurationUserStatusIdOption = new Option("--device-configuration-user-status-id", description: "key: id of deviceConfigurationUserStatus") { }; deviceConfigurationUserStatusIdOption.IsRequired = true; command.AddOption(deviceConfigurationUserStatusIdOption); - command.SetHandler(async (string deviceConfigurationId, string deviceConfigurationUserStatusId) => { + command.SetHandler(async (string deviceConfigurationId, string deviceConfigurationUserStatusId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceConfigurationIdOption, deviceConfigurationUserStatusIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Device configuration installation status by user."; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); - var deviceConfigurationUserStatusIdOption = new Option("--deviceconfigurationuserstatus-id", description: "key: id of deviceConfigurationUserStatus") { + var deviceConfigurationUserStatusIdOption = new Option("--device-configuration-user-status-id", description: "key: id of deviceConfigurationUserStatus") { }; deviceConfigurationUserStatusIdOption.IsRequired = true; command.AddOption(deviceConfigurationUserStatusIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceConfigurationId, string deviceConfigurationUserStatusId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceConfigurationId, string deviceConfigurationUserStatusId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceConfigurationIdOption, deviceConfigurationUserStatusIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceConfigurationIdOption, deviceConfigurationUserStatusIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Device configuration installation status by user."; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); - var deviceConfigurationUserStatusIdOption = new Option("--deviceconfigurationuserstatus-id", description: "key: id of deviceConfigurationUserStatus") { + var deviceConfigurationUserStatusIdOption = new Option("--device-configuration-user-status-id", description: "key: id of deviceConfigurationUserStatus") { }; deviceConfigurationUserStatusIdOption.IsRequired = true; command.AddOption(deviceConfigurationUserStatusIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceConfigurationId, string deviceConfigurationUserStatusId, string body) => { + command.SetHandler(async (string deviceConfigurationId, string deviceConfigurationUserStatusId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceConfigurationIdOption, deviceConfigurationUserStatusIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceConfigurationUserS requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Device configuration installation status by user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device configuration installation status by user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device configuration installation status by user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceConfigurationUserStatus model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Device configuration installation status by user. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/DeviceConfigurations/Item/UserStatuses/UserStatusesRequestBuilder.cs b/src/generated/DeviceManagement/DeviceConfigurations/Item/UserStatuses/UserStatusesRequestBuilder.cs index 211944f69e3..f785917ef71 100644 --- a/src/generated/DeviceManagement/DeviceConfigurations/Item/UserStatuses/UserStatusesRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceConfigurations/Item/UserStatuses/UserStatusesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class UserStatusesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceConfigurationUserStatusRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Device configuration installation status by user."; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceConfigurationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceConfigurationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceConfigurationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceConfigurationIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Device configuration installation status by user."; // Create options for all the parameters - var deviceConfigurationIdOption = new Option("--deviceconfiguration-id", description: "key: id of deviceConfiguration") { + var deviceConfigurationIdOption = new Option("--device-configuration-id", description: "key: id of deviceConfiguration") { }; deviceConfigurationIdOption.IsRequired = true; command.AddOption(deviceConfigurationIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceConfigurationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceConfigurationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceConfigurationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceConfigurationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(DeviceConfigurationUserSt requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Device configuration installation status by user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device configuration installation status by user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceConfigurationUserStatus model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Device configuration installation status by user. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/DeviceEnrollmentConfigurations/DeviceEnrollmentConfigurationsRequestBuilder.cs b/src/generated/DeviceManagement/DeviceEnrollmentConfigurations/DeviceEnrollmentConfigurationsRequestBuilder.cs index a183186e40f..151cb7c4d57 100644 --- a/src/generated/DeviceManagement/DeviceEnrollmentConfigurations/DeviceEnrollmentConfigurationsRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceEnrollmentConfigurations/DeviceEnrollmentConfigurationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class DeviceEnrollmentConfigurationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceEnrollmentConfigurationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAssignCommand(), - builder.BuildAssignmentsCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSetPriorityCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAssignCommand()); + commands.Add(builder.BuildAssignmentsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSetPriorityCommand()); return commands; } /// @@ -43,21 +42,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -102,7 +100,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -113,15 +115,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -176,31 +173,6 @@ public RequestInformation CreatePostRequestInformation(DeviceEnrollmentConfigura requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of device enrollment configurations - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of device enrollment configurations - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceEnrollmentConfiguration model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of device enrollment configurations public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/DeviceEnrollmentConfigurations/Item/Assign/AssignRequestBuilder.cs b/src/generated/DeviceManagement/DeviceEnrollmentConfigurations/Item/Assign/AssignRequestBuilder.cs index 80d0097020c..730ae126650 100644 --- a/src/generated/DeviceManagement/DeviceEnrollmentConfigurations/Item/Assign/AssignRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceEnrollmentConfigurations/Item/Assign/AssignRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action assign"; // Create options for all the parameters - var deviceEnrollmentConfigurationIdOption = new Option("--deviceenrollmentconfiguration-id", description: "key: id of deviceEnrollmentConfiguration") { + var deviceEnrollmentConfigurationIdOption = new Option("--device-enrollment-configuration-id", description: "key: id of deviceEnrollmentConfiguration") { }; deviceEnrollmentConfigurationIdOption.IsRequired = true; command.AddOption(deviceEnrollmentConfigurationIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceEnrollmentConfigurationId, string body) => { + command.SetHandler(async (string deviceEnrollmentConfigurationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceEnrollmentConfigurationIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/DeviceEnrollmentConfigurations/Item/Assignments/AssignmentsRequestBuilder.cs b/src/generated/DeviceManagement/DeviceEnrollmentConfigurations/Item/Assignments/AssignmentsRequestBuilder.cs index 1c171656a5f..d9330c77057 100644 --- a/src/generated/DeviceManagement/DeviceEnrollmentConfigurations/Item/Assignments/AssignmentsRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceEnrollmentConfigurations/Item/Assignments/AssignmentsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AssignmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EnrollmentConfigurationAssignmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The list of group assignments for the device configuration profile"; // Create options for all the parameters - var deviceEnrollmentConfigurationIdOption = new Option("--deviceenrollmentconfiguration-id", description: "key: id of deviceEnrollmentConfiguration") { + var deviceEnrollmentConfigurationIdOption = new Option("--device-enrollment-configuration-id", description: "key: id of deviceEnrollmentConfiguration") { }; deviceEnrollmentConfigurationIdOption.IsRequired = true; command.AddOption(deviceEnrollmentConfigurationIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceEnrollmentConfigurationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceEnrollmentConfigurationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceEnrollmentConfigurationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceEnrollmentConfigurationIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The list of group assignments for the device configuration profile"; // Create options for all the parameters - var deviceEnrollmentConfigurationIdOption = new Option("--deviceenrollmentconfiguration-id", description: "key: id of deviceEnrollmentConfiguration") { + var deviceEnrollmentConfigurationIdOption = new Option("--device-enrollment-configuration-id", description: "key: id of deviceEnrollmentConfiguration") { }; deviceEnrollmentConfigurationIdOption.IsRequired = true; command.AddOption(deviceEnrollmentConfigurationIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceEnrollmentConfigurationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceEnrollmentConfigurationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceEnrollmentConfigurationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceEnrollmentConfigurationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(EnrollmentConfigurationAs requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of group assignments for the device configuration profile - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of group assignments for the device configuration profile - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EnrollmentConfigurationAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of group assignments for the device configuration profile public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/DeviceEnrollmentConfigurations/Item/Assignments/Item/EnrollmentConfigurationAssignmentRequestBuilder.cs b/src/generated/DeviceManagement/DeviceEnrollmentConfigurations/Item/Assignments/Item/EnrollmentConfigurationAssignmentRequestBuilder.cs index 7d4c07c4332..df899e3bbd2 100644 --- a/src/generated/DeviceManagement/DeviceEnrollmentConfigurations/Item/Assignments/Item/EnrollmentConfigurationAssignmentRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceEnrollmentConfigurations/Item/Assignments/Item/EnrollmentConfigurationAssignmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of group assignments for the device configuration profile"; // Create options for all the parameters - var deviceEnrollmentConfigurationIdOption = new Option("--deviceenrollmentconfiguration-id", description: "key: id of deviceEnrollmentConfiguration") { + var deviceEnrollmentConfigurationIdOption = new Option("--device-enrollment-configuration-id", description: "key: id of deviceEnrollmentConfiguration") { }; deviceEnrollmentConfigurationIdOption.IsRequired = true; command.AddOption(deviceEnrollmentConfigurationIdOption); - var enrollmentConfigurationAssignmentIdOption = new Option("--enrollmentconfigurationassignment-id", description: "key: id of enrollmentConfigurationAssignment") { + var enrollmentConfigurationAssignmentIdOption = new Option("--enrollment-configuration-assignment-id", description: "key: id of enrollmentConfigurationAssignment") { }; enrollmentConfigurationAssignmentIdOption.IsRequired = true; command.AddOption(enrollmentConfigurationAssignmentIdOption); - command.SetHandler(async (string deviceEnrollmentConfigurationId, string enrollmentConfigurationAssignmentId) => { + command.SetHandler(async (string deviceEnrollmentConfigurationId, string enrollmentConfigurationAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceEnrollmentConfigurationIdOption, enrollmentConfigurationAssignmentIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of group assignments for the device configuration profile"; // Create options for all the parameters - var deviceEnrollmentConfigurationIdOption = new Option("--deviceenrollmentconfiguration-id", description: "key: id of deviceEnrollmentConfiguration") { + var deviceEnrollmentConfigurationIdOption = new Option("--device-enrollment-configuration-id", description: "key: id of deviceEnrollmentConfiguration") { }; deviceEnrollmentConfigurationIdOption.IsRequired = true; command.AddOption(deviceEnrollmentConfigurationIdOption); - var enrollmentConfigurationAssignmentIdOption = new Option("--enrollmentconfigurationassignment-id", description: "key: id of enrollmentConfigurationAssignment") { + var enrollmentConfigurationAssignmentIdOption = new Option("--enrollment-configuration-assignment-id", description: "key: id of enrollmentConfigurationAssignment") { }; enrollmentConfigurationAssignmentIdOption.IsRequired = true; command.AddOption(enrollmentConfigurationAssignmentIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceEnrollmentConfigurationId, string enrollmentConfigurationAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceEnrollmentConfigurationId, string enrollmentConfigurationAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceEnrollmentConfigurationIdOption, enrollmentConfigurationAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceEnrollmentConfigurationIdOption, enrollmentConfigurationAssignmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of group assignments for the device configuration profile"; // Create options for all the parameters - var deviceEnrollmentConfigurationIdOption = new Option("--deviceenrollmentconfiguration-id", description: "key: id of deviceEnrollmentConfiguration") { + var deviceEnrollmentConfigurationIdOption = new Option("--device-enrollment-configuration-id", description: "key: id of deviceEnrollmentConfiguration") { }; deviceEnrollmentConfigurationIdOption.IsRequired = true; command.AddOption(deviceEnrollmentConfigurationIdOption); - var enrollmentConfigurationAssignmentIdOption = new Option("--enrollmentconfigurationassignment-id", description: "key: id of enrollmentConfigurationAssignment") { + var enrollmentConfigurationAssignmentIdOption = new Option("--enrollment-configuration-assignment-id", description: "key: id of enrollmentConfigurationAssignment") { }; enrollmentConfigurationAssignmentIdOption.IsRequired = true; command.AddOption(enrollmentConfigurationAssignmentIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceEnrollmentConfigurationId, string enrollmentConfigurationAssignmentId, string body) => { + command.SetHandler(async (string deviceEnrollmentConfigurationId, string enrollmentConfigurationAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceEnrollmentConfigurationIdOption, enrollmentConfigurationAssignmentIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(EnrollmentConfigurationA requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of group assignments for the device configuration profile - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of group assignments for the device configuration profile - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of group assignments for the device configuration profile - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EnrollmentConfigurationAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of group assignments for the device configuration profile public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/DeviceEnrollmentConfigurations/Item/DeviceEnrollmentConfigurationRequestBuilder.cs b/src/generated/DeviceManagement/DeviceEnrollmentConfigurations/Item/DeviceEnrollmentConfigurationRequestBuilder.cs index 3b2275cdff2..cb08f45ca2b 100644 --- a/src/generated/DeviceManagement/DeviceEnrollmentConfigurations/Item/DeviceEnrollmentConfigurationRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceEnrollmentConfigurations/Item/DeviceEnrollmentConfigurationRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,6 +31,9 @@ public Command BuildAssignCommand() { public Command BuildAssignmentsCommand() { var command = new Command("assignments"); var builder = new ApiSdk.DeviceManagement.DeviceEnrollmentConfigurations.Item.Assignments.AssignmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -42,15 +45,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of device enrollment configurations"; // Create options for all the parameters - var deviceEnrollmentConfigurationIdOption = new Option("--deviceenrollmentconfiguration-id", description: "key: id of deviceEnrollmentConfiguration") { + var deviceEnrollmentConfigurationIdOption = new Option("--device-enrollment-configuration-id", description: "key: id of deviceEnrollmentConfiguration") { }; deviceEnrollmentConfigurationIdOption.IsRequired = true; command.AddOption(deviceEnrollmentConfigurationIdOption); - command.SetHandler(async (string deviceEnrollmentConfigurationId) => { + command.SetHandler(async (string deviceEnrollmentConfigurationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceEnrollmentConfigurationIdOption); return command; @@ -62,7 +64,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of device enrollment configurations"; // Create options for all the parameters - var deviceEnrollmentConfigurationIdOption = new Option("--deviceenrollmentconfiguration-id", description: "key: id of deviceEnrollmentConfiguration") { + var deviceEnrollmentConfigurationIdOption = new Option("--device-enrollment-configuration-id", description: "key: id of deviceEnrollmentConfiguration") { }; deviceEnrollmentConfigurationIdOption.IsRequired = true; command.AddOption(deviceEnrollmentConfigurationIdOption); @@ -76,20 +78,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceEnrollmentConfigurationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceEnrollmentConfigurationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceEnrollmentConfigurationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceEnrollmentConfigurationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,7 +100,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of device enrollment configurations"; // Create options for all the parameters - var deviceEnrollmentConfigurationIdOption = new Option("--deviceenrollmentconfiguration-id", description: "key: id of deviceEnrollmentConfiguration") { + var deviceEnrollmentConfigurationIdOption = new Option("--device-enrollment-configuration-id", description: "key: id of deviceEnrollmentConfiguration") { }; deviceEnrollmentConfigurationIdOption.IsRequired = true; command.AddOption(deviceEnrollmentConfigurationIdOption); @@ -107,14 +108,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceEnrollmentConfigurationId, string body) => { + command.SetHandler(async (string deviceEnrollmentConfigurationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceEnrollmentConfigurationIdOption, bodyOption); return command; @@ -192,42 +192,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceEnrollmentConfigur requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of device enrollment configurations - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of device enrollment configurations - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of device enrollment configurations - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceEnrollmentConfiguration model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of device enrollment configurations public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/DeviceEnrollmentConfigurations/Item/SetPriority/SetPriorityRequestBuilder.cs b/src/generated/DeviceManagement/DeviceEnrollmentConfigurations/Item/SetPriority/SetPriorityRequestBuilder.cs index 5c4888793c0..351eaa0c4d5 100644 --- a/src/generated/DeviceManagement/DeviceEnrollmentConfigurations/Item/SetPriority/SetPriorityRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceEnrollmentConfigurations/Item/SetPriority/SetPriorityRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setPriority"; // Create options for all the parameters - var deviceEnrollmentConfigurationIdOption = new Option("--deviceenrollmentconfiguration-id", description: "key: id of deviceEnrollmentConfiguration") { + var deviceEnrollmentConfigurationIdOption = new Option("--device-enrollment-configuration-id", description: "key: id of deviceEnrollmentConfiguration") { }; deviceEnrollmentConfigurationIdOption.IsRequired = true; command.AddOption(deviceEnrollmentConfigurationIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceEnrollmentConfigurationId, string body) => { + command.SetHandler(async (string deviceEnrollmentConfigurationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceEnrollmentConfigurationIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(SetPriorityRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setPriority - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetPriorityRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/DeviceManagementPartners/DeviceManagementPartnersRequestBuilder.cs b/src/generated/DeviceManagement/DeviceManagementPartners/DeviceManagementPartnersRequestBuilder.cs index 2a001a2e7a5..97918f8a0d8 100644 --- a/src/generated/DeviceManagement/DeviceManagementPartners/DeviceManagementPartnersRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceManagementPartners/DeviceManagementPartnersRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DeviceManagementPartnersRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceManagementPartnerRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(DeviceManagementPartner b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of Device Management Partners configured by the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of Device Management Partners configured by the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceManagementPartner model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of Device Management Partners configured by the tenant. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/DeviceManagementPartners/Item/DeviceManagementPartnerRequestBuilder.cs b/src/generated/DeviceManagement/DeviceManagementPartners/Item/DeviceManagementPartnerRequestBuilder.cs index 843a4695b0a..77726dba8b9 100644 --- a/src/generated/DeviceManagement/DeviceManagementPartners/Item/DeviceManagementPartnerRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceManagementPartners/Item/DeviceManagementPartnerRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of Device Management Partners configured by the tenant."; // Create options for all the parameters - var deviceManagementPartnerIdOption = new Option("--devicemanagementpartner-id", description: "key: id of deviceManagementPartner") { + var deviceManagementPartnerIdOption = new Option("--device-management-partner-id", description: "key: id of deviceManagementPartner") { }; deviceManagementPartnerIdOption.IsRequired = true; command.AddOption(deviceManagementPartnerIdOption); - command.SetHandler(async (string deviceManagementPartnerId) => { + command.SetHandler(async (string deviceManagementPartnerId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceManagementPartnerIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of Device Management Partners configured by the tenant."; // Create options for all the parameters - var deviceManagementPartnerIdOption = new Option("--devicemanagementpartner-id", description: "key: id of deviceManagementPartner") { + var deviceManagementPartnerIdOption = new Option("--device-management-partner-id", description: "key: id of deviceManagementPartner") { }; deviceManagementPartnerIdOption.IsRequired = true; command.AddOption(deviceManagementPartnerIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceManagementPartnerId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceManagementPartnerId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceManagementPartnerIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceManagementPartnerIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of Device Management Partners configured by the tenant."; // Create options for all the parameters - var deviceManagementPartnerIdOption = new Option("--devicemanagementpartner-id", description: "key: id of deviceManagementPartner") { + var deviceManagementPartnerIdOption = new Option("--device-management-partner-id", description: "key: id of deviceManagementPartner") { }; deviceManagementPartnerIdOption.IsRequired = true; command.AddOption(deviceManagementPartnerIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceManagementPartnerId, string body) => { + command.SetHandler(async (string deviceManagementPartnerId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceManagementPartnerIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceManagementPartner requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of Device Management Partners configured by the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of Device Management Partners configured by the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of Device Management Partners configured by the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceManagementPartner model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of Device Management Partners configured by the tenant. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/DeviceManagementRequestBuilder.cs b/src/generated/DeviceManagement/DeviceManagementRequestBuilder.cs index ed59583a53e..3132f3a0f12 100644 --- a/src/generated/DeviceManagement/DeviceManagementRequestBuilder.cs +++ b/src/generated/DeviceManagement/DeviceManagementRequestBuilder.cs @@ -34,10 +34,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -63,6 +63,9 @@ public Command BuildApplePushNotificationCertificateCommand() { public Command BuildComplianceManagementPartnersCommand() { var command = new Command("compliance-management-partners"); var builder = new ApiSdk.DeviceManagement.ComplianceManagementPartners.ComplianceManagementPartnersRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -78,6 +81,9 @@ public Command BuildConditionalAccessSettingsCommand() { public Command BuildDetectedAppsCommand() { var command = new Command("detected-apps"); var builder = new ApiSdk.DeviceManagement.DetectedApps.DetectedAppsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -85,6 +91,9 @@ public Command BuildDetectedAppsCommand() { public Command BuildDeviceCategoriesCommand() { var command = new Command("device-categories"); var builder = new ApiSdk.DeviceManagement.DeviceCategories.DeviceCategoriesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -92,6 +101,9 @@ public Command BuildDeviceCategoriesCommand() { public Command BuildDeviceCompliancePoliciesCommand() { var command = new Command("device-compliance-policies"); var builder = new ApiSdk.DeviceManagement.DeviceCompliancePolicies.DeviceCompliancePoliciesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -107,6 +119,9 @@ public Command BuildDeviceCompliancePolicyDeviceStateSummaryCommand() { public Command BuildDeviceCompliancePolicySettingStateSummariesCommand() { var command = new Command("device-compliance-policy-setting-state-summaries"); var builder = new ApiSdk.DeviceManagement.DeviceCompliancePolicySettingStateSummaries.DeviceCompliancePolicySettingStateSummariesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -122,6 +137,9 @@ public Command BuildDeviceConfigurationDeviceStateSummariesCommand() { public Command BuildDeviceConfigurationsCommand() { var command = new Command("device-configurations"); var builder = new ApiSdk.DeviceManagement.DeviceConfigurations.DeviceConfigurationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -129,6 +147,9 @@ public Command BuildDeviceConfigurationsCommand() { public Command BuildDeviceEnrollmentConfigurationsCommand() { var command = new Command("device-enrollment-configurations"); var builder = new ApiSdk.DeviceManagement.DeviceEnrollmentConfigurations.DeviceEnrollmentConfigurationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -136,6 +157,9 @@ public Command BuildDeviceEnrollmentConfigurationsCommand() { public Command BuildDeviceManagementPartnersCommand() { var command = new Command("device-management-partners"); var builder = new ApiSdk.DeviceManagement.DeviceManagementPartners.DeviceManagementPartnersRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -143,6 +167,9 @@ public Command BuildDeviceManagementPartnersCommand() { public Command BuildExchangeConnectorsCommand() { var command = new Command("exchange-connectors"); var builder = new ApiSdk.DeviceManagement.ExchangeConnectors.ExchangeConnectorsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -164,25 +191,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } public Command BuildImportedWindowsAutopilotDeviceIdentitiesCommand() { var command = new Command("imported-windows-autopilot-device-identities"); var builder = new ApiSdk.DeviceManagement.ImportedWindowsAutopilotDeviceIdentities.ImportedWindowsAutopilotDeviceIdentitiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildImportCommand()); command.AddCommand(builder.BuildListCommand()); @@ -191,6 +220,9 @@ public Command BuildImportedWindowsAutopilotDeviceIdentitiesCommand() { public Command BuildIosUpdateStatusesCommand() { var command = new Command("ios-update-statuses"); var builder = new ApiSdk.DeviceManagement.IosUpdateStatuses.IosUpdateStatusesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -205,6 +237,9 @@ public Command BuildManagedDeviceOverviewCommand() { public Command BuildManagedDevicesCommand() { var command = new Command("managed-devices"); var builder = new ApiSdk.DeviceManagement.ManagedDevices.ManagedDevicesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -212,6 +247,9 @@ public Command BuildManagedDevicesCommand() { public Command BuildMobileThreatDefenseConnectorsCommand() { var command = new Command("mobile-threat-defense-connectors"); var builder = new ApiSdk.DeviceManagement.MobileThreatDefenseConnectors.MobileThreatDefenseConnectorsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -219,6 +257,9 @@ public Command BuildMobileThreatDefenseConnectorsCommand() { public Command BuildNotificationMessageTemplatesCommand() { var command = new Command("notification-message-templates"); var builder = new ApiSdk.DeviceManagement.NotificationMessageTemplates.NotificationMessageTemplatesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -234,14 +275,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -249,6 +289,9 @@ public Command BuildPatchCommand() { public Command BuildRemoteAssistancePartnersCommand() { var command = new Command("remote-assistance-partners"); var builder = new ApiSdk.DeviceManagement.RemoteAssistancePartners.RemoteAssistancePartnersRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -281,6 +324,9 @@ public Command BuildReportsCommand() { public Command BuildResourceOperationsCommand() { var command = new Command("resource-operations"); var builder = new ApiSdk.DeviceManagement.ResourceOperations.ResourceOperationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -288,6 +334,9 @@ public Command BuildResourceOperationsCommand() { public Command BuildRoleAssignmentsCommand() { var command = new Command("role-assignments"); var builder = new ApiSdk.DeviceManagement.RoleAssignments.RoleAssignmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -295,6 +344,9 @@ public Command BuildRoleAssignmentsCommand() { public Command BuildRoleDefinitionsCommand() { var command = new Command("role-definitions"); var builder = new ApiSdk.DeviceManagement.RoleDefinitions.RoleDefinitionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -309,6 +361,9 @@ public Command BuildSoftwareUpdateStatusSummaryCommand() { public Command BuildTelecomExpenseManagementPartnersCommand() { var command = new Command("telecom-expense-management-partners"); var builder = new ApiSdk.DeviceManagement.TelecomExpenseManagementPartners.TelecomExpenseManagementPartnersRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -316,6 +371,9 @@ public Command BuildTelecomExpenseManagementPartnersCommand() { public Command BuildTermsAndConditionsCommand() { var command = new Command("terms-and-conditions"); var builder = new ApiSdk.DeviceManagement.TermsAndConditions.TermsAndConditionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -323,6 +381,9 @@ public Command BuildTermsAndConditionsCommand() { public Command BuildTroubleshootingEventsCommand() { var command = new Command("troubleshooting-events"); var builder = new ApiSdk.DeviceManagement.TroubleshootingEvents.TroubleshootingEventsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -330,6 +391,9 @@ public Command BuildTroubleshootingEventsCommand() { public Command BuildWindowsAutopilotDeviceIdentitiesCommand() { var command = new Command("windows-autopilot-device-identities"); var builder = new ApiSdk.DeviceManagement.WindowsAutopilotDeviceIdentities.WindowsAutopilotDeviceIdentitiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -337,6 +401,9 @@ public Command BuildWindowsAutopilotDeviceIdentitiesCommand() { public Command BuildWindowsInformationProtectionAppLearningSummariesCommand() { var command = new Command("windows-information-protection-app-learning-summaries"); var builder = new ApiSdk.DeviceManagement.WindowsInformationProtectionAppLearningSummaries.WindowsInformationProtectionAppLearningSummariesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -344,6 +411,9 @@ public Command BuildWindowsInformationProtectionAppLearningSummariesCommand() { public Command BuildWindowsInformationProtectionNetworkLearningSummariesCommand() { var command = new Command("windows-information-protection-network-learning-summaries"); var builder = new ApiSdk.DeviceManagement.WindowsInformationProtectionNetworkLearningSummaries.WindowsInformationProtectionNetworkLearningSummariesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -401,18 +471,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. return requestInfo; } /// - /// Get deviceManagement - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \deviceManagement\microsoft.graph.getEffectivePermissions(scope='{scope}') /// Usage: scope={scope} /// @@ -421,19 +479,6 @@ public GetEffectivePermissionsWithScopeRequestBuilder GetEffectivePermissionsWit return new GetEffectivePermissionsWithScopeRequestBuilder(PathParameters, RequestAdapter, scope); } /// - /// Update deviceManagement - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DeviceManagement model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \deviceManagement\microsoft.graph.verifyWindowsEnrollmentAutoDiscovery(domainName='{domainName}') /// Usage: domainName={domainName} /// diff --git a/src/generated/DeviceManagement/ExchangeConnectors/ExchangeConnectorsRequestBuilder.cs b/src/generated/DeviceManagement/ExchangeConnectors/ExchangeConnectorsRequestBuilder.cs index c34396701e8..3995275704e 100644 --- a/src/generated/DeviceManagement/ExchangeConnectors/ExchangeConnectorsRequestBuilder.cs +++ b/src/generated/DeviceManagement/ExchangeConnectors/ExchangeConnectorsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class ExchangeConnectorsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceManagementExchangeConnectorRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSyncCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSyncCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(DeviceManagementExchangeC requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of Exchange Connectors configured by the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of Exchange Connectors configured by the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceManagementExchangeConnector model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of Exchange Connectors configured by the tenant. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/ExchangeConnectors/Item/DeviceManagementExchangeConnectorRequestBuilder.cs b/src/generated/DeviceManagement/ExchangeConnectors/Item/DeviceManagementExchangeConnectorRequestBuilder.cs index 3f8e4b3b17c..e3f9780e749 100644 --- a/src/generated/DeviceManagement/ExchangeConnectors/Item/DeviceManagementExchangeConnectorRequestBuilder.cs +++ b/src/generated/DeviceManagement/ExchangeConnectors/Item/DeviceManagementExchangeConnectorRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,15 +27,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of Exchange Connectors configured by the tenant."; // Create options for all the parameters - var deviceManagementExchangeConnectorIdOption = new Option("--devicemanagementexchangeconnector-id", description: "key: id of deviceManagementExchangeConnector") { + var deviceManagementExchangeConnectorIdOption = new Option("--device-management-exchange-connector-id", description: "key: id of deviceManagementExchangeConnector") { }; deviceManagementExchangeConnectorIdOption.IsRequired = true; command.AddOption(deviceManagementExchangeConnectorIdOption); - command.SetHandler(async (string deviceManagementExchangeConnectorId) => { + command.SetHandler(async (string deviceManagementExchangeConnectorId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceManagementExchangeConnectorIdOption); return command; @@ -47,7 +46,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of Exchange Connectors configured by the tenant."; // Create options for all the parameters - var deviceManagementExchangeConnectorIdOption = new Option("--devicemanagementexchangeconnector-id", description: "key: id of deviceManagementExchangeConnector") { + var deviceManagementExchangeConnectorIdOption = new Option("--device-management-exchange-connector-id", description: "key: id of deviceManagementExchangeConnector") { }; deviceManagementExchangeConnectorIdOption.IsRequired = true; command.AddOption(deviceManagementExchangeConnectorIdOption); @@ -61,20 +60,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceManagementExchangeConnectorId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceManagementExchangeConnectorId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceManagementExchangeConnectorIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceManagementExchangeConnectorIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of Exchange Connectors configured by the tenant."; // Create options for all the parameters - var deviceManagementExchangeConnectorIdOption = new Option("--devicemanagementexchangeconnector-id", description: "key: id of deviceManagementExchangeConnector") { + var deviceManagementExchangeConnectorIdOption = new Option("--device-management-exchange-connector-id", description: "key: id of deviceManagementExchangeConnector") { }; deviceManagementExchangeConnectorIdOption.IsRequired = true; command.AddOption(deviceManagementExchangeConnectorIdOption); @@ -92,14 +90,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceManagementExchangeConnectorId, string body) => { + command.SetHandler(async (string deviceManagementExchangeConnectorId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceManagementExchangeConnectorIdOption, bodyOption); return command; @@ -177,42 +174,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceManagementExchange requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of Exchange Connectors configured by the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of Exchange Connectors configured by the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of Exchange Connectors configured by the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceManagementExchangeConnector model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of Exchange Connectors configured by the tenant. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/ExchangeConnectors/Item/Sync/SyncRequestBuilder.cs b/src/generated/DeviceManagement/ExchangeConnectors/Item/Sync/SyncRequestBuilder.cs index 3a462204442..2c63977ed4b 100644 --- a/src/generated/DeviceManagement/ExchangeConnectors/Item/Sync/SyncRequestBuilder.cs +++ b/src/generated/DeviceManagement/ExchangeConnectors/Item/Sync/SyncRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action sync"; // Create options for all the parameters - var deviceManagementExchangeConnectorIdOption = new Option("--devicemanagementexchangeconnector-id", description: "key: id of deviceManagementExchangeConnector") { + var deviceManagementExchangeConnectorIdOption = new Option("--device-management-exchange-connector-id", description: "key: id of deviceManagementExchangeConnector") { }; deviceManagementExchangeConnectorIdOption.IsRequired = true; command.AddOption(deviceManagementExchangeConnectorIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceManagementExchangeConnectorId, string body) => { + command.SetHandler(async (string deviceManagementExchangeConnectorId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceManagementExchangeConnectorIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(SyncRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action sync - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SyncRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/GetEffectivePermissionsWithScope/GetEffectivePermissionsWithScopeRequestBuilder.cs b/src/generated/DeviceManagement/GetEffectivePermissionsWithScope/GetEffectivePermissionsWithScopeRequestBuilder.cs index cbfd85b813e..0608cabb848 100644 --- a/src/generated/DeviceManagement/GetEffectivePermissionsWithScope/GetEffectivePermissionsWithScopeRequestBuilder.cs +++ b/src/generated/DeviceManagement/GetEffectivePermissionsWithScope/GetEffectivePermissionsWithScopeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +29,17 @@ public Command BuildGetCommand() { }; scopeOption.IsRequired = true; command.AddOption(scopeOption); - command.SetHandler(async (string scope) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string scope, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, scopeOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, scopeOption, outputOption); return command; } /// @@ -73,16 +72,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Retrieves the effective permissions of the currently authenticated user - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/ImportedWindowsAutopilotDeviceIdentities/Import/ImportRequestBuilder.cs b/src/generated/DeviceManagement/ImportedWindowsAutopilotDeviceIdentities/Import/ImportRequestBuilder.cs index 511708bf828..b6eb4a05bc2 100644 --- a/src/generated/DeviceManagement/ImportedWindowsAutopilotDeviceIdentities/Import/ImportRequestBuilder.cs +++ b/src/generated/DeviceManagement/ImportedWindowsAutopilotDeviceIdentities/Import/ImportRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +29,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +76,5 @@ public RequestInformation CreatePostRequestInformation(ImportRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action import - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(ImportRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/ImportedWindowsAutopilotDeviceIdentities/ImportedWindowsAutopilotDeviceIdentitiesRequestBuilder.cs b/src/generated/DeviceManagement/ImportedWindowsAutopilotDeviceIdentities/ImportedWindowsAutopilotDeviceIdentitiesRequestBuilder.cs index cfedbeb1f64..e32a0746956 100644 --- a/src/generated/DeviceManagement/ImportedWindowsAutopilotDeviceIdentities/ImportedWindowsAutopilotDeviceIdentitiesRequestBuilder.cs +++ b/src/generated/DeviceManagement/ImportedWindowsAutopilotDeviceIdentities/ImportedWindowsAutopilotDeviceIdentitiesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class ImportedWindowsAutopilotDeviceIdentitiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ImportedWindowsAutopilotDeviceIdentityRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } public Command BuildImportCommand() { @@ -106,7 +104,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -117,15 +119,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -180,31 +177,6 @@ public RequestInformation CreatePostRequestInformation(ImportedWindowsAutopilotD requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of imported Windows autopilot devices. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of imported Windows autopilot devices. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ImportedWindowsAutopilotDeviceIdentity model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of imported Windows autopilot devices. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/ImportedWindowsAutopilotDeviceIdentities/Item/ImportedWindowsAutopilotDeviceIdentityRequestBuilder.cs b/src/generated/DeviceManagement/ImportedWindowsAutopilotDeviceIdentities/Item/ImportedWindowsAutopilotDeviceIdentityRequestBuilder.cs index 97ed6944990..d103989e421 100644 --- a/src/generated/DeviceManagement/ImportedWindowsAutopilotDeviceIdentities/Item/ImportedWindowsAutopilotDeviceIdentityRequestBuilder.cs +++ b/src/generated/DeviceManagement/ImportedWindowsAutopilotDeviceIdentities/Item/ImportedWindowsAutopilotDeviceIdentityRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Collection of imported Windows autopilot devices."; // Create options for all the parameters - var importedWindowsAutopilotDeviceIdentityIdOption = new Option("--importedwindowsautopilotdeviceidentity-id", description: "key: id of importedWindowsAutopilotDeviceIdentity") { + var importedWindowsAutopilotDeviceIdentityIdOption = new Option("--imported-windows-autopilot-device-identity-id", description: "key: id of importedWindowsAutopilotDeviceIdentity") { }; importedWindowsAutopilotDeviceIdentityIdOption.IsRequired = true; command.AddOption(importedWindowsAutopilotDeviceIdentityIdOption); - command.SetHandler(async (string importedWindowsAutopilotDeviceIdentityId) => { + command.SetHandler(async (string importedWindowsAutopilotDeviceIdentityId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, importedWindowsAutopilotDeviceIdentityIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Collection of imported Windows autopilot devices."; // Create options for all the parameters - var importedWindowsAutopilotDeviceIdentityIdOption = new Option("--importedwindowsautopilotdeviceidentity-id", description: "key: id of importedWindowsAutopilotDeviceIdentity") { + var importedWindowsAutopilotDeviceIdentityIdOption = new Option("--imported-windows-autopilot-device-identity-id", description: "key: id of importedWindowsAutopilotDeviceIdentity") { }; importedWindowsAutopilotDeviceIdentityIdOption.IsRequired = true; command.AddOption(importedWindowsAutopilotDeviceIdentityIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string importedWindowsAutopilotDeviceIdentityId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string importedWindowsAutopilotDeviceIdentityId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, importedWindowsAutopilotDeviceIdentityIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, importedWindowsAutopilotDeviceIdentityIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Collection of imported Windows autopilot devices."; // Create options for all the parameters - var importedWindowsAutopilotDeviceIdentityIdOption = new Option("--importedwindowsautopilotdeviceidentity-id", description: "key: id of importedWindowsAutopilotDeviceIdentity") { + var importedWindowsAutopilotDeviceIdentityIdOption = new Option("--imported-windows-autopilot-device-identity-id", description: "key: id of importedWindowsAutopilotDeviceIdentity") { }; importedWindowsAutopilotDeviceIdentityIdOption.IsRequired = true; command.AddOption(importedWindowsAutopilotDeviceIdentityIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string importedWindowsAutopilotDeviceIdentityId, string body) => { + command.SetHandler(async (string importedWindowsAutopilotDeviceIdentityId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, importedWindowsAutopilotDeviceIdentityIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ImportedWindowsAutopilot requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of imported Windows autopilot devices. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of imported Windows autopilot devices. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of imported Windows autopilot devices. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ImportedWindowsAutopilotDeviceIdentity model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of imported Windows autopilot devices. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/IosUpdateStatuses/IosUpdateStatusesRequestBuilder.cs b/src/generated/DeviceManagement/IosUpdateStatuses/IosUpdateStatusesRequestBuilder.cs index 015a79b4110..019069c697f 100644 --- a/src/generated/DeviceManagement/IosUpdateStatuses/IosUpdateStatusesRequestBuilder.cs +++ b/src/generated/DeviceManagement/IosUpdateStatuses/IosUpdateStatusesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class IosUpdateStatusesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new IosUpdateDeviceStatusRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(IosUpdateDeviceStatus bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The IOS software update installation statuses for this account. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The IOS software update installation statuses for this account. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(IosUpdateDeviceStatus model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The IOS software update installation statuses for this account. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/IosUpdateStatuses/Item/IosUpdateDeviceStatusRequestBuilder.cs b/src/generated/DeviceManagement/IosUpdateStatuses/Item/IosUpdateDeviceStatusRequestBuilder.cs index 8d3683fd1bf..f31c32ac86f 100644 --- a/src/generated/DeviceManagement/IosUpdateStatuses/Item/IosUpdateDeviceStatusRequestBuilder.cs +++ b/src/generated/DeviceManagement/IosUpdateStatuses/Item/IosUpdateDeviceStatusRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The IOS software update installation statuses for this account."; // Create options for all the parameters - var iosUpdateDeviceStatusIdOption = new Option("--iosupdatedevicestatus-id", description: "key: id of iosUpdateDeviceStatus") { + var iosUpdateDeviceStatusIdOption = new Option("--ios-update-device-status-id", description: "key: id of iosUpdateDeviceStatus") { }; iosUpdateDeviceStatusIdOption.IsRequired = true; command.AddOption(iosUpdateDeviceStatusIdOption); - command.SetHandler(async (string iosUpdateDeviceStatusId) => { + command.SetHandler(async (string iosUpdateDeviceStatusId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, iosUpdateDeviceStatusIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The IOS software update installation statuses for this account."; // Create options for all the parameters - var iosUpdateDeviceStatusIdOption = new Option("--iosupdatedevicestatus-id", description: "key: id of iosUpdateDeviceStatus") { + var iosUpdateDeviceStatusIdOption = new Option("--ios-update-device-status-id", description: "key: id of iosUpdateDeviceStatus") { }; iosUpdateDeviceStatusIdOption.IsRequired = true; command.AddOption(iosUpdateDeviceStatusIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string iosUpdateDeviceStatusId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string iosUpdateDeviceStatusId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, iosUpdateDeviceStatusIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, iosUpdateDeviceStatusIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The IOS software update installation statuses for this account."; // Create options for all the parameters - var iosUpdateDeviceStatusIdOption = new Option("--iosupdatedevicestatus-id", description: "key: id of iosUpdateDeviceStatus") { + var iosUpdateDeviceStatusIdOption = new Option("--ios-update-device-status-id", description: "key: id of iosUpdateDeviceStatus") { }; iosUpdateDeviceStatusIdOption.IsRequired = true; command.AddOption(iosUpdateDeviceStatusIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string iosUpdateDeviceStatusId, string body) => { + command.SetHandler(async (string iosUpdateDeviceStatusId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, iosUpdateDeviceStatusIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(IosUpdateDeviceStatus bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The IOS software update installation statuses for this account. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The IOS software update installation statuses for this account. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The IOS software update installation statuses for this account. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(IosUpdateDeviceStatus model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The IOS software update installation statuses for this account. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/ManagedDeviceOverview/@Ref/@Ref.cs b/src/generated/DeviceManagement/ManagedDeviceOverview/@Ref/@Ref.cs deleted file mode 100644 index 38fc93d8e61..00000000000 --- a/src/generated/DeviceManagement/ManagedDeviceOverview/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.DeviceManagement.ManagedDeviceOverview.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/DeviceManagement/ManagedDeviceOverview/@Ref/RefRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDeviceOverview/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 08e4d934054..00000000000 --- a/src/generated/DeviceManagement/ManagedDeviceOverview/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,178 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.DeviceManagement.ManagedDeviceOverview.@Ref { - /// Builds and executes requests for operations under \deviceManagement\managedDeviceOverview\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Device overview - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Device overview"; - // Create options for all the parameters - command.SetHandler(async () => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }); - return command; - } - /// - /// Device overview - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Device overview"; - // Create options for all the parameters - command.SetHandler(async () => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); - return command; - } - /// - /// Device overview - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Device overview"; - // Create options for all the parameters - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/deviceManagement/managedDeviceOverview/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Device overview - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Device overview - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Device overview - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.DeviceManagement.ManagedDeviceOverview.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Device overview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device overview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device overview - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.DeviceManagement.ManagedDeviceOverview.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/DeviceManagement/ManagedDeviceOverview/ManagedDeviceOverviewRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDeviceOverview/ManagedDeviceOverviewRequestBuilder.cs index 8d78f4f595c..8ed3053f9a8 100644 --- a/src/generated/DeviceManagement/ManagedDeviceOverview/ManagedDeviceOverviewRequestBuilder.cs +++ b/src/generated/DeviceManagement/ManagedDeviceOverview/ManagedDeviceOverviewRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,25 +37,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.DeviceManagement.ManagedDeviceOverview.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.DeviceManagement.ManagedDeviceOverview.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -95,18 +94,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Device overview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Device overview public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/ManagedDeviceOverview/Ref/Ref.cs b/src/generated/DeviceManagement/ManagedDeviceOverview/Ref/Ref.cs new file mode 100644 index 00000000000..ae27516f250 --- /dev/null +++ b/src/generated/DeviceManagement/ManagedDeviceOverview/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.DeviceManagement.ManagedDeviceOverview.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/DeviceManagement/ManagedDeviceOverview/Ref/RefRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDeviceOverview/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..d4a6358777b --- /dev/null +++ b/src/generated/DeviceManagement/ManagedDeviceOverview/Ref/RefRequestBuilder.cs @@ -0,0 +1,140 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.DeviceManagement.ManagedDeviceOverview.Ref { + /// Builds and executes requests for operations under \deviceManagement\managedDeviceOverview\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Device overview + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Device overview"; + // Create options for all the parameters + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }); + return command; + } + /// + /// Device overview + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Device overview"; + // Create options for all the parameters + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); + return command; + } + /// + /// Device overview + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Device overview"; + // Create options for all the parameters + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/deviceManagement/managedDeviceOverview/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Device overview + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Device overview + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Device overview + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.DeviceManagement.ManagedDeviceOverview.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/DeviceManagement/ManagedDevices/Item/BypassActivationLock/BypassActivationLockRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDevices/Item/BypassActivationLock/BypassActivationLockRequestBuilder.cs index 4820d88dede..680a5f4d024 100644 --- a/src/generated/DeviceManagement/ManagedDevices/Item/BypassActivationLock/BypassActivationLockRequestBuilder.cs +++ b/src/generated/DeviceManagement/ManagedDevices/Item/BypassActivationLock/BypassActivationLockRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Bypass activation lock"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Bypass activation lock - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/ManagedDevices/Item/CleanWindowsDevice/CleanWindowsDeviceRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDevices/Item/CleanWindowsDevice/CleanWindowsDeviceRequestBuilder.cs index bcaa052a3ea..4c9454fb436 100644 --- a/src/generated/DeviceManagement/ManagedDevices/Item/CleanWindowsDevice/CleanWindowsDeviceRequestBuilder.cs +++ b/src/generated/DeviceManagement/ManagedDevices/Item/CleanWindowsDevice/CleanWindowsDeviceRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Clean Windows device"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceId, string body) => { + command.SetHandler(async (string managedDeviceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(CleanWindowsDeviceRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Clean Windows device - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CleanWindowsDeviceRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/ManagedDevices/Item/DeleteUserFromSharedAppleDevice/DeleteUserFromSharedAppleDeviceRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDevices/Item/DeleteUserFromSharedAppleDevice/DeleteUserFromSharedAppleDeviceRequestBuilder.cs index b93e570c3ca..a6ccc070f1c 100644 --- a/src/generated/DeviceManagement/ManagedDevices/Item/DeleteUserFromSharedAppleDevice/DeleteUserFromSharedAppleDeviceRequestBuilder.cs +++ b/src/generated/DeviceManagement/ManagedDevices/Item/DeleteUserFromSharedAppleDevice/DeleteUserFromSharedAppleDeviceRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Delete user from shared Apple device"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceId, string body) => { + command.SetHandler(async (string managedDeviceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(DeleteUserFromSharedApple requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete user from shared Apple device - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeleteUserFromSharedAppleDeviceRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/ManagedDevices/Item/DeviceCategory/DeviceCategoryRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDevices/Item/DeviceCategory/DeviceCategoryRequestBuilder.cs index f78cef8d59f..48ca75596e0 100644 --- a/src/generated/DeviceManagement/ManagedDevices/Item/DeviceCategory/DeviceCategoryRequestBuilder.cs +++ b/src/generated/DeviceManagement/ManagedDevices/Item/DeviceCategory/DeviceCategoryRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Device category"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Device category"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedDeviceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Device category"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceId, string body) => { + command.SetHandler(async (string managedDeviceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Device category - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device category - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device category - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DeviceCategory model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Device category public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/ManagedDevices/Item/DeviceCompliancePolicyStates/DeviceCompliancePolicyStatesRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDevices/Item/DeviceCompliancePolicyStates/DeviceCompliancePolicyStatesRequestBuilder.cs index 37e2c19755a..bd991419fee 100644 --- a/src/generated/DeviceManagement/ManagedDevices/Item/DeviceCompliancePolicyStates/DeviceCompliancePolicyStatesRequestBuilder.cs +++ b/src/generated/DeviceManagement/ManagedDevices/Item/DeviceCompliancePolicyStates/DeviceCompliancePolicyStatesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DeviceCompliancePolicyStatesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceCompliancePolicyStateRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Device compliance policy states for this device."; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Device compliance policy states for this device."; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedDeviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(DeviceCompliancePolicySta requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Device compliance policy states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device compliance policy states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceCompliancePolicyState model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Device compliance policy states for this device. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/ManagedDevices/Item/DeviceCompliancePolicyStates/Item/DeviceCompliancePolicyStateRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDevices/Item/DeviceCompliancePolicyStates/Item/DeviceCompliancePolicyStateRequestBuilder.cs index a79df43c2d2..028e4422760 100644 --- a/src/generated/DeviceManagement/ManagedDevices/Item/DeviceCompliancePolicyStates/Item/DeviceCompliancePolicyStateRequestBuilder.cs +++ b/src/generated/DeviceManagement/ManagedDevices/Item/DeviceCompliancePolicyStates/Item/DeviceCompliancePolicyStateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Device compliance policy states for this device."; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - var deviceCompliancePolicyStateIdOption = new Option("--devicecompliancepolicystate-id", description: "key: id of deviceCompliancePolicyState") { + var deviceCompliancePolicyStateIdOption = new Option("--device-compliance-policy-state-id", description: "key: id of deviceCompliancePolicyState") { }; deviceCompliancePolicyStateIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyStateIdOption); - command.SetHandler(async (string managedDeviceId, string deviceCompliancePolicyStateId) => { + command.SetHandler(async (string managedDeviceId, string deviceCompliancePolicyStateId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption, deviceCompliancePolicyStateIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Device compliance policy states for this device."; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - var deviceCompliancePolicyStateIdOption = new Option("--devicecompliancepolicystate-id", description: "key: id of deviceCompliancePolicyState") { + var deviceCompliancePolicyStateIdOption = new Option("--device-compliance-policy-state-id", description: "key: id of deviceCompliancePolicyState") { }; deviceCompliancePolicyStateIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyStateIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedDeviceId, string deviceCompliancePolicyStateId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceId, string deviceCompliancePolicyStateId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceIdOption, deviceCompliancePolicyStateIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceIdOption, deviceCompliancePolicyStateIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Device compliance policy states for this device."; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - var deviceCompliancePolicyStateIdOption = new Option("--devicecompliancepolicystate-id", description: "key: id of deviceCompliancePolicyState") { + var deviceCompliancePolicyStateIdOption = new Option("--device-compliance-policy-state-id", description: "key: id of deviceCompliancePolicyState") { }; deviceCompliancePolicyStateIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyStateIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceId, string deviceCompliancePolicyStateId, string body) => { + command.SetHandler(async (string managedDeviceId, string deviceCompliancePolicyStateId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption, deviceCompliancePolicyStateIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceCompliancePolicySt requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Device compliance policy states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device compliance policy states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device compliance policy states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceCompliancePolicyState model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Device compliance policy states for this device. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/ManagedDevices/Item/DeviceConfigurationStates/DeviceConfigurationStatesRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDevices/Item/DeviceConfigurationStates/DeviceConfigurationStatesRequestBuilder.cs index ca62ede36e5..bffebf3804d 100644 --- a/src/generated/DeviceManagement/ManagedDevices/Item/DeviceConfigurationStates/DeviceConfigurationStatesRequestBuilder.cs +++ b/src/generated/DeviceManagement/ManagedDevices/Item/DeviceConfigurationStates/DeviceConfigurationStatesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DeviceConfigurationStatesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceConfigurationStateRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Device configuration states for this device."; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Device configuration states for this device."; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedDeviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(DeviceConfigurationState requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Device configuration states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device configuration states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceConfigurationState model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Device configuration states for this device. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/ManagedDevices/Item/DeviceConfigurationStates/Item/DeviceConfigurationStateRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDevices/Item/DeviceConfigurationStates/Item/DeviceConfigurationStateRequestBuilder.cs index f29406be233..21d50e57806 100644 --- a/src/generated/DeviceManagement/ManagedDevices/Item/DeviceConfigurationStates/Item/DeviceConfigurationStateRequestBuilder.cs +++ b/src/generated/DeviceManagement/ManagedDevices/Item/DeviceConfigurationStates/Item/DeviceConfigurationStateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Device configuration states for this device."; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - var deviceConfigurationStateIdOption = new Option("--deviceconfigurationstate-id", description: "key: id of deviceConfigurationState") { + var deviceConfigurationStateIdOption = new Option("--device-configuration-state-id", description: "key: id of deviceConfigurationState") { }; deviceConfigurationStateIdOption.IsRequired = true; command.AddOption(deviceConfigurationStateIdOption); - command.SetHandler(async (string managedDeviceId, string deviceConfigurationStateId) => { + command.SetHandler(async (string managedDeviceId, string deviceConfigurationStateId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption, deviceConfigurationStateIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Device configuration states for this device."; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - var deviceConfigurationStateIdOption = new Option("--deviceconfigurationstate-id", description: "key: id of deviceConfigurationState") { + var deviceConfigurationStateIdOption = new Option("--device-configuration-state-id", description: "key: id of deviceConfigurationState") { }; deviceConfigurationStateIdOption.IsRequired = true; command.AddOption(deviceConfigurationStateIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedDeviceId, string deviceConfigurationStateId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceId, string deviceConfigurationStateId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceIdOption, deviceConfigurationStateIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceIdOption, deviceConfigurationStateIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Device configuration states for this device."; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - var deviceConfigurationStateIdOption = new Option("--deviceconfigurationstate-id", description: "key: id of deviceConfigurationState") { + var deviceConfigurationStateIdOption = new Option("--device-configuration-state-id", description: "key: id of deviceConfigurationState") { }; deviceConfigurationStateIdOption.IsRequired = true; command.AddOption(deviceConfigurationStateIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceId, string deviceConfigurationStateId, string body) => { + command.SetHandler(async (string managedDeviceId, string deviceConfigurationStateId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption, deviceConfigurationStateIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceConfigurationState requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Device configuration states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device configuration states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device configuration states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceConfigurationState model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Device configuration states for this device. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/ManagedDevices/Item/DisableLostMode/DisableLostModeRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDevices/Item/DisableLostMode/DisableLostModeRequestBuilder.cs index 1184e92a576..2e8aecbe8c0 100644 --- a/src/generated/DeviceManagement/ManagedDevices/Item/DisableLostMode/DisableLostModeRequestBuilder.cs +++ b/src/generated/DeviceManagement/ManagedDevices/Item/DisableLostMode/DisableLostModeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Disable lost mode"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Disable lost mode - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/ManagedDevices/Item/LocateDevice/LocateDeviceRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDevices/Item/LocateDevice/LocateDeviceRequestBuilder.cs index a2d7ad306a5..5c58d5a76a7 100644 --- a/src/generated/DeviceManagement/ManagedDevices/Item/LocateDevice/LocateDeviceRequestBuilder.cs +++ b/src/generated/DeviceManagement/ManagedDevices/Item/LocateDevice/LocateDeviceRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Locate a device"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Locate a device - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/ManagedDevices/Item/LogoutSharedAppleDeviceActiveUser/LogoutSharedAppleDeviceActiveUserRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDevices/Item/LogoutSharedAppleDeviceActiveUser/LogoutSharedAppleDeviceActiveUserRequestBuilder.cs index ee3758263ac..81964a922b4 100644 --- a/src/generated/DeviceManagement/ManagedDevices/Item/LogoutSharedAppleDeviceActiveUser/LogoutSharedAppleDeviceActiveUserRequestBuilder.cs +++ b/src/generated/DeviceManagement/ManagedDevices/Item/LogoutSharedAppleDeviceActiveUser/LogoutSharedAppleDeviceActiveUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Logout shared Apple device active user"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Logout shared Apple device active user - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/ManagedDevices/Item/ManagedDeviceRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDevices/Item/ManagedDeviceRequestBuilder.cs index 24e61d0d3ef..9065cb8631e 100644 --- a/src/generated/DeviceManagement/ManagedDevices/Item/ManagedDeviceRequestBuilder.cs +++ b/src/generated/DeviceManagement/ManagedDevices/Item/ManagedDeviceRequestBuilder.cs @@ -22,10 +22,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -59,15 +59,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of managed devices."; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -89,6 +88,9 @@ public Command BuildDeviceCategoryCommand() { public Command BuildDeviceCompliancePolicyStatesCommand() { var command = new Command("device-compliance-policy-states"); var builder = new ApiSdk.DeviceManagement.ManagedDevices.Item.DeviceCompliancePolicyStates.DeviceCompliancePolicyStatesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -96,6 +98,9 @@ public Command BuildDeviceCompliancePolicyStatesCommand() { public Command BuildDeviceConfigurationStatesCommand() { var command = new Command("device-configuration-states"); var builder = new ApiSdk.DeviceManagement.ManagedDevices.Item.DeviceConfigurationStates.DeviceConfigurationStatesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -113,7 +118,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of managed devices."; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -127,20 +132,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedDeviceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLocateDeviceCommand() { @@ -162,7 +166,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of managed devices."; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -170,14 +174,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceId, string body) => { + command.SetHandler(async (string managedDeviceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption, bodyOption); return command; @@ -321,42 +324,6 @@ public RequestInformation CreatePatchRequestInformation(ManagedDevice body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of managed devices. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of managed devices. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of managed devices. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ManagedDevice model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of managed devices. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/ManagedDevices/Item/RebootNow/RebootNowRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDevices/Item/RebootNow/RebootNowRequestBuilder.cs index 7e346098cb0..b5b1cf2e041 100644 --- a/src/generated/DeviceManagement/ManagedDevices/Item/RebootNow/RebootNowRequestBuilder.cs +++ b/src/generated/DeviceManagement/ManagedDevices/Item/RebootNow/RebootNowRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Reboot device"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Reboot device - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/ManagedDevices/Item/RecoverPasscode/RecoverPasscodeRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDevices/Item/RecoverPasscode/RecoverPasscodeRequestBuilder.cs index af74c532e2d..1b16da720bd 100644 --- a/src/generated/DeviceManagement/ManagedDevices/Item/RecoverPasscode/RecoverPasscodeRequestBuilder.cs +++ b/src/generated/DeviceManagement/ManagedDevices/Item/RecoverPasscode/RecoverPasscodeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Recover passcode"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Recover passcode - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/ManagedDevices/Item/RemoteLock/RemoteLockRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDevices/Item/RemoteLock/RemoteLockRequestBuilder.cs index 7dc19aefdf7..3e3df3917be 100644 --- a/src/generated/DeviceManagement/ManagedDevices/Item/RemoteLock/RemoteLockRequestBuilder.cs +++ b/src/generated/DeviceManagement/ManagedDevices/Item/RemoteLock/RemoteLockRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Remote lock"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Remote lock - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/ManagedDevices/Item/RequestRemoteAssistance/RequestRemoteAssistanceRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDevices/Item/RequestRemoteAssistance/RequestRemoteAssistanceRequestBuilder.cs index 5573ebaa24b..f4493ccb3ba 100644 --- a/src/generated/DeviceManagement/ManagedDevices/Item/RequestRemoteAssistance/RequestRemoteAssistanceRequestBuilder.cs +++ b/src/generated/DeviceManagement/ManagedDevices/Item/RequestRemoteAssistance/RequestRemoteAssistanceRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Request remote assistance"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Request remote assistance - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/ManagedDevices/Item/ResetPasscode/ResetPasscodeRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDevices/Item/ResetPasscode/ResetPasscodeRequestBuilder.cs index 11def50340a..45d9eb9bc41 100644 --- a/src/generated/DeviceManagement/ManagedDevices/Item/ResetPasscode/ResetPasscodeRequestBuilder.cs +++ b/src/generated/DeviceManagement/ManagedDevices/Item/ResetPasscode/ResetPasscodeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Reset passcode"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Reset passcode - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/ManagedDevices/Item/Retire/RetireRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDevices/Item/Retire/RetireRequestBuilder.cs index 14f31c8c163..d2e8062d321 100644 --- a/src/generated/DeviceManagement/ManagedDevices/Item/Retire/RetireRequestBuilder.cs +++ b/src/generated/DeviceManagement/ManagedDevices/Item/Retire/RetireRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Retire a device"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Retire a device - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/ManagedDevices/Item/ShutDown/ShutDownRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDevices/Item/ShutDown/ShutDownRequestBuilder.cs index b6ea724939c..a6427f644bc 100644 --- a/src/generated/DeviceManagement/ManagedDevices/Item/ShutDown/ShutDownRequestBuilder.cs +++ b/src/generated/DeviceManagement/ManagedDevices/Item/ShutDown/ShutDownRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Shut down device"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Shut down device - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/ManagedDevices/Item/SyncDevice/SyncDeviceRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDevices/Item/SyncDevice/SyncDeviceRequestBuilder.cs index e79c7305a7c..24da7c4abf2 100644 --- a/src/generated/DeviceManagement/ManagedDevices/Item/SyncDevice/SyncDeviceRequestBuilder.cs +++ b/src/generated/DeviceManagement/ManagedDevices/Item/SyncDevice/SyncDeviceRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action syncDevice"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action syncDevice - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/ManagedDevices/Item/UpdateWindowsDeviceAccount/UpdateWindowsDeviceAccountRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDevices/Item/UpdateWindowsDeviceAccount/UpdateWindowsDeviceAccountRequestBuilder.cs index 14a2a34577e..62a654322c0 100644 --- a/src/generated/DeviceManagement/ManagedDevices/Item/UpdateWindowsDeviceAccount/UpdateWindowsDeviceAccountRequestBuilder.cs +++ b/src/generated/DeviceManagement/ManagedDevices/Item/UpdateWindowsDeviceAccount/UpdateWindowsDeviceAccountRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action updateWindowsDeviceAccount"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceId, string body) => { + command.SetHandler(async (string managedDeviceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(UpdateWindowsDeviceAccoun requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action updateWindowsDeviceAccount - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UpdateWindowsDeviceAccountRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/ManagedDevices/Item/WindowsDefenderScan/WindowsDefenderScanRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDevices/Item/WindowsDefenderScan/WindowsDefenderScanRequestBuilder.cs index a454e1a2ea4..7a666a88da5 100644 --- a/src/generated/DeviceManagement/ManagedDevices/Item/WindowsDefenderScan/WindowsDefenderScanRequestBuilder.cs +++ b/src/generated/DeviceManagement/ManagedDevices/Item/WindowsDefenderScan/WindowsDefenderScanRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action windowsDefenderScan"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceId, string body) => { + command.SetHandler(async (string managedDeviceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(WindowsDefenderScanReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action windowsDefenderScan - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WindowsDefenderScanRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/ManagedDevices/Item/WindowsDefenderUpdateSignatures/WindowsDefenderUpdateSignaturesRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDevices/Item/WindowsDefenderUpdateSignatures/WindowsDefenderUpdateSignaturesRequestBuilder.cs index 0f222dee33d..eacccf710e7 100644 --- a/src/generated/DeviceManagement/ManagedDevices/Item/WindowsDefenderUpdateSignatures/WindowsDefenderUpdateSignaturesRequestBuilder.cs +++ b/src/generated/DeviceManagement/ManagedDevices/Item/WindowsDefenderUpdateSignatures/WindowsDefenderUpdateSignaturesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action windowsDefenderUpdateSignatures"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action windowsDefenderUpdateSignatures - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/ManagedDevices/Item/Wipe/WipeRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDevices/Item/Wipe/WipeRequestBuilder.cs index d5c28dfd7e3..85edb1ffd3b 100644 --- a/src/generated/DeviceManagement/ManagedDevices/Item/Wipe/WipeRequestBuilder.cs +++ b/src/generated/DeviceManagement/ManagedDevices/Item/Wipe/WipeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Wipe a device"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceId, string body) => { + command.SetHandler(async (string managedDeviceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(WipeRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Wipe a device - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WipeRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/ManagedDevices/ManagedDevicesRequestBuilder.cs b/src/generated/DeviceManagement/ManagedDevices/ManagedDevicesRequestBuilder.cs index 9a573613c8d..a476e698eac 100644 --- a/src/generated/DeviceManagement/ManagedDevices/ManagedDevicesRequestBuilder.cs +++ b/src/generated/DeviceManagement/ManagedDevices/ManagedDevicesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,32 +22,31 @@ public class ManagedDevicesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ManagedDeviceRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildBypassActivationLockCommand(), - builder.BuildCleanWindowsDeviceCommand(), - builder.BuildDeleteCommand(), - builder.BuildDeleteUserFromSharedAppleDeviceCommand(), - builder.BuildDeviceCategoryCommand(), - builder.BuildDeviceCompliancePolicyStatesCommand(), - builder.BuildDeviceConfigurationStatesCommand(), - builder.BuildDisableLostModeCommand(), - builder.BuildGetCommand(), - builder.BuildLocateDeviceCommand(), - builder.BuildLogoutSharedAppleDeviceActiveUserCommand(), - builder.BuildPatchCommand(), - builder.BuildRebootNowCommand(), - builder.BuildRecoverPasscodeCommand(), - builder.BuildRemoteLockCommand(), - builder.BuildRequestRemoteAssistanceCommand(), - builder.BuildResetPasscodeCommand(), - builder.BuildRetireCommand(), - builder.BuildShutDownCommand(), - builder.BuildSyncDeviceCommand(), - builder.BuildUpdateWindowsDeviceAccountCommand(), - builder.BuildWindowsDefenderScanCommand(), - builder.BuildWindowsDefenderUpdateSignaturesCommand(), - builder.BuildWipeCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildBypassActivationLockCommand()); + commands.Add(builder.BuildCleanWindowsDeviceCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDeleteUserFromSharedAppleDeviceCommand()); + commands.Add(builder.BuildDeviceCategoryCommand()); + commands.Add(builder.BuildDeviceCompliancePolicyStatesCommand()); + commands.Add(builder.BuildDeviceConfigurationStatesCommand()); + commands.Add(builder.BuildDisableLostModeCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildLocateDeviceCommand()); + commands.Add(builder.BuildLogoutSharedAppleDeviceActiveUserCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRebootNowCommand()); + commands.Add(builder.BuildRecoverPasscodeCommand()); + commands.Add(builder.BuildRemoteLockCommand()); + commands.Add(builder.BuildRequestRemoteAssistanceCommand()); + commands.Add(builder.BuildResetPasscodeCommand()); + commands.Add(builder.BuildRetireCommand()); + commands.Add(builder.BuildShutDownCommand()); + commands.Add(builder.BuildSyncDeviceCommand()); + commands.Add(builder.BuildUpdateWindowsDeviceAccountCommand()); + commands.Add(builder.BuildWindowsDefenderScanCommand()); + commands.Add(builder.BuildWindowsDefenderUpdateSignaturesCommand()); + commands.Add(builder.BuildWipeCommand()); return commands; } /// @@ -61,21 +60,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -194,31 +191,6 @@ public RequestInformation CreatePostRequestInformation(ManagedDevice body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of managed devices. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of managed devices. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ManagedDevice model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of managed devices. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/MobileThreatDefenseConnectors/Item/MobileThreatDefenseConnectorRequestBuilder.cs b/src/generated/DeviceManagement/MobileThreatDefenseConnectors/Item/MobileThreatDefenseConnectorRequestBuilder.cs index 1ac1296cf8f..80e68acf1a1 100644 --- a/src/generated/DeviceManagement/MobileThreatDefenseConnectors/Item/MobileThreatDefenseConnectorRequestBuilder.cs +++ b/src/generated/DeviceManagement/MobileThreatDefenseConnectors/Item/MobileThreatDefenseConnectorRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of Mobile threat Defense connectors configured by the tenant."; // Create options for all the parameters - var mobileThreatDefenseConnectorIdOption = new Option("--mobilethreatdefenseconnector-id", description: "key: id of mobileThreatDefenseConnector") { + var mobileThreatDefenseConnectorIdOption = new Option("--mobile-threat-defense-connector-id", description: "key: id of mobileThreatDefenseConnector") { }; mobileThreatDefenseConnectorIdOption.IsRequired = true; command.AddOption(mobileThreatDefenseConnectorIdOption); - command.SetHandler(async (string mobileThreatDefenseConnectorId) => { + command.SetHandler(async (string mobileThreatDefenseConnectorId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mobileThreatDefenseConnectorIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of Mobile threat Defense connectors configured by the tenant."; // Create options for all the parameters - var mobileThreatDefenseConnectorIdOption = new Option("--mobilethreatdefenseconnector-id", description: "key: id of mobileThreatDefenseConnector") { + var mobileThreatDefenseConnectorIdOption = new Option("--mobile-threat-defense-connector-id", description: "key: id of mobileThreatDefenseConnector") { }; mobileThreatDefenseConnectorIdOption.IsRequired = true; command.AddOption(mobileThreatDefenseConnectorIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string mobileThreatDefenseConnectorId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mobileThreatDefenseConnectorId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mobileThreatDefenseConnectorIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mobileThreatDefenseConnectorIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of Mobile threat Defense connectors configured by the tenant."; // Create options for all the parameters - var mobileThreatDefenseConnectorIdOption = new Option("--mobilethreatdefenseconnector-id", description: "key: id of mobileThreatDefenseConnector") { + var mobileThreatDefenseConnectorIdOption = new Option("--mobile-threat-defense-connector-id", description: "key: id of mobileThreatDefenseConnector") { }; mobileThreatDefenseConnectorIdOption.IsRequired = true; command.AddOption(mobileThreatDefenseConnectorIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mobileThreatDefenseConnectorId, string body) => { + command.SetHandler(async (string mobileThreatDefenseConnectorId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mobileThreatDefenseConnectorIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(MobileThreatDefenseConne requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of Mobile threat Defense connectors configured by the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of Mobile threat Defense connectors configured by the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of Mobile threat Defense connectors configured by the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MobileThreatDefenseConnector model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of Mobile threat Defense connectors configured by the tenant. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/MobileThreatDefenseConnectors/MobileThreatDefenseConnectorsRequestBuilder.cs b/src/generated/DeviceManagement/MobileThreatDefenseConnectors/MobileThreatDefenseConnectorsRequestBuilder.cs index 404fa8d006d..dc4d91367ff 100644 --- a/src/generated/DeviceManagement/MobileThreatDefenseConnectors/MobileThreatDefenseConnectorsRequestBuilder.cs +++ b/src/generated/DeviceManagement/MobileThreatDefenseConnectors/MobileThreatDefenseConnectorsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MobileThreatDefenseConnectorsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MobileThreatDefenseConnectorRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(MobileThreatDefenseConnec requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of Mobile threat Defense connectors configured by the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of Mobile threat Defense connectors configured by the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MobileThreatDefenseConnector model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of Mobile threat Defense connectors configured by the tenant. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/NotificationMessageTemplates/Item/LocalizedNotificationMessages/Item/LocalizedNotificationMessageRequestBuilder.cs b/src/generated/DeviceManagement/NotificationMessageTemplates/Item/LocalizedNotificationMessages/Item/LocalizedNotificationMessageRequestBuilder.cs index 0af61a383cb..ff2209091db 100644 --- a/src/generated/DeviceManagement/NotificationMessageTemplates/Item/LocalizedNotificationMessages/Item/LocalizedNotificationMessageRequestBuilder.cs +++ b/src/generated/DeviceManagement/NotificationMessageTemplates/Item/LocalizedNotificationMessages/Item/LocalizedNotificationMessageRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of localized messages for this Notification Message Template."; // Create options for all the parameters - var notificationMessageTemplateIdOption = new Option("--notificationmessagetemplate-id", description: "key: id of notificationMessageTemplate") { + var notificationMessageTemplateIdOption = new Option("--notification-message-template-id", description: "key: id of notificationMessageTemplate") { }; notificationMessageTemplateIdOption.IsRequired = true; command.AddOption(notificationMessageTemplateIdOption); - var localizedNotificationMessageIdOption = new Option("--localizednotificationmessage-id", description: "key: id of localizedNotificationMessage") { + var localizedNotificationMessageIdOption = new Option("--localized-notification-message-id", description: "key: id of localizedNotificationMessage") { }; localizedNotificationMessageIdOption.IsRequired = true; command.AddOption(localizedNotificationMessageIdOption); - command.SetHandler(async (string notificationMessageTemplateId, string localizedNotificationMessageId) => { + command.SetHandler(async (string notificationMessageTemplateId, string localizedNotificationMessageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notificationMessageTemplateIdOption, localizedNotificationMessageIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of localized messages for this Notification Message Template."; // Create options for all the parameters - var notificationMessageTemplateIdOption = new Option("--notificationmessagetemplate-id", description: "key: id of notificationMessageTemplate") { + var notificationMessageTemplateIdOption = new Option("--notification-message-template-id", description: "key: id of notificationMessageTemplate") { }; notificationMessageTemplateIdOption.IsRequired = true; command.AddOption(notificationMessageTemplateIdOption); - var localizedNotificationMessageIdOption = new Option("--localizednotificationmessage-id", description: "key: id of localizedNotificationMessage") { + var localizedNotificationMessageIdOption = new Option("--localized-notification-message-id", description: "key: id of localizedNotificationMessage") { }; localizedNotificationMessageIdOption.IsRequired = true; command.AddOption(localizedNotificationMessageIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notificationMessageTemplateId, string localizedNotificationMessageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notificationMessageTemplateId, string localizedNotificationMessageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notificationMessageTemplateIdOption, localizedNotificationMessageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notificationMessageTemplateIdOption, localizedNotificationMessageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of localized messages for this Notification Message Template."; // Create options for all the parameters - var notificationMessageTemplateIdOption = new Option("--notificationmessagetemplate-id", description: "key: id of notificationMessageTemplate") { + var notificationMessageTemplateIdOption = new Option("--notification-message-template-id", description: "key: id of notificationMessageTemplate") { }; notificationMessageTemplateIdOption.IsRequired = true; command.AddOption(notificationMessageTemplateIdOption); - var localizedNotificationMessageIdOption = new Option("--localizednotificationmessage-id", description: "key: id of localizedNotificationMessage") { + var localizedNotificationMessageIdOption = new Option("--localized-notification-message-id", description: "key: id of localizedNotificationMessage") { }; localizedNotificationMessageIdOption.IsRequired = true; command.AddOption(localizedNotificationMessageIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notificationMessageTemplateId, string localizedNotificationMessageId, string body) => { + command.SetHandler(async (string notificationMessageTemplateId, string localizedNotificationMessageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notificationMessageTemplateIdOption, localizedNotificationMessageIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(LocalizedNotificationMes requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of localized messages for this Notification Message Template. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of localized messages for this Notification Message Template. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of localized messages for this Notification Message Template. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(LocalizedNotificationMessage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of localized messages for this Notification Message Template. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/NotificationMessageTemplates/Item/LocalizedNotificationMessages/LocalizedNotificationMessagesRequestBuilder.cs b/src/generated/DeviceManagement/NotificationMessageTemplates/Item/LocalizedNotificationMessages/LocalizedNotificationMessagesRequestBuilder.cs index 1f116225721..33068f10801 100644 --- a/src/generated/DeviceManagement/NotificationMessageTemplates/Item/LocalizedNotificationMessages/LocalizedNotificationMessagesRequestBuilder.cs +++ b/src/generated/DeviceManagement/NotificationMessageTemplates/Item/LocalizedNotificationMessages/LocalizedNotificationMessagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class LocalizedNotificationMessagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new LocalizedNotificationMessageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The list of localized messages for this Notification Message Template."; // Create options for all the parameters - var notificationMessageTemplateIdOption = new Option("--notificationmessagetemplate-id", description: "key: id of notificationMessageTemplate") { + var notificationMessageTemplateIdOption = new Option("--notification-message-template-id", description: "key: id of notificationMessageTemplate") { }; notificationMessageTemplateIdOption.IsRequired = true; command.AddOption(notificationMessageTemplateIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notificationMessageTemplateId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notificationMessageTemplateId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notificationMessageTemplateIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notificationMessageTemplateIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The list of localized messages for this Notification Message Template."; // Create options for all the parameters - var notificationMessageTemplateIdOption = new Option("--notificationmessagetemplate-id", description: "key: id of notificationMessageTemplate") { + var notificationMessageTemplateIdOption = new Option("--notification-message-template-id", description: "key: id of notificationMessageTemplate") { }; notificationMessageTemplateIdOption.IsRequired = true; command.AddOption(notificationMessageTemplateIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notificationMessageTemplateId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notificationMessageTemplateId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notificationMessageTemplateIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notificationMessageTemplateIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(LocalizedNotificationMess requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of localized messages for this Notification Message Template. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of localized messages for this Notification Message Template. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(LocalizedNotificationMessage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of localized messages for this Notification Message Template. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/NotificationMessageTemplates/Item/NotificationMessageTemplateRequestBuilder.cs b/src/generated/DeviceManagement/NotificationMessageTemplates/Item/NotificationMessageTemplateRequestBuilder.cs index 7be0ebd810f..58684d32d0b 100644 --- a/src/generated/DeviceManagement/NotificationMessageTemplates/Item/NotificationMessageTemplateRequestBuilder.cs +++ b/src/generated/DeviceManagement/NotificationMessageTemplates/Item/NotificationMessageTemplateRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,15 +28,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The Notification Message Templates."; // Create options for all the parameters - var notificationMessageTemplateIdOption = new Option("--notificationmessagetemplate-id", description: "key: id of notificationMessageTemplate") { + var notificationMessageTemplateIdOption = new Option("--notification-message-template-id", description: "key: id of notificationMessageTemplate") { }; notificationMessageTemplateIdOption.IsRequired = true; command.AddOption(notificationMessageTemplateIdOption); - command.SetHandler(async (string notificationMessageTemplateId) => { + command.SetHandler(async (string notificationMessageTemplateId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notificationMessageTemplateIdOption); return command; @@ -48,7 +47,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The Notification Message Templates."; // Create options for all the parameters - var notificationMessageTemplateIdOption = new Option("--notificationmessagetemplate-id", description: "key: id of notificationMessageTemplate") { + var notificationMessageTemplateIdOption = new Option("--notification-message-template-id", description: "key: id of notificationMessageTemplate") { }; notificationMessageTemplateIdOption.IsRequired = true; command.AddOption(notificationMessageTemplateIdOption); @@ -62,25 +61,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notificationMessageTemplateId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notificationMessageTemplateId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notificationMessageTemplateIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notificationMessageTemplateIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLocalizedNotificationMessagesCommand() { var command = new Command("localized-notification-messages"); var builder = new ApiSdk.DeviceManagement.NotificationMessageTemplates.Item.LocalizedNotificationMessages.LocalizedNotificationMessagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -92,7 +93,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The Notification Message Templates."; // Create options for all the parameters - var notificationMessageTemplateIdOption = new Option("--notificationmessagetemplate-id", description: "key: id of notificationMessageTemplate") { + var notificationMessageTemplateIdOption = new Option("--notification-message-template-id", description: "key: id of notificationMessageTemplate") { }; notificationMessageTemplateIdOption.IsRequired = true; command.AddOption(notificationMessageTemplateIdOption); @@ -100,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notificationMessageTemplateId, string body) => { + command.SetHandler(async (string notificationMessageTemplateId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notificationMessageTemplateIdOption, bodyOption); return command; @@ -185,42 +185,6 @@ public RequestInformation CreatePatchRequestInformation(NotificationMessageTempl requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The Notification Message Templates. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Notification Message Templates. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Notification Message Templates. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(NotificationMessageTemplate model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The Notification Message Templates. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/NotificationMessageTemplates/Item/SendTestMessage/SendTestMessageRequestBuilder.cs b/src/generated/DeviceManagement/NotificationMessageTemplates/Item/SendTestMessage/SendTestMessageRequestBuilder.cs index 6099fa6b5f9..a68c27039e9 100644 --- a/src/generated/DeviceManagement/NotificationMessageTemplates/Item/SendTestMessage/SendTestMessageRequestBuilder.cs +++ b/src/generated/DeviceManagement/NotificationMessageTemplates/Item/SendTestMessage/SendTestMessageRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Sends test message using the specified notificationMessageTemplate in the default locale"; // Create options for all the parameters - var notificationMessageTemplateIdOption = new Option("--notificationmessagetemplate-id", description: "key: id of notificationMessageTemplate") { + var notificationMessageTemplateIdOption = new Option("--notification-message-template-id", description: "key: id of notificationMessageTemplate") { }; notificationMessageTemplateIdOption.IsRequired = true; command.AddOption(notificationMessageTemplateIdOption); - command.SetHandler(async (string notificationMessageTemplateId) => { + command.SetHandler(async (string notificationMessageTemplateId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notificationMessageTemplateIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Sends test message using the specified notificationMessageTemplate in the default locale - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/NotificationMessageTemplates/NotificationMessageTemplatesRequestBuilder.cs b/src/generated/DeviceManagement/NotificationMessageTemplates/NotificationMessageTemplatesRequestBuilder.cs index 59b99667d53..b61e5817d8e 100644 --- a/src/generated/DeviceManagement/NotificationMessageTemplates/NotificationMessageTemplatesRequestBuilder.cs +++ b/src/generated/DeviceManagement/NotificationMessageTemplates/NotificationMessageTemplatesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class NotificationMessageTemplatesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new NotificationMessageTemplateRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildLocalizedNotificationMessagesCommand(), - builder.BuildPatchCommand(), - builder.BuildSendTestMessageCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildLocalizedNotificationMessagesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSendTestMessageCommand()); return commands; } /// @@ -42,21 +41,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -101,7 +99,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -112,15 +114,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -175,31 +172,6 @@ public RequestInformation CreatePostRequestInformation(NotificationMessageTempla requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The Notification Message Templates. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Notification Message Templates. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(NotificationMessageTemplate model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The Notification Message Templates. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/RemoteAssistancePartners/Item/BeginOnboarding/BeginOnboardingRequestBuilder.cs b/src/generated/DeviceManagement/RemoteAssistancePartners/Item/BeginOnboarding/BeginOnboardingRequestBuilder.cs index 3c6a9b5b09e..aee3d4f94d4 100644 --- a/src/generated/DeviceManagement/RemoteAssistancePartners/Item/BeginOnboarding/BeginOnboardingRequestBuilder.cs +++ b/src/generated/DeviceManagement/RemoteAssistancePartners/Item/BeginOnboarding/BeginOnboardingRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "A request to start onboarding. Must be coupled with the appropriate TeamViewer account information"; // Create options for all the parameters - var remoteAssistancePartnerIdOption = new Option("--remoteassistancepartner-id", description: "key: id of remoteAssistancePartner") { + var remoteAssistancePartnerIdOption = new Option("--remote-assistance-partner-id", description: "key: id of remoteAssistancePartner") { }; remoteAssistancePartnerIdOption.IsRequired = true; command.AddOption(remoteAssistancePartnerIdOption); - command.SetHandler(async (string remoteAssistancePartnerId) => { + command.SetHandler(async (string remoteAssistancePartnerId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, remoteAssistancePartnerIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// A request to start onboarding. Must be coupled with the appropriate TeamViewer account information - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/RemoteAssistancePartners/Item/Disconnect/DisconnectRequestBuilder.cs b/src/generated/DeviceManagement/RemoteAssistancePartners/Item/Disconnect/DisconnectRequestBuilder.cs index 0b2cb4c4c6d..57f90ab3029 100644 --- a/src/generated/DeviceManagement/RemoteAssistancePartners/Item/Disconnect/DisconnectRequestBuilder.cs +++ b/src/generated/DeviceManagement/RemoteAssistancePartners/Item/Disconnect/DisconnectRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "A request to remove the active TeamViewer connector"; // Create options for all the parameters - var remoteAssistancePartnerIdOption = new Option("--remoteassistancepartner-id", description: "key: id of remoteAssistancePartner") { + var remoteAssistancePartnerIdOption = new Option("--remote-assistance-partner-id", description: "key: id of remoteAssistancePartner") { }; remoteAssistancePartnerIdOption.IsRequired = true; command.AddOption(remoteAssistancePartnerIdOption); - command.SetHandler(async (string remoteAssistancePartnerId) => { + command.SetHandler(async (string remoteAssistancePartnerId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, remoteAssistancePartnerIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// A request to remove the active TeamViewer connector - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/RemoteAssistancePartners/Item/RemoteAssistancePartnerRequestBuilder.cs b/src/generated/DeviceManagement/RemoteAssistancePartners/Item/RemoteAssistancePartnerRequestBuilder.cs index e40fb80e986..38ae238537b 100644 --- a/src/generated/DeviceManagement/RemoteAssistancePartners/Item/RemoteAssistancePartnerRequestBuilder.cs +++ b/src/generated/DeviceManagement/RemoteAssistancePartners/Item/RemoteAssistancePartnerRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The remote assist partners."; // Create options for all the parameters - var remoteAssistancePartnerIdOption = new Option("--remoteassistancepartner-id", description: "key: id of remoteAssistancePartner") { + var remoteAssistancePartnerIdOption = new Option("--remote-assistance-partner-id", description: "key: id of remoteAssistancePartner") { }; remoteAssistancePartnerIdOption.IsRequired = true; command.AddOption(remoteAssistancePartnerIdOption); - command.SetHandler(async (string remoteAssistancePartnerId) => { + command.SetHandler(async (string remoteAssistancePartnerId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, remoteAssistancePartnerIdOption); return command; @@ -60,7 +59,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The remote assist partners."; // Create options for all the parameters - var remoteAssistancePartnerIdOption = new Option("--remoteassistancepartner-id", description: "key: id of remoteAssistancePartner") { + var remoteAssistancePartnerIdOption = new Option("--remote-assistance-partner-id", description: "key: id of remoteAssistancePartner") { }; remoteAssistancePartnerIdOption.IsRequired = true; command.AddOption(remoteAssistancePartnerIdOption); @@ -74,20 +73,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string remoteAssistancePartnerId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string remoteAssistancePartnerId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, remoteAssistancePartnerIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, remoteAssistancePartnerIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -97,7 +95,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The remote assist partners."; // Create options for all the parameters - var remoteAssistancePartnerIdOption = new Option("--remoteassistancepartner-id", description: "key: id of remoteAssistancePartner") { + var remoteAssistancePartnerIdOption = new Option("--remote-assistance-partner-id", description: "key: id of remoteAssistancePartner") { }; remoteAssistancePartnerIdOption.IsRequired = true; command.AddOption(remoteAssistancePartnerIdOption); @@ -105,14 +103,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string remoteAssistancePartnerId, string body) => { + command.SetHandler(async (string remoteAssistancePartnerId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, remoteAssistancePartnerIdOption, bodyOption); return command; @@ -184,42 +181,6 @@ public RequestInformation CreatePatchRequestInformation(RemoteAssistancePartner requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The remote assist partners. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The remote assist partners. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The remote assist partners. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(RemoteAssistancePartner model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The remote assist partners. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/RemoteAssistancePartners/RemoteAssistancePartnersRequestBuilder.cs b/src/generated/DeviceManagement/RemoteAssistancePartners/RemoteAssistancePartnersRequestBuilder.cs index dc2e251368b..f5d5aea5215 100644 --- a/src/generated/DeviceManagement/RemoteAssistancePartners/RemoteAssistancePartnersRequestBuilder.cs +++ b/src/generated/DeviceManagement/RemoteAssistancePartners/RemoteAssistancePartnersRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class RemoteAssistancePartnersRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new RemoteAssistancePartnerRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildBeginOnboardingCommand(), - builder.BuildDeleteCommand(), - builder.BuildDisconnectCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildBeginOnboardingCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDisconnectCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,21 +41,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -101,7 +99,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -112,15 +114,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -175,31 +172,6 @@ public RequestInformation CreatePostRequestInformation(RemoteAssistancePartner b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The remote assist partners. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The remote assist partners. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RemoteAssistancePartner model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The remote assist partners. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/Reports/ExportJobs/ExportJobsRequestBuilder.cs b/src/generated/DeviceManagement/Reports/ExportJobs/ExportJobsRequestBuilder.cs index feb0d58291f..481bd701073 100644 --- a/src/generated/DeviceManagement/Reports/ExportJobs/ExportJobsRequestBuilder.cs +++ b/src/generated/DeviceManagement/Reports/ExportJobs/ExportJobsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExportJobsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceManagementExportJobRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(DeviceManagementExportJob requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Entity representing a job to export a report - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Entity representing a job to export a report - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceManagementExportJob model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Entity representing a job to export a report public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/Reports/ExportJobs/Item/DeviceManagementExportJobRequestBuilder.cs b/src/generated/DeviceManagement/Reports/ExportJobs/Item/DeviceManagementExportJobRequestBuilder.cs index e1548b072bd..dfd6c331aa9 100644 --- a/src/generated/DeviceManagement/Reports/ExportJobs/Item/DeviceManagementExportJobRequestBuilder.cs +++ b/src/generated/DeviceManagement/Reports/ExportJobs/Item/DeviceManagementExportJobRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Entity representing a job to export a report"; // Create options for all the parameters - var deviceManagementExportJobIdOption = new Option("--devicemanagementexportjob-id", description: "key: id of deviceManagementExportJob") { + var deviceManagementExportJobIdOption = new Option("--device-management-export-job-id", description: "key: id of deviceManagementExportJob") { }; deviceManagementExportJobIdOption.IsRequired = true; command.AddOption(deviceManagementExportJobIdOption); - command.SetHandler(async (string deviceManagementExportJobId) => { + command.SetHandler(async (string deviceManagementExportJobId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceManagementExportJobIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Entity representing a job to export a report"; // Create options for all the parameters - var deviceManagementExportJobIdOption = new Option("--devicemanagementexportjob-id", description: "key: id of deviceManagementExportJob") { + var deviceManagementExportJobIdOption = new Option("--device-management-export-job-id", description: "key: id of deviceManagementExportJob") { }; deviceManagementExportJobIdOption.IsRequired = true; command.AddOption(deviceManagementExportJobIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceManagementExportJobId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceManagementExportJobId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceManagementExportJobIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceManagementExportJobIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Entity representing a job to export a report"; // Create options for all the parameters - var deviceManagementExportJobIdOption = new Option("--devicemanagementexportjob-id", description: "key: id of deviceManagementExportJob") { + var deviceManagementExportJobIdOption = new Option("--device-management-export-job-id", description: "key: id of deviceManagementExportJob") { }; deviceManagementExportJobIdOption.IsRequired = true; command.AddOption(deviceManagementExportJobIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceManagementExportJobId, string body) => { + command.SetHandler(async (string deviceManagementExportJobId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceManagementExportJobIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceManagementExportJo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Entity representing a job to export a report - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Entity representing a job to export a report - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Entity representing a job to export a report - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceManagementExportJob model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Entity representing a job to export a report public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/Reports/GetCachedReport/GetCachedReportRequestBuilder.cs b/src/generated/DeviceManagement/Reports/GetCachedReport/GetCachedReportRequestBuilder.cs index 1a88671ff2b..83fa9f2c458 100644 --- a/src/generated/DeviceManagement/Reports/GetCachedReport/GetCachedReportRequestBuilder.cs +++ b/src/generated/DeviceManagement/Reports/GetCachedReport/GetCachedReportRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,27 +29,29 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string body, FileInfo output) => { + command.SetHandler(async (string body, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, bodyOption, outputOption); + }, bodyOption, fileOption, outputOption); return command; } /// @@ -83,18 +85,5 @@ public RequestInformation CreatePostRequestInformation(GetCachedReportRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getCachedReport - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GetCachedReportRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/Reports/GetCompliancePolicyNonComplianceReport/GetCompliancePolicyNonComplianceReportRequestBuilder.cs b/src/generated/DeviceManagement/Reports/GetCompliancePolicyNonComplianceReport/GetCompliancePolicyNonComplianceReportRequestBuilder.cs index 0f6464009f3..3f07f9eb5f9 100644 --- a/src/generated/DeviceManagement/Reports/GetCompliancePolicyNonComplianceReport/GetCompliancePolicyNonComplianceReportRequestBuilder.cs +++ b/src/generated/DeviceManagement/Reports/GetCompliancePolicyNonComplianceReport/GetCompliancePolicyNonComplianceReportRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,27 +29,29 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string body, FileInfo output) => { + command.SetHandler(async (string body, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, bodyOption, outputOption); + }, bodyOption, fileOption, outputOption); return command; } /// @@ -83,18 +85,5 @@ public RequestInformation CreatePostRequestInformation(GetCompliancePolicyNonCom requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getCompliancePolicyNonComplianceReport - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GetCompliancePolicyNonComplianceReportRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/Reports/GetCompliancePolicyNonComplianceSummaryReport/GetCompliancePolicyNonComplianceSummaryReportRequestBuilder.cs b/src/generated/DeviceManagement/Reports/GetCompliancePolicyNonComplianceSummaryReport/GetCompliancePolicyNonComplianceSummaryReportRequestBuilder.cs index dd7415219e7..4c239a80fa8 100644 --- a/src/generated/DeviceManagement/Reports/GetCompliancePolicyNonComplianceSummaryReport/GetCompliancePolicyNonComplianceSummaryReportRequestBuilder.cs +++ b/src/generated/DeviceManagement/Reports/GetCompliancePolicyNonComplianceSummaryReport/GetCompliancePolicyNonComplianceSummaryReportRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,27 +29,29 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string body, FileInfo output) => { + command.SetHandler(async (string body, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, bodyOption, outputOption); + }, bodyOption, fileOption, outputOption); return command; } /// @@ -83,18 +85,5 @@ public RequestInformation CreatePostRequestInformation(GetCompliancePolicyNonCom requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getCompliancePolicyNonComplianceSummaryReport - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GetCompliancePolicyNonComplianceSummaryReportRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/Reports/GetComplianceSettingNonComplianceReport/GetComplianceSettingNonComplianceReportRequestBuilder.cs b/src/generated/DeviceManagement/Reports/GetComplianceSettingNonComplianceReport/GetComplianceSettingNonComplianceReportRequestBuilder.cs index 2a5ed83eddd..268a6ba18c1 100644 --- a/src/generated/DeviceManagement/Reports/GetComplianceSettingNonComplianceReport/GetComplianceSettingNonComplianceReportRequestBuilder.cs +++ b/src/generated/DeviceManagement/Reports/GetComplianceSettingNonComplianceReport/GetComplianceSettingNonComplianceReportRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,27 +29,29 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string body, FileInfo output) => { + command.SetHandler(async (string body, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, bodyOption, outputOption); + }, bodyOption, fileOption, outputOption); return command; } /// @@ -83,18 +85,5 @@ public RequestInformation CreatePostRequestInformation(GetComplianceSettingNonCo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getComplianceSettingNonComplianceReport - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GetComplianceSettingNonComplianceReportRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/Reports/GetConfigurationPolicyNonComplianceReport/GetConfigurationPolicyNonComplianceReportRequestBuilder.cs b/src/generated/DeviceManagement/Reports/GetConfigurationPolicyNonComplianceReport/GetConfigurationPolicyNonComplianceReportRequestBuilder.cs index 7556341274a..4ece743292b 100644 --- a/src/generated/DeviceManagement/Reports/GetConfigurationPolicyNonComplianceReport/GetConfigurationPolicyNonComplianceReportRequestBuilder.cs +++ b/src/generated/DeviceManagement/Reports/GetConfigurationPolicyNonComplianceReport/GetConfigurationPolicyNonComplianceReportRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,27 +29,29 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string body, FileInfo output) => { + command.SetHandler(async (string body, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, bodyOption, outputOption); + }, bodyOption, fileOption, outputOption); return command; } /// @@ -83,18 +85,5 @@ public RequestInformation CreatePostRequestInformation(GetConfigurationPolicyNon requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getConfigurationPolicyNonComplianceReport - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GetConfigurationPolicyNonComplianceReportRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/Reports/GetConfigurationPolicyNonComplianceSummaryReport/GetConfigurationPolicyNonComplianceSummaryReportRequestBuilder.cs b/src/generated/DeviceManagement/Reports/GetConfigurationPolicyNonComplianceSummaryReport/GetConfigurationPolicyNonComplianceSummaryReportRequestBuilder.cs index 5a451947949..688dca7d364 100644 --- a/src/generated/DeviceManagement/Reports/GetConfigurationPolicyNonComplianceSummaryReport/GetConfigurationPolicyNonComplianceSummaryReportRequestBuilder.cs +++ b/src/generated/DeviceManagement/Reports/GetConfigurationPolicyNonComplianceSummaryReport/GetConfigurationPolicyNonComplianceSummaryReportRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,27 +29,29 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string body, FileInfo output) => { + command.SetHandler(async (string body, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, bodyOption, outputOption); + }, bodyOption, fileOption, outputOption); return command; } /// @@ -83,18 +85,5 @@ public RequestInformation CreatePostRequestInformation(GetConfigurationPolicyNon requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getConfigurationPolicyNonComplianceSummaryReport - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GetConfigurationPolicyNonComplianceSummaryReportRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/Reports/GetConfigurationSettingNonComplianceReport/GetConfigurationSettingNonComplianceReportRequestBuilder.cs b/src/generated/DeviceManagement/Reports/GetConfigurationSettingNonComplianceReport/GetConfigurationSettingNonComplianceReportRequestBuilder.cs index b84045896c6..a50f8f6b344 100644 --- a/src/generated/DeviceManagement/Reports/GetConfigurationSettingNonComplianceReport/GetConfigurationSettingNonComplianceReportRequestBuilder.cs +++ b/src/generated/DeviceManagement/Reports/GetConfigurationSettingNonComplianceReport/GetConfigurationSettingNonComplianceReportRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,27 +29,29 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string body, FileInfo output) => { + command.SetHandler(async (string body, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, bodyOption, outputOption); + }, bodyOption, fileOption, outputOption); return command; } /// @@ -83,18 +85,5 @@ public RequestInformation CreatePostRequestInformation(GetConfigurationSettingNo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getConfigurationSettingNonComplianceReport - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GetConfigurationSettingNonComplianceReportRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/Reports/GetDeviceManagementIntentPerSettingContributingProfiles/GetDeviceManagementIntentPerSettingContributingProfilesRequestBuilder.cs b/src/generated/DeviceManagement/Reports/GetDeviceManagementIntentPerSettingContributingProfiles/GetDeviceManagementIntentPerSettingContributingProfilesRequestBuilder.cs index 9312a657b32..98644960ade 100644 --- a/src/generated/DeviceManagement/Reports/GetDeviceManagementIntentPerSettingContributingProfiles/GetDeviceManagementIntentPerSettingContributingProfilesRequestBuilder.cs +++ b/src/generated/DeviceManagement/Reports/GetDeviceManagementIntentPerSettingContributingProfiles/GetDeviceManagementIntentPerSettingContributingProfilesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,27 +29,29 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string body, FileInfo output) => { + command.SetHandler(async (string body, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, bodyOption, outputOption); + }, bodyOption, fileOption, outputOption); return command; } /// @@ -83,18 +85,5 @@ public RequestInformation CreatePostRequestInformation(GetDeviceManagementIntent requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getDeviceManagementIntentPerSettingContributingProfiles - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GetDeviceManagementIntentPerSettingContributingProfilesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/Reports/GetDeviceManagementIntentSettingsReport/GetDeviceManagementIntentSettingsReportRequestBuilder.cs b/src/generated/DeviceManagement/Reports/GetDeviceManagementIntentSettingsReport/GetDeviceManagementIntentSettingsReportRequestBuilder.cs index 5eebd8e7783..17e7359edf6 100644 --- a/src/generated/DeviceManagement/Reports/GetDeviceManagementIntentSettingsReport/GetDeviceManagementIntentSettingsReportRequestBuilder.cs +++ b/src/generated/DeviceManagement/Reports/GetDeviceManagementIntentSettingsReport/GetDeviceManagementIntentSettingsReportRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,27 +29,29 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string body, FileInfo output) => { + command.SetHandler(async (string body, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, bodyOption, outputOption); + }, bodyOption, fileOption, outputOption); return command; } /// @@ -83,18 +85,5 @@ public RequestInformation CreatePostRequestInformation(GetDeviceManagementIntent requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getDeviceManagementIntentSettingsReport - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GetDeviceManagementIntentSettingsReportRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/Reports/GetDeviceNonComplianceReport/GetDeviceNonComplianceReportRequestBuilder.cs b/src/generated/DeviceManagement/Reports/GetDeviceNonComplianceReport/GetDeviceNonComplianceReportRequestBuilder.cs index 72b5a631ada..58ec2333d6e 100644 --- a/src/generated/DeviceManagement/Reports/GetDeviceNonComplianceReport/GetDeviceNonComplianceReportRequestBuilder.cs +++ b/src/generated/DeviceManagement/Reports/GetDeviceNonComplianceReport/GetDeviceNonComplianceReportRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,27 +29,29 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string body, FileInfo output) => { + command.SetHandler(async (string body, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, bodyOption, outputOption); + }, bodyOption, fileOption, outputOption); return command; } /// @@ -83,18 +85,5 @@ public RequestInformation CreatePostRequestInformation(GetDeviceNonComplianceRep requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getDeviceNonComplianceReport - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GetDeviceNonComplianceReportRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/Reports/GetHistoricalReport/GetHistoricalReportRequestBuilder.cs b/src/generated/DeviceManagement/Reports/GetHistoricalReport/GetHistoricalReportRequestBuilder.cs index 198f718dc3e..fce1ff5cf6e 100644 --- a/src/generated/DeviceManagement/Reports/GetHistoricalReport/GetHistoricalReportRequestBuilder.cs +++ b/src/generated/DeviceManagement/Reports/GetHistoricalReport/GetHistoricalReportRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,27 +29,29 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string body, FileInfo output) => { + command.SetHandler(async (string body, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, bodyOption, outputOption); + }, bodyOption, fileOption, outputOption); return command; } /// @@ -83,18 +85,5 @@ public RequestInformation CreatePostRequestInformation(GetHistoricalReportReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getHistoricalReport - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GetHistoricalReportRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/Reports/GetPolicyNonComplianceMetadata/GetPolicyNonComplianceMetadataRequestBuilder.cs b/src/generated/DeviceManagement/Reports/GetPolicyNonComplianceMetadata/GetPolicyNonComplianceMetadataRequestBuilder.cs index d724e258295..28028fb2514 100644 --- a/src/generated/DeviceManagement/Reports/GetPolicyNonComplianceMetadata/GetPolicyNonComplianceMetadataRequestBuilder.cs +++ b/src/generated/DeviceManagement/Reports/GetPolicyNonComplianceMetadata/GetPolicyNonComplianceMetadataRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,27 +29,29 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string body, FileInfo output) => { + command.SetHandler(async (string body, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, bodyOption, outputOption); + }, bodyOption, fileOption, outputOption); return command; } /// @@ -83,18 +85,5 @@ public RequestInformation CreatePostRequestInformation(GetPolicyNonComplianceMet requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getPolicyNonComplianceMetadata - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GetPolicyNonComplianceMetadataRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/Reports/GetPolicyNonComplianceReport/GetPolicyNonComplianceReportRequestBuilder.cs b/src/generated/DeviceManagement/Reports/GetPolicyNonComplianceReport/GetPolicyNonComplianceReportRequestBuilder.cs index ddc92a52c1d..4407db35c96 100644 --- a/src/generated/DeviceManagement/Reports/GetPolicyNonComplianceReport/GetPolicyNonComplianceReportRequestBuilder.cs +++ b/src/generated/DeviceManagement/Reports/GetPolicyNonComplianceReport/GetPolicyNonComplianceReportRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,27 +29,29 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string body, FileInfo output) => { + command.SetHandler(async (string body, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, bodyOption, outputOption); + }, bodyOption, fileOption, outputOption); return command; } /// @@ -83,18 +85,5 @@ public RequestInformation CreatePostRequestInformation(GetPolicyNonComplianceRep requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getPolicyNonComplianceReport - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GetPolicyNonComplianceReportRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/Reports/GetPolicyNonComplianceSummaryReport/GetPolicyNonComplianceSummaryReportRequestBuilder.cs b/src/generated/DeviceManagement/Reports/GetPolicyNonComplianceSummaryReport/GetPolicyNonComplianceSummaryReportRequestBuilder.cs index a9441cafd23..88508b57dea 100644 --- a/src/generated/DeviceManagement/Reports/GetPolicyNonComplianceSummaryReport/GetPolicyNonComplianceSummaryReportRequestBuilder.cs +++ b/src/generated/DeviceManagement/Reports/GetPolicyNonComplianceSummaryReport/GetPolicyNonComplianceSummaryReportRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,27 +29,29 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string body, FileInfo output) => { + command.SetHandler(async (string body, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, bodyOption, outputOption); + }, bodyOption, fileOption, outputOption); return command; } /// @@ -83,18 +85,5 @@ public RequestInformation CreatePostRequestInformation(GetPolicyNonComplianceSum requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getPolicyNonComplianceSummaryReport - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GetPolicyNonComplianceSummaryReportRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/Reports/GetReportFilters/GetReportFiltersRequestBuilder.cs b/src/generated/DeviceManagement/Reports/GetReportFilters/GetReportFiltersRequestBuilder.cs index 886a2b2c3fe..47b3e9621c6 100644 --- a/src/generated/DeviceManagement/Reports/GetReportFilters/GetReportFiltersRequestBuilder.cs +++ b/src/generated/DeviceManagement/Reports/GetReportFilters/GetReportFiltersRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,27 +29,29 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string body, FileInfo output) => { + command.SetHandler(async (string body, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, bodyOption, outputOption); + }, bodyOption, fileOption, outputOption); return command; } /// @@ -83,18 +85,5 @@ public RequestInformation CreatePostRequestInformation(GetReportFiltersRequestBo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getReportFilters - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GetReportFiltersRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/Reports/GetSettingNonComplianceReport/GetSettingNonComplianceReportRequestBuilder.cs b/src/generated/DeviceManagement/Reports/GetSettingNonComplianceReport/GetSettingNonComplianceReportRequestBuilder.cs index 4ca5acb99d9..46ee54c2987 100644 --- a/src/generated/DeviceManagement/Reports/GetSettingNonComplianceReport/GetSettingNonComplianceReportRequestBuilder.cs +++ b/src/generated/DeviceManagement/Reports/GetSettingNonComplianceReport/GetSettingNonComplianceReportRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,27 +29,29 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string body, FileInfo output) => { + command.SetHandler(async (string body, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, bodyOption, outputOption); + }, bodyOption, fileOption, outputOption); return command; } /// @@ -83,18 +85,5 @@ public RequestInformation CreatePostRequestInformation(GetSettingNonComplianceRe requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSettingNonComplianceReport - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GetSettingNonComplianceReportRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/Reports/ReportsRequestBuilder.cs b/src/generated/DeviceManagement/Reports/ReportsRequestBuilder.cs index bed53642714..17378b5f578 100644 --- a/src/generated/DeviceManagement/Reports/ReportsRequestBuilder.cs +++ b/src/generated/DeviceManagement/Reports/ReportsRequestBuilder.cs @@ -18,10 +18,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -43,11 +43,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Reports singleton"; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -55,6 +54,9 @@ public Command BuildDeleteCommand() { public Command BuildExportJobsCommand() { var command = new Command("export-jobs"); var builder = new ApiSdk.DeviceManagement.Reports.ExportJobs.ExportJobsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -82,20 +84,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } public Command BuildGetCompliancePolicyNonComplianceReportCommand() { @@ -199,14 +200,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -278,42 +278,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceManagementReports requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Reports singleton - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Reports singleton - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Reports singleton - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceManagementReports model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Reports singleton public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/ResourceOperations/Item/ResourceOperationRequestBuilder.cs b/src/generated/DeviceManagement/ResourceOperations/Item/ResourceOperationRequestBuilder.cs index 34d6792717d..536e1c9df24 100644 --- a/src/generated/DeviceManagement/ResourceOperations/Item/ResourceOperationRequestBuilder.cs +++ b/src/generated/DeviceManagement/ResourceOperations/Item/ResourceOperationRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The Resource Operations."; // Create options for all the parameters - var resourceOperationIdOption = new Option("--resourceoperation-id", description: "key: id of resourceOperation") { + var resourceOperationIdOption = new Option("--resource-operation-id", description: "key: id of resourceOperation") { }; resourceOperationIdOption.IsRequired = true; command.AddOption(resourceOperationIdOption); - command.SetHandler(async (string resourceOperationId) => { + command.SetHandler(async (string resourceOperationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, resourceOperationIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The Resource Operations."; // Create options for all the parameters - var resourceOperationIdOption = new Option("--resourceoperation-id", description: "key: id of resourceOperation") { + var resourceOperationIdOption = new Option("--resource-operation-id", description: "key: id of resourceOperation") { }; resourceOperationIdOption.IsRequired = true; command.AddOption(resourceOperationIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string resourceOperationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string resourceOperationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, resourceOperationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, resourceOperationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The Resource Operations."; // Create options for all the parameters - var resourceOperationIdOption = new Option("--resourceoperation-id", description: "key: id of resourceOperation") { + var resourceOperationIdOption = new Option("--resource-operation-id", description: "key: id of resourceOperation") { }; resourceOperationIdOption.IsRequired = true; command.AddOption(resourceOperationIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string resourceOperationId, string body) => { + command.SetHandler(async (string resourceOperationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, resourceOperationIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ResourceOperation body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The Resource Operations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Resource Operations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Resource Operations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ResourceOperation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The Resource Operations. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/ResourceOperations/ResourceOperationsRequestBuilder.cs b/src/generated/DeviceManagement/ResourceOperations/ResourceOperationsRequestBuilder.cs index 1acf9a201d6..c38f114e532 100644 --- a/src/generated/DeviceManagement/ResourceOperations/ResourceOperationsRequestBuilder.cs +++ b/src/generated/DeviceManagement/ResourceOperations/ResourceOperationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ResourceOperationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ResourceOperationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(ResourceOperation body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The Resource Operations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Resource Operations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ResourceOperation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The Resource Operations. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/RoleAssignments/Item/DeviceAndAppManagementRoleAssignmentRequestBuilder.cs b/src/generated/DeviceManagement/RoleAssignments/Item/DeviceAndAppManagementRoleAssignmentRequestBuilder.cs index 9f7a9a1c1f5..a91eb7f07d0 100644 --- a/src/generated/DeviceManagement/RoleAssignments/Item/DeviceAndAppManagementRoleAssignmentRequestBuilder.cs +++ b/src/generated/DeviceManagement/RoleAssignments/Item/DeviceAndAppManagementRoleAssignmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The Role Assignments."; // Create options for all the parameters - var deviceAndAppManagementRoleAssignmentIdOption = new Option("--deviceandappmanagementroleassignment-id", description: "key: id of deviceAndAppManagementRoleAssignment") { + var deviceAndAppManagementRoleAssignmentIdOption = new Option("--device-and-app-management-role-assignment-id", description: "key: id of deviceAndAppManagementRoleAssignment") { }; deviceAndAppManagementRoleAssignmentIdOption.IsRequired = true; command.AddOption(deviceAndAppManagementRoleAssignmentIdOption); - command.SetHandler(async (string deviceAndAppManagementRoleAssignmentId) => { + command.SetHandler(async (string deviceAndAppManagementRoleAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceAndAppManagementRoleAssignmentIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The Role Assignments."; // Create options for all the parameters - var deviceAndAppManagementRoleAssignmentIdOption = new Option("--deviceandappmanagementroleassignment-id", description: "key: id of deviceAndAppManagementRoleAssignment") { + var deviceAndAppManagementRoleAssignmentIdOption = new Option("--device-and-app-management-role-assignment-id", description: "key: id of deviceAndAppManagementRoleAssignment") { }; deviceAndAppManagementRoleAssignmentIdOption.IsRequired = true; command.AddOption(deviceAndAppManagementRoleAssignmentIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceAndAppManagementRoleAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceAndAppManagementRoleAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceAndAppManagementRoleAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceAndAppManagementRoleAssignmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The Role Assignments."; // Create options for all the parameters - var deviceAndAppManagementRoleAssignmentIdOption = new Option("--deviceandappmanagementroleassignment-id", description: "key: id of deviceAndAppManagementRoleAssignment") { + var deviceAndAppManagementRoleAssignmentIdOption = new Option("--device-and-app-management-role-assignment-id", description: "key: id of deviceAndAppManagementRoleAssignment") { }; deviceAndAppManagementRoleAssignmentIdOption.IsRequired = true; command.AddOption(deviceAndAppManagementRoleAssignmentIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceAndAppManagementRoleAssignmentId, string body) => { + command.SetHandler(async (string deviceAndAppManagementRoleAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceAndAppManagementRoleAssignmentIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceAndAppManagementRo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The Role Assignments. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Role Assignments. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Role Assignments. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceAndAppManagementRoleAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The Role Assignments. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/RoleAssignments/RoleAssignmentsRequestBuilder.cs b/src/generated/DeviceManagement/RoleAssignments/RoleAssignmentsRequestBuilder.cs index b5f25f98af8..571d8582604 100644 --- a/src/generated/DeviceManagement/RoleAssignments/RoleAssignmentsRequestBuilder.cs +++ b/src/generated/DeviceManagement/RoleAssignments/RoleAssignmentsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class RoleAssignmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceAndAppManagementRoleAssignmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(DeviceAndAppManagementRol requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The Role Assignments. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Role Assignments. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceAndAppManagementRoleAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The Role Assignments. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/RoleDefinitions/Item/RoleAssignments/Item/RoleAssignmentRequestBuilder.cs b/src/generated/DeviceManagement/RoleDefinitions/Item/RoleAssignments/Item/RoleAssignmentRequestBuilder.cs index a30db6d705e..3a9982f4bfb 100644 --- a/src/generated/DeviceManagement/RoleDefinitions/Item/RoleAssignments/Item/RoleAssignmentRequestBuilder.cs +++ b/src/generated/DeviceManagement/RoleDefinitions/Item/RoleAssignments/Item/RoleAssignmentRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,19 +27,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "List of Role assignments for this role definition."; // Create options for all the parameters - var roleDefinitionIdOption = new Option("--roledefinition-id", description: "key: id of roleDefinition") { + var roleDefinitionIdOption = new Option("--role-definition-id", description: "key: id of roleDefinition") { }; roleDefinitionIdOption.IsRequired = true; command.AddOption(roleDefinitionIdOption); - var roleAssignmentIdOption = new Option("--roleassignment-id", description: "key: id of roleAssignment") { + var roleAssignmentIdOption = new Option("--role-assignment-id", description: "key: id of roleAssignment") { }; roleAssignmentIdOption.IsRequired = true; command.AddOption(roleAssignmentIdOption); - command.SetHandler(async (string roleDefinitionId, string roleAssignmentId) => { + command.SetHandler(async (string roleDefinitionId, string roleAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, roleDefinitionIdOption, roleAssignmentIdOption); return command; @@ -51,11 +50,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "List of Role assignments for this role definition."; // Create options for all the parameters - var roleDefinitionIdOption = new Option("--roledefinition-id", description: "key: id of roleDefinition") { + var roleDefinitionIdOption = new Option("--role-definition-id", description: "key: id of roleDefinition") { }; roleDefinitionIdOption.IsRequired = true; command.AddOption(roleDefinitionIdOption); - var roleAssignmentIdOption = new Option("--roleassignment-id", description: "key: id of roleAssignment") { + var roleAssignmentIdOption = new Option("--role-assignment-id", description: "key: id of roleAssignment") { }; roleAssignmentIdOption.IsRequired = true; command.AddOption(roleAssignmentIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string roleDefinitionId, string roleAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string roleDefinitionId, string roleAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, roleDefinitionIdOption, roleAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, roleDefinitionIdOption, roleAssignmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -92,11 +90,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "List of Role assignments for this role definition."; // Create options for all the parameters - var roleDefinitionIdOption = new Option("--roledefinition-id", description: "key: id of roleDefinition") { + var roleDefinitionIdOption = new Option("--role-definition-id", description: "key: id of roleDefinition") { }; roleDefinitionIdOption.IsRequired = true; command.AddOption(roleDefinitionIdOption); - var roleAssignmentIdOption = new Option("--roleassignment-id", description: "key: id of roleAssignment") { + var roleAssignmentIdOption = new Option("--role-assignment-id", description: "key: id of roleAssignment") { }; roleAssignmentIdOption.IsRequired = true; command.AddOption(roleAssignmentIdOption); @@ -104,14 +102,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string roleDefinitionId, string roleAssignmentId, string body) => { + command.SetHandler(async (string roleDefinitionId, string roleAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, roleDefinitionIdOption, roleAssignmentIdOption, bodyOption); return command; @@ -190,42 +187,6 @@ public RequestInformation CreatePatchRequestInformation(RoleAssignment body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of Role assignments for this role definition. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of Role assignments for this role definition. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of Role assignments for this role definition. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(RoleAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// List of Role assignments for this role definition. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/RoleDefinitions/Item/RoleAssignments/Item/RoleDefinition/@Ref/@Ref.cs b/src/generated/DeviceManagement/RoleDefinitions/Item/RoleAssignments/Item/RoleDefinition/@Ref/@Ref.cs deleted file mode 100644 index 297bdb8d4b1..00000000000 --- a/src/generated/DeviceManagement/RoleDefinitions/Item/RoleAssignments/Item/RoleDefinition/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.DeviceManagement.RoleDefinitions.Item.RoleAssignments.Item.RoleDefinition.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/DeviceManagement/RoleDefinitions/Item/RoleAssignments/Item/RoleDefinition/@Ref/RefRequestBuilder.cs b/src/generated/DeviceManagement/RoleDefinitions/Item/RoleAssignments/Item/RoleDefinition/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 5a2be90f08b..00000000000 --- a/src/generated/DeviceManagement/RoleDefinitions/Item/RoleAssignments/Item/RoleDefinition/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.DeviceManagement.RoleDefinitions.Item.RoleAssignments.Item.RoleDefinition.@Ref { - /// Builds and executes requests for operations under \deviceManagement\roleDefinitions\{roleDefinition-id}\roleAssignments\{roleAssignment-id}\roleDefinition\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Role definition this assignment is part of. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Role definition this assignment is part of."; - // Create options for all the parameters - var roleDefinitionIdOption = new Option("--roledefinition-id", description: "key: id of roleDefinition") { - }; - roleDefinitionIdOption.IsRequired = true; - command.AddOption(roleDefinitionIdOption); - var roleAssignmentIdOption = new Option("--roleassignment-id", description: "key: id of roleAssignment") { - }; - roleAssignmentIdOption.IsRequired = true; - command.AddOption(roleAssignmentIdOption); - command.SetHandler(async (string roleDefinitionId, string roleAssignmentId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, roleDefinitionIdOption, roleAssignmentIdOption); - return command; - } - /// - /// Role definition this assignment is part of. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Role definition this assignment is part of."; - // Create options for all the parameters - var roleDefinitionIdOption = new Option("--roledefinition-id", description: "key: id of roleDefinition") { - }; - roleDefinitionIdOption.IsRequired = true; - command.AddOption(roleDefinitionIdOption); - var roleAssignmentIdOption = new Option("--roleassignment-id", description: "key: id of roleAssignment") { - }; - roleAssignmentIdOption.IsRequired = true; - command.AddOption(roleAssignmentIdOption); - command.SetHandler(async (string roleDefinitionId, string roleAssignmentId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, roleDefinitionIdOption, roleAssignmentIdOption); - return command; - } - /// - /// Role definition this assignment is part of. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Role definition this assignment is part of."; - // Create options for all the parameters - var roleDefinitionIdOption = new Option("--roledefinition-id", description: "key: id of roleDefinition") { - }; - roleDefinitionIdOption.IsRequired = true; - command.AddOption(roleDefinitionIdOption); - var roleAssignmentIdOption = new Option("--roleassignment-id", description: "key: id of roleAssignment") { - }; - roleAssignmentIdOption.IsRequired = true; - command.AddOption(roleAssignmentIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string roleDefinitionId, string roleAssignmentId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, roleDefinitionIdOption, roleAssignmentIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/deviceManagement/roleDefinitions/{roleDefinition_id}/roleAssignments/{roleAssignment_id}/roleDefinition/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Role definition this assignment is part of. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Role definition this assignment is part of. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Role definition this assignment is part of. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.DeviceManagement.RoleDefinitions.Item.RoleAssignments.Item.RoleDefinition.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Role definition this assignment is part of. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Role definition this assignment is part of. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Role definition this assignment is part of. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.DeviceManagement.RoleDefinitions.Item.RoleAssignments.Item.RoleDefinition.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/DeviceManagement/RoleDefinitions/Item/RoleAssignments/Item/RoleDefinition/Ref/Ref.cs b/src/generated/DeviceManagement/RoleDefinitions/Item/RoleAssignments/Item/RoleDefinition/Ref/Ref.cs new file mode 100644 index 00000000000..c6dacf685b1 --- /dev/null +++ b/src/generated/DeviceManagement/RoleDefinitions/Item/RoleAssignments/Item/RoleDefinition/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.DeviceManagement.RoleDefinitions.Item.RoleAssignments.Item.RoleDefinition.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/DeviceManagement/RoleDefinitions/Item/RoleAssignments/Item/RoleDefinition/Ref/RefRequestBuilder.cs b/src/generated/DeviceManagement/RoleDefinitions/Item/RoleAssignments/Item/RoleDefinition/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..32a6442e622 --- /dev/null +++ b/src/generated/DeviceManagement/RoleDefinitions/Item/RoleAssignments/Item/RoleDefinition/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.DeviceManagement.RoleDefinitions.Item.RoleAssignments.Item.RoleDefinition.Ref { + /// Builds and executes requests for operations under \deviceManagement\roleDefinitions\{roleDefinition-id}\roleAssignments\{roleAssignment-id}\roleDefinition\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Role definition this assignment is part of. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Role definition this assignment is part of."; + // Create options for all the parameters + var roleDefinitionIdOption = new Option("--role-definition-id", description: "key: id of roleDefinition") { + }; + roleDefinitionIdOption.IsRequired = true; + command.AddOption(roleDefinitionIdOption); + var roleAssignmentIdOption = new Option("--role-assignment-id", description: "key: id of roleAssignment") { + }; + roleAssignmentIdOption.IsRequired = true; + command.AddOption(roleAssignmentIdOption); + command.SetHandler(async (string roleDefinitionId, string roleAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, roleDefinitionIdOption, roleAssignmentIdOption); + return command; + } + /// + /// Role definition this assignment is part of. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Role definition this assignment is part of."; + // Create options for all the parameters + var roleDefinitionIdOption = new Option("--role-definition-id", description: "key: id of roleDefinition") { + }; + roleDefinitionIdOption.IsRequired = true; + command.AddOption(roleDefinitionIdOption); + var roleAssignmentIdOption = new Option("--role-assignment-id", description: "key: id of roleAssignment") { + }; + roleAssignmentIdOption.IsRequired = true; + command.AddOption(roleAssignmentIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string roleDefinitionId, string roleAssignmentId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, roleDefinitionIdOption, roleAssignmentIdOption, outputOption); + return command; + } + /// + /// Role definition this assignment is part of. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Role definition this assignment is part of."; + // Create options for all the parameters + var roleDefinitionIdOption = new Option("--role-definition-id", description: "key: id of roleDefinition") { + }; + roleDefinitionIdOption.IsRequired = true; + command.AddOption(roleDefinitionIdOption); + var roleAssignmentIdOption = new Option("--role-assignment-id", description: "key: id of roleAssignment") { + }; + roleAssignmentIdOption.IsRequired = true; + command.AddOption(roleAssignmentIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string roleDefinitionId, string roleAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, roleDefinitionIdOption, roleAssignmentIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/deviceManagement/roleDefinitions/{roleDefinition_id}/roleAssignments/{roleAssignment_id}/roleDefinition/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Role definition this assignment is part of. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Role definition this assignment is part of. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Role definition this assignment is part of. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.DeviceManagement.RoleDefinitions.Item.RoleAssignments.Item.RoleDefinition.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/DeviceManagement/RoleDefinitions/Item/RoleAssignments/Item/RoleDefinition/RoleDefinitionRequestBuilder.cs b/src/generated/DeviceManagement/RoleDefinitions/Item/RoleAssignments/Item/RoleDefinition/RoleDefinitionRequestBuilder.cs index e6f7a7b2aae..60ad8fe549f 100644 --- a/src/generated/DeviceManagement/RoleDefinitions/Item/RoleAssignments/Item/RoleDefinition/RoleDefinitionRequestBuilder.cs +++ b/src/generated/DeviceManagement/RoleDefinitions/Item/RoleAssignments/Item/RoleDefinition/RoleDefinitionRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,11 +27,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Role definition this assignment is part of."; // Create options for all the parameters - var roleDefinitionIdOption = new Option("--roledefinition-id", description: "key: id of roleDefinition") { + var roleDefinitionIdOption = new Option("--role-definition-id", description: "key: id of roleDefinition") { }; roleDefinitionIdOption.IsRequired = true; command.AddOption(roleDefinitionIdOption); - var roleAssignmentIdOption = new Option("--roleassignment-id", description: "key: id of roleAssignment") { + var roleAssignmentIdOption = new Option("--role-assignment-id", description: "key: id of roleAssignment") { }; roleAssignmentIdOption.IsRequired = true; command.AddOption(roleAssignmentIdOption); @@ -45,25 +45,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string roleDefinitionId, string roleAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string roleDefinitionId, string roleAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, roleDefinitionIdOption, roleAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, roleDefinitionIdOption, roleAssignmentIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.DeviceManagement.RoleDefinitions.Item.RoleAssignments.Item.RoleDefinition.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.DeviceManagement.RoleDefinitions.Item.RoleAssignments.Item.RoleDefinition.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -103,18 +102,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Role definition this assignment is part of. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Role definition this assignment is part of. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/RoleDefinitions/Item/RoleAssignments/RoleAssignmentsRequestBuilder.cs b/src/generated/DeviceManagement/RoleDefinitions/Item/RoleAssignments/RoleAssignmentsRequestBuilder.cs index 4439551fcdc..0e5bfe61719 100644 --- a/src/generated/DeviceManagement/RoleDefinitions/Item/RoleAssignments/RoleAssignmentsRequestBuilder.cs +++ b/src/generated/DeviceManagement/RoleDefinitions/Item/RoleAssignments/RoleAssignmentsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class RoleAssignmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new RoleAssignmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildRoleDefinitionCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRoleDefinitionCommand()); return commands; } /// @@ -37,7 +36,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "List of Role assignments for this role definition."; // Create options for all the parameters - var roleDefinitionIdOption = new Option("--roledefinition-id", description: "key: id of roleDefinition") { + var roleDefinitionIdOption = new Option("--role-definition-id", description: "key: id of roleDefinition") { }; roleDefinitionIdOption.IsRequired = true; command.AddOption(roleDefinitionIdOption); @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string roleDefinitionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string roleDefinitionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, roleDefinitionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, roleDefinitionIdOption, bodyOption, outputOption); return command; } /// @@ -69,7 +67,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "List of Role assignments for this role definition."; // Create options for all the parameters - var roleDefinitionIdOption = new Option("--roledefinition-id", description: "key: id of roleDefinition") { + var roleDefinitionIdOption = new Option("--role-definition-id", description: "key: id of roleDefinition") { }; roleDefinitionIdOption.IsRequired = true; command.AddOption(roleDefinitionIdOption); @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string roleDefinitionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string roleDefinitionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, roleDefinitionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, roleDefinitionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(RoleAssignment body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of Role assignments for this role definition. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of Role assignments for this role definition. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RoleAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// List of Role assignments for this role definition. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/RoleDefinitions/Item/RoleDefinitionRequestBuilder.cs b/src/generated/DeviceManagement/RoleDefinitions/Item/RoleDefinitionRequestBuilder.cs index ec20bce5daf..822ba65dc9f 100644 --- a/src/generated/DeviceManagement/RoleDefinitions/Item/RoleDefinitionRequestBuilder.cs +++ b/src/generated/DeviceManagement/RoleDefinitions/Item/RoleDefinitionRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,15 +27,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The Role Definitions."; // Create options for all the parameters - var roleDefinitionIdOption = new Option("--roledefinition-id", description: "key: id of roleDefinition") { + var roleDefinitionIdOption = new Option("--role-definition-id", description: "key: id of roleDefinition") { }; roleDefinitionIdOption.IsRequired = true; command.AddOption(roleDefinitionIdOption); - command.SetHandler(async (string roleDefinitionId) => { + command.SetHandler(async (string roleDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, roleDefinitionIdOption); return command; @@ -47,7 +46,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The Role Definitions."; // Create options for all the parameters - var roleDefinitionIdOption = new Option("--roledefinition-id", description: "key: id of roleDefinition") { + var roleDefinitionIdOption = new Option("--role-definition-id", description: "key: id of roleDefinition") { }; roleDefinitionIdOption.IsRequired = true; command.AddOption(roleDefinitionIdOption); @@ -61,20 +60,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string roleDefinitionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string roleDefinitionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, roleDefinitionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, roleDefinitionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The Role Definitions."; // Create options for all the parameters - var roleDefinitionIdOption = new Option("--roledefinition-id", description: "key: id of roleDefinition") { + var roleDefinitionIdOption = new Option("--role-definition-id", description: "key: id of roleDefinition") { }; roleDefinitionIdOption.IsRequired = true; command.AddOption(roleDefinitionIdOption); @@ -92,14 +90,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string roleDefinitionId, string body) => { + command.SetHandler(async (string roleDefinitionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, roleDefinitionIdOption, bodyOption); return command; @@ -107,6 +104,9 @@ public Command BuildPatchCommand() { public Command BuildRoleAssignmentsCommand() { var command = new Command("role-assignments"); var builder = new ApiSdk.DeviceManagement.RoleDefinitions.Item.RoleAssignments.RoleAssignmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -178,42 +178,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The Role Definitions. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Role Definitions. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Role Definitions. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.RoleDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The Role Definitions. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/RoleDefinitions/RoleDefinitionsRequestBuilder.cs b/src/generated/DeviceManagement/RoleDefinitions/RoleDefinitionsRequestBuilder.cs index 6066d91aa6d..03e3cbfa283 100644 --- a/src/generated/DeviceManagement/RoleDefinitions/RoleDefinitionsRequestBuilder.cs +++ b/src/generated/DeviceManagement/RoleDefinitions/RoleDefinitionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class RoleDefinitionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new RoleDefinitionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildRoleAssignmentsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRoleAssignmentsCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The Role Definitions. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Role Definitions. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.RoleDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The Role Definitions. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/SoftwareUpdateStatusSummary/@Ref/@Ref.cs b/src/generated/DeviceManagement/SoftwareUpdateStatusSummary/@Ref/@Ref.cs deleted file mode 100644 index 49be30a686d..00000000000 --- a/src/generated/DeviceManagement/SoftwareUpdateStatusSummary/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.DeviceManagement.SoftwareUpdateStatusSummary.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/DeviceManagement/SoftwareUpdateStatusSummary/@Ref/RefRequestBuilder.cs b/src/generated/DeviceManagement/SoftwareUpdateStatusSummary/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 35d29cdb10d..00000000000 --- a/src/generated/DeviceManagement/SoftwareUpdateStatusSummary/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,178 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.DeviceManagement.SoftwareUpdateStatusSummary.@Ref { - /// Builds and executes requests for operations under \deviceManagement\softwareUpdateStatusSummary\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The software update status summary. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The software update status summary."; - // Create options for all the parameters - command.SetHandler(async () => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }); - return command; - } - /// - /// The software update status summary. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The software update status summary."; - // Create options for all the parameters - command.SetHandler(async () => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); - return command; - } - /// - /// The software update status summary. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The software update status summary."; - // Create options for all the parameters - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/deviceManagement/softwareUpdateStatusSummary/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The software update status summary. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The software update status summary. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The software update status summary. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.DeviceManagement.SoftwareUpdateStatusSummary.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The software update status summary. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The software update status summary. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The software update status summary. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.DeviceManagement.SoftwareUpdateStatusSummary.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/DeviceManagement/SoftwareUpdateStatusSummary/Ref/Ref.cs b/src/generated/DeviceManagement/SoftwareUpdateStatusSummary/Ref/Ref.cs new file mode 100644 index 00000000000..94e4ffb9159 --- /dev/null +++ b/src/generated/DeviceManagement/SoftwareUpdateStatusSummary/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.DeviceManagement.SoftwareUpdateStatusSummary.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/DeviceManagement/SoftwareUpdateStatusSummary/Ref/RefRequestBuilder.cs b/src/generated/DeviceManagement/SoftwareUpdateStatusSummary/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..1881a27a844 --- /dev/null +++ b/src/generated/DeviceManagement/SoftwareUpdateStatusSummary/Ref/RefRequestBuilder.cs @@ -0,0 +1,140 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.DeviceManagement.SoftwareUpdateStatusSummary.Ref { + /// Builds and executes requests for operations under \deviceManagement\softwareUpdateStatusSummary\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The software update status summary. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The software update status summary."; + // Create options for all the parameters + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }); + return command; + } + /// + /// The software update status summary. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The software update status summary."; + // Create options for all the parameters + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); + return command; + } + /// + /// The software update status summary. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The software update status summary."; + // Create options for all the parameters + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/deviceManagement/softwareUpdateStatusSummary/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The software update status summary. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The software update status summary. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The software update status summary. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.DeviceManagement.SoftwareUpdateStatusSummary.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/DeviceManagement/SoftwareUpdateStatusSummary/SoftwareUpdateStatusSummaryRequestBuilder.cs b/src/generated/DeviceManagement/SoftwareUpdateStatusSummary/SoftwareUpdateStatusSummaryRequestBuilder.cs index a520bf30938..ff401445109 100644 --- a/src/generated/DeviceManagement/SoftwareUpdateStatusSummary/SoftwareUpdateStatusSummaryRequestBuilder.cs +++ b/src/generated/DeviceManagement/SoftwareUpdateStatusSummary/SoftwareUpdateStatusSummaryRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,25 +37,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.DeviceManagement.SoftwareUpdateStatusSummary.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.DeviceManagement.SoftwareUpdateStatusSummary.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -95,18 +94,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The software update status summary. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The software update status summary. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/TelecomExpenseManagementPartners/Item/TelecomExpenseManagementPartnerRequestBuilder.cs b/src/generated/DeviceManagement/TelecomExpenseManagementPartners/Item/TelecomExpenseManagementPartnerRequestBuilder.cs index da07e69f45d..71d2fbd316d 100644 --- a/src/generated/DeviceManagement/TelecomExpenseManagementPartners/Item/TelecomExpenseManagementPartnerRequestBuilder.cs +++ b/src/generated/DeviceManagement/TelecomExpenseManagementPartners/Item/TelecomExpenseManagementPartnerRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The telecom expense management partners."; // Create options for all the parameters - var telecomExpenseManagementPartnerIdOption = new Option("--telecomexpensemanagementpartner-id", description: "key: id of telecomExpenseManagementPartner") { + var telecomExpenseManagementPartnerIdOption = new Option("--telecom-expense-management-partner-id", description: "key: id of telecomExpenseManagementPartner") { }; telecomExpenseManagementPartnerIdOption.IsRequired = true; command.AddOption(telecomExpenseManagementPartnerIdOption); - command.SetHandler(async (string telecomExpenseManagementPartnerId) => { + command.SetHandler(async (string telecomExpenseManagementPartnerId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, telecomExpenseManagementPartnerIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The telecom expense management partners."; // Create options for all the parameters - var telecomExpenseManagementPartnerIdOption = new Option("--telecomexpensemanagementpartner-id", description: "key: id of telecomExpenseManagementPartner") { + var telecomExpenseManagementPartnerIdOption = new Option("--telecom-expense-management-partner-id", description: "key: id of telecomExpenseManagementPartner") { }; telecomExpenseManagementPartnerIdOption.IsRequired = true; command.AddOption(telecomExpenseManagementPartnerIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string telecomExpenseManagementPartnerId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string telecomExpenseManagementPartnerId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, telecomExpenseManagementPartnerIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, telecomExpenseManagementPartnerIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The telecom expense management partners."; // Create options for all the parameters - var telecomExpenseManagementPartnerIdOption = new Option("--telecomexpensemanagementpartner-id", description: "key: id of telecomExpenseManagementPartner") { + var telecomExpenseManagementPartnerIdOption = new Option("--telecom-expense-management-partner-id", description: "key: id of telecomExpenseManagementPartner") { }; telecomExpenseManagementPartnerIdOption.IsRequired = true; command.AddOption(telecomExpenseManagementPartnerIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string telecomExpenseManagementPartnerId, string body) => { + command.SetHandler(async (string telecomExpenseManagementPartnerId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, telecomExpenseManagementPartnerIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(TelecomExpenseManagement requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The telecom expense management partners. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The telecom expense management partners. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The telecom expense management partners. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(TelecomExpenseManagementPartner model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The telecom expense management partners. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/TelecomExpenseManagementPartners/TelecomExpenseManagementPartnersRequestBuilder.cs b/src/generated/DeviceManagement/TelecomExpenseManagementPartners/TelecomExpenseManagementPartnersRequestBuilder.cs index 48d316b72ec..8a0a81450d1 100644 --- a/src/generated/DeviceManagement/TelecomExpenseManagementPartners/TelecomExpenseManagementPartnersRequestBuilder.cs +++ b/src/generated/DeviceManagement/TelecomExpenseManagementPartners/TelecomExpenseManagementPartnersRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class TelecomExpenseManagementPartnersRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TelecomExpenseManagementPartnerRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(TelecomExpenseManagementP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The telecom expense management partners. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The telecom expense management partners. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TelecomExpenseManagementPartner model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The telecom expense management partners. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/TermsAndConditions/Item/AcceptanceStatuses/AcceptanceStatusesRequestBuilder.cs b/src/generated/DeviceManagement/TermsAndConditions/Item/AcceptanceStatuses/AcceptanceStatusesRequestBuilder.cs index 9d68a39b321..c582e9ac51f 100644 --- a/src/generated/DeviceManagement/TermsAndConditions/Item/AcceptanceStatuses/AcceptanceStatusesRequestBuilder.cs +++ b/src/generated/DeviceManagement/TermsAndConditions/Item/AcceptanceStatuses/AcceptanceStatusesRequestBuilder.cs @@ -2,17 +2,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.DeviceManagement.TermsAndConditions.Item.AcceptanceStatuses { - /// Builds and executes requests for operations under \deviceManagement\termsAndConditions\{termsAndConditions-id}\acceptanceStatuses + /// Builds and executes requests for operations under \deviceManagement\termsAndConditions\{termsAndConditionsItem-id}\acceptanceStatuses public class AcceptanceStatusesRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -22,12 +22,11 @@ public class AcceptanceStatusesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TermsAndConditionsAcceptanceStatusRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildTermsAndConditionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildTermsAndConditionsCommand()); return commands; } /// @@ -37,29 +36,28 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The list of acceptance statuses for this T&C policy."; // Create options for all the parameters - var termsAndConditionsIdOption = new Option("--termsandconditions-id", description: "key: id of termsAndConditions") { + var termsAndConditionsItemIdOption = new Option("--terms-and-conditions-item-id", description: "key: id of termsAndConditions") { }; - termsAndConditionsIdOption.IsRequired = true; - command.AddOption(termsAndConditionsIdOption); + termsAndConditionsItemIdOption.IsRequired = true; + command.AddOption(termsAndConditionsItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string termsAndConditionsId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string termsAndConditionsItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, termsAndConditionsIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, termsAndConditionsItemIdOption, bodyOption, outputOption); return command; } /// @@ -69,10 +67,10 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The list of acceptance statuses for this T&C policy."; // Create options for all the parameters - var termsAndConditionsIdOption = new Option("--termsandconditions-id", description: "key: id of termsAndConditions") { + var termsAndConditionsItemIdOption = new Option("--terms-and-conditions-item-id", description: "key: id of termsAndConditions") { }; - termsAndConditionsIdOption.IsRequired = true; - command.AddOption(termsAndConditionsIdOption); + termsAndConditionsItemIdOption.IsRequired = true; + command.AddOption(termsAndConditionsItemIdOption); var topOption = new Option("--top", description: "Show only the first n items") { }; topOption.IsRequired = false; @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string termsAndConditionsId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string termsAndConditionsItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, termsAndConditionsIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, termsAndConditionsItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -138,7 +135,7 @@ public Command BuildListCommand() { public AcceptanceStatusesRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/deviceManagement/termsAndConditions/{termsAndConditions_id}/acceptanceStatuses{?top,skip,search,filter,count,orderby,select,expand}"; + UrlTemplate = "{+baseurl}/deviceManagement/termsAndConditions/{termsAndConditionsItem_id}/acceptanceStatuses{?top,skip,search,filter,count,orderby,select,expand}"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(TermsAndConditionsAccepta requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of acceptance statuses for this T&C policy. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of acceptance statuses for this T&C policy. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TermsAndConditionsAcceptanceStatus model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of acceptance statuses for this T&C policy. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/TermsAndConditions/Item/AcceptanceStatuses/Item/TermsAndConditions/@Ref/@Ref.cs b/src/generated/DeviceManagement/TermsAndConditions/Item/AcceptanceStatuses/Item/TermsAndConditions/@Ref/@Ref.cs deleted file mode 100644 index 5f13f60b918..00000000000 --- a/src/generated/DeviceManagement/TermsAndConditions/Item/AcceptanceStatuses/Item/TermsAndConditions/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.DeviceManagement.TermsAndConditions.Item.AcceptanceStatuses.Item.TermsAndConditions.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/DeviceManagement/TermsAndConditions/Item/AcceptanceStatuses/Item/TermsAndConditions/@Ref/RefRequestBuilder.cs b/src/generated/DeviceManagement/TermsAndConditions/Item/AcceptanceStatuses/Item/TermsAndConditions/@Ref/RefRequestBuilder.cs deleted file mode 100644 index ab46a2d9ae1..00000000000 --- a/src/generated/DeviceManagement/TermsAndConditions/Item/AcceptanceStatuses/Item/TermsAndConditions/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.DeviceManagement.TermsAndConditions.Item.AcceptanceStatuses.Item.TermsAndConditions.@Ref { - /// Builds and executes requests for operations under \deviceManagement\termsAndConditions\{termsAndConditions-id}\acceptanceStatuses\{termsAndConditionsAcceptanceStatus-id}\termsAndConditions\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Navigation link to the terms and conditions that are assigned. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Navigation link to the terms and conditions that are assigned."; - // Create options for all the parameters - var termsAndConditionsIdOption = new Option("--termsandconditions-id", description: "key: id of termsAndConditions") { - }; - termsAndConditionsIdOption.IsRequired = true; - command.AddOption(termsAndConditionsIdOption); - var termsAndConditionsAcceptanceStatusIdOption = new Option("--termsandconditionsacceptancestatus-id", description: "key: id of termsAndConditionsAcceptanceStatus") { - }; - termsAndConditionsAcceptanceStatusIdOption.IsRequired = true; - command.AddOption(termsAndConditionsAcceptanceStatusIdOption); - command.SetHandler(async (string termsAndConditionsId, string termsAndConditionsAcceptanceStatusId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, termsAndConditionsIdOption, termsAndConditionsAcceptanceStatusIdOption); - return command; - } - /// - /// Navigation link to the terms and conditions that are assigned. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Navigation link to the terms and conditions that are assigned."; - // Create options for all the parameters - var termsAndConditionsIdOption = new Option("--termsandconditions-id", description: "key: id of termsAndConditions") { - }; - termsAndConditionsIdOption.IsRequired = true; - command.AddOption(termsAndConditionsIdOption); - var termsAndConditionsAcceptanceStatusIdOption = new Option("--termsandconditionsacceptancestatus-id", description: "key: id of termsAndConditionsAcceptanceStatus") { - }; - termsAndConditionsAcceptanceStatusIdOption.IsRequired = true; - command.AddOption(termsAndConditionsAcceptanceStatusIdOption); - command.SetHandler(async (string termsAndConditionsId, string termsAndConditionsAcceptanceStatusId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, termsAndConditionsIdOption, termsAndConditionsAcceptanceStatusIdOption); - return command; - } - /// - /// Navigation link to the terms and conditions that are assigned. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Navigation link to the terms and conditions that are assigned."; - // Create options for all the parameters - var termsAndConditionsIdOption = new Option("--termsandconditions-id", description: "key: id of termsAndConditions") { - }; - termsAndConditionsIdOption.IsRequired = true; - command.AddOption(termsAndConditionsIdOption); - var termsAndConditionsAcceptanceStatusIdOption = new Option("--termsandconditionsacceptancestatus-id", description: "key: id of termsAndConditionsAcceptanceStatus") { - }; - termsAndConditionsAcceptanceStatusIdOption.IsRequired = true; - command.AddOption(termsAndConditionsAcceptanceStatusIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string termsAndConditionsId, string termsAndConditionsAcceptanceStatusId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, termsAndConditionsIdOption, termsAndConditionsAcceptanceStatusIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/deviceManagement/termsAndConditions/{termsAndConditions_id}/acceptanceStatuses/{termsAndConditionsAcceptanceStatus_id}/termsAndConditions/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Navigation link to the terms and conditions that are assigned. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Navigation link to the terms and conditions that are assigned. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Navigation link to the terms and conditions that are assigned. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.DeviceManagement.TermsAndConditions.Item.AcceptanceStatuses.Item.TermsAndConditions.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Navigation link to the terms and conditions that are assigned. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Navigation link to the terms and conditions that are assigned. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Navigation link to the terms and conditions that are assigned. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.DeviceManagement.TermsAndConditions.Item.AcceptanceStatuses.Item.TermsAndConditions.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/DeviceManagement/TermsAndConditions/Item/AcceptanceStatuses/Item/TermsAndConditions/Ref/Ref.cs b/src/generated/DeviceManagement/TermsAndConditions/Item/AcceptanceStatuses/Item/TermsAndConditions/Ref/Ref.cs new file mode 100644 index 00000000000..d69a3bbba5c --- /dev/null +++ b/src/generated/DeviceManagement/TermsAndConditions/Item/AcceptanceStatuses/Item/TermsAndConditions/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.DeviceManagement.TermsAndConditions.Item.AcceptanceStatuses.Item.TermsAndConditions.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/DeviceManagement/TermsAndConditions/Item/AcceptanceStatuses/Item/TermsAndConditions/Ref/RefRequestBuilder.cs b/src/generated/DeviceManagement/TermsAndConditions/Item/AcceptanceStatuses/Item/TermsAndConditions/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..6fe593a7f42 --- /dev/null +++ b/src/generated/DeviceManagement/TermsAndConditions/Item/AcceptanceStatuses/Item/TermsAndConditions/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.DeviceManagement.TermsAndConditions.Item.AcceptanceStatuses.Item.TermsAndConditions.Ref { + /// Builds and executes requests for operations under \deviceManagement\termsAndConditions\{termsAndConditionsItem-id}\acceptanceStatuses\{termsAndConditionsAcceptanceStatus-id}\termsAndConditions\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Navigation link to the terms and conditions that are assigned. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Navigation link to the terms and conditions that are assigned."; + // Create options for all the parameters + var termsAndConditionsItemIdOption = new Option("--terms-and-conditions-item-id", description: "key: id of termsAndConditions") { + }; + termsAndConditionsItemIdOption.IsRequired = true; + command.AddOption(termsAndConditionsItemIdOption); + var termsAndConditionsAcceptanceStatusIdOption = new Option("--terms-and-conditions-acceptance-status-id", description: "key: id of termsAndConditionsAcceptanceStatus") { + }; + termsAndConditionsAcceptanceStatusIdOption.IsRequired = true; + command.AddOption(termsAndConditionsAcceptanceStatusIdOption); + command.SetHandler(async (string termsAndConditionsItemId, string termsAndConditionsAcceptanceStatusId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, termsAndConditionsItemIdOption, termsAndConditionsAcceptanceStatusIdOption); + return command; + } + /// + /// Navigation link to the terms and conditions that are assigned. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Navigation link to the terms and conditions that are assigned."; + // Create options for all the parameters + var termsAndConditionsItemIdOption = new Option("--terms-and-conditions-item-id", description: "key: id of termsAndConditions") { + }; + termsAndConditionsItemIdOption.IsRequired = true; + command.AddOption(termsAndConditionsItemIdOption); + var termsAndConditionsAcceptanceStatusIdOption = new Option("--terms-and-conditions-acceptance-status-id", description: "key: id of termsAndConditionsAcceptanceStatus") { + }; + termsAndConditionsAcceptanceStatusIdOption.IsRequired = true; + command.AddOption(termsAndConditionsAcceptanceStatusIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string termsAndConditionsItemId, string termsAndConditionsAcceptanceStatusId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, termsAndConditionsItemIdOption, termsAndConditionsAcceptanceStatusIdOption, outputOption); + return command; + } + /// + /// Navigation link to the terms and conditions that are assigned. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Navigation link to the terms and conditions that are assigned."; + // Create options for all the parameters + var termsAndConditionsItemIdOption = new Option("--terms-and-conditions-item-id", description: "key: id of termsAndConditions") { + }; + termsAndConditionsItemIdOption.IsRequired = true; + command.AddOption(termsAndConditionsItemIdOption); + var termsAndConditionsAcceptanceStatusIdOption = new Option("--terms-and-conditions-acceptance-status-id", description: "key: id of termsAndConditionsAcceptanceStatus") { + }; + termsAndConditionsAcceptanceStatusIdOption.IsRequired = true; + command.AddOption(termsAndConditionsAcceptanceStatusIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string termsAndConditionsItemId, string termsAndConditionsAcceptanceStatusId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, termsAndConditionsItemIdOption, termsAndConditionsAcceptanceStatusIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/deviceManagement/termsAndConditions/{termsAndConditionsItem_id}/acceptanceStatuses/{termsAndConditionsAcceptanceStatus_id}/termsAndConditions/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Navigation link to the terms and conditions that are assigned. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Navigation link to the terms and conditions that are assigned. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Navigation link to the terms and conditions that are assigned. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.DeviceManagement.TermsAndConditions.Item.AcceptanceStatuses.Item.TermsAndConditions.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/DeviceManagement/TermsAndConditions/Item/AcceptanceStatuses/Item/TermsAndConditions/TermsAndConditionsRequestBuilder.cs b/src/generated/DeviceManagement/TermsAndConditions/Item/AcceptanceStatuses/Item/TermsAndConditions/TermsAndConditionsRequestBuilder.cs index cf4e1d5f95f..76b3fc88919 100644 --- a/src/generated/DeviceManagement/TermsAndConditions/Item/AcceptanceStatuses/Item/TermsAndConditions/TermsAndConditionsRequestBuilder.cs +++ b/src/generated/DeviceManagement/TermsAndConditions/Item/AcceptanceStatuses/Item/TermsAndConditions/TermsAndConditionsRequestBuilder.cs @@ -2,17 +2,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.DeviceManagement.TermsAndConditions.Item.AcceptanceStatuses.Item.TermsAndConditions { - /// Builds and executes requests for operations under \deviceManagement\termsAndConditions\{termsAndConditions-id}\acceptanceStatuses\{termsAndConditionsAcceptanceStatus-id}\termsAndConditions + /// Builds and executes requests for operations under \deviceManagement\termsAndConditions\{termsAndConditionsItem-id}\acceptanceStatuses\{termsAndConditionsAcceptanceStatus-id}\termsAndConditions public class TermsAndConditionsRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -27,11 +27,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Navigation link to the terms and conditions that are assigned."; // Create options for all the parameters - var termsAndConditionsIdOption = new Option("--termsandconditions-id", description: "key: id of termsAndConditions") { + var termsAndConditionsItemIdOption = new Option("--terms-and-conditions-item-id", description: "key: id of termsAndConditions") { }; - termsAndConditionsIdOption.IsRequired = true; - command.AddOption(termsAndConditionsIdOption); - var termsAndConditionsAcceptanceStatusIdOption = new Option("--termsandconditionsacceptancestatus-id", description: "key: id of termsAndConditionsAcceptanceStatus") { + termsAndConditionsItemIdOption.IsRequired = true; + command.AddOption(termsAndConditionsItemIdOption); + var termsAndConditionsAcceptanceStatusIdOption = new Option("--terms-and-conditions-acceptance-status-id", description: "key: id of termsAndConditionsAcceptanceStatus") { }; termsAndConditionsAcceptanceStatusIdOption.IsRequired = true; command.AddOption(termsAndConditionsAcceptanceStatusIdOption); @@ -45,25 +45,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string termsAndConditionsId, string termsAndConditionsAcceptanceStatusId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string termsAndConditionsItemId, string termsAndConditionsAcceptanceStatusId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, termsAndConditionsIdOption, termsAndConditionsAcceptanceStatusIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, termsAndConditionsItemIdOption, termsAndConditionsAcceptanceStatusIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.DeviceManagement.TermsAndConditions.Item.AcceptanceStatuses.Item.TermsAndConditions.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.DeviceManagement.TermsAndConditions.Item.AcceptanceStatuses.Item.TermsAndConditions.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -77,7 +76,7 @@ public Command BuildRefCommand() { public TermsAndConditionsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/deviceManagement/termsAndConditions/{termsAndConditions_id}/acceptanceStatuses/{termsAndConditionsAcceptanceStatus_id}/termsAndConditions{?select,expand}"; + UrlTemplate = "{+baseurl}/deviceManagement/termsAndConditions/{termsAndConditionsItem_id}/acceptanceStatuses/{termsAndConditionsAcceptanceStatus_id}/termsAndConditions{?select,expand}"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -103,18 +102,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Navigation link to the terms and conditions that are assigned. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Navigation link to the terms and conditions that are assigned. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/TermsAndConditions/Item/AcceptanceStatuses/Item/TermsAndConditionsAcceptanceStatusRequestBuilder.cs b/src/generated/DeviceManagement/TermsAndConditions/Item/AcceptanceStatuses/Item/TermsAndConditionsAcceptanceStatusRequestBuilder.cs index 365104eeefe..db26fb5b4fe 100644 --- a/src/generated/DeviceManagement/TermsAndConditions/Item/AcceptanceStatuses/Item/TermsAndConditionsAcceptanceStatusRequestBuilder.cs +++ b/src/generated/DeviceManagement/TermsAndConditions/Item/AcceptanceStatuses/Item/TermsAndConditionsAcceptanceStatusRequestBuilder.cs @@ -2,17 +2,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.DeviceManagement.TermsAndConditions.Item.AcceptanceStatuses.Item { - /// Builds and executes requests for operations under \deviceManagement\termsAndConditions\{termsAndConditions-id}\acceptanceStatuses\{termsAndConditionsAcceptanceStatus-id} + /// Builds and executes requests for operations under \deviceManagement\termsAndConditions\{termsAndConditionsItem-id}\acceptanceStatuses\{termsAndConditionsAcceptanceStatus-id} public class TermsAndConditionsAcceptanceStatusRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -27,21 +27,20 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of acceptance statuses for this T&C policy."; // Create options for all the parameters - var termsAndConditionsIdOption = new Option("--termsandconditions-id", description: "key: id of termsAndConditions") { + var termsAndConditionsItemIdOption = new Option("--terms-and-conditions-item-id", description: "key: id of termsAndConditions") { }; - termsAndConditionsIdOption.IsRequired = true; - command.AddOption(termsAndConditionsIdOption); - var termsAndConditionsAcceptanceStatusIdOption = new Option("--termsandconditionsacceptancestatus-id", description: "key: id of termsAndConditionsAcceptanceStatus") { + termsAndConditionsItemIdOption.IsRequired = true; + command.AddOption(termsAndConditionsItemIdOption); + var termsAndConditionsAcceptanceStatusIdOption = new Option("--terms-and-conditions-acceptance-status-id", description: "key: id of termsAndConditionsAcceptanceStatus") { }; termsAndConditionsAcceptanceStatusIdOption.IsRequired = true; command.AddOption(termsAndConditionsAcceptanceStatusIdOption); - command.SetHandler(async (string termsAndConditionsId, string termsAndConditionsAcceptanceStatusId) => { + command.SetHandler(async (string termsAndConditionsItemId, string termsAndConditionsAcceptanceStatusId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, termsAndConditionsIdOption, termsAndConditionsAcceptanceStatusIdOption); + }, termsAndConditionsItemIdOption, termsAndConditionsAcceptanceStatusIdOption); return command; } /// @@ -51,11 +50,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of acceptance statuses for this T&C policy."; // Create options for all the parameters - var termsAndConditionsIdOption = new Option("--termsandconditions-id", description: "key: id of termsAndConditions") { + var termsAndConditionsItemIdOption = new Option("--terms-and-conditions-item-id", description: "key: id of termsAndConditions") { }; - termsAndConditionsIdOption.IsRequired = true; - command.AddOption(termsAndConditionsIdOption); - var termsAndConditionsAcceptanceStatusIdOption = new Option("--termsandconditionsacceptancestatus-id", description: "key: id of termsAndConditionsAcceptanceStatus") { + termsAndConditionsItemIdOption.IsRequired = true; + command.AddOption(termsAndConditionsItemIdOption); + var termsAndConditionsAcceptanceStatusIdOption = new Option("--terms-and-conditions-acceptance-status-id", description: "key: id of termsAndConditionsAcceptanceStatus") { }; termsAndConditionsAcceptanceStatusIdOption.IsRequired = true; command.AddOption(termsAndConditionsAcceptanceStatusIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string termsAndConditionsId, string termsAndConditionsAcceptanceStatusId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string termsAndConditionsItemId, string termsAndConditionsAcceptanceStatusId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, termsAndConditionsIdOption, termsAndConditionsAcceptanceStatusIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, termsAndConditionsItemIdOption, termsAndConditionsAcceptanceStatusIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -92,11 +90,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of acceptance statuses for this T&C policy."; // Create options for all the parameters - var termsAndConditionsIdOption = new Option("--termsandconditions-id", description: "key: id of termsAndConditions") { + var termsAndConditionsItemIdOption = new Option("--terms-and-conditions-item-id", description: "key: id of termsAndConditions") { }; - termsAndConditionsIdOption.IsRequired = true; - command.AddOption(termsAndConditionsIdOption); - var termsAndConditionsAcceptanceStatusIdOption = new Option("--termsandconditionsacceptancestatus-id", description: "key: id of termsAndConditionsAcceptanceStatus") { + termsAndConditionsItemIdOption.IsRequired = true; + command.AddOption(termsAndConditionsItemIdOption); + var termsAndConditionsAcceptanceStatusIdOption = new Option("--terms-and-conditions-acceptance-status-id", description: "key: id of termsAndConditionsAcceptanceStatus") { }; termsAndConditionsAcceptanceStatusIdOption.IsRequired = true; command.AddOption(termsAndConditionsAcceptanceStatusIdOption); @@ -104,16 +102,15 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string termsAndConditionsId, string termsAndConditionsAcceptanceStatusId, string body) => { + command.SetHandler(async (string termsAndConditionsItemId, string termsAndConditionsAcceptanceStatusId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, termsAndConditionsIdOption, termsAndConditionsAcceptanceStatusIdOption, bodyOption); + }, termsAndConditionsItemIdOption, termsAndConditionsAcceptanceStatusIdOption, bodyOption); return command; } public Command BuildTermsAndConditionsCommand() { @@ -131,7 +128,7 @@ public Command BuildTermsAndConditionsCommand() { public TermsAndConditionsAcceptanceStatusRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/deviceManagement/termsAndConditions/{termsAndConditions_id}/acceptanceStatuses/{termsAndConditionsAcceptanceStatus_id}{?select,expand}"; + UrlTemplate = "{+baseurl}/deviceManagement/termsAndConditions/{termsAndConditionsItem_id}/acceptanceStatuses/{termsAndConditionsAcceptanceStatus_id}{?select,expand}"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -190,42 +187,6 @@ public RequestInformation CreatePatchRequestInformation(TermsAndConditionsAccept requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of acceptance statuses for this T&C policy. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of acceptance statuses for this T&C policy. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of acceptance statuses for this T&C policy. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(TermsAndConditionsAcceptanceStatus model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of acceptance statuses for this T&C policy. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/TermsAndConditions/Item/Assignments/AssignmentsRequestBuilder.cs b/src/generated/DeviceManagement/TermsAndConditions/Item/Assignments/AssignmentsRequestBuilder.cs index a04466358b1..250bd01066e 100644 --- a/src/generated/DeviceManagement/TermsAndConditions/Item/Assignments/AssignmentsRequestBuilder.cs +++ b/src/generated/DeviceManagement/TermsAndConditions/Item/Assignments/AssignmentsRequestBuilder.cs @@ -2,17 +2,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.DeviceManagement.TermsAndConditions.Item.Assignments { - /// Builds and executes requests for operations under \deviceManagement\termsAndConditions\{termsAndConditions-id}\assignments + /// Builds and executes requests for operations under \deviceManagement\termsAndConditions\{termsAndConditionsItem-id}\assignments public class AssignmentsRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -22,11 +22,10 @@ public class AssignmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TermsAndConditionsAssignmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,29 +35,28 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The list of assignments for this T&C policy."; // Create options for all the parameters - var termsAndConditionsIdOption = new Option("--termsandconditions-id", description: "key: id of termsAndConditions") { + var termsAndConditionsItemIdOption = new Option("--terms-and-conditions-item-id", description: "key: id of termsAndConditions") { }; - termsAndConditionsIdOption.IsRequired = true; - command.AddOption(termsAndConditionsIdOption); + termsAndConditionsItemIdOption.IsRequired = true; + command.AddOption(termsAndConditionsItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string termsAndConditionsId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string termsAndConditionsItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, termsAndConditionsIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, termsAndConditionsItemIdOption, bodyOption, outputOption); return command; } /// @@ -68,10 +66,10 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The list of assignments for this T&C policy."; // Create options for all the parameters - var termsAndConditionsIdOption = new Option("--termsandconditions-id", description: "key: id of termsAndConditions") { + var termsAndConditionsItemIdOption = new Option("--terms-and-conditions-item-id", description: "key: id of termsAndConditions") { }; - termsAndConditionsIdOption.IsRequired = true; - command.AddOption(termsAndConditionsIdOption); + termsAndConditionsItemIdOption.IsRequired = true; + command.AddOption(termsAndConditionsItemIdOption); var topOption = new Option("--top", description: "Show only the first n items") { }; topOption.IsRequired = false; @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string termsAndConditionsId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string termsAndConditionsItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, termsAndConditionsIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, termsAndConditionsItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -137,7 +134,7 @@ public Command BuildListCommand() { public AssignmentsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/deviceManagement/termsAndConditions/{termsAndConditions_id}/assignments{?top,skip,search,filter,count,orderby,select,expand}"; + UrlTemplate = "{+baseurl}/deviceManagement/termsAndConditions/{termsAndConditionsItem_id}/assignments{?top,skip,search,filter,count,orderby,select,expand}"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(TermsAndConditionsAssignm requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of assignments for this T&C policy. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of assignments for this T&C policy. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TermsAndConditionsAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of assignments for this T&C policy. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/TermsAndConditions/Item/Assignments/Item/TermsAndConditionsAssignmentRequestBuilder.cs b/src/generated/DeviceManagement/TermsAndConditions/Item/Assignments/Item/TermsAndConditionsAssignmentRequestBuilder.cs index 4a7e434d6d9..055129f2895 100644 --- a/src/generated/DeviceManagement/TermsAndConditions/Item/Assignments/Item/TermsAndConditionsAssignmentRequestBuilder.cs +++ b/src/generated/DeviceManagement/TermsAndConditions/Item/Assignments/Item/TermsAndConditionsAssignmentRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.DeviceManagement.TermsAndConditions.Item.Assignments.Item { - /// Builds and executes requests for operations under \deviceManagement\termsAndConditions\{termsAndConditions-id}\assignments\{termsAndConditionsAssignment-id} + /// Builds and executes requests for operations under \deviceManagement\termsAndConditions\{termsAndConditionsItem-id}\assignments\{termsAndConditionsAssignment-id} public class TermsAndConditionsAssignmentRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,21 +26,20 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of assignments for this T&C policy."; // Create options for all the parameters - var termsAndConditionsIdOption = new Option("--termsandconditions-id", description: "key: id of termsAndConditions") { + var termsAndConditionsItemIdOption = new Option("--terms-and-conditions-item-id", description: "key: id of termsAndConditions") { }; - termsAndConditionsIdOption.IsRequired = true; - command.AddOption(termsAndConditionsIdOption); - var termsAndConditionsAssignmentIdOption = new Option("--termsandconditionsassignment-id", description: "key: id of termsAndConditionsAssignment") { + termsAndConditionsItemIdOption.IsRequired = true; + command.AddOption(termsAndConditionsItemIdOption); + var termsAndConditionsAssignmentIdOption = new Option("--terms-and-conditions-assignment-id", description: "key: id of termsAndConditionsAssignment") { }; termsAndConditionsAssignmentIdOption.IsRequired = true; command.AddOption(termsAndConditionsAssignmentIdOption); - command.SetHandler(async (string termsAndConditionsId, string termsAndConditionsAssignmentId) => { + command.SetHandler(async (string termsAndConditionsItemId, string termsAndConditionsAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, termsAndConditionsIdOption, termsAndConditionsAssignmentIdOption); + }, termsAndConditionsItemIdOption, termsAndConditionsAssignmentIdOption); return command; } /// @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of assignments for this T&C policy."; // Create options for all the parameters - var termsAndConditionsIdOption = new Option("--termsandconditions-id", description: "key: id of termsAndConditions") { + var termsAndConditionsItemIdOption = new Option("--terms-and-conditions-item-id", description: "key: id of termsAndConditions") { }; - termsAndConditionsIdOption.IsRequired = true; - command.AddOption(termsAndConditionsIdOption); - var termsAndConditionsAssignmentIdOption = new Option("--termsandconditionsassignment-id", description: "key: id of termsAndConditionsAssignment") { + termsAndConditionsItemIdOption.IsRequired = true; + command.AddOption(termsAndConditionsItemIdOption); + var termsAndConditionsAssignmentIdOption = new Option("--terms-and-conditions-assignment-id", description: "key: id of termsAndConditionsAssignment") { }; termsAndConditionsAssignmentIdOption.IsRequired = true; command.AddOption(termsAndConditionsAssignmentIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string termsAndConditionsId, string termsAndConditionsAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string termsAndConditionsItemId, string termsAndConditionsAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, termsAndConditionsIdOption, termsAndConditionsAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, termsAndConditionsItemIdOption, termsAndConditionsAssignmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of assignments for this T&C policy."; // Create options for all the parameters - var termsAndConditionsIdOption = new Option("--termsandconditions-id", description: "key: id of termsAndConditions") { + var termsAndConditionsItemIdOption = new Option("--terms-and-conditions-item-id", description: "key: id of termsAndConditions") { }; - termsAndConditionsIdOption.IsRequired = true; - command.AddOption(termsAndConditionsIdOption); - var termsAndConditionsAssignmentIdOption = new Option("--termsandconditionsassignment-id", description: "key: id of termsAndConditionsAssignment") { + termsAndConditionsItemIdOption.IsRequired = true; + command.AddOption(termsAndConditionsItemIdOption); + var termsAndConditionsAssignmentIdOption = new Option("--terms-and-conditions-assignment-id", description: "key: id of termsAndConditionsAssignment") { }; termsAndConditionsAssignmentIdOption.IsRequired = true; command.AddOption(termsAndConditionsAssignmentIdOption); @@ -103,16 +101,15 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string termsAndConditionsId, string termsAndConditionsAssignmentId, string body) => { + command.SetHandler(async (string termsAndConditionsItemId, string termsAndConditionsAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, termsAndConditionsIdOption, termsAndConditionsAssignmentIdOption, bodyOption); + }, termsAndConditionsItemIdOption, termsAndConditionsAssignmentIdOption, bodyOption); return command; } /// @@ -123,7 +120,7 @@ public Command BuildPatchCommand() { public TermsAndConditionsAssignmentRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/deviceManagement/termsAndConditions/{termsAndConditions_id}/assignments/{termsAndConditionsAssignment_id}{?select,expand}"; + UrlTemplate = "{+baseurl}/deviceManagement/termsAndConditions/{termsAndConditionsItem_id}/assignments/{termsAndConditionsAssignment_id}{?select,expand}"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(TermsAndConditionsAssign requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of assignments for this T&C policy. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of assignments for this T&C policy. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of assignments for this T&C policy. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(TermsAndConditionsAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of assignments for this T&C policy. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/TermsAndConditions/Item/TermsAndConditionsItemRequestBuilder.cs b/src/generated/DeviceManagement/TermsAndConditions/Item/TermsAndConditionsItemRequestBuilder.cs new file mode 100644 index 00000000000..cada2fb7573 --- /dev/null +++ b/src/generated/DeviceManagement/TermsAndConditions/Item/TermsAndConditionsItemRequestBuilder.cs @@ -0,0 +1,200 @@ +using ApiSdk.DeviceManagement.TermsAndConditions.Item.AcceptanceStatuses; +using ApiSdk.DeviceManagement.TermsAndConditions.Item.Assignments; +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.DeviceManagement.TermsAndConditions.Item { + /// Builds and executes requests for operations under \deviceManagement\termsAndConditions\{termsAndConditionsItem-id} + public class TermsAndConditionsItemRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + public Command BuildAcceptanceStatusesCommand() { + var command = new Command("acceptance-statuses"); + var builder = new ApiSdk.DeviceManagement.TermsAndConditions.Item.AcceptanceStatuses.AcceptanceStatusesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } + command.AddCommand(builder.BuildCreateCommand()); + command.AddCommand(builder.BuildListCommand()); + return command; + } + public Command BuildAssignmentsCommand() { + var command = new Command("assignments"); + var builder = new ApiSdk.DeviceManagement.TermsAndConditions.Item.Assignments.AssignmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } + command.AddCommand(builder.BuildCreateCommand()); + command.AddCommand(builder.BuildListCommand()); + return command; + } + /// + /// The terms and conditions associated with device management of the company. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The terms and conditions associated with device management of the company."; + // Create options for all the parameters + var termsAndConditionsItemIdOption = new Option("--terms-and-conditions-item-id", description: "key: id of termsAndConditions") { + }; + termsAndConditionsItemIdOption.IsRequired = true; + command.AddOption(termsAndConditionsItemIdOption); + command.SetHandler(async (string termsAndConditionsItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, termsAndConditionsItemIdOption); + return command; + } + /// + /// The terms and conditions associated with device management of the company. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The terms and conditions associated with device management of the company."; + // Create options for all the parameters + var termsAndConditionsItemIdOption = new Option("--terms-and-conditions-item-id", description: "key: id of termsAndConditions") { + }; + termsAndConditionsItemIdOption.IsRequired = true; + command.AddOption(termsAndConditionsItemIdOption); + var selectOption = new Option("--select", description: "Select properties to be returned") { + Arity = ArgumentArity.ZeroOrMore + }; + selectOption.IsRequired = false; + command.AddOption(selectOption); + var expandOption = new Option("--expand", description: "Expand related entities") { + Arity = ArgumentArity.ZeroOrMore + }; + expandOption.IsRequired = false; + command.AddOption(expandOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string termsAndConditionsItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Select = select; + q.Expand = expand; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, termsAndConditionsItemIdOption, selectOption, expandOption, outputOption); + return command; + } + /// + /// The terms and conditions associated with device management of the company. + /// + public Command BuildPatchCommand() { + var command = new Command("patch"); + command.Description = "The terms and conditions associated with device management of the company."; + // Create options for all the parameters + var termsAndConditionsItemIdOption = new Option("--terms-and-conditions-item-id", description: "key: id of termsAndConditions") { + }; + termsAndConditionsItemIdOption.IsRequired = true; + command.AddOption(termsAndConditionsItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string termsAndConditionsItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePatchRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, termsAndConditionsItemIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new TermsAndConditionsItemRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public TermsAndConditionsItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/deviceManagement/termsAndConditions/{termsAndConditionsItem_id}{?select,expand}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The terms and conditions associated with device management of the company. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The terms and conditions associated with device management of the company. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The terms and conditions associated with device management of the company. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft.Graph.TermsAndConditions body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PATCH, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The terms and conditions associated with device management of the company. + public class GetQueryParameters : QueryParametersBase { + /// Expand related entities + public string[] Expand { get; set; } + /// Select properties to be returned + public string[] Select { get; set; } + } + } +} diff --git a/src/generated/DeviceManagement/TermsAndConditions/Item/TermsAndConditionsRequestBuilder.cs b/src/generated/DeviceManagement/TermsAndConditions/Item/TermsAndConditionsRequestBuilder.cs deleted file mode 100644 index 83913b733be..00000000000 --- a/src/generated/DeviceManagement/TermsAndConditions/Item/TermsAndConditionsRequestBuilder.cs +++ /dev/null @@ -1,233 +0,0 @@ -using ApiSdk.DeviceManagement.TermsAndConditions.Item.AcceptanceStatuses; -using ApiSdk.DeviceManagement.TermsAndConditions.Item.Assignments; -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.DeviceManagement.TermsAndConditions.Item { - /// Builds and executes requests for operations under \deviceManagement\termsAndConditions\{termsAndConditions-id} - public class TermsAndConditionsRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - public Command BuildAcceptanceStatusesCommand() { - var command = new Command("acceptance-statuses"); - var builder = new ApiSdk.DeviceManagement.TermsAndConditions.Item.AcceptanceStatuses.AcceptanceStatusesRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildCreateCommand()); - command.AddCommand(builder.BuildListCommand()); - return command; - } - public Command BuildAssignmentsCommand() { - var command = new Command("assignments"); - var builder = new ApiSdk.DeviceManagement.TermsAndConditions.Item.Assignments.AssignmentsRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildCreateCommand()); - command.AddCommand(builder.BuildListCommand()); - return command; - } - /// - /// The terms and conditions associated with device management of the company. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The terms and conditions associated with device management of the company."; - // Create options for all the parameters - var termsAndConditionsIdOption = new Option("--termsandconditions-id", description: "key: id of termsAndConditions") { - }; - termsAndConditionsIdOption.IsRequired = true; - command.AddOption(termsAndConditionsIdOption); - command.SetHandler(async (string termsAndConditionsId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, termsAndConditionsIdOption); - return command; - } - /// - /// The terms and conditions associated with device management of the company. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The terms and conditions associated with device management of the company."; - // Create options for all the parameters - var termsAndConditionsIdOption = new Option("--termsandconditions-id", description: "key: id of termsAndConditions") { - }; - termsAndConditionsIdOption.IsRequired = true; - command.AddOption(termsAndConditionsIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string termsAndConditionsId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, termsAndConditionsIdOption, selectOption, expandOption); - return command; - } - /// - /// The terms and conditions associated with device management of the company. - /// - public Command BuildPatchCommand() { - var command = new Command("patch"); - command.Description = "The terms and conditions associated with device management of the company."; - // Create options for all the parameters - var termsAndConditionsIdOption = new Option("--termsandconditions-id", description: "key: id of termsAndConditions") { - }; - termsAndConditionsIdOption.IsRequired = true; - command.AddOption(termsAndConditionsIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string termsAndConditionsId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePatchRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, termsAndConditionsIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new TermsAndConditionsRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public TermsAndConditionsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/deviceManagement/termsAndConditions/{termsAndConditions_id}{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The terms and conditions associated with device management of the company. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The terms and conditions associated with device management of the company. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The terms and conditions associated with device management of the company. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft.Graph.TermsAndConditions body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PATCH, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The terms and conditions associated with device management of the company. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The terms and conditions associated with device management of the company. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The terms and conditions associated with device management of the company. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.TermsAndConditions model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// The terms and conditions associated with device management of the company. - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/DeviceManagement/TermsAndConditions/TermsAndConditionsRequestBuilder.cs b/src/generated/DeviceManagement/TermsAndConditions/TermsAndConditionsRequestBuilder.cs index 931e5f1b060..ebce01ca464 100644 --- a/src/generated/DeviceManagement/TermsAndConditions/TermsAndConditionsRequestBuilder.cs +++ b/src/generated/DeviceManagement/TermsAndConditions/TermsAndConditionsRequestBuilder.cs @@ -1,10 +1,11 @@ +using ApiSdk.DeviceManagement.TermsAndConditions.Item; using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -20,11 +21,13 @@ public class TermsAndConditionsRequestBuilder { /// Url template to use to build the URL for the current request builder private string UrlTemplate { get; set; } public List BuildCommand() { - var builder = new TermsAndConditionsRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCreateCommand(), - builder.BuildListCommand(), - }; + var builder = new TermsAndConditionsItemRequestBuilder(PathParameters, RequestAdapter); + var commands = new List(); + commands.Add(builder.BuildAcceptanceStatusesCommand()); + commands.Add(builder.BuildAssignmentsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -38,21 +41,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -97,7 +99,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -108,15 +114,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -171,31 +172,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The terms and conditions associated with device management of the company. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The terms and conditions associated with device management of the company. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.TermsAndConditions model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The terms and conditions associated with device management of the company. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/TroubleshootingEvents/Item/DeviceManagementTroubleshootingEventRequestBuilder.cs b/src/generated/DeviceManagement/TroubleshootingEvents/Item/DeviceManagementTroubleshootingEventRequestBuilder.cs index c799f8ceb50..e00fde82c1a 100644 --- a/src/generated/DeviceManagement/TroubleshootingEvents/Item/DeviceManagementTroubleshootingEventRequestBuilder.cs +++ b/src/generated/DeviceManagement/TroubleshootingEvents/Item/DeviceManagementTroubleshootingEventRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of troubleshooting events for the tenant."; // Create options for all the parameters - var deviceManagementTroubleshootingEventIdOption = new Option("--devicemanagementtroubleshootingevent-id", description: "key: id of deviceManagementTroubleshootingEvent") { + var deviceManagementTroubleshootingEventIdOption = new Option("--device-management-troubleshooting-event-id", description: "key: id of deviceManagementTroubleshootingEvent") { }; deviceManagementTroubleshootingEventIdOption.IsRequired = true; command.AddOption(deviceManagementTroubleshootingEventIdOption); - command.SetHandler(async (string deviceManagementTroubleshootingEventId) => { + command.SetHandler(async (string deviceManagementTroubleshootingEventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceManagementTroubleshootingEventIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of troubleshooting events for the tenant."; // Create options for all the parameters - var deviceManagementTroubleshootingEventIdOption = new Option("--devicemanagementtroubleshootingevent-id", description: "key: id of deviceManagementTroubleshootingEvent") { + var deviceManagementTroubleshootingEventIdOption = new Option("--device-management-troubleshooting-event-id", description: "key: id of deviceManagementTroubleshootingEvent") { }; deviceManagementTroubleshootingEventIdOption.IsRequired = true; command.AddOption(deviceManagementTroubleshootingEventIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceManagementTroubleshootingEventId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceManagementTroubleshootingEventId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceManagementTroubleshootingEventIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceManagementTroubleshootingEventIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of troubleshooting events for the tenant."; // Create options for all the parameters - var deviceManagementTroubleshootingEventIdOption = new Option("--devicemanagementtroubleshootingevent-id", description: "key: id of deviceManagementTroubleshootingEvent") { + var deviceManagementTroubleshootingEventIdOption = new Option("--device-management-troubleshooting-event-id", description: "key: id of deviceManagementTroubleshootingEvent") { }; deviceManagementTroubleshootingEventIdOption.IsRequired = true; command.AddOption(deviceManagementTroubleshootingEventIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceManagementTroubleshootingEventId, string body) => { + command.SetHandler(async (string deviceManagementTroubleshootingEventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceManagementTroubleshootingEventIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceManagementTroubles requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of troubleshooting events for the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of troubleshooting events for the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of troubleshooting events for the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceManagementTroubleshootingEvent model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of troubleshooting events for the tenant. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/TroubleshootingEvents/TroubleshootingEventsRequestBuilder.cs b/src/generated/DeviceManagement/TroubleshootingEvents/TroubleshootingEventsRequestBuilder.cs index 3b46c87001f..3ed54556f6b 100644 --- a/src/generated/DeviceManagement/TroubleshootingEvents/TroubleshootingEventsRequestBuilder.cs +++ b/src/generated/DeviceManagement/TroubleshootingEvents/TroubleshootingEventsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class TroubleshootingEventsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceManagementTroubleshootingEventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(DeviceManagementTroublesh requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of troubleshooting events for the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of troubleshooting events for the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceManagementTroubleshootingEvent model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of troubleshooting events for the tenant. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/VerifyWindowsEnrollmentAutoDiscoveryWithDomainName/VerifyWindowsEnrollmentAutoDiscoveryWithDomainNameRequestBuilder.cs b/src/generated/DeviceManagement/VerifyWindowsEnrollmentAutoDiscoveryWithDomainName/VerifyWindowsEnrollmentAutoDiscoveryWithDomainNameRequestBuilder.cs index ccc39f03227..963c4c50517 100644 --- a/src/generated/DeviceManagement/VerifyWindowsEnrollmentAutoDiscoveryWithDomainName/VerifyWindowsEnrollmentAutoDiscoveryWithDomainNameRequestBuilder.cs +++ b/src/generated/DeviceManagement/VerifyWindowsEnrollmentAutoDiscoveryWithDomainName/VerifyWindowsEnrollmentAutoDiscoveryWithDomainNameRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,22 +25,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function verifyWindowsEnrollmentAutoDiscovery"; // Create options for all the parameters - var domainNameOption = new Option("--domainname", description: "Usage: domainName={domainName}") { + var domainNameOption = new Option("--domain-name", description: "Usage: domainName={domainName}") { }; domainNameOption.IsRequired = true; command.AddOption(domainNameOption); - command.SetHandler(async (string domainName) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string domainName, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteBoolValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, domainNameOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, domainNameOption, outputOption); return command; } /// @@ -73,16 +72,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function verifyWindowsEnrollmentAutoDiscovery - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/WindowsAutopilotDeviceIdentities/Item/AssignUserToDevice/AssignUserToDeviceRequestBuilder.cs b/src/generated/DeviceManagement/WindowsAutopilotDeviceIdentities/Item/AssignUserToDevice/AssignUserToDeviceRequestBuilder.cs index a20322b1983..9ae2fbe626e 100644 --- a/src/generated/DeviceManagement/WindowsAutopilotDeviceIdentities/Item/AssignUserToDevice/AssignUserToDeviceRequestBuilder.cs +++ b/src/generated/DeviceManagement/WindowsAutopilotDeviceIdentities/Item/AssignUserToDevice/AssignUserToDeviceRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Assigns user to Autopilot devices."; // Create options for all the parameters - var windowsAutopilotDeviceIdentityIdOption = new Option("--windowsautopilotdeviceidentity-id", description: "key: id of windowsAutopilotDeviceIdentity") { + var windowsAutopilotDeviceIdentityIdOption = new Option("--windows-autopilot-device-identity-id", description: "key: id of windowsAutopilotDeviceIdentity") { }; windowsAutopilotDeviceIdentityIdOption.IsRequired = true; command.AddOption(windowsAutopilotDeviceIdentityIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string windowsAutopilotDeviceIdentityId, string body) => { + command.SetHandler(async (string windowsAutopilotDeviceIdentityId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, windowsAutopilotDeviceIdentityIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(AssignUserToDeviceRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Assigns user to Autopilot devices. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignUserToDeviceRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/WindowsAutopilotDeviceIdentities/Item/UnassignUserFromDevice/UnassignUserFromDeviceRequestBuilder.cs b/src/generated/DeviceManagement/WindowsAutopilotDeviceIdentities/Item/UnassignUserFromDevice/UnassignUserFromDeviceRequestBuilder.cs index 27d52a9ff3e..5995cfe55f5 100644 --- a/src/generated/DeviceManagement/WindowsAutopilotDeviceIdentities/Item/UnassignUserFromDevice/UnassignUserFromDeviceRequestBuilder.cs +++ b/src/generated/DeviceManagement/WindowsAutopilotDeviceIdentities/Item/UnassignUserFromDevice/UnassignUserFromDeviceRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Unassigns the user from an Autopilot device."; // Create options for all the parameters - var windowsAutopilotDeviceIdentityIdOption = new Option("--windowsautopilotdeviceidentity-id", description: "key: id of windowsAutopilotDeviceIdentity") { + var windowsAutopilotDeviceIdentityIdOption = new Option("--windows-autopilot-device-identity-id", description: "key: id of windowsAutopilotDeviceIdentity") { }; windowsAutopilotDeviceIdentityIdOption.IsRequired = true; command.AddOption(windowsAutopilotDeviceIdentityIdOption); - command.SetHandler(async (string windowsAutopilotDeviceIdentityId) => { + command.SetHandler(async (string windowsAutopilotDeviceIdentityId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, windowsAutopilotDeviceIdentityIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Unassigns the user from an Autopilot device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/WindowsAutopilotDeviceIdentities/Item/UpdateDeviceProperties/UpdateDevicePropertiesRequestBuilder.cs b/src/generated/DeviceManagement/WindowsAutopilotDeviceIdentities/Item/UpdateDeviceProperties/UpdateDevicePropertiesRequestBuilder.cs index 7e8503cd384..bfe71fb8600 100644 --- a/src/generated/DeviceManagement/WindowsAutopilotDeviceIdentities/Item/UpdateDeviceProperties/UpdateDevicePropertiesRequestBuilder.cs +++ b/src/generated/DeviceManagement/WindowsAutopilotDeviceIdentities/Item/UpdateDeviceProperties/UpdateDevicePropertiesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Updates properties on Autopilot devices."; // Create options for all the parameters - var windowsAutopilotDeviceIdentityIdOption = new Option("--windowsautopilotdeviceidentity-id", description: "key: id of windowsAutopilotDeviceIdentity") { + var windowsAutopilotDeviceIdentityIdOption = new Option("--windows-autopilot-device-identity-id", description: "key: id of windowsAutopilotDeviceIdentity") { }; windowsAutopilotDeviceIdentityIdOption.IsRequired = true; command.AddOption(windowsAutopilotDeviceIdentityIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string windowsAutopilotDeviceIdentityId, string body) => { + command.SetHandler(async (string windowsAutopilotDeviceIdentityId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, windowsAutopilotDeviceIdentityIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(UpdateDevicePropertiesReq requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Updates properties on Autopilot devices. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UpdateDevicePropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DeviceManagement/WindowsAutopilotDeviceIdentities/Item/WindowsAutopilotDeviceIdentityRequestBuilder.cs b/src/generated/DeviceManagement/WindowsAutopilotDeviceIdentities/Item/WindowsAutopilotDeviceIdentityRequestBuilder.cs index 4fcd650e685..16714ae42e4 100644 --- a/src/generated/DeviceManagement/WindowsAutopilotDeviceIdentities/Item/WindowsAutopilotDeviceIdentityRequestBuilder.cs +++ b/src/generated/DeviceManagement/WindowsAutopilotDeviceIdentities/Item/WindowsAutopilotDeviceIdentityRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,15 +35,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The Windows autopilot device identities contained collection."; // Create options for all the parameters - var windowsAutopilotDeviceIdentityIdOption = new Option("--windowsautopilotdeviceidentity-id", description: "key: id of windowsAutopilotDeviceIdentity") { + var windowsAutopilotDeviceIdentityIdOption = new Option("--windows-autopilot-device-identity-id", description: "key: id of windowsAutopilotDeviceIdentity") { }; windowsAutopilotDeviceIdentityIdOption.IsRequired = true; command.AddOption(windowsAutopilotDeviceIdentityIdOption); - command.SetHandler(async (string windowsAutopilotDeviceIdentityId) => { + command.SetHandler(async (string windowsAutopilotDeviceIdentityId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, windowsAutopilotDeviceIdentityIdOption); return command; @@ -55,7 +54,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The Windows autopilot device identities contained collection."; // Create options for all the parameters - var windowsAutopilotDeviceIdentityIdOption = new Option("--windowsautopilotdeviceidentity-id", description: "key: id of windowsAutopilotDeviceIdentity") { + var windowsAutopilotDeviceIdentityIdOption = new Option("--windows-autopilot-device-identity-id", description: "key: id of windowsAutopilotDeviceIdentity") { }; windowsAutopilotDeviceIdentityIdOption.IsRequired = true; command.AddOption(windowsAutopilotDeviceIdentityIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string windowsAutopilotDeviceIdentityId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string windowsAutopilotDeviceIdentityId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, windowsAutopilotDeviceIdentityIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, windowsAutopilotDeviceIdentityIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -92,7 +90,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The Windows autopilot device identities contained collection."; // Create options for all the parameters - var windowsAutopilotDeviceIdentityIdOption = new Option("--windowsautopilotdeviceidentity-id", description: "key: id of windowsAutopilotDeviceIdentity") { + var windowsAutopilotDeviceIdentityIdOption = new Option("--windows-autopilot-device-identity-id", description: "key: id of windowsAutopilotDeviceIdentity") { }; windowsAutopilotDeviceIdentityIdOption.IsRequired = true; command.AddOption(windowsAutopilotDeviceIdentityIdOption); @@ -100,14 +98,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string windowsAutopilotDeviceIdentityId, string body) => { + command.SetHandler(async (string windowsAutopilotDeviceIdentityId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, windowsAutopilotDeviceIdentityIdOption, bodyOption); return command; @@ -191,42 +188,6 @@ public RequestInformation CreatePatchRequestInformation(WindowsAutopilotDeviceId requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The Windows autopilot device identities contained collection. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Windows autopilot device identities contained collection. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Windows autopilot device identities contained collection. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WindowsAutopilotDeviceIdentity model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The Windows autopilot device identities contained collection. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/WindowsAutopilotDeviceIdentities/WindowsAutopilotDeviceIdentitiesRequestBuilder.cs b/src/generated/DeviceManagement/WindowsAutopilotDeviceIdentities/WindowsAutopilotDeviceIdentitiesRequestBuilder.cs index 3d920337fb5..231d11b927e 100644 --- a/src/generated/DeviceManagement/WindowsAutopilotDeviceIdentities/WindowsAutopilotDeviceIdentitiesRequestBuilder.cs +++ b/src/generated/DeviceManagement/WindowsAutopilotDeviceIdentities/WindowsAutopilotDeviceIdentitiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class WindowsAutopilotDeviceIdentitiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new WindowsAutopilotDeviceIdentityRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAssignUserToDeviceCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildUnassignUserFromDeviceCommand(), - builder.BuildUpdateDevicePropertiesCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAssignUserToDeviceCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildUnassignUserFromDeviceCommand()); + commands.Add(builder.BuildUpdateDevicePropertiesCommand()); return commands; } /// @@ -43,21 +42,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -102,7 +100,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -113,15 +115,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -176,31 +173,6 @@ public RequestInformation CreatePostRequestInformation(WindowsAutopilotDeviceIde requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The Windows autopilot device identities contained collection. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Windows autopilot device identities contained collection. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WindowsAutopilotDeviceIdentity model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The Windows autopilot device identities contained collection. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/WindowsInformationProtectionAppLearningSummaries/Item/WindowsInformationProtectionAppLearningSummaryRequestBuilder.cs b/src/generated/DeviceManagement/WindowsInformationProtectionAppLearningSummaries/Item/WindowsInformationProtectionAppLearningSummaryRequestBuilder.cs index c10879c678b..1e72901973f 100644 --- a/src/generated/DeviceManagement/WindowsInformationProtectionAppLearningSummaries/Item/WindowsInformationProtectionAppLearningSummaryRequestBuilder.cs +++ b/src/generated/DeviceManagement/WindowsInformationProtectionAppLearningSummaries/Item/WindowsInformationProtectionAppLearningSummaryRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The windows information protection app learning summaries."; // Create options for all the parameters - var windowsInformationProtectionAppLearningSummaryIdOption = new Option("--windowsinformationprotectionapplearningsummary-id", description: "key: id of windowsInformationProtectionAppLearningSummary") { + var windowsInformationProtectionAppLearningSummaryIdOption = new Option("--windows-information-protection-app-learning-summary-id", description: "key: id of windowsInformationProtectionAppLearningSummary") { }; windowsInformationProtectionAppLearningSummaryIdOption.IsRequired = true; command.AddOption(windowsInformationProtectionAppLearningSummaryIdOption); - command.SetHandler(async (string windowsInformationProtectionAppLearningSummaryId) => { + command.SetHandler(async (string windowsInformationProtectionAppLearningSummaryId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, windowsInformationProtectionAppLearningSummaryIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The windows information protection app learning summaries."; // Create options for all the parameters - var windowsInformationProtectionAppLearningSummaryIdOption = new Option("--windowsinformationprotectionapplearningsummary-id", description: "key: id of windowsInformationProtectionAppLearningSummary") { + var windowsInformationProtectionAppLearningSummaryIdOption = new Option("--windows-information-protection-app-learning-summary-id", description: "key: id of windowsInformationProtectionAppLearningSummary") { }; windowsInformationProtectionAppLearningSummaryIdOption.IsRequired = true; command.AddOption(windowsInformationProtectionAppLearningSummaryIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string windowsInformationProtectionAppLearningSummaryId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string windowsInformationProtectionAppLearningSummaryId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, windowsInformationProtectionAppLearningSummaryIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, windowsInformationProtectionAppLearningSummaryIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The windows information protection app learning summaries."; // Create options for all the parameters - var windowsInformationProtectionAppLearningSummaryIdOption = new Option("--windowsinformationprotectionapplearningsummary-id", description: "key: id of windowsInformationProtectionAppLearningSummary") { + var windowsInformationProtectionAppLearningSummaryIdOption = new Option("--windows-information-protection-app-learning-summary-id", description: "key: id of windowsInformationProtectionAppLearningSummary") { }; windowsInformationProtectionAppLearningSummaryIdOption.IsRequired = true; command.AddOption(windowsInformationProtectionAppLearningSummaryIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string windowsInformationProtectionAppLearningSummaryId, string body) => { + command.SetHandler(async (string windowsInformationProtectionAppLearningSummaryId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, windowsInformationProtectionAppLearningSummaryIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(WindowsInformationProtec requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The windows information protection app learning summaries. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The windows information protection app learning summaries. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The windows information protection app learning summaries. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WindowsInformationProtectionAppLearningSummary model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The windows information protection app learning summaries. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/WindowsInformationProtectionAppLearningSummaries/WindowsInformationProtectionAppLearningSummariesRequestBuilder.cs b/src/generated/DeviceManagement/WindowsInformationProtectionAppLearningSummaries/WindowsInformationProtectionAppLearningSummariesRequestBuilder.cs index fd2aa57d0ef..7c81c420154 100644 --- a/src/generated/DeviceManagement/WindowsInformationProtectionAppLearningSummaries/WindowsInformationProtectionAppLearningSummariesRequestBuilder.cs +++ b/src/generated/DeviceManagement/WindowsInformationProtectionAppLearningSummaries/WindowsInformationProtectionAppLearningSummariesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class WindowsInformationProtectionAppLearningSummariesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new WindowsInformationProtectionAppLearningSummaryRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(WindowsInformationProtect requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The windows information protection app learning summaries. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The windows information protection app learning summaries. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WindowsInformationProtectionAppLearningSummary model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The windows information protection app learning summaries. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DeviceManagement/WindowsInformationProtectionNetworkLearningSummaries/Item/WindowsInformationProtectionNetworkLearningSummaryRequestBuilder.cs b/src/generated/DeviceManagement/WindowsInformationProtectionNetworkLearningSummaries/Item/WindowsInformationProtectionNetworkLearningSummaryRequestBuilder.cs index ac5343d6e36..f6d3731c7a1 100644 --- a/src/generated/DeviceManagement/WindowsInformationProtectionNetworkLearningSummaries/Item/WindowsInformationProtectionNetworkLearningSummaryRequestBuilder.cs +++ b/src/generated/DeviceManagement/WindowsInformationProtectionNetworkLearningSummaries/Item/WindowsInformationProtectionNetworkLearningSummaryRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The windows information protection network learning summaries."; // Create options for all the parameters - var windowsInformationProtectionNetworkLearningSummaryIdOption = new Option("--windowsinformationprotectionnetworklearningsummary-id", description: "key: id of windowsInformationProtectionNetworkLearningSummary") { + var windowsInformationProtectionNetworkLearningSummaryIdOption = new Option("--windows-information-protection-network-learning-summary-id", description: "key: id of windowsInformationProtectionNetworkLearningSummary") { }; windowsInformationProtectionNetworkLearningSummaryIdOption.IsRequired = true; command.AddOption(windowsInformationProtectionNetworkLearningSummaryIdOption); - command.SetHandler(async (string windowsInformationProtectionNetworkLearningSummaryId) => { + command.SetHandler(async (string windowsInformationProtectionNetworkLearningSummaryId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, windowsInformationProtectionNetworkLearningSummaryIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The windows information protection network learning summaries."; // Create options for all the parameters - var windowsInformationProtectionNetworkLearningSummaryIdOption = new Option("--windowsinformationprotectionnetworklearningsummary-id", description: "key: id of windowsInformationProtectionNetworkLearningSummary") { + var windowsInformationProtectionNetworkLearningSummaryIdOption = new Option("--windows-information-protection-network-learning-summary-id", description: "key: id of windowsInformationProtectionNetworkLearningSummary") { }; windowsInformationProtectionNetworkLearningSummaryIdOption.IsRequired = true; command.AddOption(windowsInformationProtectionNetworkLearningSummaryIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string windowsInformationProtectionNetworkLearningSummaryId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string windowsInformationProtectionNetworkLearningSummaryId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, windowsInformationProtectionNetworkLearningSummaryIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, windowsInformationProtectionNetworkLearningSummaryIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The windows information protection network learning summaries."; // Create options for all the parameters - var windowsInformationProtectionNetworkLearningSummaryIdOption = new Option("--windowsinformationprotectionnetworklearningsummary-id", description: "key: id of windowsInformationProtectionNetworkLearningSummary") { + var windowsInformationProtectionNetworkLearningSummaryIdOption = new Option("--windows-information-protection-network-learning-summary-id", description: "key: id of windowsInformationProtectionNetworkLearningSummary") { }; windowsInformationProtectionNetworkLearningSummaryIdOption.IsRequired = true; command.AddOption(windowsInformationProtectionNetworkLearningSummaryIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string windowsInformationProtectionNetworkLearningSummaryId, string body) => { + command.SetHandler(async (string windowsInformationProtectionNetworkLearningSummaryId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, windowsInformationProtectionNetworkLearningSummaryIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(WindowsInformationProtec requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The windows information protection network learning summaries. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The windows information protection network learning summaries. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The windows information protection network learning summaries. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WindowsInformationProtectionNetworkLearningSummary model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The windows information protection network learning summaries. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DeviceManagement/WindowsInformationProtectionNetworkLearningSummaries/WindowsInformationProtectionNetworkLearningSummariesRequestBuilder.cs b/src/generated/DeviceManagement/WindowsInformationProtectionNetworkLearningSummaries/WindowsInformationProtectionNetworkLearningSummariesRequestBuilder.cs index ca7a0fee3de..5b1f10a5d3f 100644 --- a/src/generated/DeviceManagement/WindowsInformationProtectionNetworkLearningSummaries/WindowsInformationProtectionNetworkLearningSummariesRequestBuilder.cs +++ b/src/generated/DeviceManagement/WindowsInformationProtectionNetworkLearningSummaries/WindowsInformationProtectionNetworkLearningSummariesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class WindowsInformationProtectionNetworkLearningSummariesRequestBuilder private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new WindowsInformationProtectionNetworkLearningSummaryRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(WindowsInformationProtect requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The windows information protection network learning summaries. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The windows information protection network learning summaries. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WindowsInformationProtectionNetworkLearningSummary model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The windows information protection network learning summaries. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Devices/DevicesRequestBuilder.cs b/src/generated/Devices/DevicesRequestBuilder.cs index dc87578e047..7939497ab12 100644 --- a/src/generated/Devices/DevicesRequestBuilder.cs +++ b/src/generated/Devices/DevicesRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,21 +25,20 @@ public class DevicesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCheckMemberGroupsCommand(), - builder.BuildCheckMemberObjectsCommand(), - builder.BuildDeleteCommand(), - builder.BuildExtensionsCommand(), - builder.BuildGetCommand(), - builder.BuildGetMemberGroupsCommand(), - builder.BuildGetMemberObjectsCommand(), - builder.BuildMemberOfCommand(), - builder.BuildPatchCommand(), - builder.BuildRegisteredOwnersCommand(), - builder.BuildRegisteredUsersCommand(), - builder.BuildRestoreCommand(), - builder.BuildTransitiveMemberOfCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCheckMemberGroupsCommand()); + commands.Add(builder.BuildCheckMemberObjectsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildGetMemberGroupsCommand()); + commands.Add(builder.BuildGetMemberObjectsCommand()); + commands.Add(builder.BuildMemberOfCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRegisteredOwnersCommand()); + commands.Add(builder.BuildRegisteredUsersCommand()); + commands.Add(builder.BuildRestoreCommand()); + commands.Add(builder.BuildTransitiveMemberOfCommand()); return commands; } /// @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } public Command BuildGetAvailableExtensionPropertiesCommand() { @@ -124,7 +122,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -135,15 +137,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildValidatePropertiesCommand() { @@ -204,31 +201,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get entities from devices - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to devices - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Device model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from devices public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Devices/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs b/src/generated/Devices/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs deleted file mode 100644 index 09d62133177..00000000000 --- a/src/generated/Devices/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs +++ /dev/null @@ -1,45 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Devices.GetAvailableExtensionProperties { - public class GetAvailableExtensionProperties : DirectoryObject, IParsable { - /// Display name of the application object on which this extension property is defined. Read-only. - public string AppDisplayName { get; set; } - /// Specifies the data type of the value the extension property can hold. Following values are supported. Not nullable. Binary - 256 bytes maximumBooleanDateTime - Must be specified in ISO 8601 format. Will be stored in UTC.Integer - 32-bit value.LargeInteger - 64-bit value.String - 256 characters maximum - public string DataType { get; set; } - /// Indicates if this extension property was sycned from onpremises directory using Azure AD Connect. Read-only. - public bool? IsSyncedFromOnPremises { get; set; } - /// Name of the extension property. Not nullable. - public string Name { get; set; } - /// Following values are supported. Not nullable. UserGroupOrganizationDeviceApplication - public List TargetObjects { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"appDisplayName", (o,n) => { (o as GetAvailableExtensionProperties).AppDisplayName = n.GetStringValue(); } }, - {"dataType", (o,n) => { (o as GetAvailableExtensionProperties).DataType = n.GetStringValue(); } }, - {"isSyncedFromOnPremises", (o,n) => { (o as GetAvailableExtensionProperties).IsSyncedFromOnPremises = n.GetBoolValue(); } }, - {"name", (o,n) => { (o as GetAvailableExtensionProperties).Name = n.GetStringValue(); } }, - {"targetObjects", (o,n) => { (o as GetAvailableExtensionProperties).TargetObjects = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteStringValue("appDisplayName", AppDisplayName); - writer.WriteStringValue("dataType", DataType); - writer.WriteBoolValue("isSyncedFromOnPremises", IsSyncedFromOnPremises); - writer.WriteStringValue("name", Name); - writer.WriteCollectionOfPrimitiveValues("targetObjects", TargetObjects); - } - } -} diff --git a/src/generated/Devices/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs b/src/generated/Devices/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs index 55ad6bb486a..6d553728cbe 100644 --- a/src/generated/Devices/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs +++ b/src/generated/Devices/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(GetAvailableExtensionProp requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getAvailableExtensionProperties - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetAvailableExtensionPropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Devices/GetByIds/GetByIds.cs b/src/generated/Devices/GetByIds/GetByIds.cs deleted file mode 100644 index b858d6549eb..00000000000 --- a/src/generated/Devices/GetByIds/GetByIds.cs +++ /dev/null @@ -1,28 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Devices.GetByIds { - public class GetByIds : Entity, IParsable { - public DateTimeOffset? DeletedDateTime { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"deletedDateTime", (o,n) => { (o as GetByIds).DeletedDateTime = n.GetDateTimeOffsetValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteDateTimeOffsetValue("deletedDateTime", DeletedDateTime); - } - } -} diff --git a/src/generated/Devices/GetByIds/GetByIdsRequestBuilder.cs b/src/generated/Devices/GetByIds/GetByIdsRequestBuilder.cs index 74845770956..1626671962a 100644 --- a/src/generated/Devices/GetByIds/GetByIdsRequestBuilder.cs +++ b/src/generated/Devices/GetByIds/GetByIdsRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(GetByIdsRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getByIds - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetByIdsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Devices/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs b/src/generated/Devices/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs index a345a43aba2..5a7e6b0af11 100644 --- a/src/generated/Devices/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs +++ b/src/generated/Devices/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberGroupsRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Devices/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs b/src/generated/Devices/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs index fda5b2a315a..90310b1140c 100644 --- a/src/generated/Devices/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs +++ b/src/generated/Devices/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberObjectsRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Devices/Item/DeviceRequestBuilder.cs b/src/generated/Devices/Item/DeviceRequestBuilder.cs index fb6b62163cb..bc93b5e79a3 100644 --- a/src/generated/Devices/Item/DeviceRequestBuilder.cs +++ b/src/generated/Devices/Item/DeviceRequestBuilder.cs @@ -11,10 +11,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -52,11 +52,10 @@ public Command BuildDeleteCommand() { }; deviceIdOption.IsRequired = true; command.AddOption(deviceIdOption); - command.SetHandler(async (string deviceId) => { + command.SetHandler(async (string deviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceIdOption); return command; @@ -64,6 +63,9 @@ public Command BuildDeleteCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Devices.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -89,20 +91,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildGetMemberGroupsCommand() { @@ -139,14 +140,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceId, string body) => { + command.SetHandler(async (string deviceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceIdOption, bodyOption); return command; @@ -245,42 +245,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from devices - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from devices by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in devices - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Device model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from devices by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Devices/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Devices/Item/Extensions/ExtensionsRequestBuilder.cs index 5a03368c18f..bd0a2ca468d 100644 --- a/src/generated/Devices/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Devices/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the device. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the device. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the device. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Devices/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Devices/Item/Extensions/Item/ExtensionRequestBuilder.cs index 18fa10031c2..52abee11a74 100644 --- a/src/generated/Devices/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Devices/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string deviceId, string extensionId) => { + command.SetHandler(async (string deviceId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceIdOption, extensionIdOption); return command; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceId, string extensionId, string body) => { + command.SetHandler(async (string deviceId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceIdOption, extensionIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the device. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the device. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the device. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the device. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Devices/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs b/src/generated/Devices/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs index 14d00c0633b..083da3b213c 100644 --- a/src/generated/Devices/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs +++ b/src/generated/Devices/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberGroupsRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Devices/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs b/src/generated/Devices/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs index cb9fc73d16a..bde33a17e7e 100644 --- a/src/generated/Devices/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs +++ b/src/generated/Devices/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberObjectsRequestBo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Devices/Item/MemberOf/@Ref/@Ref.cs b/src/generated/Devices/Item/MemberOf/@Ref/@Ref.cs deleted file mode 100644 index ac0fb0acc25..00000000000 --- a/src/generated/Devices/Item/MemberOf/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Devices.Item.MemberOf.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Devices/Item/MemberOf/@Ref/RefRequestBuilder.cs b/src/generated/Devices/Item/MemberOf/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 270723c2595..00000000000 --- a/src/generated/Devices/Item/MemberOf/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Devices.Item.MemberOf.@Ref { - /// Builds and executes requests for operations under \devices\{device-id}\memberOf\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Groups that this device is a member of. Read-only. Nullable. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Groups that this device is a member of. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var deviceIdOption = new Option("--device-id", description: "key: id of device") { - }; - deviceIdOption.IsRequired = true; - command.AddOption(deviceIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string deviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Groups that this device is a member of. Read-only. Nullable. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Groups that this device is a member of. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var deviceIdOption = new Option("--device-id", description: "key: id of device") { - }; - deviceIdOption.IsRequired = true; - command.AddOption(deviceIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string deviceId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/devices/{device_id}/memberOf/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Groups that this device is a member of. Read-only. Nullable. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Groups that this device is a member of. Read-only. Nullable. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Devices.Item.MemberOf.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Groups that this device is a member of. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Groups that this device is a member of. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Devices.Item.MemberOf.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Groups that this device is a member of. Read-only. Nullable. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Devices/Item/MemberOf/@Ref/RefResponse.cs b/src/generated/Devices/Item/MemberOf/@Ref/RefResponse.cs deleted file mode 100644 index 13c08935f70..00000000000 --- a/src/generated/Devices/Item/MemberOf/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Devices.Item.MemberOf.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Devices/Item/MemberOf/MemberOfRequestBuilder.cs b/src/generated/Devices/Item/MemberOf/MemberOfRequestBuilder.cs index 919917205f3..5ce250680b3 100644 --- a/src/generated/Devices/Item/MemberOf/MemberOfRequestBuilder.cs +++ b/src/generated/Devices/Item/MemberOf/MemberOfRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Devices.Item.MemberOf.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Devices.Item.MemberOf.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Devices.Item.MemberOf.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Groups that this device is a member of. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Groups that this device is a member of. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Devices/Item/MemberOf/Ref/Ref.cs b/src/generated/Devices/Item/MemberOf/Ref/Ref.cs new file mode 100644 index 00000000000..52770ebc465 --- /dev/null +++ b/src/generated/Devices/Item/MemberOf/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Devices.Item.MemberOf.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Devices/Item/MemberOf/Ref/RefRequestBuilder.cs b/src/generated/Devices/Item/MemberOf/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..377e69afc82 --- /dev/null +++ b/src/generated/Devices/Item/MemberOf/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Devices.Item.MemberOf.Ref { + /// Builds and executes requests for operations under \devices\{device-id}\memberOf\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Groups that this device is a member of. Read-only. Nullable. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Groups that this device is a member of. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var deviceIdOption = new Option("--device-id", description: "key: id of device") { + }; + deviceIdOption.IsRequired = true; + command.AddOption(deviceIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Groups that this device is a member of. Read-only. Nullable. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Groups that this device is a member of. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var deviceIdOption = new Option("--device-id", description: "key: id of device") { + }; + deviceIdOption.IsRequired = true; + command.AddOption(deviceIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/devices/{device_id}/memberOf/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Groups that this device is a member of. Read-only. Nullable. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Groups that this device is a member of. Read-only. Nullable. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Devices.Item.MemberOf.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Groups that this device is a member of. Read-only. Nullable. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Devices/Item/MemberOf/Ref/RefResponse.cs b/src/generated/Devices/Item/MemberOf/Ref/RefResponse.cs new file mode 100644 index 00000000000..5118e6ace5d --- /dev/null +++ b/src/generated/Devices/Item/MemberOf/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Devices.Item.MemberOf.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Devices/Item/RegisteredOwners/@Ref/@Ref.cs b/src/generated/Devices/Item/RegisteredOwners/@Ref/@Ref.cs deleted file mode 100644 index ec8b9c840b6..00000000000 --- a/src/generated/Devices/Item/RegisteredOwners/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Devices.Item.RegisteredOwners.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Devices/Item/RegisteredOwners/@Ref/RefRequestBuilder.cs b/src/generated/Devices/Item/RegisteredOwners/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 04b06f0619b..00000000000 --- a/src/generated/Devices/Item/RegisteredOwners/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Devices.Item.RegisteredOwners.@Ref { - /// Builds and executes requests for operations under \devices\{device-id}\registeredOwners\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The user that cloud joined the device or registered their personal device. The registered owner is set at the time of registration. Currently, there can be only one owner. Read-only. Nullable. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The user that cloud joined the device or registered their personal device. The registered owner is set at the time of registration. Currently, there can be only one owner. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var deviceIdOption = new Option("--device-id", description: "key: id of device") { - }; - deviceIdOption.IsRequired = true; - command.AddOption(deviceIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string deviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The user that cloud joined the device or registered their personal device. The registered owner is set at the time of registration. Currently, there can be only one owner. Read-only. Nullable. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The user that cloud joined the device or registered their personal device. The registered owner is set at the time of registration. Currently, there can be only one owner. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var deviceIdOption = new Option("--device-id", description: "key: id of device") { - }; - deviceIdOption.IsRequired = true; - command.AddOption(deviceIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string deviceId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/devices/{device_id}/registeredOwners/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The user that cloud joined the device or registered their personal device. The registered owner is set at the time of registration. Currently, there can be only one owner. Read-only. Nullable. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The user that cloud joined the device or registered their personal device. The registered owner is set at the time of registration. Currently, there can be only one owner. Read-only. Nullable. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Devices.Item.RegisteredOwners.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The user that cloud joined the device or registered their personal device. The registered owner is set at the time of registration. Currently, there can be only one owner. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user that cloud joined the device or registered their personal device. The registered owner is set at the time of registration. Currently, there can be only one owner. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Devices.Item.RegisteredOwners.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The user that cloud joined the device or registered their personal device. The registered owner is set at the time of registration. Currently, there can be only one owner. Read-only. Nullable. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Devices/Item/RegisteredOwners/@Ref/RefResponse.cs b/src/generated/Devices/Item/RegisteredOwners/@Ref/RefResponse.cs deleted file mode 100644 index 120eee6e954..00000000000 --- a/src/generated/Devices/Item/RegisteredOwners/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Devices.Item.RegisteredOwners.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Devices/Item/RegisteredOwners/Ref/Ref.cs b/src/generated/Devices/Item/RegisteredOwners/Ref/Ref.cs new file mode 100644 index 00000000000..b3dd2148c01 --- /dev/null +++ b/src/generated/Devices/Item/RegisteredOwners/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Devices.Item.RegisteredOwners.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Devices/Item/RegisteredOwners/Ref/RefRequestBuilder.cs b/src/generated/Devices/Item/RegisteredOwners/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..a74d95500a5 --- /dev/null +++ b/src/generated/Devices/Item/RegisteredOwners/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Devices.Item.RegisteredOwners.Ref { + /// Builds and executes requests for operations under \devices\{device-id}\registeredOwners\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The user that cloud joined the device or registered their personal device. The registered owner is set at the time of registration. Currently, there can be only one owner. Read-only. Nullable. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The user that cloud joined the device or registered their personal device. The registered owner is set at the time of registration. Currently, there can be only one owner. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var deviceIdOption = new Option("--device-id", description: "key: id of device") { + }; + deviceIdOption.IsRequired = true; + command.AddOption(deviceIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The user that cloud joined the device or registered their personal device. The registered owner is set at the time of registration. Currently, there can be only one owner. Read-only. Nullable. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The user that cloud joined the device or registered their personal device. The registered owner is set at the time of registration. Currently, there can be only one owner. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var deviceIdOption = new Option("--device-id", description: "key: id of device") { + }; + deviceIdOption.IsRequired = true; + command.AddOption(deviceIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/devices/{device_id}/registeredOwners/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The user that cloud joined the device or registered their personal device. The registered owner is set at the time of registration. Currently, there can be only one owner. Read-only. Nullable. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The user that cloud joined the device or registered their personal device. The registered owner is set at the time of registration. Currently, there can be only one owner. Read-only. Nullable. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Devices.Item.RegisteredOwners.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The user that cloud joined the device or registered their personal device. The registered owner is set at the time of registration. Currently, there can be only one owner. Read-only. Nullable. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Devices/Item/RegisteredOwners/Ref/RefResponse.cs b/src/generated/Devices/Item/RegisteredOwners/Ref/RefResponse.cs new file mode 100644 index 00000000000..b4fec37c20b --- /dev/null +++ b/src/generated/Devices/Item/RegisteredOwners/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Devices.Item.RegisteredOwners.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Devices/Item/RegisteredOwners/RegisteredOwnersRequestBuilder.cs b/src/generated/Devices/Item/RegisteredOwners/RegisteredOwnersRequestBuilder.cs index cfbf28782c5..cd9c2d81cda 100644 --- a/src/generated/Devices/Item/RegisteredOwners/RegisteredOwnersRequestBuilder.cs +++ b/src/generated/Devices/Item/RegisteredOwners/RegisteredOwnersRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Devices.Item.RegisteredOwners.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Devices.Item.RegisteredOwners.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Devices.Item.RegisteredOwners.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user that cloud joined the device or registered their personal device. The registered owner is set at the time of registration. Currently, there can be only one owner. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The user that cloud joined the device or registered their personal device. The registered owner is set at the time of registration. Currently, there can be only one owner. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Devices/Item/RegisteredUsers/@Ref/@Ref.cs b/src/generated/Devices/Item/RegisteredUsers/@Ref/@Ref.cs deleted file mode 100644 index bc4e5bc896b..00000000000 --- a/src/generated/Devices/Item/RegisteredUsers/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Devices.Item.RegisteredUsers.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Devices/Item/RegisteredUsers/@Ref/RefRequestBuilder.cs b/src/generated/Devices/Item/RegisteredUsers/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 7618c690fb9..00000000000 --- a/src/generated/Devices/Item/RegisteredUsers/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Devices.Item.RegisteredUsers.@Ref { - /// Builds and executes requests for operations under \devices\{device-id}\registeredUsers\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Collection of registered users of the device. For cloud joined devices and registered personal devices, registered users are set to the same value as registered owners at the time of registration. Read-only. Nullable. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Collection of registered users of the device. For cloud joined devices and registered personal devices, registered users are set to the same value as registered owners at the time of registration. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var deviceIdOption = new Option("--device-id", description: "key: id of device") { - }; - deviceIdOption.IsRequired = true; - command.AddOption(deviceIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string deviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Collection of registered users of the device. For cloud joined devices and registered personal devices, registered users are set to the same value as registered owners at the time of registration. Read-only. Nullable. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Collection of registered users of the device. For cloud joined devices and registered personal devices, registered users are set to the same value as registered owners at the time of registration. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var deviceIdOption = new Option("--device-id", description: "key: id of device") { - }; - deviceIdOption.IsRequired = true; - command.AddOption(deviceIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string deviceId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/devices/{device_id}/registeredUsers/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Collection of registered users of the device. For cloud joined devices and registered personal devices, registered users are set to the same value as registered owners at the time of registration. Read-only. Nullable. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Collection of registered users of the device. For cloud joined devices and registered personal devices, registered users are set to the same value as registered owners at the time of registration. Read-only. Nullable. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Devices.Item.RegisteredUsers.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Collection of registered users of the device. For cloud joined devices and registered personal devices, registered users are set to the same value as registered owners at the time of registration. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of registered users of the device. For cloud joined devices and registered personal devices, registered users are set to the same value as registered owners at the time of registration. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Devices.Item.RegisteredUsers.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Collection of registered users of the device. For cloud joined devices and registered personal devices, registered users are set to the same value as registered owners at the time of registration. Read-only. Nullable. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Devices/Item/RegisteredUsers/@Ref/RefResponse.cs b/src/generated/Devices/Item/RegisteredUsers/@Ref/RefResponse.cs deleted file mode 100644 index a1f74e54038..00000000000 --- a/src/generated/Devices/Item/RegisteredUsers/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Devices.Item.RegisteredUsers.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Devices/Item/RegisteredUsers/Ref/Ref.cs b/src/generated/Devices/Item/RegisteredUsers/Ref/Ref.cs new file mode 100644 index 00000000000..dab46c4ea88 --- /dev/null +++ b/src/generated/Devices/Item/RegisteredUsers/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Devices.Item.RegisteredUsers.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Devices/Item/RegisteredUsers/Ref/RefRequestBuilder.cs b/src/generated/Devices/Item/RegisteredUsers/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..7683c47a865 --- /dev/null +++ b/src/generated/Devices/Item/RegisteredUsers/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Devices.Item.RegisteredUsers.Ref { + /// Builds and executes requests for operations under \devices\{device-id}\registeredUsers\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Collection of registered users of the device. For cloud joined devices and registered personal devices, registered users are set to the same value as registered owners at the time of registration. Read-only. Nullable. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Collection of registered users of the device. For cloud joined devices and registered personal devices, registered users are set to the same value as registered owners at the time of registration. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var deviceIdOption = new Option("--device-id", description: "key: id of device") { + }; + deviceIdOption.IsRequired = true; + command.AddOption(deviceIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Collection of registered users of the device. For cloud joined devices and registered personal devices, registered users are set to the same value as registered owners at the time of registration. Read-only. Nullable. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Collection of registered users of the device. For cloud joined devices and registered personal devices, registered users are set to the same value as registered owners at the time of registration. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var deviceIdOption = new Option("--device-id", description: "key: id of device") { + }; + deviceIdOption.IsRequired = true; + command.AddOption(deviceIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/devices/{device_id}/registeredUsers/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Collection of registered users of the device. For cloud joined devices and registered personal devices, registered users are set to the same value as registered owners at the time of registration. Read-only. Nullable. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Collection of registered users of the device. For cloud joined devices and registered personal devices, registered users are set to the same value as registered owners at the time of registration. Read-only. Nullable. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Devices.Item.RegisteredUsers.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Collection of registered users of the device. For cloud joined devices and registered personal devices, registered users are set to the same value as registered owners at the time of registration. Read-only. Nullable. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Devices/Item/RegisteredUsers/Ref/RefResponse.cs b/src/generated/Devices/Item/RegisteredUsers/Ref/RefResponse.cs new file mode 100644 index 00000000000..262041da2da --- /dev/null +++ b/src/generated/Devices/Item/RegisteredUsers/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Devices.Item.RegisteredUsers.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Devices/Item/RegisteredUsers/RegisteredUsersRequestBuilder.cs b/src/generated/Devices/Item/RegisteredUsers/RegisteredUsersRequestBuilder.cs index 327b98e654e..ab47a3a3a6c 100644 --- a/src/generated/Devices/Item/RegisteredUsers/RegisteredUsersRequestBuilder.cs +++ b/src/generated/Devices/Item/RegisteredUsers/RegisteredUsersRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Devices.Item.RegisteredUsers.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Devices.Item.RegisteredUsers.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Devices.Item.RegisteredUsers.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of registered users of the device. For cloud joined devices and registered personal devices, registered users are set to the same value as registered owners at the time of registration. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of registered users of the device. For cloud joined devices and registered personal devices, registered users are set to the same value as registered owners at the time of registration. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Devices/Item/Restore/RestoreRequestBuilder.cs b/src/generated/Devices/Item/Restore/RestoreRequestBuilder.cs index f00d6d179e9..0461891bf9c 100644 --- a/src/generated/Devices/Item/Restore/RestoreRequestBuilder.cs +++ b/src/generated/Devices/Item/Restore/RestoreRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildPostCommand() { }; deviceIdOption.IsRequired = true; command.AddOption(deviceIdOption); - command.SetHandler(async (string deviceId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action restore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes directoryObject public class RestoreResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Devices/Item/TransitiveMemberOf/@Ref/@Ref.cs b/src/generated/Devices/Item/TransitiveMemberOf/@Ref/@Ref.cs deleted file mode 100644 index 4545ddeec22..00000000000 --- a/src/generated/Devices/Item/TransitiveMemberOf/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Devices.Item.TransitiveMemberOf.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Devices/Item/TransitiveMemberOf/@Ref/RefRequestBuilder.cs b/src/generated/Devices/Item/TransitiveMemberOf/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 6da8992a32d..00000000000 --- a/src/generated/Devices/Item/TransitiveMemberOf/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Devices.Item.TransitiveMemberOf.@Ref { - /// Builds and executes requests for operations under \devices\{device-id}\transitiveMemberOf\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Groups that this device is a member of. This operation is transitive. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Groups that this device is a member of. This operation is transitive. Supports $expand."; - // Create options for all the parameters - var deviceIdOption = new Option("--device-id", description: "key: id of device") { - }; - deviceIdOption.IsRequired = true; - command.AddOption(deviceIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string deviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Groups that this device is a member of. This operation is transitive. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Groups that this device is a member of. This operation is transitive. Supports $expand."; - // Create options for all the parameters - var deviceIdOption = new Option("--device-id", description: "key: id of device") { - }; - deviceIdOption.IsRequired = true; - command.AddOption(deviceIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string deviceId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/devices/{device_id}/transitiveMemberOf/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Groups that this device is a member of. This operation is transitive. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Groups that this device is a member of. This operation is transitive. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Devices.Item.TransitiveMemberOf.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Groups that this device is a member of. This operation is transitive. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Groups that this device is a member of. This operation is transitive. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Devices.Item.TransitiveMemberOf.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Groups that this device is a member of. This operation is transitive. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Devices/Item/TransitiveMemberOf/@Ref/RefResponse.cs b/src/generated/Devices/Item/TransitiveMemberOf/@Ref/RefResponse.cs deleted file mode 100644 index 3e61fd662ed..00000000000 --- a/src/generated/Devices/Item/TransitiveMemberOf/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Devices.Item.TransitiveMemberOf.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Devices/Item/TransitiveMemberOf/Ref/Ref.cs b/src/generated/Devices/Item/TransitiveMemberOf/Ref/Ref.cs new file mode 100644 index 00000000000..bdfcde37c46 --- /dev/null +++ b/src/generated/Devices/Item/TransitiveMemberOf/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Devices.Item.TransitiveMemberOf.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Devices/Item/TransitiveMemberOf/Ref/RefRequestBuilder.cs b/src/generated/Devices/Item/TransitiveMemberOf/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..8b8d690b057 --- /dev/null +++ b/src/generated/Devices/Item/TransitiveMemberOf/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Devices.Item.TransitiveMemberOf.Ref { + /// Builds and executes requests for operations under \devices\{device-id}\transitiveMemberOf\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Groups that this device is a member of. This operation is transitive. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Groups that this device is a member of. This operation is transitive. Supports $expand."; + // Create options for all the parameters + var deviceIdOption = new Option("--device-id", description: "key: id of device") { + }; + deviceIdOption.IsRequired = true; + command.AddOption(deviceIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Groups that this device is a member of. This operation is transitive. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Groups that this device is a member of. This operation is transitive. Supports $expand."; + // Create options for all the parameters + var deviceIdOption = new Option("--device-id", description: "key: id of device") { + }; + deviceIdOption.IsRequired = true; + command.AddOption(deviceIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/devices/{device_id}/transitiveMemberOf/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Groups that this device is a member of. This operation is transitive. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Groups that this device is a member of. This operation is transitive. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Devices.Item.TransitiveMemberOf.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Groups that this device is a member of. This operation is transitive. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Devices/Item/TransitiveMemberOf/Ref/RefResponse.cs b/src/generated/Devices/Item/TransitiveMemberOf/Ref/RefResponse.cs new file mode 100644 index 00000000000..03ff983d824 --- /dev/null +++ b/src/generated/Devices/Item/TransitiveMemberOf/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Devices.Item.TransitiveMemberOf.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Devices/Item/TransitiveMemberOf/TransitiveMemberOfRequestBuilder.cs b/src/generated/Devices/Item/TransitiveMemberOf/TransitiveMemberOfRequestBuilder.cs index b84e906e7a2..da25a4ceb60 100644 --- a/src/generated/Devices/Item/TransitiveMemberOf/TransitiveMemberOfRequestBuilder.cs +++ b/src/generated/Devices/Item/TransitiveMemberOf/TransitiveMemberOfRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Devices.Item.TransitiveMemberOf.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Devices.Item.TransitiveMemberOf.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Devices.Item.TransitiveMemberOf.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Groups that this device is a member of. This operation is transitive. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Groups that this device is a member of. This operation is transitive. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Devices/ValidateProperties/ValidatePropertiesRequestBuilder.cs b/src/generated/Devices/ValidateProperties/ValidatePropertiesRequestBuilder.cs index 19b3f7ab56c..37b29656216 100644 --- a/src/generated/Devices/ValidateProperties/ValidatePropertiesRequestBuilder.cs +++ b/src/generated/Devices/ValidateProperties/ValidatePropertiesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,14 +29,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -72,18 +71,5 @@ public RequestInformation CreatePostRequestInformation(ValidatePropertiesRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action validateProperties - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ValidatePropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Directory/AdministrativeUnits/AdministrativeUnitsRequestBuilder.cs b/src/generated/Directory/AdministrativeUnits/AdministrativeUnitsRequestBuilder.cs index ff268569c0b..2384b262c87 100644 --- a/src/generated/Directory/AdministrativeUnits/AdministrativeUnitsRequestBuilder.cs +++ b/src/generated/Directory/AdministrativeUnits/AdministrativeUnitsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,14 +23,13 @@ public class AdministrativeUnitsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AdministrativeUnitRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildExtensionsCommand(), - builder.BuildGetCommand(), - builder.BuildMembersCommand(), - builder.BuildPatchCommand(), - builder.BuildScopedRoleMembersCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildMembersCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildScopedRoleMembersCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -103,7 +101,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -114,15 +116,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -183,31 +180,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// Conceptual container for user and group directory objects. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Conceptual container for user and group directory objects. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.AdministrativeUnit model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Conceptual container for user and group directory objects. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Directory/AdministrativeUnits/Delta/DeltaRequestBuilder.cs b/src/generated/Directory/AdministrativeUnits/Delta/DeltaRequestBuilder.cs index 60d3ada7874..b1d5afc1e53 100644 --- a/src/generated/Directory/AdministrativeUnits/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Directory/AdministrativeUnits/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Directory/AdministrativeUnits/Item/AdministrativeUnitRequestBuilder.cs b/src/generated/Directory/AdministrativeUnits/Item/AdministrativeUnitRequestBuilder.cs index 26a67d21d38..a391c91d5c4 100644 --- a/src/generated/Directory/AdministrativeUnits/Item/AdministrativeUnitRequestBuilder.cs +++ b/src/generated/Directory/AdministrativeUnits/Item/AdministrativeUnitRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Conceptual container for user and group directory objects."; // Create options for all the parameters - var administrativeUnitIdOption = new Option("--administrativeunit-id", description: "key: id of administrativeUnit") { + var administrativeUnitIdOption = new Option("--administrative-unit-id", description: "key: id of administrativeUnit") { }; administrativeUnitIdOption.IsRequired = true; command.AddOption(administrativeUnitIdOption); - command.SetHandler(async (string administrativeUnitId) => { + command.SetHandler(async (string administrativeUnitId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, administrativeUnitIdOption); return command; @@ -45,6 +44,9 @@ public Command BuildDeleteCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Directory.AdministrativeUnits.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -56,7 +58,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Conceptual container for user and group directory objects."; // Create options for all the parameters - var administrativeUnitIdOption = new Option("--administrativeunit-id", description: "key: id of administrativeUnit") { + var administrativeUnitIdOption = new Option("--administrative-unit-id", description: "key: id of administrativeUnit") { }; administrativeUnitIdOption.IsRequired = true; command.AddOption(administrativeUnitIdOption); @@ -70,20 +72,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string administrativeUnitId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string administrativeUnitId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, administrativeUnitIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, administrativeUnitIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildMembersCommand() { @@ -100,7 +101,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Conceptual container for user and group directory objects."; // Create options for all the parameters - var administrativeUnitIdOption = new Option("--administrativeunit-id", description: "key: id of administrativeUnit") { + var administrativeUnitIdOption = new Option("--administrative-unit-id", description: "key: id of administrativeUnit") { }; administrativeUnitIdOption.IsRequired = true; command.AddOption(administrativeUnitIdOption); @@ -108,14 +109,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string administrativeUnitId, string body) => { + command.SetHandler(async (string administrativeUnitId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, administrativeUnitIdOption, bodyOption); return command; @@ -123,6 +123,9 @@ public Command BuildPatchCommand() { public Command BuildScopedRoleMembersCommand() { var command = new Command("scoped-role-members"); var builder = new ApiSdk.Directory.AdministrativeUnits.Item.ScopedRoleMembers.ScopedRoleMembersRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -194,42 +197,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Conceptual container for user and group directory objects. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Conceptual container for user and group directory objects. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Conceptual container for user and group directory objects. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.AdministrativeUnit model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Conceptual container for user and group directory objects. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Directory/AdministrativeUnits/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Directory/AdministrativeUnits/Item/Extensions/ExtensionsRequestBuilder.cs index a7a4d3e4dca..7801318901d 100644 --- a/src/generated/Directory/AdministrativeUnits/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Directory/AdministrativeUnits/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of open extensions defined for this administrative unit. Nullable."; // Create options for all the parameters - var administrativeUnitIdOption = new Option("--administrativeunit-id", description: "key: id of administrativeUnit") { + var administrativeUnitIdOption = new Option("--administrative-unit-id", description: "key: id of administrativeUnit") { }; administrativeUnitIdOption.IsRequired = true; command.AddOption(administrativeUnitIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string administrativeUnitId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string administrativeUnitId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, administrativeUnitIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, administrativeUnitIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of open extensions defined for this administrative unit. Nullable."; // Create options for all the parameters - var administrativeUnitIdOption = new Option("--administrativeunit-id", description: "key: id of administrativeUnit") { + var administrativeUnitIdOption = new Option("--administrative-unit-id", description: "key: id of administrativeUnit") { }; administrativeUnitIdOption.IsRequired = true; command.AddOption(administrativeUnitIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string administrativeUnitId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string administrativeUnitId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, administrativeUnitIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, administrativeUnitIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for this administrative unit. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for this administrative unit. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for this administrative unit. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Directory/AdministrativeUnits/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Directory/AdministrativeUnits/Item/Extensions/Item/ExtensionRequestBuilder.cs index 1b1f837ae7d..253dfaa2bee 100644 --- a/src/generated/Directory/AdministrativeUnits/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Directory/AdministrativeUnits/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of open extensions defined for this administrative unit. Nullable."; // Create options for all the parameters - var administrativeUnitIdOption = new Option("--administrativeunit-id", description: "key: id of administrativeUnit") { + var administrativeUnitIdOption = new Option("--administrative-unit-id", description: "key: id of administrativeUnit") { }; administrativeUnitIdOption.IsRequired = true; command.AddOption(administrativeUnitIdOption); @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string administrativeUnitId, string extensionId) => { + command.SetHandler(async (string administrativeUnitId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, administrativeUnitIdOption, extensionIdOption); return command; @@ -50,7 +49,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of open extensions defined for this administrative unit. Nullable."; // Create options for all the parameters - var administrativeUnitIdOption = new Option("--administrativeunit-id", description: "key: id of administrativeUnit") { + var administrativeUnitIdOption = new Option("--administrative-unit-id", description: "key: id of administrativeUnit") { }; administrativeUnitIdOption.IsRequired = true; command.AddOption(administrativeUnitIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string administrativeUnitId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string administrativeUnitId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, administrativeUnitIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, administrativeUnitIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,7 +89,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of open extensions defined for this administrative unit. Nullable."; // Create options for all the parameters - var administrativeUnitIdOption = new Option("--administrativeunit-id", description: "key: id of administrativeUnit") { + var administrativeUnitIdOption = new Option("--administrative-unit-id", description: "key: id of administrativeUnit") { }; administrativeUnitIdOption.IsRequired = true; command.AddOption(administrativeUnitIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string administrativeUnitId, string extensionId, string body) => { + command.SetHandler(async (string administrativeUnitId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, administrativeUnitIdOption, extensionIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for this administrative unit. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for this administrative unit. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for this administrative unit. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for this administrative unit. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Directory/AdministrativeUnits/Item/Members/@Ref/@Ref.cs b/src/generated/Directory/AdministrativeUnits/Item/Members/@Ref/@Ref.cs deleted file mode 100644 index b3b4c546de5..00000000000 --- a/src/generated/Directory/AdministrativeUnits/Item/Members/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Directory.AdministrativeUnits.Item.Members.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Directory/AdministrativeUnits/Item/Members/@Ref/RefRequestBuilder.cs b/src/generated/Directory/AdministrativeUnits/Item/Members/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 768adc7b961..00000000000 --- a/src/generated/Directory/AdministrativeUnits/Item/Members/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Directory.AdministrativeUnits.Item.Members.@Ref { - /// Builds and executes requests for operations under \directory\administrativeUnits\{administrativeUnit-id}\members\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Users and groups that are members of this administrative unit. HTTP Methods: GET (list members), POST (add members), DELETE (remove members). - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Users and groups that are members of this administrative unit. HTTP Methods: GET (list members), POST (add members), DELETE (remove members)."; - // Create options for all the parameters - var administrativeUnitIdOption = new Option("--administrativeunit-id", description: "key: id of administrativeUnit") { - }; - administrativeUnitIdOption.IsRequired = true; - command.AddOption(administrativeUnitIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string administrativeUnitId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, administrativeUnitIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Users and groups that are members of this administrative unit. HTTP Methods: GET (list members), POST (add members), DELETE (remove members). - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Users and groups that are members of this administrative unit. HTTP Methods: GET (list members), POST (add members), DELETE (remove members)."; - // Create options for all the parameters - var administrativeUnitIdOption = new Option("--administrativeunit-id", description: "key: id of administrativeUnit") { - }; - administrativeUnitIdOption.IsRequired = true; - command.AddOption(administrativeUnitIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string administrativeUnitId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, administrativeUnitIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/directory/administrativeUnits/{administrativeUnit_id}/members/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Users and groups that are members of this administrative unit. HTTP Methods: GET (list members), POST (add members), DELETE (remove members). - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Users and groups that are members of this administrative unit. HTTP Methods: GET (list members), POST (add members), DELETE (remove members). - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Directory.AdministrativeUnits.Item.Members.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Users and groups that are members of this administrative unit. HTTP Methods: GET (list members), POST (add members), DELETE (remove members). - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Users and groups that are members of this administrative unit. HTTP Methods: GET (list members), POST (add members), DELETE (remove members). - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Directory.AdministrativeUnits.Item.Members.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Users and groups that are members of this administrative unit. HTTP Methods: GET (list members), POST (add members), DELETE (remove members). - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Directory/AdministrativeUnits/Item/Members/@Ref/RefResponse.cs b/src/generated/Directory/AdministrativeUnits/Item/Members/@Ref/RefResponse.cs deleted file mode 100644 index f35a91c9c52..00000000000 --- a/src/generated/Directory/AdministrativeUnits/Item/Members/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Directory.AdministrativeUnits.Item.Members.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Directory/AdministrativeUnits/Item/Members/MembersRequestBuilder.cs b/src/generated/Directory/AdministrativeUnits/Item/Members/MembersRequestBuilder.cs index 498f929e07f..36c9edc41b0 100644 --- a/src/generated/Directory/AdministrativeUnits/Item/Members/MembersRequestBuilder.cs +++ b/src/generated/Directory/AdministrativeUnits/Item/Members/MembersRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Directory.AdministrativeUnits.Item.Members.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -20,13 +20,13 @@ public class MembersRequestBuilder { /// Url template to use to build the URL for the current request builder private string UrlTemplate { get; set; } /// - /// Users and groups that are members of this administrative unit. HTTP Methods: GET (list members), POST (add members), DELETE (remove members). + /// Users and groups that are members of this administrative unit. Supports $expand. /// public Command BuildGetCommand() { var command = new Command("get"); - command.Description = "Users and groups that are members of this administrative unit. HTTP Methods: GET (list members), POST (add members), DELETE (remove members)."; + command.Description = "Users and groups that are members of this administrative unit. Supports $expand."; // Create options for all the parameters - var administrativeUnitIdOption = new Option("--administrativeunit-id", description: "key: id of administrativeUnit") { + var administrativeUnitIdOption = new Option("--administrative-unit-id", description: "key: id of administrativeUnit") { }; administrativeUnitIdOption.IsRequired = true; command.AddOption(administrativeUnitIdOption); @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string administrativeUnitId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string administrativeUnitId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, administrativeUnitIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, administrativeUnitIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Directory.AdministrativeUnits.Item.Members.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Directory.AdministrativeUnits.Item.Members.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -108,7 +107,7 @@ public MembersRequestBuilder(Dictionary pathParameters, IRequest RequestAdapter = requestAdapter; } /// - /// Users and groups that are members of this administrative unit. HTTP Methods: GET (list members), POST (add members), DELETE (remove members). + /// Users and groups that are members of this administrative unit. Supports $expand. /// Request headers /// Request options /// Request query parameters @@ -128,19 +127,7 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Users and groups that are members of this administrative unit. HTTP Methods: GET (list members), POST (add members), DELETE (remove members). - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Users and groups that are members of this administrative unit. HTTP Methods: GET (list members), POST (add members), DELETE (remove members). + /// Users and groups that are members of this administrative unit. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items public bool? Count { get; set; } diff --git a/src/generated/Directory/AdministrativeUnits/Item/Members/Ref/Ref.cs b/src/generated/Directory/AdministrativeUnits/Item/Members/Ref/Ref.cs new file mode 100644 index 00000000000..872eb8d94af --- /dev/null +++ b/src/generated/Directory/AdministrativeUnits/Item/Members/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Directory.AdministrativeUnits.Item.Members.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Directory/AdministrativeUnits/Item/Members/Ref/RefRequestBuilder.cs b/src/generated/Directory/AdministrativeUnits/Item/Members/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..24eb816b304 --- /dev/null +++ b/src/generated/Directory/AdministrativeUnits/Item/Members/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Directory.AdministrativeUnits.Item.Members.Ref { + /// Builds and executes requests for operations under \directory\administrativeUnits\{administrativeUnit-id}\members\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Users and groups that are members of this administrative unit. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Users and groups that are members of this administrative unit. Supports $expand."; + // Create options for all the parameters + var administrativeUnitIdOption = new Option("--administrative-unit-id", description: "key: id of administrativeUnit") { + }; + administrativeUnitIdOption.IsRequired = true; + command.AddOption(administrativeUnitIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string administrativeUnitId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, administrativeUnitIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Users and groups that are members of this administrative unit. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Users and groups that are members of this administrative unit. Supports $expand."; + // Create options for all the parameters + var administrativeUnitIdOption = new Option("--administrative-unit-id", description: "key: id of administrativeUnit") { + }; + administrativeUnitIdOption.IsRequired = true; + command.AddOption(administrativeUnitIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string administrativeUnitId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, administrativeUnitIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/directory/administrativeUnits/{administrativeUnit_id}/members/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Users and groups that are members of this administrative unit. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Users and groups that are members of this administrative unit. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Directory.AdministrativeUnits.Item.Members.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Users and groups that are members of this administrative unit. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Directory/AdministrativeUnits/Item/Members/Ref/RefResponse.cs b/src/generated/Directory/AdministrativeUnits/Item/Members/Ref/RefResponse.cs new file mode 100644 index 00000000000..bbdd358601d --- /dev/null +++ b/src/generated/Directory/AdministrativeUnits/Item/Members/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Directory.AdministrativeUnits.Item.Members.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Directory/AdministrativeUnits/Item/ScopedRoleMembers/Item/ScopedRoleMembershipRequestBuilder.cs b/src/generated/Directory/AdministrativeUnits/Item/ScopedRoleMembers/Item/ScopedRoleMembershipRequestBuilder.cs index 2cbcd444bdb..199d976b0ac 100644 --- a/src/generated/Directory/AdministrativeUnits/Item/ScopedRoleMembers/Item/ScopedRoleMembershipRequestBuilder.cs +++ b/src/generated/Directory/AdministrativeUnits/Item/ScopedRoleMembers/Item/ScopedRoleMembershipRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -20,41 +20,40 @@ public class ScopedRoleMembershipRequestBuilder { /// Url template to use to build the URL for the current request builder private string UrlTemplate { get; set; } /// - /// Scoped-role members of this administrative unit. HTTP Methods: GET (list scopedRoleMemberships), POST (add scopedRoleMembership), DELETE (remove scopedRoleMembership). + /// Scoped-role members of this administrative unit. /// public Command BuildDeleteCommand() { var command = new Command("delete"); - command.Description = "Scoped-role members of this administrative unit. HTTP Methods: GET (list scopedRoleMemberships), POST (add scopedRoleMembership), DELETE (remove scopedRoleMembership)."; + command.Description = "Scoped-role members of this administrative unit."; // Create options for all the parameters - var administrativeUnitIdOption = new Option("--administrativeunit-id", description: "key: id of administrativeUnit") { + var administrativeUnitIdOption = new Option("--administrative-unit-id", description: "key: id of administrativeUnit") { }; administrativeUnitIdOption.IsRequired = true; command.AddOption(administrativeUnitIdOption); - var scopedRoleMembershipIdOption = new Option("--scopedrolemembership-id", description: "key: id of scopedRoleMembership") { + var scopedRoleMembershipIdOption = new Option("--scoped-role-membership-id", description: "key: id of scopedRoleMembership") { }; scopedRoleMembershipIdOption.IsRequired = true; command.AddOption(scopedRoleMembershipIdOption); - command.SetHandler(async (string administrativeUnitId, string scopedRoleMembershipId) => { + command.SetHandler(async (string administrativeUnitId, string scopedRoleMembershipId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, administrativeUnitIdOption, scopedRoleMembershipIdOption); return command; } /// - /// Scoped-role members of this administrative unit. HTTP Methods: GET (list scopedRoleMemberships), POST (add scopedRoleMembership), DELETE (remove scopedRoleMembership). + /// Scoped-role members of this administrative unit. /// public Command BuildGetCommand() { var command = new Command("get"); - command.Description = "Scoped-role members of this administrative unit. HTTP Methods: GET (list scopedRoleMemberships), POST (add scopedRoleMembership), DELETE (remove scopedRoleMembership)."; + command.Description = "Scoped-role members of this administrative unit."; // Create options for all the parameters - var administrativeUnitIdOption = new Option("--administrativeunit-id", description: "key: id of administrativeUnit") { + var administrativeUnitIdOption = new Option("--administrative-unit-id", description: "key: id of administrativeUnit") { }; administrativeUnitIdOption.IsRequired = true; command.AddOption(administrativeUnitIdOption); - var scopedRoleMembershipIdOption = new Option("--scopedrolemembership-id", description: "key: id of scopedRoleMembership") { + var scopedRoleMembershipIdOption = new Option("--scoped-role-membership-id", description: "key: id of scopedRoleMembership") { }; scopedRoleMembershipIdOption.IsRequired = true; command.AddOption(scopedRoleMembershipIdOption); @@ -68,34 +67,33 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string administrativeUnitId, string scopedRoleMembershipId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string administrativeUnitId, string scopedRoleMembershipId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, administrativeUnitIdOption, scopedRoleMembershipIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, administrativeUnitIdOption, scopedRoleMembershipIdOption, selectOption, expandOption, outputOption); return command; } /// - /// Scoped-role members of this administrative unit. HTTP Methods: GET (list scopedRoleMemberships), POST (add scopedRoleMembership), DELETE (remove scopedRoleMembership). + /// Scoped-role members of this administrative unit. /// public Command BuildPatchCommand() { var command = new Command("patch"); - command.Description = "Scoped-role members of this administrative unit. HTTP Methods: GET (list scopedRoleMemberships), POST (add scopedRoleMembership), DELETE (remove scopedRoleMembership)."; + command.Description = "Scoped-role members of this administrative unit."; // Create options for all the parameters - var administrativeUnitIdOption = new Option("--administrativeunit-id", description: "key: id of administrativeUnit") { + var administrativeUnitIdOption = new Option("--administrative-unit-id", description: "key: id of administrativeUnit") { }; administrativeUnitIdOption.IsRequired = true; command.AddOption(administrativeUnitIdOption); - var scopedRoleMembershipIdOption = new Option("--scopedrolemembership-id", description: "key: id of scopedRoleMembership") { + var scopedRoleMembershipIdOption = new Option("--scoped-role-membership-id", description: "key: id of scopedRoleMembership") { }; scopedRoleMembershipIdOption.IsRequired = true; command.AddOption(scopedRoleMembershipIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string administrativeUnitId, string scopedRoleMembershipId, string body) => { + command.SetHandler(async (string administrativeUnitId, string scopedRoleMembershipId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, administrativeUnitIdOption, scopedRoleMembershipIdOption, bodyOption); return command; @@ -129,7 +126,7 @@ public ScopedRoleMembershipRequestBuilder(Dictionary pathParamet RequestAdapter = requestAdapter; } /// - /// Scoped-role members of this administrative unit. HTTP Methods: GET (list scopedRoleMemberships), POST (add scopedRoleMembership), DELETE (remove scopedRoleMembership). + /// Scoped-role members of this administrative unit. /// Request headers /// Request options /// @@ -144,7 +141,7 @@ public RequestInformation CreateDeleteRequestInformation(Action - /// Scoped-role members of this administrative unit. HTTP Methods: GET (list scopedRoleMemberships), POST (add scopedRoleMembership), DELETE (remove scopedRoleMembership). + /// Scoped-role members of this administrative unit. /// Request headers /// Request options /// Request query parameters @@ -165,7 +162,7 @@ public RequestInformation CreateGetRequestInformation(Action return requestInfo; } /// - /// Scoped-role members of this administrative unit. HTTP Methods: GET (list scopedRoleMemberships), POST (add scopedRoleMembership), DELETE (remove scopedRoleMembership). + /// Scoped-role members of this administrative unit. /// /// Request headers /// Request options @@ -182,43 +179,7 @@ public RequestInformation CreatePatchRequestInformation(ScopedRoleMembership bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Scoped-role members of this administrative unit. HTTP Methods: GET (list scopedRoleMemberships), POST (add scopedRoleMembership), DELETE (remove scopedRoleMembership). - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Scoped-role members of this administrative unit. HTTP Methods: GET (list scopedRoleMemberships), POST (add scopedRoleMembership), DELETE (remove scopedRoleMembership). - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Scoped-role members of this administrative unit. HTTP Methods: GET (list scopedRoleMemberships), POST (add scopedRoleMembership), DELETE (remove scopedRoleMembership). - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ScopedRoleMembership model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// Scoped-role members of this administrative unit. HTTP Methods: GET (list scopedRoleMemberships), POST (add scopedRoleMembership), DELETE (remove scopedRoleMembership). + /// Scoped-role members of this administrative unit. public class GetQueryParameters : QueryParametersBase { /// Expand related entities public string[] Expand { get; set; } diff --git a/src/generated/Directory/AdministrativeUnits/Item/ScopedRoleMembers/ScopedRoleMembersRequestBuilder.cs b/src/generated/Directory/AdministrativeUnits/Item/ScopedRoleMembers/ScopedRoleMembersRequestBuilder.cs index 77acaf1c44b..ecad5cd79e6 100644 --- a/src/generated/Directory/AdministrativeUnits/Item/ScopedRoleMembers/ScopedRoleMembersRequestBuilder.cs +++ b/src/generated/Directory/AdministrativeUnits/Item/ScopedRoleMembers/ScopedRoleMembersRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,21 +22,20 @@ public class ScopedRoleMembersRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ScopedRoleMembershipRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// - /// Scoped-role members of this administrative unit. HTTP Methods: GET (list scopedRoleMemberships), POST (add scopedRoleMembership), DELETE (remove scopedRoleMembership). + /// Scoped-role members of this administrative unit. /// public Command BuildCreateCommand() { var command = new Command("create"); - command.Description = "Scoped-role members of this administrative unit. HTTP Methods: GET (list scopedRoleMemberships), POST (add scopedRoleMembership), DELETE (remove scopedRoleMembership)."; + command.Description = "Scoped-role members of this administrative unit."; // Create options for all the parameters - var administrativeUnitIdOption = new Option("--administrativeunit-id", description: "key: id of administrativeUnit") { + var administrativeUnitIdOption = new Option("--administrative-unit-id", description: "key: id of administrativeUnit") { }; administrativeUnitIdOption.IsRequired = true; command.AddOption(administrativeUnitIdOption); @@ -44,31 +43,30 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string administrativeUnitId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string administrativeUnitId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, administrativeUnitIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, administrativeUnitIdOption, bodyOption, outputOption); return command; } /// - /// Scoped-role members of this administrative unit. HTTP Methods: GET (list scopedRoleMemberships), POST (add scopedRoleMembership), DELETE (remove scopedRoleMembership). + /// Scoped-role members of this administrative unit. /// public Command BuildListCommand() { var command = new Command("list"); - command.Description = "Scoped-role members of this administrative unit. HTTP Methods: GET (list scopedRoleMemberships), POST (add scopedRoleMembership), DELETE (remove scopedRoleMembership)."; + command.Description = "Scoped-role members of this administrative unit."; // Create options for all the parameters - var administrativeUnitIdOption = new Option("--administrativeunit-id", description: "key: id of administrativeUnit") { + var administrativeUnitIdOption = new Option("--administrative-unit-id", description: "key: id of administrativeUnit") { }; administrativeUnitIdOption.IsRequired = true; command.AddOption(administrativeUnitIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string administrativeUnitId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string administrativeUnitId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, administrativeUnitIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, administrativeUnitIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -143,7 +140,7 @@ public ScopedRoleMembersRequestBuilder(Dictionary pathParameters RequestAdapter = requestAdapter; } /// - /// Scoped-role members of this administrative unit. HTTP Methods: GET (list scopedRoleMemberships), POST (add scopedRoleMembership), DELETE (remove scopedRoleMembership). + /// Scoped-role members of this administrative unit. /// Request headers /// Request options /// Request query parameters @@ -164,7 +161,7 @@ public RequestInformation CreateGetRequestInformation(Action return requestInfo; } /// - /// Scoped-role members of this administrative unit. HTTP Methods: GET (list scopedRoleMemberships), POST (add scopedRoleMembership), DELETE (remove scopedRoleMembership). + /// Scoped-role members of this administrative unit. /// /// Request headers /// Request options @@ -181,32 +178,7 @@ public RequestInformation CreatePostRequestInformation(ScopedRoleMembership body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Scoped-role members of this administrative unit. HTTP Methods: GET (list scopedRoleMemberships), POST (add scopedRoleMembership), DELETE (remove scopedRoleMembership). - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Scoped-role members of this administrative unit. HTTP Methods: GET (list scopedRoleMemberships), POST (add scopedRoleMembership), DELETE (remove scopedRoleMembership). - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ScopedRoleMembership model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Scoped-role members of this administrative unit. HTTP Methods: GET (list scopedRoleMemberships), POST (add scopedRoleMembership), DELETE (remove scopedRoleMembership). + /// Scoped-role members of this administrative unit. public class GetQueryParameters : QueryParametersBase { /// Include count of items public bool? Count { get; set; } diff --git a/src/generated/Directory/DeletedItems/DeletedItemsRequestBuilder.cs b/src/generated/Directory/DeletedItems/DeletedItemsRequestBuilder.cs index f8edb2c0b78..6a2e8c426d6 100644 --- a/src/generated/Directory/DeletedItems/DeletedItemsRequestBuilder.cs +++ b/src/generated/Directory/DeletedItems/DeletedItemsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DeletedItemsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DirectoryObjectRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(DirectoryObject body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Recently deleted items. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Recently deleted items. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DirectoryObject model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Recently deleted items. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Directory/DeletedItems/Item/DirectoryObjectRequestBuilder.cs b/src/generated/Directory/DeletedItems/Item/DirectoryObjectRequestBuilder.cs index feb0e4a19fb..0a5304e0563 100644 --- a/src/generated/Directory/DeletedItems/Item/DirectoryObjectRequestBuilder.cs +++ b/src/generated/Directory/DeletedItems/Item/DirectoryObjectRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Recently deleted items. Read-only. Nullable."; // Create options for all the parameters - var directoryObjectIdOption = new Option("--directoryobject-id", description: "key: id of directoryObject") { + var directoryObjectIdOption = new Option("--directory-object-id", description: "key: id of directoryObject") { }; directoryObjectIdOption.IsRequired = true; command.AddOption(directoryObjectIdOption); - command.SetHandler(async (string directoryObjectId) => { + command.SetHandler(async (string directoryObjectId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, directoryObjectIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Recently deleted items. Read-only. Nullable."; // Create options for all the parameters - var directoryObjectIdOption = new Option("--directoryobject-id", description: "key: id of directoryObject") { + var directoryObjectIdOption = new Option("--directory-object-id", description: "key: id of directoryObject") { }; directoryObjectIdOption.IsRequired = true; command.AddOption(directoryObjectIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string directoryObjectId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string directoryObjectId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, directoryObjectIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, directoryObjectIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Recently deleted items. Read-only. Nullable."; // Create options for all the parameters - var directoryObjectIdOption = new Option("--directoryobject-id", description: "key: id of directoryObject") { + var directoryObjectIdOption = new Option("--directory-object-id", description: "key: id of directoryObject") { }; directoryObjectIdOption.IsRequired = true; command.AddOption(directoryObjectIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string directoryObjectId, string body) => { + command.SetHandler(async (string directoryObjectId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, directoryObjectIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(DirectoryObject body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Recently deleted items. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Recently deleted items. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Recently deleted items. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DirectoryObject model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Recently deleted items. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Directory/DirectoryRequestBuilder.cs b/src/generated/Directory/DirectoryRequestBuilder.cs index b6f824946cb..9e7b5dc828a 100644 --- a/src/generated/Directory/DirectoryRequestBuilder.cs +++ b/src/generated/Directory/DirectoryRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -24,6 +24,9 @@ public class DirectoryRequestBuilder { public Command BuildAdministrativeUnitsCommand() { var command = new Command("administrative-units"); var builder = new ApiSdk.Directory.AdministrativeUnits.AdministrativeUnitsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -31,6 +34,9 @@ public Command BuildAdministrativeUnitsCommand() { public Command BuildDeletedItemsCommand() { var command = new Command("deleted-items"); var builder = new ApiSdk.Directory.DeletedItems.DeletedItemsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -52,20 +58,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -79,14 +84,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -143,31 +147,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get directory - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update directory - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Directory model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get directory public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DirectoryObjects/DirectoryObjectsRequestBuilder.cs b/src/generated/DirectoryObjects/DirectoryObjectsRequestBuilder.cs index 227d7cbbdca..b8d18b9a15c 100644 --- a/src/generated/DirectoryObjects/DirectoryObjectsRequestBuilder.cs +++ b/src/generated/DirectoryObjects/DirectoryObjectsRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,16 +25,15 @@ public class DirectoryObjectsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DirectoryObjectRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCheckMemberGroupsCommand(), - builder.BuildCheckMemberObjectsCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildGetMemberGroupsCommand(), - builder.BuildGetMemberObjectsCommand(), - builder.BuildPatchCommand(), - builder.BuildRestoreCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCheckMemberGroupsCommand()); + commands.Add(builder.BuildCheckMemberObjectsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildGetMemberGroupsCommand()); + commands.Add(builder.BuildGetMemberObjectsCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRestoreCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } public Command BuildGetAvailableExtensionPropertiesCommand() { @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -130,15 +132,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildValidatePropertiesCommand() { @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(DirectoryObject body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get entities from directoryObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to directoryObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DirectoryObject model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from directoryObjects public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DirectoryObjects/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs b/src/generated/DirectoryObjects/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs deleted file mode 100644 index 69e8d40f4fd..00000000000 --- a/src/generated/DirectoryObjects/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs +++ /dev/null @@ -1,45 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.DirectoryObjects.GetAvailableExtensionProperties { - public class GetAvailableExtensionProperties : DirectoryObject, IParsable { - /// Display name of the application object on which this extension property is defined. Read-only. - public string AppDisplayName { get; set; } - /// Specifies the data type of the value the extension property can hold. Following values are supported. Not nullable. Binary - 256 bytes maximumBooleanDateTime - Must be specified in ISO 8601 format. Will be stored in UTC.Integer - 32-bit value.LargeInteger - 64-bit value.String - 256 characters maximum - public string DataType { get; set; } - /// Indicates if this extension property was sycned from onpremises directory using Azure AD Connect. Read-only. - public bool? IsSyncedFromOnPremises { get; set; } - /// Name of the extension property. Not nullable. - public string Name { get; set; } - /// Following values are supported. Not nullable. UserGroupOrganizationDeviceApplication - public List TargetObjects { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"appDisplayName", (o,n) => { (o as GetAvailableExtensionProperties).AppDisplayName = n.GetStringValue(); } }, - {"dataType", (o,n) => { (o as GetAvailableExtensionProperties).DataType = n.GetStringValue(); } }, - {"isSyncedFromOnPremises", (o,n) => { (o as GetAvailableExtensionProperties).IsSyncedFromOnPremises = n.GetBoolValue(); } }, - {"name", (o,n) => { (o as GetAvailableExtensionProperties).Name = n.GetStringValue(); } }, - {"targetObjects", (o,n) => { (o as GetAvailableExtensionProperties).TargetObjects = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteStringValue("appDisplayName", AppDisplayName); - writer.WriteStringValue("dataType", DataType); - writer.WriteBoolValue("isSyncedFromOnPremises", IsSyncedFromOnPremises); - writer.WriteStringValue("name", Name); - writer.WriteCollectionOfPrimitiveValues("targetObjects", TargetObjects); - } - } -} diff --git a/src/generated/DirectoryObjects/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs b/src/generated/DirectoryObjects/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs index c6d1f6867a2..5504980d2a8 100644 --- a/src/generated/DirectoryObjects/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs +++ b/src/generated/DirectoryObjects/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(GetAvailableExtensionProp requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getAvailableExtensionProperties - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetAvailableExtensionPropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DirectoryObjects/GetByIds/GetByIds.cs b/src/generated/DirectoryObjects/GetByIds/GetByIds.cs deleted file mode 100644 index 0db8cae01da..00000000000 --- a/src/generated/DirectoryObjects/GetByIds/GetByIds.cs +++ /dev/null @@ -1,28 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.DirectoryObjects.GetByIds { - public class GetByIds : Entity, IParsable { - public DateTimeOffset? DeletedDateTime { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"deletedDateTime", (o,n) => { (o as GetByIds).DeletedDateTime = n.GetDateTimeOffsetValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteDateTimeOffsetValue("deletedDateTime", DeletedDateTime); - } - } -} diff --git a/src/generated/DirectoryObjects/GetByIds/GetByIdsRequestBuilder.cs b/src/generated/DirectoryObjects/GetByIds/GetByIdsRequestBuilder.cs index 69e804e8c7e..3d82aeb616c 100644 --- a/src/generated/DirectoryObjects/GetByIds/GetByIdsRequestBuilder.cs +++ b/src/generated/DirectoryObjects/GetByIds/GetByIdsRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(GetByIdsRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getByIds - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetByIdsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DirectoryObjects/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs b/src/generated/DirectoryObjects/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs index 40129fc0501..c343a02186c 100644 --- a/src/generated/DirectoryObjects/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs +++ b/src/generated/DirectoryObjects/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action checkMemberGroups"; // Create options for all the parameters - var directoryObjectIdOption = new Option("--directoryobject-id", description: "key: id of directoryObject") { + var directoryObjectIdOption = new Option("--directory-object-id", description: "key: id of directoryObject") { }; directoryObjectIdOption.IsRequired = true; command.AddOption(directoryObjectIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string directoryObjectId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string directoryObjectId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, directoryObjectIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, directoryObjectIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberGroupsRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DirectoryObjects/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs b/src/generated/DirectoryObjects/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs index 628e6836df1..6b6371abd2e 100644 --- a/src/generated/DirectoryObjects/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs +++ b/src/generated/DirectoryObjects/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action checkMemberObjects"; // Create options for all the parameters - var directoryObjectIdOption = new Option("--directoryobject-id", description: "key: id of directoryObject") { + var directoryObjectIdOption = new Option("--directory-object-id", description: "key: id of directoryObject") { }; directoryObjectIdOption.IsRequired = true; command.AddOption(directoryObjectIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string directoryObjectId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string directoryObjectId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, directoryObjectIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, directoryObjectIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberObjectsRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DirectoryObjects/Item/DirectoryObjectRequestBuilder.cs b/src/generated/DirectoryObjects/Item/DirectoryObjectRequestBuilder.cs index 8b7e3be057d..70777e49d94 100644 --- a/src/generated/DirectoryObjects/Item/DirectoryObjectRequestBuilder.cs +++ b/src/generated/DirectoryObjects/Item/DirectoryObjectRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -43,15 +43,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete entity from directoryObjects"; // Create options for all the parameters - var directoryObjectIdOption = new Option("--directoryobject-id", description: "key: id of directoryObject") { + var directoryObjectIdOption = new Option("--directory-object-id", description: "key: id of directoryObject") { }; directoryObjectIdOption.IsRequired = true; command.AddOption(directoryObjectIdOption); - command.SetHandler(async (string directoryObjectId) => { + command.SetHandler(async (string directoryObjectId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, directoryObjectIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get entity from directoryObjects by key"; // Create options for all the parameters - var directoryObjectIdOption = new Option("--directoryobject-id", description: "key: id of directoryObject") { + var directoryObjectIdOption = new Option("--directory-object-id", description: "key: id of directoryObject") { }; directoryObjectIdOption.IsRequired = true; command.AddOption(directoryObjectIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string directoryObjectId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string directoryObjectId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, directoryObjectIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, directoryObjectIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildGetMemberGroupsCommand() { @@ -112,7 +110,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update entity in directoryObjects"; // Create options for all the parameters - var directoryObjectIdOption = new Option("--directoryobject-id", description: "key: id of directoryObject") { + var directoryObjectIdOption = new Option("--directory-object-id", description: "key: id of directoryObject") { }; directoryObjectIdOption.IsRequired = true; command.AddOption(directoryObjectIdOption); @@ -120,14 +118,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string directoryObjectId, string body) => { + command.SetHandler(async (string directoryObjectId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, directoryObjectIdOption, bodyOption); return command; @@ -205,42 +202,6 @@ public RequestInformation CreatePatchRequestInformation(DirectoryObject body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from directoryObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from directoryObjects by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in directoryObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DirectoryObject model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from directoryObjects by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DirectoryObjects/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs b/src/generated/DirectoryObjects/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs index 53f228c0772..e460dcb0781 100644 --- a/src/generated/DirectoryObjects/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs +++ b/src/generated/DirectoryObjects/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action getMemberGroups"; // Create options for all the parameters - var directoryObjectIdOption = new Option("--directoryobject-id", description: "key: id of directoryObject") { + var directoryObjectIdOption = new Option("--directory-object-id", description: "key: id of directoryObject") { }; directoryObjectIdOption.IsRequired = true; command.AddOption(directoryObjectIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string directoryObjectId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string directoryObjectId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, directoryObjectIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, directoryObjectIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberGroupsRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DirectoryObjects/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs b/src/generated/DirectoryObjects/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs index fdc11f69a52..510e743829b 100644 --- a/src/generated/DirectoryObjects/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs +++ b/src/generated/DirectoryObjects/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action getMemberObjects"; // Create options for all the parameters - var directoryObjectIdOption = new Option("--directoryobject-id", description: "key: id of directoryObject") { + var directoryObjectIdOption = new Option("--directory-object-id", description: "key: id of directoryObject") { }; directoryObjectIdOption.IsRequired = true; command.AddOption(directoryObjectIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string directoryObjectId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string directoryObjectId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, directoryObjectIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, directoryObjectIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberObjectsRequestBo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DirectoryObjects/Item/Restore/RestoreRequestBuilder.cs b/src/generated/DirectoryObjects/Item/Restore/RestoreRequestBuilder.cs index ff002a3dbc0..81983d5dbee 100644 --- a/src/generated/DirectoryObjects/Item/Restore/RestoreRequestBuilder.cs +++ b/src/generated/DirectoryObjects/Item/Restore/RestoreRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action restore"; // Create options for all the parameters - var directoryObjectIdOption = new Option("--directoryobject-id", description: "key: id of directoryObject") { + var directoryObjectIdOption = new Option("--directory-object-id", description: "key: id of directoryObject") { }; directoryObjectIdOption.IsRequired = true; command.AddOption(directoryObjectIdOption); - command.SetHandler(async (string directoryObjectId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string directoryObjectId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, directoryObjectIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, directoryObjectIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action restore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes directoryObject public class RestoreResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/DirectoryObjects/ValidateProperties/ValidatePropertiesRequestBuilder.cs b/src/generated/DirectoryObjects/ValidateProperties/ValidatePropertiesRequestBuilder.cs index 2f4c26ba24b..9ef625519ab 100644 --- a/src/generated/DirectoryObjects/ValidateProperties/ValidatePropertiesRequestBuilder.cs +++ b/src/generated/DirectoryObjects/ValidateProperties/ValidatePropertiesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,14 +29,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -72,18 +71,5 @@ public RequestInformation CreatePostRequestInformation(ValidatePropertiesRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action validateProperties - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ValidatePropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DirectoryRoleTemplates/DirectoryRoleTemplatesRequestBuilder.cs b/src/generated/DirectoryRoleTemplates/DirectoryRoleTemplatesRequestBuilder.cs index 12b46ee4e46..23aa8c402ba 100644 --- a/src/generated/DirectoryRoleTemplates/DirectoryRoleTemplatesRequestBuilder.cs +++ b/src/generated/DirectoryRoleTemplates/DirectoryRoleTemplatesRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,16 +25,15 @@ public class DirectoryRoleTemplatesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DirectoryRoleTemplateRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCheckMemberGroupsCommand(), - builder.BuildCheckMemberObjectsCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildGetMemberGroupsCommand(), - builder.BuildGetMemberObjectsCommand(), - builder.BuildPatchCommand(), - builder.BuildRestoreCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCheckMemberGroupsCommand()); + commands.Add(builder.BuildCheckMemberObjectsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildGetMemberGroupsCommand()); + commands.Add(builder.BuildGetMemberObjectsCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRestoreCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } public Command BuildGetAvailableExtensionPropertiesCommand() { @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Skip = skip; if (!String.IsNullOrEmpty(search)) q.Search = search; @@ -125,15 +127,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildValidatePropertiesCommand() { @@ -194,31 +191,6 @@ public RequestInformation CreatePostRequestInformation(DirectoryRoleTemplate bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get entities from directoryRoleTemplates - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to directoryRoleTemplates - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DirectoryRoleTemplate model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from directoryRoleTemplates public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DirectoryRoleTemplates/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs b/src/generated/DirectoryRoleTemplates/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs deleted file mode 100644 index 7df5afc47bd..00000000000 --- a/src/generated/DirectoryRoleTemplates/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs +++ /dev/null @@ -1,45 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.DirectoryRoleTemplates.GetAvailableExtensionProperties { - public class GetAvailableExtensionProperties : DirectoryObject, IParsable { - /// Display name of the application object on which this extension property is defined. Read-only. - public string AppDisplayName { get; set; } - /// Specifies the data type of the value the extension property can hold. Following values are supported. Not nullable. Binary - 256 bytes maximumBooleanDateTime - Must be specified in ISO 8601 format. Will be stored in UTC.Integer - 32-bit value.LargeInteger - 64-bit value.String - 256 characters maximum - public string DataType { get; set; } - /// Indicates if this extension property was sycned from onpremises directory using Azure AD Connect. Read-only. - public bool? IsSyncedFromOnPremises { get; set; } - /// Name of the extension property. Not nullable. - public string Name { get; set; } - /// Following values are supported. Not nullable. UserGroupOrganizationDeviceApplication - public List TargetObjects { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"appDisplayName", (o,n) => { (o as GetAvailableExtensionProperties).AppDisplayName = n.GetStringValue(); } }, - {"dataType", (o,n) => { (o as GetAvailableExtensionProperties).DataType = n.GetStringValue(); } }, - {"isSyncedFromOnPremises", (o,n) => { (o as GetAvailableExtensionProperties).IsSyncedFromOnPremises = n.GetBoolValue(); } }, - {"name", (o,n) => { (o as GetAvailableExtensionProperties).Name = n.GetStringValue(); } }, - {"targetObjects", (o,n) => { (o as GetAvailableExtensionProperties).TargetObjects = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteStringValue("appDisplayName", AppDisplayName); - writer.WriteStringValue("dataType", DataType); - writer.WriteBoolValue("isSyncedFromOnPremises", IsSyncedFromOnPremises); - writer.WriteStringValue("name", Name); - writer.WriteCollectionOfPrimitiveValues("targetObjects", TargetObjects); - } - } -} diff --git a/src/generated/DirectoryRoleTemplates/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs b/src/generated/DirectoryRoleTemplates/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs index 35d66745518..681b851cb2d 100644 --- a/src/generated/DirectoryRoleTemplates/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs +++ b/src/generated/DirectoryRoleTemplates/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(GetAvailableExtensionProp requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getAvailableExtensionProperties - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetAvailableExtensionPropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DirectoryRoleTemplates/GetByIds/GetByIds.cs b/src/generated/DirectoryRoleTemplates/GetByIds/GetByIds.cs deleted file mode 100644 index 09506008dc0..00000000000 --- a/src/generated/DirectoryRoleTemplates/GetByIds/GetByIds.cs +++ /dev/null @@ -1,28 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.DirectoryRoleTemplates.GetByIds { - public class GetByIds : Entity, IParsable { - public DateTimeOffset? DeletedDateTime { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"deletedDateTime", (o,n) => { (o as GetByIds).DeletedDateTime = n.GetDateTimeOffsetValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteDateTimeOffsetValue("deletedDateTime", DeletedDateTime); - } - } -} diff --git a/src/generated/DirectoryRoleTemplates/GetByIds/GetByIdsRequestBuilder.cs b/src/generated/DirectoryRoleTemplates/GetByIds/GetByIdsRequestBuilder.cs index 6d0ed596d44..c41f35302d0 100644 --- a/src/generated/DirectoryRoleTemplates/GetByIds/GetByIdsRequestBuilder.cs +++ b/src/generated/DirectoryRoleTemplates/GetByIds/GetByIdsRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(GetByIdsRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getByIds - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetByIdsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DirectoryRoleTemplates/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs b/src/generated/DirectoryRoleTemplates/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs index 100fb21f220..1509b485a8b 100644 --- a/src/generated/DirectoryRoleTemplates/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs +++ b/src/generated/DirectoryRoleTemplates/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action checkMemberGroups"; // Create options for all the parameters - var directoryRoleTemplateIdOption = new Option("--directoryroletemplate-id", description: "key: id of directoryRoleTemplate") { + var directoryRoleTemplateIdOption = new Option("--directory-role-template-id", description: "key: id of directoryRoleTemplate") { }; directoryRoleTemplateIdOption.IsRequired = true; command.AddOption(directoryRoleTemplateIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string directoryRoleTemplateId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string directoryRoleTemplateId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, directoryRoleTemplateIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, directoryRoleTemplateIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberGroupsRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DirectoryRoleTemplates/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs b/src/generated/DirectoryRoleTemplates/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs index 6f9e4da585a..0e85817814e 100644 --- a/src/generated/DirectoryRoleTemplates/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs +++ b/src/generated/DirectoryRoleTemplates/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action checkMemberObjects"; // Create options for all the parameters - var directoryRoleTemplateIdOption = new Option("--directoryroletemplate-id", description: "key: id of directoryRoleTemplate") { + var directoryRoleTemplateIdOption = new Option("--directory-role-template-id", description: "key: id of directoryRoleTemplate") { }; directoryRoleTemplateIdOption.IsRequired = true; command.AddOption(directoryRoleTemplateIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string directoryRoleTemplateId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string directoryRoleTemplateId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, directoryRoleTemplateIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, directoryRoleTemplateIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberObjectsRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DirectoryRoleTemplates/Item/DirectoryRoleTemplateRequestBuilder.cs b/src/generated/DirectoryRoleTemplates/Item/DirectoryRoleTemplateRequestBuilder.cs index 8bed309f74a..7aa702991b3 100644 --- a/src/generated/DirectoryRoleTemplates/Item/DirectoryRoleTemplateRequestBuilder.cs +++ b/src/generated/DirectoryRoleTemplates/Item/DirectoryRoleTemplateRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -43,15 +43,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete entity from directoryRoleTemplates"; // Create options for all the parameters - var directoryRoleTemplateIdOption = new Option("--directoryroletemplate-id", description: "key: id of directoryRoleTemplate") { + var directoryRoleTemplateIdOption = new Option("--directory-role-template-id", description: "key: id of directoryRoleTemplate") { }; directoryRoleTemplateIdOption.IsRequired = true; command.AddOption(directoryRoleTemplateIdOption); - command.SetHandler(async (string directoryRoleTemplateId) => { + command.SetHandler(async (string directoryRoleTemplateId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, directoryRoleTemplateIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get entity from directoryRoleTemplates by key"; // Create options for all the parameters - var directoryRoleTemplateIdOption = new Option("--directoryroletemplate-id", description: "key: id of directoryRoleTemplate") { + var directoryRoleTemplateIdOption = new Option("--directory-role-template-id", description: "key: id of directoryRoleTemplate") { }; directoryRoleTemplateIdOption.IsRequired = true; command.AddOption(directoryRoleTemplateIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string directoryRoleTemplateId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string directoryRoleTemplateId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, directoryRoleTemplateIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, directoryRoleTemplateIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildGetMemberGroupsCommand() { @@ -112,7 +110,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update entity in directoryRoleTemplates"; // Create options for all the parameters - var directoryRoleTemplateIdOption = new Option("--directoryroletemplate-id", description: "key: id of directoryRoleTemplate") { + var directoryRoleTemplateIdOption = new Option("--directory-role-template-id", description: "key: id of directoryRoleTemplate") { }; directoryRoleTemplateIdOption.IsRequired = true; command.AddOption(directoryRoleTemplateIdOption); @@ -120,14 +118,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string directoryRoleTemplateId, string body) => { + command.SetHandler(async (string directoryRoleTemplateId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, directoryRoleTemplateIdOption, bodyOption); return command; @@ -205,42 +202,6 @@ public RequestInformation CreatePatchRequestInformation(DirectoryRoleTemplate bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from directoryRoleTemplates - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from directoryRoleTemplates by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in directoryRoleTemplates - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DirectoryRoleTemplate model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from directoryRoleTemplates by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DirectoryRoleTemplates/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs b/src/generated/DirectoryRoleTemplates/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs index 6135121f90d..1cdf40a9b40 100644 --- a/src/generated/DirectoryRoleTemplates/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs +++ b/src/generated/DirectoryRoleTemplates/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action getMemberGroups"; // Create options for all the parameters - var directoryRoleTemplateIdOption = new Option("--directoryroletemplate-id", description: "key: id of directoryRoleTemplate") { + var directoryRoleTemplateIdOption = new Option("--directory-role-template-id", description: "key: id of directoryRoleTemplate") { }; directoryRoleTemplateIdOption.IsRequired = true; command.AddOption(directoryRoleTemplateIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string directoryRoleTemplateId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string directoryRoleTemplateId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, directoryRoleTemplateIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, directoryRoleTemplateIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberGroupsRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DirectoryRoleTemplates/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs b/src/generated/DirectoryRoleTemplates/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs index d326c047471..d32c6ecec45 100644 --- a/src/generated/DirectoryRoleTemplates/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs +++ b/src/generated/DirectoryRoleTemplates/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action getMemberObjects"; // Create options for all the parameters - var directoryRoleTemplateIdOption = new Option("--directoryroletemplate-id", description: "key: id of directoryRoleTemplate") { + var directoryRoleTemplateIdOption = new Option("--directory-role-template-id", description: "key: id of directoryRoleTemplate") { }; directoryRoleTemplateIdOption.IsRequired = true; command.AddOption(directoryRoleTemplateIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string directoryRoleTemplateId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string directoryRoleTemplateId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, directoryRoleTemplateIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, directoryRoleTemplateIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberObjectsRequestBo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DirectoryRoleTemplates/Item/Restore/RestoreRequestBuilder.cs b/src/generated/DirectoryRoleTemplates/Item/Restore/RestoreRequestBuilder.cs index ff7e03c3910..15185dbefa0 100644 --- a/src/generated/DirectoryRoleTemplates/Item/Restore/RestoreRequestBuilder.cs +++ b/src/generated/DirectoryRoleTemplates/Item/Restore/RestoreRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action restore"; // Create options for all the parameters - var directoryRoleTemplateIdOption = new Option("--directoryroletemplate-id", description: "key: id of directoryRoleTemplate") { + var directoryRoleTemplateIdOption = new Option("--directory-role-template-id", description: "key: id of directoryRoleTemplate") { }; directoryRoleTemplateIdOption.IsRequired = true; command.AddOption(directoryRoleTemplateIdOption); - command.SetHandler(async (string directoryRoleTemplateId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string directoryRoleTemplateId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, directoryRoleTemplateIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, directoryRoleTemplateIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action restore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes directoryObject public class RestoreResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/DirectoryRoleTemplates/ValidateProperties/ValidatePropertiesRequestBuilder.cs b/src/generated/DirectoryRoleTemplates/ValidateProperties/ValidatePropertiesRequestBuilder.cs index 2dcb7a52918..48c43f49a6e 100644 --- a/src/generated/DirectoryRoleTemplates/ValidateProperties/ValidatePropertiesRequestBuilder.cs +++ b/src/generated/DirectoryRoleTemplates/ValidateProperties/ValidatePropertiesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,14 +29,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -72,18 +71,5 @@ public RequestInformation CreatePostRequestInformation(ValidatePropertiesRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action validateProperties - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ValidatePropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DirectoryRoles/Delta/DeltaRequestBuilder.cs b/src/generated/DirectoryRoles/Delta/DeltaRequestBuilder.cs index 19f81aad6ae..fac49ba4848 100644 --- a/src/generated/DirectoryRoles/Delta/DeltaRequestBuilder.cs +++ b/src/generated/DirectoryRoles/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DirectoryRoles/DirectoryRolesRequestBuilder.cs b/src/generated/DirectoryRoles/DirectoryRolesRequestBuilder.cs index cf78795273a..9e696355ca5 100644 --- a/src/generated/DirectoryRoles/DirectoryRolesRequestBuilder.cs +++ b/src/generated/DirectoryRoles/DirectoryRolesRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,18 +26,17 @@ public class DirectoryRolesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DirectoryRoleRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCheckMemberGroupsCommand(), - builder.BuildCheckMemberObjectsCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildGetMemberGroupsCommand(), - builder.BuildGetMemberObjectsCommand(), - builder.BuildMembersCommand(), - builder.BuildPatchCommand(), - builder.BuildRestoreCommand(), - builder.BuildScopedMembersCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCheckMemberGroupsCommand()); + commands.Add(builder.BuildCheckMemberObjectsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildGetMemberGroupsCommand()); + commands.Add(builder.BuildGetMemberObjectsCommand()); + commands.Add(builder.BuildMembersCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRestoreCommand()); + commands.Add(builder.BuildScopedMembersCommand()); return commands; } /// @@ -51,21 +50,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } public Command BuildGetAvailableExtensionPropertiesCommand() { @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Skip = skip; if (!String.IsNullOrEmpty(search)) q.Search = search; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildValidatePropertiesCommand() { @@ -203,31 +200,6 @@ public RequestInformation CreatePostRequestInformation(DirectoryRole body, Actio public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// Get entities from directoryRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to directoryRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DirectoryRole model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from directoryRoles public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DirectoryRoles/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs b/src/generated/DirectoryRoles/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs deleted file mode 100644 index 8f2be489eb8..00000000000 --- a/src/generated/DirectoryRoles/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs +++ /dev/null @@ -1,45 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.DirectoryRoles.GetAvailableExtensionProperties { - public class GetAvailableExtensionProperties : DirectoryObject, IParsable { - /// Display name of the application object on which this extension property is defined. Read-only. - public string AppDisplayName { get; set; } - /// Specifies the data type of the value the extension property can hold. Following values are supported. Not nullable. Binary - 256 bytes maximumBooleanDateTime - Must be specified in ISO 8601 format. Will be stored in UTC.Integer - 32-bit value.LargeInteger - 64-bit value.String - 256 characters maximum - public string DataType { get; set; } - /// Indicates if this extension property was sycned from onpremises directory using Azure AD Connect. Read-only. - public bool? IsSyncedFromOnPremises { get; set; } - /// Name of the extension property. Not nullable. - public string Name { get; set; } - /// Following values are supported. Not nullable. UserGroupOrganizationDeviceApplication - public List TargetObjects { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"appDisplayName", (o,n) => { (o as GetAvailableExtensionProperties).AppDisplayName = n.GetStringValue(); } }, - {"dataType", (o,n) => { (o as GetAvailableExtensionProperties).DataType = n.GetStringValue(); } }, - {"isSyncedFromOnPremises", (o,n) => { (o as GetAvailableExtensionProperties).IsSyncedFromOnPremises = n.GetBoolValue(); } }, - {"name", (o,n) => { (o as GetAvailableExtensionProperties).Name = n.GetStringValue(); } }, - {"targetObjects", (o,n) => { (o as GetAvailableExtensionProperties).TargetObjects = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteStringValue("appDisplayName", AppDisplayName); - writer.WriteStringValue("dataType", DataType); - writer.WriteBoolValue("isSyncedFromOnPremises", IsSyncedFromOnPremises); - writer.WriteStringValue("name", Name); - writer.WriteCollectionOfPrimitiveValues("targetObjects", TargetObjects); - } - } -} diff --git a/src/generated/DirectoryRoles/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs b/src/generated/DirectoryRoles/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs index fa9e54bd382..76cdab8a20d 100644 --- a/src/generated/DirectoryRoles/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs +++ b/src/generated/DirectoryRoles/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(GetAvailableExtensionProp requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getAvailableExtensionProperties - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetAvailableExtensionPropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DirectoryRoles/GetByIds/GetByIds.cs b/src/generated/DirectoryRoles/GetByIds/GetByIds.cs deleted file mode 100644 index 06958e0ff3f..00000000000 --- a/src/generated/DirectoryRoles/GetByIds/GetByIds.cs +++ /dev/null @@ -1,28 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.DirectoryRoles.GetByIds { - public class GetByIds : Entity, IParsable { - public DateTimeOffset? DeletedDateTime { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"deletedDateTime", (o,n) => { (o as GetByIds).DeletedDateTime = n.GetDateTimeOffsetValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteDateTimeOffsetValue("deletedDateTime", DeletedDateTime); - } - } -} diff --git a/src/generated/DirectoryRoles/GetByIds/GetByIdsRequestBuilder.cs b/src/generated/DirectoryRoles/GetByIds/GetByIdsRequestBuilder.cs index d8ad4d5f9ea..519cd5af1dd 100644 --- a/src/generated/DirectoryRoles/GetByIds/GetByIdsRequestBuilder.cs +++ b/src/generated/DirectoryRoles/GetByIds/GetByIdsRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(GetByIdsRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getByIds - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetByIdsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DirectoryRoles/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs b/src/generated/DirectoryRoles/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs index 3cb34193d81..2f57c71cb72 100644 --- a/src/generated/DirectoryRoles/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs +++ b/src/generated/DirectoryRoles/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action checkMemberGroups"; // Create options for all the parameters - var directoryRoleIdOption = new Option("--directoryrole-id", description: "key: id of directoryRole") { + var directoryRoleIdOption = new Option("--directory-role-id", description: "key: id of directoryRole") { }; directoryRoleIdOption.IsRequired = true; command.AddOption(directoryRoleIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string directoryRoleId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string directoryRoleId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, directoryRoleIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, directoryRoleIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberGroupsRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DirectoryRoles/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs b/src/generated/DirectoryRoles/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs index d8667fa2a6e..d1935ee1cab 100644 --- a/src/generated/DirectoryRoles/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs +++ b/src/generated/DirectoryRoles/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action checkMemberObjects"; // Create options for all the parameters - var directoryRoleIdOption = new Option("--directoryrole-id", description: "key: id of directoryRole") { + var directoryRoleIdOption = new Option("--directory-role-id", description: "key: id of directoryRole") { }; directoryRoleIdOption.IsRequired = true; command.AddOption(directoryRoleIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string directoryRoleId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string directoryRoleId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, directoryRoleIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, directoryRoleIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberObjectsRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DirectoryRoles/Item/DirectoryRoleRequestBuilder.cs b/src/generated/DirectoryRoles/Item/DirectoryRoleRequestBuilder.cs index 7c6a86ca184..1ff9111f519 100644 --- a/src/generated/DirectoryRoles/Item/DirectoryRoleRequestBuilder.cs +++ b/src/generated/DirectoryRoles/Item/DirectoryRoleRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -45,15 +45,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete entity from directoryRoles"; // Create options for all the parameters - var directoryRoleIdOption = new Option("--directoryrole-id", description: "key: id of directoryRole") { + var directoryRoleIdOption = new Option("--directory-role-id", description: "key: id of directoryRole") { }; directoryRoleIdOption.IsRequired = true; command.AddOption(directoryRoleIdOption); - command.SetHandler(async (string directoryRoleId) => { + command.SetHandler(async (string directoryRoleId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, directoryRoleIdOption); return command; @@ -65,7 +64,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get entity from directoryRoles by key"; // Create options for all the parameters - var directoryRoleIdOption = new Option("--directoryrole-id", description: "key: id of directoryRole") { + var directoryRoleIdOption = new Option("--directory-role-id", description: "key: id of directoryRole") { }; directoryRoleIdOption.IsRequired = true; command.AddOption(directoryRoleIdOption); @@ -79,20 +78,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string directoryRoleId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string directoryRoleId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, directoryRoleIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, directoryRoleIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildGetMemberGroupsCommand() { @@ -121,7 +119,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update entity in directoryRoles"; // Create options for all the parameters - var directoryRoleIdOption = new Option("--directoryrole-id", description: "key: id of directoryRole") { + var directoryRoleIdOption = new Option("--directory-role-id", description: "key: id of directoryRole") { }; directoryRoleIdOption.IsRequired = true; command.AddOption(directoryRoleIdOption); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string directoryRoleId, string body) => { + command.SetHandler(async (string directoryRoleId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, directoryRoleIdOption, bodyOption); return command; @@ -150,6 +147,9 @@ public Command BuildRestoreCommand() { public Command BuildScopedMembersCommand() { var command = new Command("scoped-members"); var builder = new ApiSdk.DirectoryRoles.Item.ScopedMembers.ScopedMembersRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -221,42 +221,6 @@ public RequestInformation CreatePatchRequestInformation(DirectoryRole body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from directoryRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from directoryRoles by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in directoryRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DirectoryRole model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from directoryRoles by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DirectoryRoles/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs b/src/generated/DirectoryRoles/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs index 81204eda3ae..179b16f2222 100644 --- a/src/generated/DirectoryRoles/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs +++ b/src/generated/DirectoryRoles/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action getMemberGroups"; // Create options for all the parameters - var directoryRoleIdOption = new Option("--directoryrole-id", description: "key: id of directoryRole") { + var directoryRoleIdOption = new Option("--directory-role-id", description: "key: id of directoryRole") { }; directoryRoleIdOption.IsRequired = true; command.AddOption(directoryRoleIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string directoryRoleId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string directoryRoleId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, directoryRoleIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, directoryRoleIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberGroupsRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DirectoryRoles/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs b/src/generated/DirectoryRoles/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs index 03f8bf7abe5..8d12a3167df 100644 --- a/src/generated/DirectoryRoles/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs +++ b/src/generated/DirectoryRoles/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action getMemberObjects"; // Create options for all the parameters - var directoryRoleIdOption = new Option("--directoryrole-id", description: "key: id of directoryRole") { + var directoryRoleIdOption = new Option("--directory-role-id", description: "key: id of directoryRole") { }; directoryRoleIdOption.IsRequired = true; command.AddOption(directoryRoleIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string directoryRoleId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string directoryRoleId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, directoryRoleIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, directoryRoleIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberObjectsRequestBo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DirectoryRoles/Item/Members/@Ref/@Ref.cs b/src/generated/DirectoryRoles/Item/Members/@Ref/@Ref.cs deleted file mode 100644 index 58c24c674b3..00000000000 --- a/src/generated/DirectoryRoles/Item/Members/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.DirectoryRoles.Item.Members.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/DirectoryRoles/Item/Members/@Ref/RefRequestBuilder.cs b/src/generated/DirectoryRoles/Item/Members/@Ref/RefRequestBuilder.cs deleted file mode 100644 index b25f3c1f1f8..00000000000 --- a/src/generated/DirectoryRoles/Item/Members/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.DirectoryRoles.Item.Members.@Ref { - /// Builds and executes requests for operations under \directoryRoles\{directoryRole-id}\members\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Users that are members of this directory role. HTTP Methods: GET, POST, DELETE. Read-only. Nullable. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Users that are members of this directory role. HTTP Methods: GET, POST, DELETE. Read-only. Nullable."; - // Create options for all the parameters - var directoryRoleIdOption = new Option("--directoryrole-id", description: "key: id of directoryRole") { - }; - directoryRoleIdOption.IsRequired = true; - command.AddOption(directoryRoleIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string directoryRoleId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, directoryRoleIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Users that are members of this directory role. HTTP Methods: GET, POST, DELETE. Read-only. Nullable. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Users that are members of this directory role. HTTP Methods: GET, POST, DELETE. Read-only. Nullable."; - // Create options for all the parameters - var directoryRoleIdOption = new Option("--directoryrole-id", description: "key: id of directoryRole") { - }; - directoryRoleIdOption.IsRequired = true; - command.AddOption(directoryRoleIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string directoryRoleId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, directoryRoleIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/directoryRoles/{directoryRole_id}/members/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Users that are members of this directory role. HTTP Methods: GET, POST, DELETE. Read-only. Nullable. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Users that are members of this directory role. HTTP Methods: GET, POST, DELETE. Read-only. Nullable. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.DirectoryRoles.Item.Members.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Users that are members of this directory role. HTTP Methods: GET, POST, DELETE. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Users that are members of this directory role. HTTP Methods: GET, POST, DELETE. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.DirectoryRoles.Item.Members.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Users that are members of this directory role. HTTP Methods: GET, POST, DELETE. Read-only. Nullable. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/DirectoryRoles/Item/Members/@Ref/RefResponse.cs b/src/generated/DirectoryRoles/Item/Members/@Ref/RefResponse.cs deleted file mode 100644 index 7868047558e..00000000000 --- a/src/generated/DirectoryRoles/Item/Members/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.DirectoryRoles.Item.Members.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/DirectoryRoles/Item/Members/MembersRequestBuilder.cs b/src/generated/DirectoryRoles/Item/Members/MembersRequestBuilder.cs index ba5057d2abf..304cb25700d 100644 --- a/src/generated/DirectoryRoles/Item/Members/MembersRequestBuilder.cs +++ b/src/generated/DirectoryRoles/Item/Members/MembersRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.DirectoryRoles.Item.Members.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -20,13 +20,13 @@ public class MembersRequestBuilder { /// Url template to use to build the URL for the current request builder private string UrlTemplate { get; set; } /// - /// Users that are members of this directory role. HTTP Methods: GET, POST, DELETE. Read-only. Nullable. + /// Users that are members of this directory role. HTTP Methods: GET, POST, DELETE. Read-only. Nullable. Supports $expand. /// public Command BuildGetCommand() { var command = new Command("get"); - command.Description = "Users that are members of this directory role. HTTP Methods: GET, POST, DELETE. Read-only. Nullable."; + command.Description = "Users that are members of this directory role. HTTP Methods: GET, POST, DELETE. Read-only. Nullable. Supports $expand."; // Create options for all the parameters - var directoryRoleIdOption = new Option("--directoryrole-id", description: "key: id of directoryRole") { + var directoryRoleIdOption = new Option("--directory-role-id", description: "key: id of directoryRole") { }; directoryRoleIdOption.IsRequired = true; command.AddOption(directoryRoleIdOption); @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string directoryRoleId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string directoryRoleId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, directoryRoleIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, directoryRoleIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.DirectoryRoles.Item.Members.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.DirectoryRoles.Item.Members.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -108,7 +107,7 @@ public MembersRequestBuilder(Dictionary pathParameters, IRequest RequestAdapter = requestAdapter; } /// - /// Users that are members of this directory role. HTTP Methods: GET, POST, DELETE. Read-only. Nullable. + /// Users that are members of this directory role. HTTP Methods: GET, POST, DELETE. Read-only. Nullable. Supports $expand. /// Request headers /// Request options /// Request query parameters @@ -128,19 +127,7 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Users that are members of this directory role. HTTP Methods: GET, POST, DELETE. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Users that are members of this directory role. HTTP Methods: GET, POST, DELETE. Read-only. Nullable. + /// Users that are members of this directory role. HTTP Methods: GET, POST, DELETE. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items public bool? Count { get; set; } diff --git a/src/generated/DirectoryRoles/Item/Members/Ref/Ref.cs b/src/generated/DirectoryRoles/Item/Members/Ref/Ref.cs new file mode 100644 index 00000000000..58b508a04cf --- /dev/null +++ b/src/generated/DirectoryRoles/Item/Members/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.DirectoryRoles.Item.Members.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/DirectoryRoles/Item/Members/Ref/RefRequestBuilder.cs b/src/generated/DirectoryRoles/Item/Members/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..28832955cac --- /dev/null +++ b/src/generated/DirectoryRoles/Item/Members/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.DirectoryRoles.Item.Members.Ref { + /// Builds and executes requests for operations under \directoryRoles\{directoryRole-id}\members\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Users that are members of this directory role. HTTP Methods: GET, POST, DELETE. Read-only. Nullable. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Users that are members of this directory role. HTTP Methods: GET, POST, DELETE. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var directoryRoleIdOption = new Option("--directory-role-id", description: "key: id of directoryRole") { + }; + directoryRoleIdOption.IsRequired = true; + command.AddOption(directoryRoleIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string directoryRoleId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, directoryRoleIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Users that are members of this directory role. HTTP Methods: GET, POST, DELETE. Read-only. Nullable. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Users that are members of this directory role. HTTP Methods: GET, POST, DELETE. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var directoryRoleIdOption = new Option("--directory-role-id", description: "key: id of directoryRole") { + }; + directoryRoleIdOption.IsRequired = true; + command.AddOption(directoryRoleIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string directoryRoleId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, directoryRoleIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/directoryRoles/{directoryRole_id}/members/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Users that are members of this directory role. HTTP Methods: GET, POST, DELETE. Read-only. Nullable. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Users that are members of this directory role. HTTP Methods: GET, POST, DELETE. Read-only. Nullable. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.DirectoryRoles.Item.Members.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Users that are members of this directory role. HTTP Methods: GET, POST, DELETE. Read-only. Nullable. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/DirectoryRoles/Item/Members/Ref/RefResponse.cs b/src/generated/DirectoryRoles/Item/Members/Ref/RefResponse.cs new file mode 100644 index 00000000000..94309c65168 --- /dev/null +++ b/src/generated/DirectoryRoles/Item/Members/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.DirectoryRoles.Item.Members.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/DirectoryRoles/Item/Restore/RestoreRequestBuilder.cs b/src/generated/DirectoryRoles/Item/Restore/RestoreRequestBuilder.cs index 2320f217948..745eb0df8f3 100644 --- a/src/generated/DirectoryRoles/Item/Restore/RestoreRequestBuilder.cs +++ b/src/generated/DirectoryRoles/Item/Restore/RestoreRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action restore"; // Create options for all the parameters - var directoryRoleIdOption = new Option("--directoryrole-id", description: "key: id of directoryRole") { + var directoryRoleIdOption = new Option("--directory-role-id", description: "key: id of directoryRole") { }; directoryRoleIdOption.IsRequired = true; command.AddOption(directoryRoleIdOption); - command.SetHandler(async (string directoryRoleId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string directoryRoleId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, directoryRoleIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, directoryRoleIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action restore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes directoryObject public class RestoreResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/DirectoryRoles/Item/ScopedMembers/Item/ScopedRoleMembershipRequestBuilder.cs b/src/generated/DirectoryRoles/Item/ScopedMembers/Item/ScopedRoleMembershipRequestBuilder.cs index a68624a1e57..22721a878f6 100644 --- a/src/generated/DirectoryRoles/Item/ScopedMembers/Item/ScopedRoleMembershipRequestBuilder.cs +++ b/src/generated/DirectoryRoles/Item/ScopedMembers/Item/ScopedRoleMembershipRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Members of this directory role that are scoped to administrative units. Read-only. Nullable."; // Create options for all the parameters - var directoryRoleIdOption = new Option("--directoryrole-id", description: "key: id of directoryRole") { + var directoryRoleIdOption = new Option("--directory-role-id", description: "key: id of directoryRole") { }; directoryRoleIdOption.IsRequired = true; command.AddOption(directoryRoleIdOption); - var scopedRoleMembershipIdOption = new Option("--scopedrolemembership-id", description: "key: id of scopedRoleMembership") { + var scopedRoleMembershipIdOption = new Option("--scoped-role-membership-id", description: "key: id of scopedRoleMembership") { }; scopedRoleMembershipIdOption.IsRequired = true; command.AddOption(scopedRoleMembershipIdOption); - command.SetHandler(async (string directoryRoleId, string scopedRoleMembershipId) => { + command.SetHandler(async (string directoryRoleId, string scopedRoleMembershipId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, directoryRoleIdOption, scopedRoleMembershipIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Members of this directory role that are scoped to administrative units. Read-only. Nullable."; // Create options for all the parameters - var directoryRoleIdOption = new Option("--directoryrole-id", description: "key: id of directoryRole") { + var directoryRoleIdOption = new Option("--directory-role-id", description: "key: id of directoryRole") { }; directoryRoleIdOption.IsRequired = true; command.AddOption(directoryRoleIdOption); - var scopedRoleMembershipIdOption = new Option("--scopedrolemembership-id", description: "key: id of scopedRoleMembership") { + var scopedRoleMembershipIdOption = new Option("--scoped-role-membership-id", description: "key: id of scopedRoleMembership") { }; scopedRoleMembershipIdOption.IsRequired = true; command.AddOption(scopedRoleMembershipIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string directoryRoleId, string scopedRoleMembershipId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string directoryRoleId, string scopedRoleMembershipId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, directoryRoleIdOption, scopedRoleMembershipIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, directoryRoleIdOption, scopedRoleMembershipIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Members of this directory role that are scoped to administrative units. Read-only. Nullable."; // Create options for all the parameters - var directoryRoleIdOption = new Option("--directoryrole-id", description: "key: id of directoryRole") { + var directoryRoleIdOption = new Option("--directory-role-id", description: "key: id of directoryRole") { }; directoryRoleIdOption.IsRequired = true; command.AddOption(directoryRoleIdOption); - var scopedRoleMembershipIdOption = new Option("--scopedrolemembership-id", description: "key: id of scopedRoleMembership") { + var scopedRoleMembershipIdOption = new Option("--scoped-role-membership-id", description: "key: id of scopedRoleMembership") { }; scopedRoleMembershipIdOption.IsRequired = true; command.AddOption(scopedRoleMembershipIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string directoryRoleId, string scopedRoleMembershipId, string body) => { + command.SetHandler(async (string directoryRoleId, string scopedRoleMembershipId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, directoryRoleIdOption, scopedRoleMembershipIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ScopedRoleMembership bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Members of this directory role that are scoped to administrative units. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Members of this directory role that are scoped to administrative units. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Members of this directory role that are scoped to administrative units. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ScopedRoleMembership model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Members of this directory role that are scoped to administrative units. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/DirectoryRoles/Item/ScopedMembers/ScopedMembersRequestBuilder.cs b/src/generated/DirectoryRoles/Item/ScopedMembers/ScopedMembersRequestBuilder.cs index 01c062b97c6..152fc028261 100644 --- a/src/generated/DirectoryRoles/Item/ScopedMembers/ScopedMembersRequestBuilder.cs +++ b/src/generated/DirectoryRoles/Item/ScopedMembers/ScopedMembersRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ScopedMembersRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ScopedRoleMembershipRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Members of this directory role that are scoped to administrative units. Read-only. Nullable."; // Create options for all the parameters - var directoryRoleIdOption = new Option("--directoryrole-id", description: "key: id of directoryRole") { + var directoryRoleIdOption = new Option("--directory-role-id", description: "key: id of directoryRole") { }; directoryRoleIdOption.IsRequired = true; command.AddOption(directoryRoleIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string directoryRoleId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string directoryRoleId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, directoryRoleIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, directoryRoleIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Members of this directory role that are scoped to administrative units. Read-only. Nullable."; // Create options for all the parameters - var directoryRoleIdOption = new Option("--directoryrole-id", description: "key: id of directoryRole") { + var directoryRoleIdOption = new Option("--directory-role-id", description: "key: id of directoryRole") { }; directoryRoleIdOption.IsRequired = true; command.AddOption(directoryRoleIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string directoryRoleId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string directoryRoleId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, directoryRoleIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, directoryRoleIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ScopedRoleMembership body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Members of this directory role that are scoped to administrative units. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Members of this directory role that are scoped to administrative units. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ScopedRoleMembership model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Members of this directory role that are scoped to administrative units. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DirectoryRoles/ValidateProperties/ValidatePropertiesRequestBuilder.cs b/src/generated/DirectoryRoles/ValidateProperties/ValidatePropertiesRequestBuilder.cs index 012566e890e..47ee205edc4 100644 --- a/src/generated/DirectoryRoles/ValidateProperties/ValidatePropertiesRequestBuilder.cs +++ b/src/generated/DirectoryRoles/ValidateProperties/ValidatePropertiesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,14 +29,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -72,18 +71,5 @@ public RequestInformation CreatePostRequestInformation(ValidatePropertiesRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action validateProperties - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ValidatePropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/DomainDnsRecords/DomainDnsRecordsRequestBuilder.cs b/src/generated/DomainDnsRecords/DomainDnsRecordsRequestBuilder.cs index 83ba8d4d843..959cd43fdba 100644 --- a/src/generated/DomainDnsRecords/DomainDnsRecordsRequestBuilder.cs +++ b/src/generated/DomainDnsRecords/DomainDnsRecordsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DomainDnsRecordsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DomainDnsRecordRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(DomainDnsRecord body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get entities from domainDnsRecords - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to domainDnsRecords - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DomainDnsRecord model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from domainDnsRecords public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/DomainDnsRecords/Item/DomainDnsRecordRequestBuilder.cs b/src/generated/DomainDnsRecords/Item/DomainDnsRecordRequestBuilder.cs index 35fdbb1b871..71e8611895d 100644 --- a/src/generated/DomainDnsRecords/Item/DomainDnsRecordRequestBuilder.cs +++ b/src/generated/DomainDnsRecords/Item/DomainDnsRecordRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete entity from domainDnsRecords"; // Create options for all the parameters - var domainDnsRecordIdOption = new Option("--domaindnsrecord-id", description: "key: id of domainDnsRecord") { + var domainDnsRecordIdOption = new Option("--domain-dns-record-id", description: "key: id of domainDnsRecord") { }; domainDnsRecordIdOption.IsRequired = true; command.AddOption(domainDnsRecordIdOption); - command.SetHandler(async (string domainDnsRecordId) => { + command.SetHandler(async (string domainDnsRecordId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, domainDnsRecordIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get entity from domainDnsRecords by key"; // Create options for all the parameters - var domainDnsRecordIdOption = new Option("--domaindnsrecord-id", description: "key: id of domainDnsRecord") { + var domainDnsRecordIdOption = new Option("--domain-dns-record-id", description: "key: id of domainDnsRecord") { }; domainDnsRecordIdOption.IsRequired = true; command.AddOption(domainDnsRecordIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string domainDnsRecordId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string domainDnsRecordId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, domainDnsRecordIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, domainDnsRecordIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update entity in domainDnsRecords"; // Create options for all the parameters - var domainDnsRecordIdOption = new Option("--domaindnsrecord-id", description: "key: id of domainDnsRecord") { + var domainDnsRecordIdOption = new Option("--domain-dns-record-id", description: "key: id of domainDnsRecord") { }; domainDnsRecordIdOption.IsRequired = true; command.AddOption(domainDnsRecordIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string domainDnsRecordId, string body) => { + command.SetHandler(async (string domainDnsRecordId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, domainDnsRecordIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(DomainDnsRecord body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from domainDnsRecords - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from domainDnsRecords by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in domainDnsRecords - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DomainDnsRecord model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from domainDnsRecords by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Domains/DomainsRequestBuilder.cs b/src/generated/Domains/DomainsRequestBuilder.cs index bed85baaf22..358f6e0cf1e 100644 --- a/src/generated/Domains/DomainsRequestBuilder.cs +++ b/src/generated/Domains/DomainsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class DomainsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DomainRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildDomainNameReferencesCommand(), - builder.BuildForceDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildServiceConfigurationRecordsCommand(), - builder.BuildVerificationDnsRecordsCommand(), - builder.BuildVerifyCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDomainNameReferencesCommand()); + commands.Add(builder.BuildForceDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildServiceConfigurationRecordsCommand()); + commands.Add(builder.BuildVerificationDnsRecordsCommand()); + commands.Add(builder.BuildVerifyCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -104,7 +102,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -115,15 +117,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -178,31 +175,6 @@ public RequestInformation CreatePostRequestInformation(Domain body, Action - /// Get entities from domains - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to domains - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Domain model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from domains public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Domains/Item/DomainNameReferences/@Ref/@Ref.cs b/src/generated/Domains/Item/DomainNameReferences/@Ref/@Ref.cs deleted file mode 100644 index 610487916c1..00000000000 --- a/src/generated/Domains/Item/DomainNameReferences/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Domains.Item.DomainNameReferences.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Domains/Item/DomainNameReferences/@Ref/RefRequestBuilder.cs b/src/generated/Domains/Item/DomainNameReferences/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 8b18b80d743..00000000000 --- a/src/generated/Domains/Item/DomainNameReferences/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Domains.Item.DomainNameReferences.@Ref { - /// Builds and executes requests for operations under \domains\{domain-id}\domainNameReferences\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Read-only, Nullable - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Read-only, Nullable"; - // Create options for all the parameters - var domainIdOption = new Option("--domain-id", description: "key: id of domain") { - }; - domainIdOption.IsRequired = true; - command.AddOption(domainIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string domainId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, domainIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Read-only, Nullable - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Read-only, Nullable"; - // Create options for all the parameters - var domainIdOption = new Option("--domain-id", description: "key: id of domain") { - }; - domainIdOption.IsRequired = true; - command.AddOption(domainIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string domainId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, domainIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/domains/{domain_id}/domainNameReferences/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Read-only, Nullable - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Read-only, Nullable - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Domains.Item.DomainNameReferences.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Read-only, Nullable - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only, Nullable - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Domains.Item.DomainNameReferences.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Read-only, Nullable - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Domains/Item/DomainNameReferences/@Ref/RefResponse.cs b/src/generated/Domains/Item/DomainNameReferences/@Ref/RefResponse.cs deleted file mode 100644 index 7aab523084e..00000000000 --- a/src/generated/Domains/Item/DomainNameReferences/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Domains.Item.DomainNameReferences.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Domains/Item/DomainNameReferences/DomainNameReferencesRequestBuilder.cs b/src/generated/Domains/Item/DomainNameReferences/DomainNameReferencesRequestBuilder.cs index e53cacb9f28..244f87c5a71 100644 --- a/src/generated/Domains/Item/DomainNameReferences/DomainNameReferencesRequestBuilder.cs +++ b/src/generated/Domains/Item/DomainNameReferences/DomainNameReferencesRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Domains.Item.DomainNameReferences.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string domainId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string domainId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, domainIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, domainIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Domains.Item.DomainNameReferences.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Domains.Item.DomainNameReferences.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only, Nullable - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only, Nullable public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Domains/Item/DomainNameReferences/Ref/Ref.cs b/src/generated/Domains/Item/DomainNameReferences/Ref/Ref.cs new file mode 100644 index 00000000000..a720793eb70 --- /dev/null +++ b/src/generated/Domains/Item/DomainNameReferences/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Domains.Item.DomainNameReferences.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Domains/Item/DomainNameReferences/Ref/RefRequestBuilder.cs b/src/generated/Domains/Item/DomainNameReferences/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..2e5ba7eddbb --- /dev/null +++ b/src/generated/Domains/Item/DomainNameReferences/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Domains.Item.DomainNameReferences.Ref { + /// Builds and executes requests for operations under \domains\{domain-id}\domainNameReferences\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Read-only, Nullable + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Read-only, Nullable"; + // Create options for all the parameters + var domainIdOption = new Option("--domain-id", description: "key: id of domain") { + }; + domainIdOption.IsRequired = true; + command.AddOption(domainIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string domainId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, domainIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Read-only, Nullable + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Read-only, Nullable"; + // Create options for all the parameters + var domainIdOption = new Option("--domain-id", description: "key: id of domain") { + }; + domainIdOption.IsRequired = true; + command.AddOption(domainIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string domainId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, domainIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/domains/{domain_id}/domainNameReferences/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Read-only, Nullable + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Read-only, Nullable + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Domains.Item.DomainNameReferences.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Read-only, Nullable + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Domains/Item/DomainNameReferences/Ref/RefResponse.cs b/src/generated/Domains/Item/DomainNameReferences/Ref/RefResponse.cs new file mode 100644 index 00000000000..6121144c24d --- /dev/null +++ b/src/generated/Domains/Item/DomainNameReferences/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Domains.Item.DomainNameReferences.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Domains/Item/DomainRequestBuilder.cs b/src/generated/Domains/Item/DomainRequestBuilder.cs index 01eccb90ed0..b5f02751806 100644 --- a/src/generated/Domains/Item/DomainRequestBuilder.cs +++ b/src/generated/Domains/Item/DomainRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,11 +35,10 @@ public Command BuildDeleteCommand() { }; domainIdOption.IsRequired = true; command.AddOption(domainIdOption); - command.SetHandler(async (string domainId) => { + command.SetHandler(async (string domainId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, domainIdOption); return command; @@ -78,20 +77,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string domainId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string domainId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, domainIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, domainIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,14 +107,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string domainId, string body) => { + command.SetHandler(async (string domainId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, domainIdOption, bodyOption); return command; @@ -124,6 +121,9 @@ public Command BuildPatchCommand() { public Command BuildServiceConfigurationRecordsCommand() { var command = new Command("service-configuration-records"); var builder = new ApiSdk.Domains.Item.ServiceConfigurationRecords.ServiceConfigurationRecordsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -131,6 +131,9 @@ public Command BuildServiceConfigurationRecordsCommand() { public Command BuildVerificationDnsRecordsCommand() { var command = new Command("verification-dns-records"); var builder = new ApiSdk.Domains.Item.VerificationDnsRecords.VerificationDnsRecordsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -208,42 +211,6 @@ public RequestInformation CreatePatchRequestInformation(Domain body, Action - /// Delete entity from domains - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from domains by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in domains - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Domain model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from domains by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Domains/Item/ForceDelete/ForceDeleteRequestBuilder.cs b/src/generated/Domains/Item/ForceDelete/ForceDeleteRequestBuilder.cs index a21be88f681..07f5b03dc4e 100644 --- a/src/generated/Domains/Item/ForceDelete/ForceDeleteRequestBuilder.cs +++ b/src/generated/Domains/Item/ForceDelete/ForceDeleteRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string domainId, string body) => { + command.SetHandler(async (string domainId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, domainIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ForceDeleteRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forceDelete - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForceDeleteRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Domains/Item/ServiceConfigurationRecords/Item/DomainDnsRecordRequestBuilder.cs b/src/generated/Domains/Item/ServiceConfigurationRecords/Item/DomainDnsRecordRequestBuilder.cs index 37ce971bce3..035668cec18 100644 --- a/src/generated/Domains/Item/ServiceConfigurationRecords/Item/DomainDnsRecordRequestBuilder.cs +++ b/src/generated/Domains/Item/ServiceConfigurationRecords/Item/DomainDnsRecordRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; domainIdOption.IsRequired = true; command.AddOption(domainIdOption); - var domainDnsRecordIdOption = new Option("--domaindnsrecord-id", description: "key: id of domainDnsRecord") { + var domainDnsRecordIdOption = new Option("--domain-dns-record-id", description: "key: id of domainDnsRecord") { }; domainDnsRecordIdOption.IsRequired = true; command.AddOption(domainDnsRecordIdOption); - command.SetHandler(async (string domainId, string domainDnsRecordId) => { + command.SetHandler(async (string domainId, string domainDnsRecordId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, domainIdOption, domainDnsRecordIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; domainIdOption.IsRequired = true; command.AddOption(domainIdOption); - var domainDnsRecordIdOption = new Option("--domaindnsrecord-id", description: "key: id of domainDnsRecord") { + var domainDnsRecordIdOption = new Option("--domain-dns-record-id", description: "key: id of domainDnsRecord") { }; domainDnsRecordIdOption.IsRequired = true; command.AddOption(domainDnsRecordIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string domainId, string domainDnsRecordId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string domainId, string domainDnsRecordId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, domainIdOption, domainDnsRecordIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, domainIdOption, domainDnsRecordIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; domainIdOption.IsRequired = true; command.AddOption(domainIdOption); - var domainDnsRecordIdOption = new Option("--domaindnsrecord-id", description: "key: id of domainDnsRecord") { + var domainDnsRecordIdOption = new Option("--domain-dns-record-id", description: "key: id of domainDnsRecord") { }; domainDnsRecordIdOption.IsRequired = true; command.AddOption(domainDnsRecordIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string domainId, string domainDnsRecordId, string body) => { + command.SetHandler(async (string domainId, string domainDnsRecordId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, domainIdOption, domainDnsRecordIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(DomainDnsRecord body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// DNS records the customer adds to the DNS zone file of the domain before the domain can be used by Microsoft Online services. Read-only, Nullable - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// DNS records the customer adds to the DNS zone file of the domain before the domain can be used by Microsoft Online services. Read-only, Nullable - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// DNS records the customer adds to the DNS zone file of the domain before the domain can be used by Microsoft Online services. Read-only, Nullable - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DomainDnsRecord model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// DNS records the customer adds to the DNS zone file of the domain before the domain can be used by Microsoft Online services. Read-only, Nullable public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Domains/Item/ServiceConfigurationRecords/ServiceConfigurationRecordsRequestBuilder.cs b/src/generated/Domains/Item/ServiceConfigurationRecords/ServiceConfigurationRecordsRequestBuilder.cs index 3ce9449d376..b24bc5d5029 100644 --- a/src/generated/Domains/Item/ServiceConfigurationRecords/ServiceConfigurationRecordsRequestBuilder.cs +++ b/src/generated/Domains/Item/ServiceConfigurationRecords/ServiceConfigurationRecordsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ServiceConfigurationRecordsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DomainDnsRecordRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string domainId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string domainId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, domainIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, domainIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string domainId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string domainId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, domainIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, domainIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(DomainDnsRecord body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// DNS records the customer adds to the DNS zone file of the domain before the domain can be used by Microsoft Online services. Read-only, Nullable - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// DNS records the customer adds to the DNS zone file of the domain before the domain can be used by Microsoft Online services. Read-only, Nullable - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DomainDnsRecord model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// DNS records the customer adds to the DNS zone file of the domain before the domain can be used by Microsoft Online services. Read-only, Nullable public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Domains/Item/VerificationDnsRecords/Item/DomainDnsRecordRequestBuilder.cs b/src/generated/Domains/Item/VerificationDnsRecords/Item/DomainDnsRecordRequestBuilder.cs index 37b04daaa44..69780a6cde0 100644 --- a/src/generated/Domains/Item/VerificationDnsRecords/Item/DomainDnsRecordRequestBuilder.cs +++ b/src/generated/Domains/Item/VerificationDnsRecords/Item/DomainDnsRecordRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; domainIdOption.IsRequired = true; command.AddOption(domainIdOption); - var domainDnsRecordIdOption = new Option("--domaindnsrecord-id", description: "key: id of domainDnsRecord") { + var domainDnsRecordIdOption = new Option("--domain-dns-record-id", description: "key: id of domainDnsRecord") { }; domainDnsRecordIdOption.IsRequired = true; command.AddOption(domainDnsRecordIdOption); - command.SetHandler(async (string domainId, string domainDnsRecordId) => { + command.SetHandler(async (string domainId, string domainDnsRecordId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, domainIdOption, domainDnsRecordIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; domainIdOption.IsRequired = true; command.AddOption(domainIdOption); - var domainDnsRecordIdOption = new Option("--domaindnsrecord-id", description: "key: id of domainDnsRecord") { + var domainDnsRecordIdOption = new Option("--domain-dns-record-id", description: "key: id of domainDnsRecord") { }; domainDnsRecordIdOption.IsRequired = true; command.AddOption(domainDnsRecordIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string domainId, string domainDnsRecordId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string domainId, string domainDnsRecordId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, domainIdOption, domainDnsRecordIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, domainIdOption, domainDnsRecordIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; domainIdOption.IsRequired = true; command.AddOption(domainIdOption); - var domainDnsRecordIdOption = new Option("--domaindnsrecord-id", description: "key: id of domainDnsRecord") { + var domainDnsRecordIdOption = new Option("--domain-dns-record-id", description: "key: id of domainDnsRecord") { }; domainDnsRecordIdOption.IsRequired = true; command.AddOption(domainDnsRecordIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string domainId, string domainDnsRecordId, string body) => { + command.SetHandler(async (string domainId, string domainDnsRecordId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, domainIdOption, domainDnsRecordIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(DomainDnsRecord body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// DNS records that the customer adds to the DNS zone file of the domain before the customer can complete domain ownership verification with Azure AD. Read-only, Nullable - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// DNS records that the customer adds to the DNS zone file of the domain before the customer can complete domain ownership verification with Azure AD. Read-only, Nullable - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// DNS records that the customer adds to the DNS zone file of the domain before the customer can complete domain ownership verification with Azure AD. Read-only, Nullable - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DomainDnsRecord model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// DNS records that the customer adds to the DNS zone file of the domain before the customer can complete domain ownership verification with Azure AD. Read-only, Nullable public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Domains/Item/VerificationDnsRecords/VerificationDnsRecordsRequestBuilder.cs b/src/generated/Domains/Item/VerificationDnsRecords/VerificationDnsRecordsRequestBuilder.cs index 2501c994567..2a3b2e91506 100644 --- a/src/generated/Domains/Item/VerificationDnsRecords/VerificationDnsRecordsRequestBuilder.cs +++ b/src/generated/Domains/Item/VerificationDnsRecords/VerificationDnsRecordsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class VerificationDnsRecordsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DomainDnsRecordRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string domainId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string domainId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, domainIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, domainIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string domainId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string domainId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, domainIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, domainIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(DomainDnsRecord body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// DNS records that the customer adds to the DNS zone file of the domain before the customer can complete domain ownership verification with Azure AD. Read-only, Nullable - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// DNS records that the customer adds to the DNS zone file of the domain before the customer can complete domain ownership verification with Azure AD. Read-only, Nullable - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DomainDnsRecord model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// DNS records that the customer adds to the DNS zone file of the domain before the customer can complete domain ownership verification with Azure AD. Read-only, Nullable public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Domains/Item/Verify/VerifyRequestBuilder.cs b/src/generated/Domains/Item/Verify/VerifyRequestBuilder.cs index bbbf4c6c57b..17cf22469f4 100644 --- a/src/generated/Domains/Item/Verify/VerifyRequestBuilder.cs +++ b/src/generated/Domains/Item/Verify/VerifyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildPostCommand() { }; domainIdOption.IsRequired = true; command.AddOption(domainIdOption); - command.SetHandler(async (string domainId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string domainId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, domainIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, domainIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action verify - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes domain public class VerifyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Drive/Bundles/BundlesRequestBuilder.cs b/src/generated/Drive/Bundles/BundlesRequestBuilder.cs index b0c3ae528e8..5d3d5f3f8c2 100644 --- a/src/generated/Drive/Bundles/BundlesRequestBuilder.cs +++ b/src/generated/Drive/Bundles/BundlesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class BundlesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DriveItemRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of [bundles][bundle] (albums and multi-select-shared sets of items). Only in personal OneDrive. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of [bundles][bundle] (albums and multi-select-shared sets of items). Only in personal OneDrive. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of [bundles][bundle] (albums and multi-select-shared sets of items). Only in personal OneDrive. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Drive/Bundles/Item/Content/ContentRequestBuilder.cs b/src/generated/Drive/Bundles/Item/Content/ContentRequestBuilder.cs index b49d0b8505a..fd049bc7cd2 100644 --- a/src/generated/Drive/Bundles/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Drive/Bundles/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,28 +25,30 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get media content for the navigation property bundles from drive"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string driveItemId, FileInfo output) => { + command.SetHandler(async (string driveItemId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, driveItemIdOption, outputOption); + }, driveItemIdOption, fileOption, outputOption); return command; } /// @@ -56,7 +58,7 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "Update media content for the navigation property bundles in drive"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -64,12 +66,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, FileInfo file) => { + command.SetHandler(async (string driveItemId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, bodyOption); return command; @@ -120,29 +121,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property bundles from drive - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property bundles in drive - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drive/Bundles/Item/DriveItemRequestBuilder.cs b/src/generated/Drive/Bundles/Item/DriveItemRequestBuilder.cs index 913b8a7e538..082cc93327d 100644 --- a/src/generated/Drive/Bundles/Item/DriveItemRequestBuilder.cs +++ b/src/generated/Drive/Bundles/Item/DriveItemRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Collection of [bundles][bundle] (albums and multi-select-shared sets of items). Only in personal OneDrive."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { + command.SetHandler(async (string driveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Collection of [bundles][bundle] (albums and multi-select-shared sets of items). Only in personal OneDrive."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,7 +89,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Collection of [bundles][bundle] (albums and multi-select-shared sets of items). Only in personal OneDrive."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -99,14 +97,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + command.SetHandler(async (string driveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, bodyOption); return command; @@ -178,42 +175,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of [bundles][bundle] (albums and multi-select-shared sets of items). Only in personal OneDrive. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of [bundles][bundle] (albums and multi-select-shared sets of items). Only in personal OneDrive. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of [bundles][bundle] (albums and multi-select-shared sets of items). Only in personal OneDrive. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of [bundles][bundle] (albums and multi-select-shared sets of items). Only in personal OneDrive. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drive/DriveRequestBuilder.cs b/src/generated/Drive/DriveRequestBuilder.cs index 7a411a5faed..272203195ac 100644 --- a/src/generated/Drive/DriveRequestBuilder.cs +++ b/src/generated/Drive/DriveRequestBuilder.cs @@ -10,10 +10,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,6 +31,9 @@ public class DriveRequestBuilder { public Command BuildBundlesCommand() { var command = new Command("bundles"); var builder = new ApiSdk.Drive.Bundles.BundlesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -38,6 +41,9 @@ public Command BuildBundlesCommand() { public Command BuildFollowingCommand() { var command = new Command("following"); var builder = new ApiSdk.Drive.Following.FollowingRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -59,25 +65,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } public Command BuildItemsCommand() { var command = new Command("items"); var builder = new ApiSdk.Drive.Items.ItemsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -106,14 +114,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -130,6 +137,9 @@ public Command BuildRootCommand() { public Command BuildSpecialCommand() { var command = new Command("special"); var builder = new ApiSdk.Drive.Special.SpecialRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -187,31 +197,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. return requestInfo; } /// - /// Get drive - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update drive - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Drive model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \drive\microsoft.graph.recent() /// public RecentRequestBuilder Recent() { diff --git a/src/generated/Drive/Following/FollowingRequestBuilder.cs b/src/generated/Drive/Following/FollowingRequestBuilder.cs index f12f43855f7..240270c0906 100644 --- a/src/generated/Drive/Following/FollowingRequestBuilder.cs +++ b/src/generated/Drive/Following/FollowingRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class FollowingRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DriveItemRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of items the user is following. Only in OneDrive for Business. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of items the user is following. Only in OneDrive for Business. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of items the user is following. Only in OneDrive for Business. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Drive/Following/Item/Content/ContentRequestBuilder.cs b/src/generated/Drive/Following/Item/Content/ContentRequestBuilder.cs index 3e53912ade3..d6cad07b1fa 100644 --- a/src/generated/Drive/Following/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Drive/Following/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,28 +25,30 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get media content for the navigation property following from drive"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string driveItemId, FileInfo output) => { + command.SetHandler(async (string driveItemId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, driveItemIdOption, outputOption); + }, driveItemIdOption, fileOption, outputOption); return command; } /// @@ -56,7 +58,7 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "Update media content for the navigation property following in drive"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -64,12 +66,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, FileInfo file) => { + command.SetHandler(async (string driveItemId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, bodyOption); return command; @@ -120,29 +121,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property following from drive - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property following in drive - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drive/Following/Item/DriveItemRequestBuilder.cs b/src/generated/Drive/Following/Item/DriveItemRequestBuilder.cs index e601438f09d..fd2b3a71d23 100644 --- a/src/generated/Drive/Following/Item/DriveItemRequestBuilder.cs +++ b/src/generated/Drive/Following/Item/DriveItemRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of items the user is following. Only in OneDrive for Business."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { + command.SetHandler(async (string driveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of items the user is following. Only in OneDrive for Business."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,7 +89,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of items the user is following. Only in OneDrive for Business."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -99,14 +97,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + command.SetHandler(async (string driveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, bodyOption); return command; @@ -178,42 +175,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of items the user is following. Only in OneDrive for Business. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of items the user is following. Only in OneDrive for Business. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of items the user is following. Only in OneDrive for Business. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of items the user is following. Only in OneDrive for Business. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drive/Items/Item/Content/ContentRequestBuilder.cs b/src/generated/Drive/Items/Item/Content/ContentRequestBuilder.cs index 86a0f07cf2e..b7b1f17640a 100644 --- a/src/generated/Drive/Items/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Drive/Items/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,28 +25,30 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get media content for the navigation property items from drive"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string driveItemId, FileInfo output) => { + command.SetHandler(async (string driveItemId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, driveItemIdOption, outputOption); + }, driveItemIdOption, fileOption, outputOption); return command; } /// @@ -56,7 +58,7 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "Update media content for the navigation property items in drive"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -64,12 +66,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, FileInfo file) => { + command.SetHandler(async (string driveItemId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, bodyOption); return command; @@ -120,29 +121,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property items from drive - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property items in drive - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drive/Items/Item/DriveItemRequestBuilder.cs b/src/generated/Drive/Items/Item/DriveItemRequestBuilder.cs index 005d0293712..8743983d9ff 100644 --- a/src/generated/Drive/Items/Item/DriveItemRequestBuilder.cs +++ b/src/generated/Drive/Items/Item/DriveItemRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "All items contained in the drive. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { + command.SetHandler(async (string driveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "All items contained in the drive. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,7 +89,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "All items contained in the drive. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -99,14 +97,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + command.SetHandler(async (string driveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, bodyOption); return command; @@ -178,42 +175,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All items contained in the drive. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All items contained in the drive. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All items contained in the drive. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// All items contained in the drive. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drive/Items/ItemsRequestBuilder.cs b/src/generated/Drive/Items/ItemsRequestBuilder.cs index 54b5ce1ce82..abb7bdcc370 100644 --- a/src/generated/Drive/Items/ItemsRequestBuilder.cs +++ b/src/generated/Drive/Items/ItemsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class ItemsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DriveItemRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All items contained in the drive. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All items contained in the drive. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// All items contained in the drive. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Drive/List/Columns/ColumnsRequestBuilder.cs b/src/generated/Drive/List/Columns/ColumnsRequestBuilder.cs index 246d726b12d..edea77debdc 100644 --- a/src/generated/Drive/List/Columns/ColumnsRequestBuilder.cs +++ b/src/generated/Drive/List/Columns/ColumnsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class ColumnsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ColumnDefinitionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSourceColumnCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSourceColumnCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(ColumnDefinition body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of field definitions for this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of field definitions for this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ColumnDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of field definitions for this list. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Drive/List/Columns/Item/ColumnDefinitionRequestBuilder.cs b/src/generated/Drive/List/Columns/Item/ColumnDefinitionRequestBuilder.cs index 2db0e97e4bc..c56619b5c6e 100644 --- a/src/generated/Drive/List/Columns/Item/ColumnDefinitionRequestBuilder.cs +++ b/src/generated/Drive/List/Columns/Item/ColumnDefinitionRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,15 +27,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of field definitions for this list."; // Create options for all the parameters - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string columnDefinitionId) => { + command.SetHandler(async (string columnDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, columnDefinitionIdOption); return command; @@ -47,7 +46,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of field definitions for this list."; // Create options for all the parameters - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -61,20 +60,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string columnDefinitionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string columnDefinitionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, columnDefinitionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, columnDefinitionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of field definitions for this list."; // Create options for all the parameters - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -92,14 +90,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string columnDefinitionId, string body) => { + command.SetHandler(async (string columnDefinitionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, columnDefinitionIdOption, bodyOption); return command; @@ -178,42 +175,6 @@ public RequestInformation CreatePatchRequestInformation(ColumnDefinition body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of field definitions for this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of field definitions for this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of field definitions for this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ColumnDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of field definitions for this list. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drive/List/Columns/Item/SourceColumn/@Ref/@Ref.cs b/src/generated/Drive/List/Columns/Item/SourceColumn/@Ref/@Ref.cs deleted file mode 100644 index 05d20e6269d..00000000000 --- a/src/generated/Drive/List/Columns/Item/SourceColumn/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Drive.List.Columns.Item.SourceColumn.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Drive/List/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs b/src/generated/Drive/List/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs deleted file mode 100644 index f68fed1ad03..00000000000 --- a/src/generated/Drive/List/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Drive.List.Columns.Item.SourceColumn.@Ref { - /// Builds and executes requests for operations under \drive\list\columns\{columnDefinition-id}\sourceColumn\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The source column for content type column. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string columnDefinitionId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, columnDefinitionIdOption); - return command; - } - /// - /// The source column for content type column. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string columnDefinitionId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, columnDefinitionIdOption); - return command; - } - /// - /// The source column for content type column. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string columnDefinitionId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, columnDefinitionIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/drive/list/columns/{columnDefinition_id}/sourceColumn/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The source column for content type column. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Drive.List.Columns.Item.SourceColumn.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Drive.List.Columns.Item.SourceColumn.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Drive/List/Columns/Item/SourceColumn/Ref/Ref.cs b/src/generated/Drive/List/Columns/Item/SourceColumn/Ref/Ref.cs new file mode 100644 index 00000000000..47ad7ff40fd --- /dev/null +++ b/src/generated/Drive/List/Columns/Item/SourceColumn/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Drive.List.Columns.Item.SourceColumn.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Drive/List/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs b/src/generated/Drive/List/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..ba363bd0213 --- /dev/null +++ b/src/generated/Drive/List/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Drive.List.Columns.Item.SourceColumn.Ref { + /// Builds and executes requests for operations under \drive\list\columns\{columnDefinition-id}\sourceColumn\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The source column for content type column. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + command.SetHandler(async (string columnDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, columnDefinitionIdOption); + return command; + } + /// + /// The source column for content type column. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string columnDefinitionId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, columnDefinitionIdOption, outputOption); + return command; + } + /// + /// The source column for content type column. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string columnDefinitionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, columnDefinitionIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/drive/list/columns/{columnDefinition_id}/sourceColumn/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The source column for content type column. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The source column for content type column. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The source column for content type column. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Drive.List.Columns.Item.SourceColumn.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Drive/List/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs b/src/generated/Drive/List/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs index c61846629f7..5e4a4fd0ab0 100644 --- a/src/generated/Drive/List/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs +++ b/src/generated/Drive/List/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The source column for content type column."; // Create options for all the parameters - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string columnDefinitionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string columnDefinitionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, columnDefinitionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, columnDefinitionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Drive.List.Columns.Item.SourceColumn.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Drive.List.Columns.Item.SourceColumn.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The source column for content type column. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drive/List/ContentTypes/AddCopy/AddCopyRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/AddCopy/AddCopyRequestBuilder.cs index 37136bb021c..d831820cc11 100644 --- a/src/generated/Drive/List/ContentTypes/AddCopy/AddCopyRequestBuilder.cs +++ b/src/generated/Drive/List/ContentTypes/AddCopy/AddCopyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -78,19 +77,6 @@ public RequestInformation CreatePostRequestInformation(AddCopyRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action addCopy - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddCopyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes contentType public class AddCopyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Drive/List/ContentTypes/ContentTypesRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/ContentTypesRequestBuilder.cs index a73109566eb..0ed7c279837 100644 --- a/src/generated/Drive/List/ContentTypes/ContentTypesRequestBuilder.cs +++ b/src/generated/Drive/List/ContentTypes/ContentTypesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,20 +29,19 @@ public Command BuildAddCopyCommand() { } public List BuildCommand() { var builder = new ContentTypeRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAssociateWithHubSitesCommand(), - builder.BuildBaseCommand(), - builder.BuildBaseTypesCommand(), - builder.BuildColumnLinksCommand(), - builder.BuildColumnPositionsCommand(), - builder.BuildColumnsCommand(), - builder.BuildCopyToDefaultContentLocationCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildPublishCommand(), - builder.BuildUnpublishCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAssociateWithHubSitesCommand()); + commands.Add(builder.BuildBaseCommand()); + commands.Add(builder.BuildBaseTypesCommand()); + commands.Add(builder.BuildColumnLinksCommand()); + commands.Add(builder.BuildColumnPositionsCommand()); + commands.Add(builder.BuildColumnsCommand()); + commands.Add(builder.BuildCopyToDefaultContentLocationCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPublishCommand()); + commands.Add(builder.BuildUnpublishCommand()); return commands; } /// @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(ContentType body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of content types present in this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of content types present in this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ContentType model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of content types present in this list. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Drive/List/ContentTypes/Item/@Base/@Ref/@Ref.cs b/src/generated/Drive/List/ContentTypes/Item/@Base/@Ref/@Ref.cs deleted file mode 100644 index 745b8b9ee8b..00000000000 --- a/src/generated/Drive/List/ContentTypes/Item/@Base/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Drive.List.ContentTypes.Item.@Base.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Drive/List/ContentTypes/Item/@Base/@Ref/RefRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/@Base/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 779f118f1d8..00000000000 --- a/src/generated/Drive/List/ContentTypes/Item/@Base/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Drive.List.ContentTypes.Item.@Base.@Ref { - /// Builds and executes requests for operations under \drive\list\contentTypes\{contentType-id}\base\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Parent contentType from which this content type is derived. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Parent contentType from which this content type is derived."; - // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - command.SetHandler(async (string contentTypeId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, contentTypeIdOption); - return command; - } - /// - /// Parent contentType from which this content type is derived. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Parent contentType from which this content type is derived."; - // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - command.SetHandler(async (string contentTypeId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contentTypeIdOption); - return command; - } - /// - /// Parent contentType from which this content type is derived. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Parent contentType from which this content type is derived."; - // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string contentTypeId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, contentTypeIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/drive/list/contentTypes/{contentType_id}/base/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Parent contentType from which this content type is derived. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Parent contentType from which this content type is derived. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Parent contentType from which this content type is derived. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Drive.List.ContentTypes.Item.@Base.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Parent contentType from which this content type is derived. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Parent contentType from which this content type is derived. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Parent contentType from which this content type is derived. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Drive.List.ContentTypes.Item.@Base.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Drive/List/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs b/src/generated/Drive/List/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs deleted file mode 100644 index faf214088c8..00000000000 --- a/src/generated/Drive/List/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Drive.List.ContentTypes.Item.@Base.AssociateWithHubSites { - public class AssociateWithHubSitesRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public List HubSiteUrls { get; set; } - public bool? PropagateToExistingLists { get; set; } - /// - /// Instantiates a new associateWithHubSitesRequestBody and sets the default values. - /// - public AssociateWithHubSitesRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"hubSiteUrls", (o,n) => { (o as AssociateWithHubSitesRequestBody).HubSiteUrls = n.GetCollectionOfPrimitiveValues().ToList(); } }, - {"propagateToExistingLists", (o,n) => { (o as AssociateWithHubSitesRequestBody).PropagateToExistingLists = n.GetBoolValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteCollectionOfPrimitiveValues("hubSiteUrls", HubSiteUrls); - writer.WriteBoolValue("propagateToExistingLists", PropagateToExistingLists); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Drive/List/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs deleted file mode 100644 index cf45641000f..00000000000 --- a/src/generated/Drive/List/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs +++ /dev/null @@ -1,93 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Drive.List.ContentTypes.Item.@Base.AssociateWithHubSites { - /// Builds and executes requests for operations under \drive\list\contentTypes\{contentType-id}\base\microsoft.graph.associateWithHubSites - public class AssociateWithHubSitesRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action associateWithHubSites - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action associateWithHubSites"; - // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string contentTypeId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, contentTypeIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AssociateWithHubSitesRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AssociateWithHubSitesRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/drive/list/contentTypes/{contentType_id}/base/microsoft.graph.associateWithHubSites"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action associateWithHubSites - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AssociateWithHubSitesRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action associateWithHubSites - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssociateWithHubSitesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Drive/List/ContentTypes/Item/@Base/BaseRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/@Base/BaseRequestBuilder.cs deleted file mode 100644 index ee2210fb7ac..00000000000 --- a/src/generated/Drive/List/ContentTypes/Item/@Base/BaseRequestBuilder.cs +++ /dev/null @@ -1,157 +0,0 @@ -using ApiSdk.Drive.List.ContentTypes.Item.Base.AssociateWithHubSites; -using ApiSdk.Drive.List.ContentTypes.Item.Base.CopyToDefaultContentLocation; -using ApiSdk.Drive.List.ContentTypes.Item.Base.IsPublished; -using ApiSdk.Drive.List.ContentTypes.Item.Base.Publish; -using ApiSdk.Drive.List.ContentTypes.Item.Base.Ref; -using ApiSdk.Drive.List.ContentTypes.Item.Base.Unpublish; -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Drive.List.ContentTypes.Item.@Base { - /// Builds and executes requests for operations under \drive\list\contentTypes\{contentType-id}\base - public class BaseRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - public Command BuildAssociateWithHubSitesCommand() { - var command = new Command("associate-with-hub-sites"); - var builder = new ApiSdk.Drive.List.ContentTypes.Item.@Base.AssociateWithHubSites.AssociateWithHubSitesRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildPostCommand()); - return command; - } - public Command BuildCopyToDefaultContentLocationCommand() { - var command = new Command("copy-to-default-content-location"); - var builder = new ApiSdk.Drive.List.ContentTypes.Item.@Base.CopyToDefaultContentLocation.CopyToDefaultContentLocationRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildPostCommand()); - return command; - } - /// - /// Parent contentType from which this content type is derived. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Parent contentType from which this content type is derived."; - // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string contentTypeId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contentTypeIdOption, selectOption, expandOption); - return command; - } - public Command BuildPublishCommand() { - var command = new Command("publish"); - var builder = new ApiSdk.Drive.List.ContentTypes.Item.@Base.Publish.PublishRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildPostCommand()); - return command; - } - public Command BuildRefCommand() { - var command = new Command("ref"); - var builder = new ApiSdk.Drive.List.ContentTypes.Item.@Base.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildDeleteCommand()); - command.AddCommand(builder.BuildGetCommand()); - command.AddCommand(builder.BuildPutCommand()); - return command; - } - public Command BuildUnpublishCommand() { - var command = new Command("unpublish"); - var builder = new ApiSdk.Drive.List.ContentTypes.Item.@Base.Unpublish.UnpublishRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildPostCommand()); - return command; - } - /// - /// Instantiates a new BaseRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public BaseRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/drive/list/contentTypes/{contentType_id}/base{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Parent contentType from which this content type is derived. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Parent contentType from which this content type is derived. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Builds and executes requests for operations under \drive\list\contentTypes\{contentType-id}\base\microsoft.graph.isPublished() - /// - public IsPublishedRequestBuilder IsPublished() { - return new IsPublishedRequestBuilder(PathParameters, RequestAdapter); - } - /// Parent contentType from which this content type is derived. - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/Drive/List/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs b/src/generated/Drive/List/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs deleted file mode 100644 index 3af061906a5..00000000000 --- a/src/generated/Drive/List/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs +++ /dev/null @@ -1,39 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Drive.List.ContentTypes.Item.@Base.CopyToDefaultContentLocation { - public class CopyToDefaultContentLocationRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string DestinationFileName { get; set; } - public ItemReference SourceFile { get; set; } - /// - /// Instantiates a new copyToDefaultContentLocationRequestBody and sets the default values. - /// - public CopyToDefaultContentLocationRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"destinationFileName", (o,n) => { (o as CopyToDefaultContentLocationRequestBody).DestinationFileName = n.GetStringValue(); } }, - {"sourceFile", (o,n) => { (o as CopyToDefaultContentLocationRequestBody).SourceFile = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("destinationFileName", DestinationFileName); - writer.WriteObjectValue("sourceFile", SourceFile); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Drive/List/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs deleted file mode 100644 index 705714410c9..00000000000 --- a/src/generated/Drive/List/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs +++ /dev/null @@ -1,93 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Drive.List.ContentTypes.Item.@Base.CopyToDefaultContentLocation { - /// Builds and executes requests for operations under \drive\list\contentTypes\{contentType-id}\base\microsoft.graph.copyToDefaultContentLocation - public class CopyToDefaultContentLocationRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action copyToDefaultContentLocation - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action copyToDefaultContentLocation"; - // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string contentTypeId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, contentTypeIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new CopyToDefaultContentLocationRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public CopyToDefaultContentLocationRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/drive/list/contentTypes/{contentType_id}/base/microsoft.graph.copyToDefaultContentLocation"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action copyToDefaultContentLocation - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(CopyToDefaultContentLocationRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action copyToDefaultContentLocation - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToDefaultContentLocationRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Drive/List/ContentTypes/Item/@Base/IsPublished/IsPublishedRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/@Base/IsPublished/IsPublishedRequestBuilder.cs deleted file mode 100644 index 903a3e8622a..00000000000 --- a/src/generated/Drive/List/ContentTypes/Item/@Base/IsPublished/IsPublishedRequestBuilder.cs +++ /dev/null @@ -1,86 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Drive.List.ContentTypes.Item.@Base.IsPublished { - /// Builds and executes requests for operations under \drive\list\contentTypes\{contentType-id}\base\microsoft.graph.isPublished() - public class IsPublishedRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke function isPublished - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Invoke function isPublished"; - // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - command.SetHandler(async (string contentTypeId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteBoolValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contentTypeIdOption); - return command; - } - /// - /// Instantiates a new IsPublishedRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public IsPublishedRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/drive/list/contentTypes/{contentType_id}/base/microsoft.graph.isPublished()"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke function isPublished - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke function isPublished - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Drive/List/ContentTypes/Item/@Base/Publish/PublishRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/@Base/Publish/PublishRequestBuilder.cs deleted file mode 100644 index 342dbd923e3..00000000000 --- a/src/generated/Drive/List/ContentTypes/Item/@Base/Publish/PublishRequestBuilder.cs +++ /dev/null @@ -1,81 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Drive.List.ContentTypes.Item.@Base.Publish { - /// Builds and executes requests for operations under \drive\list\contentTypes\{contentType-id}\base\microsoft.graph.publish - public class PublishRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action publish - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action publish"; - // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - command.SetHandler(async (string contentTypeId) => { - var requestInfo = CreatePostRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, contentTypeIdOption); - return command; - } - /// - /// Instantiates a new PublishRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public PublishRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/drive/list/contentTypes/{contentType_id}/base/microsoft.graph.publish"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action publish - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action publish - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Drive/List/ContentTypes/Item/@Base/Unpublish/UnpublishRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/@Base/Unpublish/UnpublishRequestBuilder.cs deleted file mode 100644 index 12f7398830e..00000000000 --- a/src/generated/Drive/List/ContentTypes/Item/@Base/Unpublish/UnpublishRequestBuilder.cs +++ /dev/null @@ -1,81 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Drive.List.ContentTypes.Item.@Base.Unpublish { - /// Builds and executes requests for operations under \drive\list\contentTypes\{contentType-id}\base\microsoft.graph.unpublish - public class UnpublishRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action unpublish - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action unpublish"; - // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - command.SetHandler(async (string contentTypeId) => { - var requestInfo = CreatePostRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, contentTypeIdOption); - return command; - } - /// - /// Instantiates a new UnpublishRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public UnpublishRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/drive/list/contentTypes/{contentType_id}/base/microsoft.graph.unpublish"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action unpublish - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action unpublish - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Drive/List/ContentTypes/Item/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs index 9c943ccb7be..108e36a3bce 100644 --- a/src/generated/Drive/List/ContentTypes/Item/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs +++ b/src/generated/Drive/List/ContentTypes/Item/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action associateWithHubSites"; // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contentTypeId, string body) => { + command.SetHandler(async (string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contentTypeIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(AssociateWithHubSitesRequ requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action associateWithHubSites - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssociateWithHubSitesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drive/List/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs b/src/generated/Drive/List/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs new file mode 100644 index 00000000000..56fe50aeb58 --- /dev/null +++ b/src/generated/Drive/List/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Drive.List.ContentTypes.Item.Base.AssociateWithHubSites { + public class AssociateWithHubSitesRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public List HubSiteUrls { get; set; } + public bool? PropagateToExistingLists { get; set; } + /// + /// Instantiates a new associateWithHubSitesRequestBody and sets the default values. + /// + public AssociateWithHubSitesRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"hubSiteUrls", (o,n) => { (o as AssociateWithHubSitesRequestBody).HubSiteUrls = n.GetCollectionOfPrimitiveValues().ToList(); } }, + {"propagateToExistingLists", (o,n) => { (o as AssociateWithHubSitesRequestBody).PropagateToExistingLists = n.GetBoolValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfPrimitiveValues("hubSiteUrls", HubSiteUrls); + writer.WriteBoolValue("propagateToExistingLists", PropagateToExistingLists); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Drive/List/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs new file mode 100644 index 00000000000..71597edee9a --- /dev/null +++ b/src/generated/Drive/List/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs @@ -0,0 +1,79 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Drive.List.ContentTypes.Item.Base.AssociateWithHubSites { + /// Builds and executes requests for operations under \drive\list\contentTypes\{contentType-id}\base\microsoft.graph.associateWithHubSites + public class AssociateWithHubSitesRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action associateWithHubSites + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action associateWithHubSites"; + // Create options for all the parameters + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, contentTypeIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new AssociateWithHubSitesRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AssociateWithHubSitesRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/drive/list/contentTypes/{contentType_id}/base/microsoft.graph.associateWithHubSites"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action associateWithHubSites + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AssociateWithHubSitesRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Drive/List/ContentTypes/Item/Base/BaseRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/Base/BaseRequestBuilder.cs new file mode 100644 index 00000000000..7d8ddee2547 --- /dev/null +++ b/src/generated/Drive/List/ContentTypes/Item/Base/BaseRequestBuilder.cs @@ -0,0 +1,144 @@ +using ApiSdk.Drive.List.ContentTypes.Item.Base.AssociateWithHubSites; +using ApiSdk.Drive.List.ContentTypes.Item.Base.CopyToDefaultContentLocation; +using ApiSdk.Drive.List.ContentTypes.Item.Base.IsPublished; +using ApiSdk.Drive.List.ContentTypes.Item.Base.Publish; +using ApiSdk.Drive.List.ContentTypes.Item.Base.Ref; +using ApiSdk.Drive.List.ContentTypes.Item.Base.Unpublish; +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Drive.List.ContentTypes.Item.Base { + /// Builds and executes requests for operations under \drive\list\contentTypes\{contentType-id}\base + public class BaseRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + public Command BuildAssociateWithHubSitesCommand() { + var command = new Command("associate-with-hub-sites"); + var builder = new ApiSdk.Drive.List.ContentTypes.Item.Base.AssociateWithHubSites.AssociateWithHubSitesRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildPostCommand()); + return command; + } + public Command BuildCopyToDefaultContentLocationCommand() { + var command = new Command("copy-to-default-content-location"); + var builder = new ApiSdk.Drive.List.ContentTypes.Item.Base.CopyToDefaultContentLocation.CopyToDefaultContentLocationRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildPostCommand()); + return command; + } + /// + /// Parent contentType from which this content type is derived. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Parent contentType from which this content type is derived."; + // Create options for all the parameters + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var selectOption = new Option("--select", description: "Select properties to be returned") { + Arity = ArgumentArity.ZeroOrMore + }; + selectOption.IsRequired = false; + command.AddOption(selectOption); + var expandOption = new Option("--expand", description: "Expand related entities") { + Arity = ArgumentArity.ZeroOrMore + }; + expandOption.IsRequired = false; + command.AddOption(expandOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contentTypeId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Select = select; + q.Expand = expand; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contentTypeIdOption, selectOption, expandOption, outputOption); + return command; + } + public Command BuildPublishCommand() { + var command = new Command("publish"); + var builder = new ApiSdk.Drive.List.ContentTypes.Item.Base.Publish.PublishRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildPostCommand()); + return command; + } + public Command BuildRefCommand() { + var command = new Command("ref"); + var builder = new ApiSdk.Drive.List.ContentTypes.Item.Base.Ref.RefRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildDeleteCommand()); + command.AddCommand(builder.BuildGetCommand()); + command.AddCommand(builder.BuildPutCommand()); + return command; + } + public Command BuildUnpublishCommand() { + var command = new Command("unpublish"); + var builder = new ApiSdk.Drive.List.ContentTypes.Item.Base.Unpublish.UnpublishRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildPostCommand()); + return command; + } + /// + /// Instantiates a new BaseRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public BaseRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/drive/list/contentTypes/{contentType_id}/base{?select,expand}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Parent contentType from which this content type is derived. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Builds and executes requests for operations under \drive\list\contentTypes\{contentType-id}\base\microsoft.graph.isPublished() + /// + public IsPublishedRequestBuilder IsPublished() { + return new IsPublishedRequestBuilder(PathParameters, RequestAdapter); + } + /// Parent contentType from which this content type is derived. + public class GetQueryParameters : QueryParametersBase { + /// Expand related entities + public string[] Expand { get; set; } + /// Select properties to be returned + public string[] Select { get; set; } + } + } +} diff --git a/src/generated/Drive/List/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs b/src/generated/Drive/List/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs new file mode 100644 index 00000000000..bfb6f9c40a1 --- /dev/null +++ b/src/generated/Drive/List/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs @@ -0,0 +1,39 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Drive.List.ContentTypes.Item.Base.CopyToDefaultContentLocation { + public class CopyToDefaultContentLocationRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string DestinationFileName { get; set; } + public ItemReference SourceFile { get; set; } + /// + /// Instantiates a new copyToDefaultContentLocationRequestBody and sets the default values. + /// + public CopyToDefaultContentLocationRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"destinationFileName", (o,n) => { (o as CopyToDefaultContentLocationRequestBody).DestinationFileName = n.GetStringValue(); } }, + {"sourceFile", (o,n) => { (o as CopyToDefaultContentLocationRequestBody).SourceFile = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("destinationFileName", DestinationFileName); + writer.WriteObjectValue("sourceFile", SourceFile); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Drive/List/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs new file mode 100644 index 00000000000..986ce46e067 --- /dev/null +++ b/src/generated/Drive/List/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs @@ -0,0 +1,79 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Drive.List.ContentTypes.Item.Base.CopyToDefaultContentLocation { + /// Builds and executes requests for operations under \drive\list\contentTypes\{contentType-id}\base\microsoft.graph.copyToDefaultContentLocation + public class CopyToDefaultContentLocationRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action copyToDefaultContentLocation + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action copyToDefaultContentLocation"; + // Create options for all the parameters + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, contentTypeIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new CopyToDefaultContentLocationRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public CopyToDefaultContentLocationRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/drive/list/contentTypes/{contentType_id}/base/microsoft.graph.copyToDefaultContentLocation"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action copyToDefaultContentLocation + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(CopyToDefaultContentLocationRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Drive/List/ContentTypes/Item/Base/IsPublished/IsPublishedRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/Base/IsPublished/IsPublishedRequestBuilder.cs new file mode 100644 index 00000000000..9d708987970 --- /dev/null +++ b/src/generated/Drive/List/ContentTypes/Item/Base/IsPublished/IsPublishedRequestBuilder.cs @@ -0,0 +1,74 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Drive.List.ContentTypes.Item.Base.IsPublished { + /// Builds and executes requests for operations under \drive\list\contentTypes\{contentType-id}\base\microsoft.graph.isPublished() + public class IsPublishedRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke function isPublished + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Invoke function isPublished"; + // Create options for all the parameters + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contentTypeId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contentTypeIdOption, outputOption); + return command; + } + /// + /// Instantiates a new IsPublishedRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public IsPublishedRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/drive/list/contentTypes/{contentType_id}/base/microsoft.graph.isPublished()"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke function isPublished + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Drive/List/ContentTypes/Item/Base/Publish/PublishRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/Base/Publish/PublishRequestBuilder.cs new file mode 100644 index 00000000000..e3c611fa44c --- /dev/null +++ b/src/generated/Drive/List/ContentTypes/Item/Base/Publish/PublishRequestBuilder.cs @@ -0,0 +1,69 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Drive.List.ContentTypes.Item.Base.Publish { + /// Builds and executes requests for operations under \drive\list\contentTypes\{contentType-id}\base\microsoft.graph.publish + public class PublishRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action publish + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action publish"; + // Create options for all the parameters + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + command.SetHandler(async (string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreatePostRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, contentTypeIdOption); + return command; + } + /// + /// Instantiates a new PublishRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public PublishRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/drive/list/contentTypes/{contentType_id}/base/microsoft.graph.publish"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action publish + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Drive/List/ContentTypes/Item/Base/Ref/Ref.cs b/src/generated/Drive/List/ContentTypes/Item/Base/Ref/Ref.cs new file mode 100644 index 00000000000..c72b8adfa4b --- /dev/null +++ b/src/generated/Drive/List/ContentTypes/Item/Base/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Drive.List.ContentTypes.Item.Base.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Drive/List/ContentTypes/Item/Base/Ref/RefRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/Base/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..41cbbee259a --- /dev/null +++ b/src/generated/Drive/List/ContentTypes/Item/Base/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Drive.List.ContentTypes.Item.Base.Ref { + /// Builds and executes requests for operations under \drive\list\contentTypes\{contentType-id}\base\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Parent contentType from which this content type is derived. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Parent contentType from which this content type is derived."; + // Create options for all the parameters + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + command.SetHandler(async (string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, contentTypeIdOption); + return command; + } + /// + /// Parent contentType from which this content type is derived. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Parent contentType from which this content type is derived."; + // Create options for all the parameters + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contentTypeId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contentTypeIdOption, outputOption); + return command; + } + /// + /// Parent contentType from which this content type is derived. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Parent contentType from which this content type is derived."; + // Create options for all the parameters + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, contentTypeIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/drive/list/contentTypes/{contentType_id}/base/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Parent contentType from which this content type is derived. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Parent contentType from which this content type is derived. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Parent contentType from which this content type is derived. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Drive.List.ContentTypes.Item.Base.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Drive/List/ContentTypes/Item/Base/Unpublish/UnpublishRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/Base/Unpublish/UnpublishRequestBuilder.cs new file mode 100644 index 00000000000..27dd570d90c --- /dev/null +++ b/src/generated/Drive/List/ContentTypes/Item/Base/Unpublish/UnpublishRequestBuilder.cs @@ -0,0 +1,69 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Drive.List.ContentTypes.Item.Base.Unpublish { + /// Builds and executes requests for operations under \drive\list\contentTypes\{contentType-id}\base\microsoft.graph.unpublish + public class UnpublishRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action unpublish + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action unpublish"; + // Create options for all the parameters + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + command.SetHandler(async (string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreatePostRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, contentTypeIdOption); + return command; + } + /// + /// Instantiates a new UnpublishRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public UnpublishRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/drive/list/contentTypes/{contentType_id}/base/microsoft.graph.unpublish"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action unpublish + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Drive/List/ContentTypes/Item/BaseTypes/@Ref/@Ref.cs b/src/generated/Drive/List/ContentTypes/Item/BaseTypes/@Ref/@Ref.cs deleted file mode 100644 index 471dfe04a8f..00000000000 --- a/src/generated/Drive/List/ContentTypes/Item/BaseTypes/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Drive.List.ContentTypes.Item.BaseTypes.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Drive/List/ContentTypes/Item/BaseTypes/@Ref/RefRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/BaseTypes/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 7b85c9d1a8e..00000000000 --- a/src/generated/Drive/List/ContentTypes/Item/BaseTypes/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Drive.List.ContentTypes.Item.BaseTypes.@Ref { - /// Builds and executes requests for operations under \drive\list\contentTypes\{contentType-id}\baseTypes\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The collection of content types that are ancestors of this content type. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The collection of content types that are ancestors of this content type."; - // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The collection of content types that are ancestors of this content type. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The collection of content types that are ancestors of this content type."; - // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string contentTypeId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contentTypeIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/drive/list/contentTypes/{contentType_id}/baseTypes/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The collection of content types that are ancestors of this content type. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The collection of content types that are ancestors of this content type. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Drive.List.ContentTypes.Item.BaseTypes.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The collection of content types that are ancestors of this content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of content types that are ancestors of this content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Drive.List.ContentTypes.Item.BaseTypes.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The collection of content types that are ancestors of this content type. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Drive/List/ContentTypes/Item/BaseTypes/@Ref/RefResponse.cs b/src/generated/Drive/List/ContentTypes/Item/BaseTypes/@Ref/RefResponse.cs deleted file mode 100644 index 18ddcd2148a..00000000000 --- a/src/generated/Drive/List/ContentTypes/Item/BaseTypes/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Drive.List.ContentTypes.Item.BaseTypes.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Drive/List/ContentTypes/Item/BaseTypes/AddCopy/AddCopyRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/BaseTypes/AddCopy/AddCopyRequestBuilder.cs index 5faa7f9061b..8e317fd10a0 100644 --- a/src/generated/Drive/List/ContentTypes/Item/BaseTypes/AddCopy/AddCopyRequestBuilder.cs +++ b/src/generated/Drive/List/ContentTypes/Item/BaseTypes/AddCopy/AddCopyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action addCopy"; // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contentTypeId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contentTypeId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contentTypeIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contentTypeIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(AddCopyRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action addCopy - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddCopyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes contentType public class AddCopyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Drive/List/ContentTypes/Item/BaseTypes/BaseTypesRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/BaseTypes/BaseTypesRequestBuilder.cs index 76d84a0f32c..33305ea0e56 100644 --- a/src/generated/Drive/List/ContentTypes/Item/BaseTypes/BaseTypesRequestBuilder.cs +++ b/src/generated/Drive/List/ContentTypes/Item/BaseTypes/BaseTypesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Drive.List.ContentTypes.Item.BaseTypes.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,7 +33,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of content types that are ancestors of this content type."; // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -72,7 +72,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -83,20 +87,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Drive.List.ContentTypes.Item.BaseTypes.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Drive.List.ContentTypes.Item.BaseTypes.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -135,18 +134,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of content types that are ancestors of this content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of content types that are ancestors of this content type. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Drive/List/ContentTypes/Item/BaseTypes/Ref/Ref.cs b/src/generated/Drive/List/ContentTypes/Item/BaseTypes/Ref/Ref.cs new file mode 100644 index 00000000000..4d75c74ed65 --- /dev/null +++ b/src/generated/Drive/List/ContentTypes/Item/BaseTypes/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Drive.List.ContentTypes.Item.BaseTypes.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Drive/List/ContentTypes/Item/BaseTypes/Ref/RefRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/BaseTypes/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..75d80426b7e --- /dev/null +++ b/src/generated/Drive/List/ContentTypes/Item/BaseTypes/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Drive.List.ContentTypes.Item.BaseTypes.Ref { + /// Builds and executes requests for operations under \drive\list\contentTypes\{contentType-id}\baseTypes\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The collection of content types that are ancestors of this content type. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The collection of content types that are ancestors of this content type."; + // Create options for all the parameters + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The collection of content types that are ancestors of this content type. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The collection of content types that are ancestors of this content type."; + // Create options for all the parameters + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contentTypeId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contentTypeIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/drive/list/contentTypes/{contentType_id}/baseTypes/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The collection of content types that are ancestors of this content type. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The collection of content types that are ancestors of this content type. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Drive.List.ContentTypes.Item.BaseTypes.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The collection of content types that are ancestors of this content type. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Drive/List/ContentTypes/Item/BaseTypes/Ref/RefResponse.cs b/src/generated/Drive/List/ContentTypes/Item/BaseTypes/Ref/RefResponse.cs new file mode 100644 index 00000000000..38484ac3cfc --- /dev/null +++ b/src/generated/Drive/List/ContentTypes/Item/BaseTypes/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Drive.List.ContentTypes.Item.BaseTypes.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Drive/List/ContentTypes/Item/ColumnLinks/ColumnLinksRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/ColumnLinks/ColumnLinksRequestBuilder.cs index cda6515854b..df84077ef76 100644 --- a/src/generated/Drive/List/ContentTypes/Item/ColumnLinks/ColumnLinksRequestBuilder.cs +++ b/src/generated/Drive/List/ContentTypes/Item/ColumnLinks/ColumnLinksRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ColumnLinksRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ColumnLinkRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of columns that are required by this content type"; // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contentTypeId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contentTypeId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contentTypeIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contentTypeIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of columns that are required by this content type"; // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ColumnLink body, Action - /// The collection of columns that are required by this content type - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of columns that are required by this content type - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ColumnLink model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of columns that are required by this content type public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Drive/List/ContentTypes/Item/ColumnLinks/Item/ColumnLinkRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/ColumnLinks/Item/ColumnLinkRequestBuilder.cs index 555644379b3..057c38654fa 100644 --- a/src/generated/Drive/List/ContentTypes/Item/ColumnLinks/Item/ColumnLinkRequestBuilder.cs +++ b/src/generated/Drive/List/ContentTypes/Item/ColumnLinks/Item/ColumnLinkRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of columns that are required by this content type"; // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnLinkIdOption = new Option("--columnlink-id", description: "key: id of columnLink") { + var columnLinkIdOption = new Option("--column-link-id", description: "key: id of columnLink") { }; columnLinkIdOption.IsRequired = true; command.AddOption(columnLinkIdOption); - command.SetHandler(async (string contentTypeId, string columnLinkId) => { + command.SetHandler(async (string contentTypeId, string columnLinkId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contentTypeIdOption, columnLinkIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of columns that are required by this content type"; // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnLinkIdOption = new Option("--columnlink-id", description: "key: id of columnLink") { + var columnLinkIdOption = new Option("--column-link-id", description: "key: id of columnLink") { }; columnLinkIdOption.IsRequired = true; command.AddOption(columnLinkIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contentTypeId, string columnLinkId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contentTypeId, string columnLinkId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contentTypeIdOption, columnLinkIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contentTypeIdOption, columnLinkIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of columns that are required by this content type"; // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnLinkIdOption = new Option("--columnlink-id", description: "key: id of columnLink") { + var columnLinkIdOption = new Option("--column-link-id", description: "key: id of columnLink") { }; columnLinkIdOption.IsRequired = true; command.AddOption(columnLinkIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contentTypeId, string columnLinkId, string body) => { + command.SetHandler(async (string contentTypeId, string columnLinkId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contentTypeIdOption, columnLinkIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ColumnLink body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of columns that are required by this content type - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of columns that are required by this content type - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of columns that are required by this content type - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ColumnLink model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of columns that are required by this content type public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drive/List/ContentTypes/Item/ColumnPositions/@Ref/@Ref.cs b/src/generated/Drive/List/ContentTypes/Item/ColumnPositions/@Ref/@Ref.cs deleted file mode 100644 index 79a11b6a86f..00000000000 --- a/src/generated/Drive/List/ContentTypes/Item/ColumnPositions/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Drive.List.ContentTypes.Item.ColumnPositions.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Drive/List/ContentTypes/Item/ColumnPositions/@Ref/RefRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/ColumnPositions/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 9dd4a70f135..00000000000 --- a/src/generated/Drive/List/ContentTypes/Item/ColumnPositions/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Drive.List.ContentTypes.Item.ColumnPositions.@Ref { - /// Builds and executes requests for operations under \drive\list\contentTypes\{contentType-id}\columnPositions\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Column order information in a content type. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Column order information in a content type."; - // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Column order information in a content type. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Column order information in a content type."; - // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string contentTypeId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contentTypeIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/drive/list/contentTypes/{contentType_id}/columnPositions/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Column order information in a content type. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Column order information in a content type. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Drive.List.ContentTypes.Item.ColumnPositions.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Column order information in a content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Column order information in a content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Drive.List.ContentTypes.Item.ColumnPositions.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Column order information in a content type. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Drive/List/ContentTypes/Item/ColumnPositions/@Ref/RefResponse.cs b/src/generated/Drive/List/ContentTypes/Item/ColumnPositions/@Ref/RefResponse.cs deleted file mode 100644 index c13275420f7..00000000000 --- a/src/generated/Drive/List/ContentTypes/Item/ColumnPositions/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Drive.List.ContentTypes.Item.ColumnPositions.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Drive/List/ContentTypes/Item/ColumnPositions/ColumnPositionsRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/ColumnPositions/ColumnPositionsRequestBuilder.cs index 2220afa59b6..a6e40ff10a9 100644 --- a/src/generated/Drive/List/ContentTypes/Item/ColumnPositions/ColumnPositionsRequestBuilder.cs +++ b/src/generated/Drive/List/ContentTypes/Item/ColumnPositions/ColumnPositionsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Drive.List.ContentTypes.Item.ColumnPositions.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Column order information in a content type."; // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Drive.List.ContentTypes.Item.ColumnPositions.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Drive.List.ContentTypes.Item.ColumnPositions.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Column order information in a content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Column order information in a content type. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Drive/List/ContentTypes/Item/ColumnPositions/Ref/Ref.cs b/src/generated/Drive/List/ContentTypes/Item/ColumnPositions/Ref/Ref.cs new file mode 100644 index 00000000000..55b659ae440 --- /dev/null +++ b/src/generated/Drive/List/ContentTypes/Item/ColumnPositions/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Drive.List.ContentTypes.Item.ColumnPositions.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Drive/List/ContentTypes/Item/ColumnPositions/Ref/RefRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/ColumnPositions/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..886d55f9c65 --- /dev/null +++ b/src/generated/Drive/List/ContentTypes/Item/ColumnPositions/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Drive.List.ContentTypes.Item.ColumnPositions.Ref { + /// Builds and executes requests for operations under \drive\list\contentTypes\{contentType-id}\columnPositions\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Column order information in a content type. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Column order information in a content type."; + // Create options for all the parameters + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Column order information in a content type. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Column order information in a content type."; + // Create options for all the parameters + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contentTypeId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contentTypeIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/drive/list/contentTypes/{contentType_id}/columnPositions/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Column order information in a content type. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Column order information in a content type. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Drive.List.ContentTypes.Item.ColumnPositions.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Column order information in a content type. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Drive/List/ContentTypes/Item/ColumnPositions/Ref/RefResponse.cs b/src/generated/Drive/List/ContentTypes/Item/ColumnPositions/Ref/RefResponse.cs new file mode 100644 index 00000000000..e8b015214dd --- /dev/null +++ b/src/generated/Drive/List/ContentTypes/Item/ColumnPositions/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Drive.List.ContentTypes.Item.ColumnPositions.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Drive/List/ContentTypes/Item/Columns/ColumnsRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/Columns/ColumnsRequestBuilder.cs index 33e80dee03d..6d78a534089 100644 --- a/src/generated/Drive/List/ContentTypes/Item/Columns/ColumnsRequestBuilder.cs +++ b/src/generated/Drive/List/ContentTypes/Item/Columns/ColumnsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class ColumnsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ColumnDefinitionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSourceColumnCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSourceColumnCommand()); return commands; } /// @@ -37,7 +36,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of column definitions for this contentType."; // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contentTypeId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contentTypeId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contentTypeIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contentTypeIdOption, bodyOption, outputOption); return command; } /// @@ -69,7 +67,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of column definitions for this contentType."; // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(ColumnDefinition body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of column definitions for this contentType. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of column definitions for this contentType. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ColumnDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of column definitions for this contentType. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Drive/List/ContentTypes/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs index 2dfcf73d301..307e84f636f 100644 --- a/src/generated/Drive/List/ContentTypes/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs +++ b/src/generated/Drive/List/ContentTypes/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,19 +27,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of column definitions for this contentType."; // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string contentTypeId, string columnDefinitionId) => { + command.SetHandler(async (string contentTypeId, string columnDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contentTypeIdOption, columnDefinitionIdOption); return command; @@ -51,11 +50,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of column definitions for this contentType."; // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contentTypeId, string columnDefinitionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contentTypeId, string columnDefinitionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contentTypeIdOption, columnDefinitionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contentTypeIdOption, columnDefinitionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -92,11 +90,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of column definitions for this contentType."; // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -104,14 +102,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contentTypeId, string columnDefinitionId, string body) => { + command.SetHandler(async (string contentTypeId, string columnDefinitionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contentTypeIdOption, columnDefinitionIdOption, bodyOption); return command; @@ -190,42 +187,6 @@ public RequestInformation CreatePatchRequestInformation(ColumnDefinition body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of column definitions for this contentType. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of column definitions for this contentType. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of column definitions for this contentType. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ColumnDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of column definitions for this contentType. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drive/List/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/@Ref.cs b/src/generated/Drive/List/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/@Ref.cs deleted file mode 100644 index 30760ec87f6..00000000000 --- a/src/generated/Drive/List/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Drive.List.ContentTypes.Item.Columns.Item.SourceColumn.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Drive/List/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 87f5637fe76..00000000000 --- a/src/generated/Drive/List/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Drive.List.ContentTypes.Item.Columns.Item.SourceColumn.@Ref { - /// Builds and executes requests for operations under \drive\list\contentTypes\{contentType-id}\columns\{columnDefinition-id}\sourceColumn\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The source column for content type column. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string contentTypeId, string columnDefinitionId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, contentTypeIdOption, columnDefinitionIdOption); - return command; - } - /// - /// The source column for content type column. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string contentTypeId, string columnDefinitionId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contentTypeIdOption, columnDefinitionIdOption); - return command; - } - /// - /// The source column for content type column. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string contentTypeId, string columnDefinitionId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, contentTypeIdOption, columnDefinitionIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/drive/list/contentTypes/{contentType_id}/columns/{columnDefinition_id}/sourceColumn/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The source column for content type column. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Drive.List.ContentTypes.Item.Columns.Item.SourceColumn.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Drive.List.ContentTypes.Item.Columns.Item.SourceColumn.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Drive/List/ContentTypes/Item/Columns/Item/SourceColumn/Ref/Ref.cs b/src/generated/Drive/List/ContentTypes/Item/Columns/Item/SourceColumn/Ref/Ref.cs new file mode 100644 index 00000000000..b666db9e702 --- /dev/null +++ b/src/generated/Drive/List/ContentTypes/Item/Columns/Item/SourceColumn/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Drive.List.ContentTypes.Item.Columns.Item.SourceColumn.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Drive/List/ContentTypes/Item/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..cb075e609b1 --- /dev/null +++ b/src/generated/Drive/List/ContentTypes/Item/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Drive.List.ContentTypes.Item.Columns.Item.SourceColumn.Ref { + /// Builds and executes requests for operations under \drive\list\contentTypes\{contentType-id}\columns\{columnDefinition-id}\sourceColumn\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The source column for content type column. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + command.SetHandler(async (string contentTypeId, string columnDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, contentTypeIdOption, columnDefinitionIdOption); + return command; + } + /// + /// The source column for content type column. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contentTypeId, string columnDefinitionId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contentTypeIdOption, columnDefinitionIdOption, outputOption); + return command; + } + /// + /// The source column for content type column. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string contentTypeId, string columnDefinitionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, contentTypeIdOption, columnDefinitionIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/drive/list/contentTypes/{contentType_id}/columns/{columnDefinition_id}/sourceColumn/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The source column for content type column. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The source column for content type column. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The source column for content type column. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Drive.List.ContentTypes.Item.Columns.Item.SourceColumn.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Drive/List/ContentTypes/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs index d28c21f06a0..eefcbd2511c 100644 --- a/src/generated/Drive/List/ContentTypes/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs +++ b/src/generated/Drive/List/ContentTypes/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,11 +27,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The source column for content type column."; // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -45,25 +45,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contentTypeId, string columnDefinitionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contentTypeId, string columnDefinitionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contentTypeIdOption, columnDefinitionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contentTypeIdOption, columnDefinitionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Drive.List.ContentTypes.Item.Columns.Item.SourceColumn.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Drive.List.ContentTypes.Item.Columns.Item.SourceColumn.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -103,18 +102,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The source column for content type column. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drive/List/ContentTypes/Item/ContentTypeRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/ContentTypeRequestBuilder.cs index f77538e52ba..c832ab766e3 100644 --- a/src/generated/Drive/List/ContentTypes/Item/ContentTypeRequestBuilder.cs +++ b/src/generated/Drive/List/ContentTypes/Item/ContentTypeRequestBuilder.cs @@ -11,10 +11,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,7 +37,7 @@ public Command BuildAssociateWithHubSitesCommand() { } public Command BuildBaseCommand() { var command = new Command("base"); - var builder = new ApiSdk.Drive.List.ContentTypes.Item.@Base.BaseRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Drive.List.ContentTypes.Item.Base.BaseRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAssociateWithHubSitesCommand()); command.AddCommand(builder.BuildCopyToDefaultContentLocationCommand()); command.AddCommand(builder.BuildGetCommand()); @@ -57,6 +57,9 @@ public Command BuildBaseTypesCommand() { public Command BuildColumnLinksCommand() { var command = new Command("column-links"); var builder = new ApiSdk.Drive.List.ContentTypes.Item.ColumnLinks.ColumnLinksRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -71,6 +74,9 @@ public Command BuildColumnPositionsCommand() { public Command BuildColumnsCommand() { var command = new Command("columns"); var builder = new ApiSdk.Drive.List.ContentTypes.Item.Columns.ColumnsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -88,15 +94,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of content types present in this list."; // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - command.SetHandler(async (string contentTypeId) => { + command.SetHandler(async (string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contentTypeIdOption); return command; @@ -108,7 +113,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of content types present in this list."; // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -122,20 +127,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contentTypeId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contentTypeId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contentTypeIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contentTypeIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -145,7 +149,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of content types present in this list."; // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -153,14 +157,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contentTypeId, string body) => { + command.SetHandler(async (string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contentTypeIdOption, bodyOption); return command; @@ -245,47 +248,11 @@ public RequestInformation CreatePatchRequestInformation(ContentType body, Action return requestInfo; } /// - /// The collection of content types present in this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of content types present in this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \drive\list\contentTypes\{contentType-id}\microsoft.graph.isPublished() /// public IsPublishedRequestBuilder IsPublished() { return new IsPublishedRequestBuilder(PathParameters, RequestAdapter); } - /// - /// The collection of content types present in this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ContentType model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of content types present in this list. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drive/List/ContentTypes/Item/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs index efcfa4886c5..86339a1ba96 100644 --- a/src/generated/Drive/List/ContentTypes/Item/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs +++ b/src/generated/Drive/List/ContentTypes/Item/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToDefaultContentLocation"; // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contentTypeId, string body) => { + command.SetHandler(async (string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contentTypeIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(CopyToDefaultContentLocat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToDefaultContentLocation - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToDefaultContentLocationRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drive/List/ContentTypes/Item/IsPublished/IsPublishedRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/IsPublished/IsPublishedRequestBuilder.cs index 4fd49edc4bc..5a219c1952a 100644 --- a/src/generated/Drive/List/ContentTypes/Item/IsPublished/IsPublishedRequestBuilder.cs +++ b/src/generated/Drive/List/ContentTypes/Item/IsPublished/IsPublishedRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,22 +25,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function isPublished"; // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - command.SetHandler(async (string contentTypeId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contentTypeId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteBoolValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contentTypeIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contentTypeIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function isPublished - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drive/List/ContentTypes/Item/Publish/PublishRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/Publish/PublishRequestBuilder.cs index cc8c5f5ff99..68707b17241 100644 --- a/src/generated/Drive/List/ContentTypes/Item/Publish/PublishRequestBuilder.cs +++ b/src/generated/Drive/List/ContentTypes/Item/Publish/PublishRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action publish"; // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - command.SetHandler(async (string contentTypeId) => { + command.SetHandler(async (string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contentTypeIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action publish - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drive/List/ContentTypes/Item/Unpublish/UnpublishRequestBuilder.cs b/src/generated/Drive/List/ContentTypes/Item/Unpublish/UnpublishRequestBuilder.cs index cb5f463e6df..c969bceca74 100644 --- a/src/generated/Drive/List/ContentTypes/Item/Unpublish/UnpublishRequestBuilder.cs +++ b/src/generated/Drive/List/ContentTypes/Item/Unpublish/UnpublishRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action unpublish"; // Create options for all the parameters - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - command.SetHandler(async (string contentTypeId) => { + command.SetHandler(async (string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contentTypeIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action unpublish - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drive/List/Drive/DriveRequestBuilder.cs b/src/generated/Drive/List/Drive/DriveRequestBuilder.cs index f34c10c9014..f605c8d79c2 100644 --- a/src/generated/Drive/List/Drive/DriveRequestBuilder.cs +++ b/src/generated/Drive/List/Drive/DriveRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Only present on document libraries. Allows access to the list as a [drive][] resource with [driveItems][driveItem]."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -52,20 +51,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -79,14 +77,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -158,42 +155,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Only present on document libraries. Allows access to the list as a [drive][] resource with [driveItems][driveItem]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Only present on document libraries. Allows access to the list as a [drive][] resource with [driveItems][driveItem]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Only present on document libraries. Allows access to the list as a [drive][] resource with [driveItems][driveItem]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Drive model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Only present on document libraries. Allows access to the list as a [drive][] resource with [driveItems][driveItem]. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drive/List/Items/Item/Analytics/@Ref/@Ref.cs b/src/generated/Drive/List/Items/Item/Analytics/@Ref/@Ref.cs deleted file mode 100644 index ecca6fe4700..00000000000 --- a/src/generated/Drive/List/Items/Item/Analytics/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Drive.List.Items.Item.Analytics.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Drive/List/Items/Item/Analytics/@Ref/RefRequestBuilder.cs b/src/generated/Drive/List/Items/Item/Analytics/@Ref/RefRequestBuilder.cs deleted file mode 100644 index a81612d8c21..00000000000 --- a/src/generated/Drive/List/Items/Item/Analytics/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Drive.List.Items.Item.Analytics.@Ref { - /// Builds and executes requests for operations under \drive\list\items\{listItem-id}\analytics\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Analytics about the view activities that took place on this item. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Analytics about the view activities that took place on this item."; - // Create options for all the parameters - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { - }; - listItemIdOption.IsRequired = true; - command.AddOption(listItemIdOption); - command.SetHandler(async (string listItemId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, listItemIdOption); - return command; - } - /// - /// Analytics about the view activities that took place on this item. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Analytics about the view activities that took place on this item."; - // Create options for all the parameters - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { - }; - listItemIdOption.IsRequired = true; - command.AddOption(listItemIdOption); - command.SetHandler(async (string listItemId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, listItemIdOption); - return command; - } - /// - /// Analytics about the view activities that took place on this item. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Analytics about the view activities that took place on this item."; - // Create options for all the parameters - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { - }; - listItemIdOption.IsRequired = true; - command.AddOption(listItemIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string listItemId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, listItemIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/drive/list/items/{listItem_id}/analytics/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Analytics about the view activities that took place on this item. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Analytics about the view activities that took place on this item. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Analytics about the view activities that took place on this item. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Drive.List.Items.Item.Analytics.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Drive.List.Items.Item.Analytics.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Drive/List/Items/Item/Analytics/AnalyticsRequestBuilder.cs b/src/generated/Drive/List/Items/Item/Analytics/AnalyticsRequestBuilder.cs index abef74fda3f..f72c4f12c24 100644 --- a/src/generated/Drive/List/Items/Item/Analytics/AnalyticsRequestBuilder.cs +++ b/src/generated/Drive/List/Items/Item/Analytics/AnalyticsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Analytics about the view activities that took place on this item."; // Create options for all the parameters - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string listItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string listItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, listItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, listItemIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Drive.List.Items.Item.Analytics.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Drive.List.Items.Item.Analytics.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Analytics about the view activities that took place on this item. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drive/List/Items/Item/Analytics/Ref/Ref.cs b/src/generated/Drive/List/Items/Item/Analytics/Ref/Ref.cs new file mode 100644 index 00000000000..29af9cd2bce --- /dev/null +++ b/src/generated/Drive/List/Items/Item/Analytics/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Drive.List.Items.Item.Analytics.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Drive/List/Items/Item/Analytics/Ref/RefRequestBuilder.cs b/src/generated/Drive/List/Items/Item/Analytics/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..07bba437c89 --- /dev/null +++ b/src/generated/Drive/List/Items/Item/Analytics/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Drive.List.Items.Item.Analytics.Ref { + /// Builds and executes requests for operations under \drive\list\items\{listItem-id}\analytics\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Analytics about the view activities that took place on this item. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Analytics about the view activities that took place on this item."; + // Create options for all the parameters + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { + }; + listItemIdOption.IsRequired = true; + command.AddOption(listItemIdOption); + command.SetHandler(async (string listItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, listItemIdOption); + return command; + } + /// + /// Analytics about the view activities that took place on this item. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Analytics about the view activities that took place on this item."; + // Create options for all the parameters + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { + }; + listItemIdOption.IsRequired = true; + command.AddOption(listItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string listItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, listItemIdOption, outputOption); + return command; + } + /// + /// Analytics about the view activities that took place on this item. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Analytics about the view activities that took place on this item."; + // Create options for all the parameters + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { + }; + listItemIdOption.IsRequired = true; + command.AddOption(listItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string listItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, listItemIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/drive/list/items/{listItem_id}/analytics/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Analytics about the view activities that took place on this item. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Analytics about the view activities that took place on this item. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Analytics about the view activities that took place on this item. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Drive.List.Items.Item.Analytics.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Drive/List/Items/Item/DriveItem/Content/ContentRequestBuilder.cs b/src/generated/Drive/List/Items/Item/DriveItem/Content/ContentRequestBuilder.cs index e099527e83a..0ee0025a1f6 100644 --- a/src/generated/Drive/List/Items/Item/DriveItem/Content/ContentRequestBuilder.cs +++ b/src/generated/Drive/List/Items/Item/DriveItem/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,28 +25,30 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get media content for the navigation property driveItem from drive"; // Create options for all the parameters - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string listItemId, FileInfo output) => { + command.SetHandler(async (string listItemId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, listItemIdOption, outputOption); + }, listItemIdOption, fileOption, outputOption); return command; } /// @@ -56,7 +58,7 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "Update media content for the navigation property driveItem in drive"; // Create options for all the parameters - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -64,12 +66,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string listItemId, FileInfo file) => { + command.SetHandler(async (string listItemId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, listItemIdOption, bodyOption); return command; @@ -120,29 +121,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property driveItem from drive - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property driveItem in drive - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drive/List/Items/Item/DriveItem/DriveItemRequestBuilder.cs b/src/generated/Drive/List/Items/Item/DriveItem/DriveItemRequestBuilder.cs index 2861e33e923..72ce16c8bcf 100644 --- a/src/generated/Drive/List/Items/Item/DriveItem/DriveItemRequestBuilder.cs +++ b/src/generated/Drive/List/Items/Item/DriveItem/DriveItemRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "For document libraries, the driveItem relationship exposes the listItem as a [driveItem][]"; // Create options for all the parameters - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - command.SetHandler(async (string listItemId) => { + command.SetHandler(async (string listItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, listItemIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "For document libraries, the driveItem relationship exposes the listItem as a [driveItem][]"; // Create options for all the parameters - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string listItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string listItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, listItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, listItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,7 +89,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "For document libraries, the driveItem relationship exposes the listItem as a [driveItem][]"; // Create options for all the parameters - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -99,14 +97,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string listItemId, string body) => { + command.SetHandler(async (string listItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, listItemIdOption, bodyOption); return command; @@ -178,42 +175,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// For document libraries, the driveItem relationship exposes the listItem as a [driveItem][] - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// For document libraries, the driveItem relationship exposes the listItem as a [driveItem][] - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// For document libraries, the driveItem relationship exposes the listItem as a [driveItem][] - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// For document libraries, the driveItem relationship exposes the listItem as a [driveItem][] public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drive/List/Items/Item/Fields/FieldsRequestBuilder.cs b/src/generated/Drive/List/Items/Item/Fields/FieldsRequestBuilder.cs index e2684777bbe..a9187b35f5d 100644 --- a/src/generated/Drive/List/Items/Item/Fields/FieldsRequestBuilder.cs +++ b/src/generated/Drive/List/Items/Item/Fields/FieldsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The values of the columns set on this list item."; // Create options for all the parameters - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - command.SetHandler(async (string listItemId) => { + command.SetHandler(async (string listItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, listItemIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The values of the columns set on this list item."; // Create options for all the parameters - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string listItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string listItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, listItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, listItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The values of the columns set on this list item."; // Create options for all the parameters - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string listItemId, string body) => { + command.SetHandler(async (string listItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, listItemIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(FieldValueSet body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The values of the columns set on this list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The values of the columns set on this list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The values of the columns set on this list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(FieldValueSet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The values of the columns set on this list item. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drive/List/Items/Item/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs b/src/generated/Drive/List/Items/Item/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs index 18e3bf9bf34..9e45908720c 100644 --- a/src/generated/Drive/List/Items/Item/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs +++ b/src/generated/Drive/List/Items/Item/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,22 +25,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function getActivitiesByInterval"; // Create options for all the parameters - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - command.SetHandler(async (string listItemId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string listItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, listItemIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, listItemIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getActivitiesByInterval - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drive/List/Items/Item/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs b/src/generated/Drive/List/Items/Item/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs index 6fc9f943904..6196bb923a1 100644 --- a/src/generated/Drive/List/Items/Item/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs +++ b/src/generated/Drive/List/Items/Item/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function getActivitiesByInterval"; // Create options for all the parameters - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var startDateTimeOption = new Option("--startdatetime", description: "Usage: startDateTime={startDateTime}") { + var startDateTimeOption = new Option("--start-date-time", description: "Usage: startDateTime={startDateTime}") { }; startDateTimeOption.IsRequired = true; command.AddOption(startDateTimeOption); - var endDateTimeOption = new Option("--enddatetime", description: "Usage: endDateTime={endDateTime}") { + var endDateTimeOption = new Option("--end-date-time", description: "Usage: endDateTime={endDateTime}") { }; endDateTimeOption.IsRequired = true; command.AddOption(endDateTimeOption); @@ -41,18 +41,17 @@ public Command BuildGetCommand() { }; intervalOption.IsRequired = true; command.AddOption(intervalOption); - command.SetHandler(async (string listItemId, string startDateTime, string endDateTime, string interval) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string listItemId, string startDateTime, string endDateTime, string interval, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, listItemIdOption, startDateTimeOption, endDateTimeOption, intervalOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, listItemIdOption, startDateTimeOption, endDateTimeOption, intervalOption, outputOption); return command; } /// @@ -89,16 +88,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getActivitiesByInterval - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drive/List/Items/Item/ListItemRequestBuilder.cs b/src/generated/Drive/List/Items/Item/ListItemRequestBuilder.cs index c2851b02f28..4dd73a8deb7 100644 --- a/src/generated/Drive/List/Items/Item/ListItemRequestBuilder.cs +++ b/src/generated/Drive/List/Items/Item/ListItemRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,15 +39,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "All items contained in the list."; // Create options for all the parameters - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - command.SetHandler(async (string listItemId) => { + command.SetHandler(async (string listItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, listItemIdOption); return command; @@ -76,7 +75,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "All items contained in the list."; // Create options for all the parameters - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string listItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string listItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, listItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, listItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -113,7 +111,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "All items contained in the list."; // Create options for all the parameters - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -121,14 +119,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string listItemId, string body) => { + command.SetHandler(async (string listItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, listItemIdOption, bodyOption); return command; @@ -136,6 +133,9 @@ public Command BuildPatchCommand() { public Command BuildVersionsCommand() { var command = new Command("versions"); var builder = new ApiSdk.Drive.List.Items.Item.Versions.VersionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -208,17 +208,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. return requestInfo; } /// - /// All items contained in the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \drive\list\items\{listItem-id}\microsoft.graph.getActivitiesByInterval() /// public GetActivitiesByIntervalRequestBuilder GetActivitiesByInterval() { @@ -236,31 +225,6 @@ public GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalReques if(string.IsNullOrEmpty(startDateTime)) throw new ArgumentNullException(nameof(startDateTime)); return new GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder(PathParameters, RequestAdapter, startDateTime, endDateTime, interval); } - /// - /// All items contained in the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All items contained in the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.ListItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// All items contained in the list. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drive/List/Items/Item/Versions/Item/Fields/FieldsRequestBuilder.cs b/src/generated/Drive/List/Items/Item/Versions/Item/Fields/FieldsRequestBuilder.cs index 0cd52892c82..0437a448ec0 100644 --- a/src/generated/Drive/List/Items/Item/Versions/Item/Fields/FieldsRequestBuilder.cs +++ b/src/generated/Drive/List/Items/Item/Versions/Item/Fields/FieldsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "A collection of the fields and values for this version of the list item."; // Create options for all the parameters - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); - command.SetHandler(async (string listItemId, string listItemVersionId) => { + command.SetHandler(async (string listItemId, string listItemVersionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, listItemIdOption, listItemVersionIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "A collection of the fields and values for this version of the list item."; // Create options for all the parameters - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string listItemId, string listItemVersionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string listItemId, string listItemVersionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, listItemIdOption, listItemVersionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, listItemIdOption, listItemVersionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "A collection of the fields and values for this version of the list item."; // Create options for all the parameters - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string listItemId, string listItemVersionId, string body) => { + command.SetHandler(async (string listItemId, string listItemVersionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, listItemIdOption, listItemVersionIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(FieldValueSet body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of the fields and values for this version of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of the fields and values for this version of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of the fields and values for this version of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(FieldValueSet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of the fields and values for this version of the list item. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drive/List/Items/Item/Versions/Item/ListItemVersionRequestBuilder.cs b/src/generated/Drive/List/Items/Item/Versions/Item/ListItemVersionRequestBuilder.cs index 0108e4b46b0..0f49dd41460 100644 --- a/src/generated/Drive/List/Items/Item/Versions/Item/ListItemVersionRequestBuilder.cs +++ b/src/generated/Drive/List/Items/Item/Versions/Item/ListItemVersionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,19 +28,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of previous versions of the list item."; // Create options for all the parameters - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); - command.SetHandler(async (string listItemId, string listItemVersionId) => { + command.SetHandler(async (string listItemId, string listItemVersionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, listItemIdOption, listItemVersionIdOption); return command; @@ -60,11 +59,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of previous versions of the list item."; // Create options for all the parameters - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); @@ -78,20 +77,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string listItemId, string listItemVersionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string listItemId, string listItemVersionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, listItemIdOption, listItemVersionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, listItemIdOption, listItemVersionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -101,11 +99,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of previous versions of the list item."; // Create options for all the parameters - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); @@ -113,14 +111,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string listItemId, string listItemVersionId, string body) => { + command.SetHandler(async (string listItemId, string listItemVersionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, listItemIdOption, listItemVersionIdOption, bodyOption); return command; @@ -198,42 +195,6 @@ public RequestInformation CreatePatchRequestInformation(ListItemVersion body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ListItemVersion model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of previous versions of the list item. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drive/List/Items/Item/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs b/src/generated/Drive/List/Items/Item/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs index 3fab7d605a1..bf4ea74ba50 100644 --- a/src/generated/Drive/List/Items/Item/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs +++ b/src/generated/Drive/List/Items/Item/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,18 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action restoreVersion"; // Create options for all the parameters - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); - command.SetHandler(async (string listItemId, string listItemVersionId) => { + command.SetHandler(async (string listItemId, string listItemVersionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, listItemIdOption, listItemVersionIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action restoreVersion - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drive/List/Items/Item/Versions/VersionsRequestBuilder.cs b/src/generated/Drive/List/Items/Item/Versions/VersionsRequestBuilder.cs index ed93233ebbe..9c959b1ef58 100644 --- a/src/generated/Drive/List/Items/Item/Versions/VersionsRequestBuilder.cs +++ b/src/generated/Drive/List/Items/Item/Versions/VersionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class VersionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ListItemVersionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildFieldsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildRestoreVersionCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFieldsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRestoreVersionCommand()); return commands; } /// @@ -38,7 +37,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The list of previous versions of the list item."; // Create options for all the parameters - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -46,21 +45,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string listItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string listItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, listItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, listItemIdOption, bodyOption, outputOption); return command; } /// @@ -70,7 +68,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The list of previous versions of the list item."; // Create options for all the parameters - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -109,7 +107,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string listItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string listItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -120,15 +122,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, listItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, listItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -183,31 +180,6 @@ public RequestInformation CreatePostRequestInformation(ListItemVersion body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ListItemVersion model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of previous versions of the list item. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Drive/List/Items/ItemsRequestBuilder.cs b/src/generated/Drive/List/Items/ItemsRequestBuilder.cs index 9d2d8527ead..127ab3592ac 100644 --- a/src/generated/Drive/List/Items/ItemsRequestBuilder.cs +++ b/src/generated/Drive/List/Items/ItemsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class ItemsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ListItemRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAnalyticsCommand(), - builder.BuildDeleteCommand(), - builder.BuildDriveItemCommand(), - builder.BuildFieldsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildVersionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAnalyticsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDriveItemCommand()); + commands.Add(builder.BuildFieldsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildVersionsCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -103,7 +101,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -114,15 +116,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -177,31 +174,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All items contained in the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All items contained in the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.ListItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// All items contained in the list. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Drive/List/ListRequestBuilder.cs b/src/generated/Drive/List/ListRequestBuilder.cs index c7fac2e3a65..cab8e627726 100644 --- a/src/generated/Drive/List/ListRequestBuilder.cs +++ b/src/generated/Drive/List/ListRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,6 +27,9 @@ public class ListRequestBuilder { public Command BuildColumnsCommand() { var command = new Command("columns"); var builder = new ApiSdk.Drive.List.Columns.ColumnsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -35,6 +38,9 @@ public Command BuildContentTypesCommand() { var command = new Command("content-types"); var builder = new ApiSdk.Drive.List.ContentTypes.ContentTypesRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCopyCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -46,11 +52,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "For drives in SharePoint, the underlying document library list. Read-only. Nullable."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -80,25 +85,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } public Command BuildItemsCommand() { var command = new Command("items"); var builder = new ApiSdk.Drive.List.Items.ItemsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -114,14 +121,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -129,6 +135,9 @@ public Command BuildPatchCommand() { public Command BuildSubscriptionsCommand() { var command = new Command("subscriptions"); var builder = new ApiSdk.Drive.List.Subscriptions.SubscriptionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -200,42 +209,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// For drives in SharePoint, the underlying document library list. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// For drives in SharePoint, the underlying document library list. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// For drives in SharePoint, the underlying document library list. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.List model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// For drives in SharePoint, the underlying document library list. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drive/List/Subscriptions/Item/SubscriptionRequestBuilder.cs b/src/generated/Drive/List/Subscriptions/Item/SubscriptionRequestBuilder.cs index 39fe8ddd571..18487bbff9f 100644 --- a/src/generated/Drive/List/Subscriptions/Item/SubscriptionRequestBuilder.cs +++ b/src/generated/Drive/List/Subscriptions/Item/SubscriptionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,10 @@ public Command BuildDeleteCommand() { }; subscriptionIdOption.IsRequired = true; command.AddOption(subscriptionIdOption); - command.SetHandler(async (string subscriptionId) => { + command.SetHandler(async (string subscriptionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, subscriptionIdOption); return command; @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string subscriptionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string subscriptionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, subscriptionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, subscriptionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string subscriptionId, string body) => { + command.SetHandler(async (string subscriptionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, subscriptionIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(Subscription body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The set of subscriptions on the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The set of subscriptions on the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The set of subscriptions on the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Subscription model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The set of subscriptions on the list. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drive/List/Subscriptions/SubscriptionsRequestBuilder.cs b/src/generated/Drive/List/Subscriptions/SubscriptionsRequestBuilder.cs index 8b96007036d..253691106c9 100644 --- a/src/generated/Drive/List/Subscriptions/SubscriptionsRequestBuilder.cs +++ b/src/generated/Drive/List/Subscriptions/SubscriptionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SubscriptionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SubscriptionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(Subscription body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The set of subscriptions on the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The set of subscriptions on the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Subscription model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The set of subscriptions on the list. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Drive/Recent/RecentRequestBuilder.cs b/src/generated/Drive/Recent/RecentRequestBuilder.cs index 556d4245b05..9aeedfc6a36 100644 --- a/src/generated/Drive/Recent/RecentRequestBuilder.cs +++ b/src/generated/Drive/Recent/RecentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function recent"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function recent - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drive/Root/Content/ContentRequestBuilder.cs b/src/generated/Drive/Root/Content/ContentRequestBuilder.cs index 2f3a68d91a0..56278dbc9e9 100644 --- a/src/generated/Drive/Root/Content/ContentRequestBuilder.cs +++ b/src/generated/Drive/Root/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,24 +25,26 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get media content for the navigation property root from drive"; // Create options for all the parameters - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (FileInfo output) => { + command.SetHandler(async (FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, outputOption); + }, fileOption, outputOption); return command; } /// @@ -56,12 +58,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (FileInfo file) => { + command.SetHandler(async (FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -112,29 +113,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property root from drive - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property root in drive - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drive/Root/RootRequestBuilder.cs b/src/generated/Drive/Root/RootRequestBuilder.cs index 91aee7edd7a..7eb54bbddf3 100644 --- a/src/generated/Drive/Root/RootRequestBuilder.cs +++ b/src/generated/Drive/Root/RootRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The root folder of the drive. Read-only."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -87,14 +85,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -166,42 +163,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The root folder of the drive. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The root folder of the drive. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The root folder of the drive. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The root folder of the drive. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drive/SearchWithQ/SearchWithQRequestBuilder.cs b/src/generated/Drive/SearchWithQ/SearchWithQRequestBuilder.cs index bd66ee507e6..4a879090e2d 100644 --- a/src/generated/Drive/SearchWithQ/SearchWithQRequestBuilder.cs +++ b/src/generated/Drive/SearchWithQ/SearchWithQRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +29,17 @@ public Command BuildGetCommand() { }; qOption.IsRequired = true; command.AddOption(qOption); - command.SetHandler(async (string q) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string q, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, qOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, qOption, outputOption); return command; } /// @@ -73,16 +72,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function search - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drive/SharedWithMe/SharedWithMeRequestBuilder.cs b/src/generated/Drive/SharedWithMe/SharedWithMeRequestBuilder.cs index ca575210158..4153f0b29a9 100644 --- a/src/generated/Drive/SharedWithMe/SharedWithMeRequestBuilder.cs +++ b/src/generated/Drive/SharedWithMe/SharedWithMeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function sharedWithMe"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function sharedWithMe - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drive/Special/Item/Content/ContentRequestBuilder.cs b/src/generated/Drive/Special/Item/Content/ContentRequestBuilder.cs index a6379df2da3..b6c3fe7e318 100644 --- a/src/generated/Drive/Special/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Drive/Special/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,28 +25,30 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get media content for the navigation property special from drive"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string driveItemId, FileInfo output) => { + command.SetHandler(async (string driveItemId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, driveItemIdOption, outputOption); + }, driveItemIdOption, fileOption, outputOption); return command; } /// @@ -56,7 +58,7 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "Update media content for the navigation property special in drive"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -64,12 +66,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, FileInfo file) => { + command.SetHandler(async (string driveItemId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, bodyOption); return command; @@ -120,29 +121,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property special from drive - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property special in drive - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drive/Special/Item/DriveItemRequestBuilder.cs b/src/generated/Drive/Special/Item/DriveItemRequestBuilder.cs index 85a99b32a99..0b87e5db010 100644 --- a/src/generated/Drive/Special/Item/DriveItemRequestBuilder.cs +++ b/src/generated/Drive/Special/Item/DriveItemRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Collection of common folders available in OneDrive. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { + command.SetHandler(async (string driveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Collection of common folders available in OneDrive. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,7 +89,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Collection of common folders available in OneDrive. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -99,14 +97,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + command.SetHandler(async (string driveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, bodyOption); return command; @@ -178,42 +175,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of common folders available in OneDrive. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of common folders available in OneDrive. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of common folders available in OneDrive. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of common folders available in OneDrive. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drive/Special/SpecialRequestBuilder.cs b/src/generated/Drive/Special/SpecialRequestBuilder.cs index ca42aea36a7..f9c6a1a0dbf 100644 --- a/src/generated/Drive/Special/SpecialRequestBuilder.cs +++ b/src/generated/Drive/Special/SpecialRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class SpecialRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DriveItemRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of common folders available in OneDrive. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of common folders available in OneDrive. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of common folders available in OneDrive. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Drives/DrivesRequestBuilder.cs b/src/generated/Drives/DrivesRequestBuilder.cs index 244ca8593f3..9296f267f4e 100644 --- a/src/generated/Drives/DrivesRequestBuilder.cs +++ b/src/generated/Drives/DrivesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,17 +22,16 @@ public class DrivesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DriveRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildBundlesCommand(), - builder.BuildDeleteCommand(), - builder.BuildFollowingCommand(), - builder.BuildGetCommand(), - builder.BuildItemsCommand(), - builder.BuildListCommand(), - builder.BuildPatchCommand(), - builder.BuildRootCommand(), - builder.BuildSpecialCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildBundlesCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFollowingCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildItemsCommand()); + commands.Add(builder.BuildListCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRootCommand()); + commands.Add(builder.BuildSpecialCommand()); return commands; } /// @@ -46,21 +45,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -105,7 +103,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -116,15 +118,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -179,31 +176,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get entities from drives - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to drives - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Drive model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from drives public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Drives/Item/Bundles/BundlesRequestBuilder.cs b/src/generated/Drives/Item/Bundles/BundlesRequestBuilder.cs index 32880ecd141..f5c2ce20e79 100644 --- a/src/generated/Drives/Item/Bundles/BundlesRequestBuilder.cs +++ b/src/generated/Drives/Item/Bundles/BundlesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class BundlesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DriveItemRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, bodyOption, outputOption); return command; } /// @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of [bundles][bundle] (albums and multi-select-shared sets of items). Only in personal OneDrive. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of [bundles][bundle] (albums and multi-select-shared sets of items). Only in personal OneDrive. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of [bundles][bundle] (albums and multi-select-shared sets of items). Only in personal OneDrive. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Drives/Item/Bundles/Item/Content/ContentRequestBuilder.cs b/src/generated/Drives/Item/Bundles/Item/Content/ContentRequestBuilder.cs index 819bde87754..c5c5f408b5f 100644 --- a/src/generated/Drives/Item/Bundles/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Drives/Item/Bundles/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,28 +29,30 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string driveId, string driveItemId, FileInfo output) => { + command.SetHandler(async (string driveId, string driveItemId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, driveIdOption, driveItemIdOption, outputOption); + }, driveIdOption, driveItemIdOption, fileOption, outputOption); return command; } /// @@ -64,7 +66,7 @@ public Command BuildPutCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -72,12 +74,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string driveItemId, FileInfo file) => { + command.SetHandler(async (string driveId, string driveItemId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, driveItemIdOption, bodyOption); return command; @@ -128,29 +129,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property bundles from drives - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property bundles in drives - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drives/Item/Bundles/Item/DriveItemRequestBuilder.cs b/src/generated/Drives/Item/Bundles/Item/DriveItemRequestBuilder.cs index 1aaaf5498de..5b91318cc78 100644 --- a/src/generated/Drives/Item/Bundles/Item/DriveItemRequestBuilder.cs +++ b/src/generated/Drives/Item/Bundles/Item/DriveItemRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveId, string driveItemId) => { + command.SetHandler(async (string driveId, string driveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, driveItemIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, string driveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string driveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, driveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, driveItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,7 +101,7 @@ public Command BuildPatchCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -111,14 +109,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string driveItemId, string body) => { + command.SetHandler(async (string driveId, string driveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, driveItemIdOption, bodyOption); return command; @@ -190,42 +187,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of [bundles][bundle] (albums and multi-select-shared sets of items). Only in personal OneDrive. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of [bundles][bundle] (albums and multi-select-shared sets of items). Only in personal OneDrive. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of [bundles][bundle] (albums and multi-select-shared sets of items). Only in personal OneDrive. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of [bundles][bundle] (albums and multi-select-shared sets of items). Only in personal OneDrive. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drives/Item/DriveRequestBuilder.cs b/src/generated/Drives/Item/DriveRequestBuilder.cs index 29a599c0902..92eeaf8e762 100644 --- a/src/generated/Drives/Item/DriveRequestBuilder.cs +++ b/src/generated/Drives/Item/DriveRequestBuilder.cs @@ -10,10 +10,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,6 +31,9 @@ public class DriveRequestBuilder { public Command BuildBundlesCommand() { var command = new Command("bundles"); var builder = new ApiSdk.Drives.Item.Bundles.BundlesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -46,11 +49,10 @@ public Command BuildDeleteCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - command.SetHandler(async (string driveId) => { + command.SetHandler(async (string driveId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption); return command; @@ -58,6 +60,9 @@ public Command BuildDeleteCommand() { public Command BuildFollowingCommand() { var command = new Command("following"); var builder = new ApiSdk.Drives.Item.Following.FollowingRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -83,25 +88,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildItemsCommand() { var command = new Command("items"); var builder = new ApiSdk.Drives.Item.Items.ItemsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,14 +141,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string body) => { + command.SetHandler(async (string driveId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, bodyOption); return command; @@ -158,6 +164,9 @@ public Command BuildRootCommand() { public Command BuildSpecialCommand() { var command = new Command("special"); var builder = new ApiSdk.Drives.Item.Special.SpecialRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -230,42 +239,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. return requestInfo; } /// - /// Delete entity from drives - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from drives by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in drives - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Drive model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \drives\{drive-id}\microsoft.graph.recent() /// public RecentRequestBuilder Recent() { diff --git a/src/generated/Drives/Item/Following/FollowingRequestBuilder.cs b/src/generated/Drives/Item/Following/FollowingRequestBuilder.cs index 92b85d3d937..4b7a3ef9ecc 100644 --- a/src/generated/Drives/Item/Following/FollowingRequestBuilder.cs +++ b/src/generated/Drives/Item/Following/FollowingRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class FollowingRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DriveItemRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, bodyOption, outputOption); return command; } /// @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of items the user is following. Only in OneDrive for Business. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of items the user is following. Only in OneDrive for Business. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of items the user is following. Only in OneDrive for Business. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Drives/Item/Following/Item/Content/ContentRequestBuilder.cs b/src/generated/Drives/Item/Following/Item/Content/ContentRequestBuilder.cs index e6dc0426529..4f8c7a9b75d 100644 --- a/src/generated/Drives/Item/Following/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Drives/Item/Following/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,28 +29,30 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string driveId, string driveItemId, FileInfo output) => { + command.SetHandler(async (string driveId, string driveItemId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, driveIdOption, driveItemIdOption, outputOption); + }, driveIdOption, driveItemIdOption, fileOption, outputOption); return command; } /// @@ -64,7 +66,7 @@ public Command BuildPutCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -72,12 +74,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string driveItemId, FileInfo file) => { + command.SetHandler(async (string driveId, string driveItemId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, driveItemIdOption, bodyOption); return command; @@ -128,29 +129,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property following from drives - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property following in drives - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drives/Item/Following/Item/DriveItemRequestBuilder.cs b/src/generated/Drives/Item/Following/Item/DriveItemRequestBuilder.cs index e3647b469a6..f1b59fdefbf 100644 --- a/src/generated/Drives/Item/Following/Item/DriveItemRequestBuilder.cs +++ b/src/generated/Drives/Item/Following/Item/DriveItemRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveId, string driveItemId) => { + command.SetHandler(async (string driveId, string driveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, driveItemIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, string driveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string driveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, driveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, driveItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,7 +101,7 @@ public Command BuildPatchCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -111,14 +109,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string driveItemId, string body) => { + command.SetHandler(async (string driveId, string driveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, driveItemIdOption, bodyOption); return command; @@ -190,42 +187,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of items the user is following. Only in OneDrive for Business. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of items the user is following. Only in OneDrive for Business. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of items the user is following. Only in OneDrive for Business. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of items the user is following. Only in OneDrive for Business. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drives/Item/Items/Item/Content/ContentRequestBuilder.cs b/src/generated/Drives/Item/Items/Item/Content/ContentRequestBuilder.cs index 63decbb9e3a..f8d8177c1c8 100644 --- a/src/generated/Drives/Item/Items/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Drives/Item/Items/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,28 +29,30 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string driveId, string driveItemId, FileInfo output) => { + command.SetHandler(async (string driveId, string driveItemId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, driveIdOption, driveItemIdOption, outputOption); + }, driveIdOption, driveItemIdOption, fileOption, outputOption); return command; } /// @@ -64,7 +66,7 @@ public Command BuildPutCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -72,12 +74,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string driveItemId, FileInfo file) => { + command.SetHandler(async (string driveId, string driveItemId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, driveItemIdOption, bodyOption); return command; @@ -128,29 +129,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property items from drives - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property items in drives - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drives/Item/Items/Item/DriveItemRequestBuilder.cs b/src/generated/Drives/Item/Items/Item/DriveItemRequestBuilder.cs index 6666cb83ae8..40fa690b6c2 100644 --- a/src/generated/Drives/Item/Items/Item/DriveItemRequestBuilder.cs +++ b/src/generated/Drives/Item/Items/Item/DriveItemRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveId, string driveItemId) => { + command.SetHandler(async (string driveId, string driveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, driveItemIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, string driveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string driveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, driveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, driveItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,7 +101,7 @@ public Command BuildPatchCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -111,14 +109,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string driveItemId, string body) => { + command.SetHandler(async (string driveId, string driveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, driveItemIdOption, bodyOption); return command; @@ -190,42 +187,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All items contained in the drive. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All items contained in the drive. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All items contained in the drive. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// All items contained in the drive. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drives/Item/Items/ItemsRequestBuilder.cs b/src/generated/Drives/Item/Items/ItemsRequestBuilder.cs index e3f7a5f7ef8..4419b4f916e 100644 --- a/src/generated/Drives/Item/Items/ItemsRequestBuilder.cs +++ b/src/generated/Drives/Item/Items/ItemsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class ItemsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DriveItemRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, bodyOption, outputOption); return command; } /// @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All items contained in the drive. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All items contained in the drive. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// All items contained in the drive. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Drives/Item/List/Columns/ColumnsRequestBuilder.cs b/src/generated/Drives/Item/List/Columns/ColumnsRequestBuilder.cs index eb74e5b7cd7..cef974cf8ea 100644 --- a/src/generated/Drives/Item/List/Columns/ColumnsRequestBuilder.cs +++ b/src/generated/Drives/Item/List/Columns/ColumnsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class ColumnsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ColumnDefinitionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSourceColumnCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSourceColumnCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, bodyOption, outputOption); return command; } /// @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(ColumnDefinition body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of field definitions for this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of field definitions for this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ColumnDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of field definitions for this list. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Drives/Item/List/Columns/Item/ColumnDefinitionRequestBuilder.cs b/src/generated/Drives/Item/List/Columns/Item/ColumnDefinitionRequestBuilder.cs index 6e6a5ecafed..7ea35cd7b51 100644 --- a/src/generated/Drives/Item/List/Columns/Item/ColumnDefinitionRequestBuilder.cs +++ b/src/generated/Drives/Item/List/Columns/Item/ColumnDefinitionRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,15 +31,14 @@ public Command BuildDeleteCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string driveId, string columnDefinitionId) => { + command.SetHandler(async (string driveId, string columnDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, columnDefinitionIdOption); return command; @@ -55,7 +54,7 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, string columnDefinitionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string columnDefinitionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, columnDefinitionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, columnDefinitionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -96,7 +94,7 @@ public Command BuildPatchCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -104,14 +102,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string columnDefinitionId, string body) => { + command.SetHandler(async (string driveId, string columnDefinitionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, columnDefinitionIdOption, bodyOption); return command; @@ -190,42 +187,6 @@ public RequestInformation CreatePatchRequestInformation(ColumnDefinition body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of field definitions for this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of field definitions for this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of field definitions for this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ColumnDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of field definitions for this list. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drives/Item/List/Columns/Item/SourceColumn/@Ref/@Ref.cs b/src/generated/Drives/Item/List/Columns/Item/SourceColumn/@Ref/@Ref.cs deleted file mode 100644 index e62e5cc7dfc..00000000000 --- a/src/generated/Drives/Item/List/Columns/Item/SourceColumn/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Drives.Item.List.Columns.Item.SourceColumn.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Drives/Item/List/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs b/src/generated/Drives/Item/List/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs deleted file mode 100644 index a78e355a286..00000000000 --- a/src/generated/Drives/Item/List/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Drives.Item.List.Columns.Item.SourceColumn.@Ref { - /// Builds and executes requests for operations under \drives\{drive-id}\list\columns\{columnDefinition-id}\sourceColumn\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The source column for content type column. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var driveIdOption = new Option("--drive-id", description: "key: id of drive") { - }; - driveIdOption.IsRequired = true; - command.AddOption(driveIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string driveId, string columnDefinitionId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, driveIdOption, columnDefinitionIdOption); - return command; - } - /// - /// The source column for content type column. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var driveIdOption = new Option("--drive-id", description: "key: id of drive") { - }; - driveIdOption.IsRequired = true; - command.AddOption(driveIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string driveId, string columnDefinitionId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, columnDefinitionIdOption); - return command; - } - /// - /// The source column for content type column. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var driveIdOption = new Option("--drive-id", description: "key: id of drive") { - }; - driveIdOption.IsRequired = true; - command.AddOption(driveIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string columnDefinitionId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, driveIdOption, columnDefinitionIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/drives/{drive_id}/list/columns/{columnDefinition_id}/sourceColumn/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The source column for content type column. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Drives.Item.List.Columns.Item.SourceColumn.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Drives.Item.List.Columns.Item.SourceColumn.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Drives/Item/List/Columns/Item/SourceColumn/Ref/Ref.cs b/src/generated/Drives/Item/List/Columns/Item/SourceColumn/Ref/Ref.cs new file mode 100644 index 00000000000..6d1e9aa1d7e --- /dev/null +++ b/src/generated/Drives/Item/List/Columns/Item/SourceColumn/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Drives.Item.List.Columns.Item.SourceColumn.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Drives/Item/List/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs b/src/generated/Drives/Item/List/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..c41ffb6709e --- /dev/null +++ b/src/generated/Drives/Item/List/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Drives.Item.List.Columns.Item.SourceColumn.Ref { + /// Builds and executes requests for operations under \drives\{drive-id}\list\columns\{columnDefinition-id}\sourceColumn\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The source column for content type column. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var driveIdOption = new Option("--drive-id", description: "key: id of drive") { + }; + driveIdOption.IsRequired = true; + command.AddOption(driveIdOption); + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + command.SetHandler(async (string driveId, string columnDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, driveIdOption, columnDefinitionIdOption); + return command; + } + /// + /// The source column for content type column. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var driveIdOption = new Option("--drive-id", description: "key: id of drive") { + }; + driveIdOption.IsRequired = true; + command.AddOption(driveIdOption); + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string columnDefinitionId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, columnDefinitionIdOption, outputOption); + return command; + } + /// + /// The source column for content type column. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var driveIdOption = new Option("--drive-id", description: "key: id of drive") { + }; + driveIdOption.IsRequired = true; + command.AddOption(driveIdOption); + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string driveId, string columnDefinitionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, driveIdOption, columnDefinitionIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/drives/{drive_id}/list/columns/{columnDefinition_id}/sourceColumn/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The source column for content type column. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The source column for content type column. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The source column for content type column. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Drives.Item.List.Columns.Item.SourceColumn.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Drives/Item/List/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs b/src/generated/Drives/Item/List/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs index 29e8e0d2ee3..6dc4235ad4d 100644 --- a/src/generated/Drives/Item/List/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs +++ b/src/generated/Drives/Item/List/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,7 +31,7 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -45,25 +45,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, string columnDefinitionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string columnDefinitionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, columnDefinitionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, columnDefinitionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Drives.Item.List.Columns.Item.SourceColumn.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Drives.Item.List.Columns.Item.SourceColumn.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -103,18 +102,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The source column for content type column. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drives/Item/List/ContentTypes/AddCopy/AddCopyRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/AddCopy/AddCopyRequestBuilder.cs index 60eb4e321d4..b39c566c7e5 100644 --- a/src/generated/Drives/Item/List/ContentTypes/AddCopy/AddCopyRequestBuilder.cs +++ b/src/generated/Drives/Item/List/ContentTypes/AddCopy/AddCopyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(AddCopyRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action addCopy - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddCopyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes contentType public class AddCopyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Drives/Item/List/ContentTypes/ContentTypesRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/ContentTypesRequestBuilder.cs index 193c1e8a503..83508a4578f 100644 --- a/src/generated/Drives/Item/List/ContentTypes/ContentTypesRequestBuilder.cs +++ b/src/generated/Drives/Item/List/ContentTypes/ContentTypesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,20 +29,19 @@ public Command BuildAddCopyCommand() { } public List BuildCommand() { var builder = new ContentTypeRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAssociateWithHubSitesCommand(), - builder.BuildBaseCommand(), - builder.BuildBaseTypesCommand(), - builder.BuildColumnLinksCommand(), - builder.BuildColumnPositionsCommand(), - builder.BuildColumnsCommand(), - builder.BuildCopyToDefaultContentLocationCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildPublishCommand(), - builder.BuildUnpublishCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAssociateWithHubSitesCommand()); + commands.Add(builder.BuildBaseCommand()); + commands.Add(builder.BuildBaseTypesCommand()); + commands.Add(builder.BuildColumnLinksCommand()); + commands.Add(builder.BuildColumnPositionsCommand()); + commands.Add(builder.BuildColumnsCommand()); + commands.Add(builder.BuildCopyToDefaultContentLocationCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPublishCommand()); + commands.Add(builder.BuildUnpublishCommand()); return commands; } /// @@ -60,21 +59,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, bodyOption, outputOption); return command; } /// @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(ContentType body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of content types present in this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of content types present in this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ContentType model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of content types present in this list. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/@Base/@Ref/@Ref.cs b/src/generated/Drives/Item/List/ContentTypes/Item/@Base/@Ref/@Ref.cs deleted file mode 100644 index 20cd800c1c5..00000000000 --- a/src/generated/Drives/Item/List/ContentTypes/Item/@Base/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Drives.Item.List.ContentTypes.Item.@Base.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/@Base/@Ref/RefRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/@Base/@Ref/RefRequestBuilder.cs deleted file mode 100644 index e38b23eb904..00000000000 --- a/src/generated/Drives/Item/List/ContentTypes/Item/@Base/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Drives.Item.List.ContentTypes.Item.@Base.@Ref { - /// Builds and executes requests for operations under \drives\{drive-id}\list\contentTypes\{contentType-id}\base\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Parent contentType from which this content type is derived. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Parent contentType from which this content type is derived."; - // Create options for all the parameters - var driveIdOption = new Option("--drive-id", description: "key: id of drive") { - }; - driveIdOption.IsRequired = true; - command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - command.SetHandler(async (string driveId, string contentTypeId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, driveIdOption, contentTypeIdOption); - return command; - } - /// - /// Parent contentType from which this content type is derived. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Parent contentType from which this content type is derived."; - // Create options for all the parameters - var driveIdOption = new Option("--drive-id", description: "key: id of drive") { - }; - driveIdOption.IsRequired = true; - command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - command.SetHandler(async (string driveId, string contentTypeId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, contentTypeIdOption); - return command; - } - /// - /// Parent contentType from which this content type is derived. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Parent contentType from which this content type is derived."; - // Create options for all the parameters - var driveIdOption = new Option("--drive-id", description: "key: id of drive") { - }; - driveIdOption.IsRequired = true; - command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string contentTypeId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, driveIdOption, contentTypeIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/drives/{drive_id}/list/contentTypes/{contentType_id}/base/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Parent contentType from which this content type is derived. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Parent contentType from which this content type is derived. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Parent contentType from which this content type is derived. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Drives.Item.List.ContentTypes.Item.@Base.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Parent contentType from which this content type is derived. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Parent contentType from which this content type is derived. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Parent contentType from which this content type is derived. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Drives.Item.List.ContentTypes.Item.@Base.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs b/src/generated/Drives/Item/List/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs deleted file mode 100644 index 5745c817b90..00000000000 --- a/src/generated/Drives/Item/List/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Drives.Item.List.ContentTypes.Item.@Base.AssociateWithHubSites { - public class AssociateWithHubSitesRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public List HubSiteUrls { get; set; } - public bool? PropagateToExistingLists { get; set; } - /// - /// Instantiates a new associateWithHubSitesRequestBody and sets the default values. - /// - public AssociateWithHubSitesRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"hubSiteUrls", (o,n) => { (o as AssociateWithHubSitesRequestBody).HubSiteUrls = n.GetCollectionOfPrimitiveValues().ToList(); } }, - {"propagateToExistingLists", (o,n) => { (o as AssociateWithHubSitesRequestBody).PropagateToExistingLists = n.GetBoolValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteCollectionOfPrimitiveValues("hubSiteUrls", HubSiteUrls); - writer.WriteBoolValue("propagateToExistingLists", PropagateToExistingLists); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs deleted file mode 100644 index 2a3806f6702..00000000000 --- a/src/generated/Drives/Item/List/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs +++ /dev/null @@ -1,97 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Drives.Item.List.ContentTypes.Item.@Base.AssociateWithHubSites { - /// Builds and executes requests for operations under \drives\{drive-id}\list\contentTypes\{contentType-id}\base\microsoft.graph.associateWithHubSites - public class AssociateWithHubSitesRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action associateWithHubSites - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action associateWithHubSites"; - // Create options for all the parameters - var driveIdOption = new Option("--drive-id", description: "key: id of drive") { - }; - driveIdOption.IsRequired = true; - command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string contentTypeId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, driveIdOption, contentTypeIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AssociateWithHubSitesRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AssociateWithHubSitesRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/drives/{drive_id}/list/contentTypes/{contentType_id}/base/microsoft.graph.associateWithHubSites"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action associateWithHubSites - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AssociateWithHubSitesRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action associateWithHubSites - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssociateWithHubSitesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/@Base/BaseRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/@Base/BaseRequestBuilder.cs deleted file mode 100644 index 72f8b5bc272..00000000000 --- a/src/generated/Drives/Item/List/ContentTypes/Item/@Base/BaseRequestBuilder.cs +++ /dev/null @@ -1,161 +0,0 @@ -using ApiSdk.Drives.Item.List.ContentTypes.Item.Base.AssociateWithHubSites; -using ApiSdk.Drives.Item.List.ContentTypes.Item.Base.CopyToDefaultContentLocation; -using ApiSdk.Drives.Item.List.ContentTypes.Item.Base.IsPublished; -using ApiSdk.Drives.Item.List.ContentTypes.Item.Base.Publish; -using ApiSdk.Drives.Item.List.ContentTypes.Item.Base.Ref; -using ApiSdk.Drives.Item.List.ContentTypes.Item.Base.Unpublish; -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Drives.Item.List.ContentTypes.Item.@Base { - /// Builds and executes requests for operations under \drives\{drive-id}\list\contentTypes\{contentType-id}\base - public class BaseRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - public Command BuildAssociateWithHubSitesCommand() { - var command = new Command("associate-with-hub-sites"); - var builder = new ApiSdk.Drives.Item.List.ContentTypes.Item.@Base.AssociateWithHubSites.AssociateWithHubSitesRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildPostCommand()); - return command; - } - public Command BuildCopyToDefaultContentLocationCommand() { - var command = new Command("copy-to-default-content-location"); - var builder = new ApiSdk.Drives.Item.List.ContentTypes.Item.@Base.CopyToDefaultContentLocation.CopyToDefaultContentLocationRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildPostCommand()); - return command; - } - /// - /// Parent contentType from which this content type is derived. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Parent contentType from which this content type is derived."; - // Create options for all the parameters - var driveIdOption = new Option("--drive-id", description: "key: id of drive") { - }; - driveIdOption.IsRequired = true; - command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string driveId, string contentTypeId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, contentTypeIdOption, selectOption, expandOption); - return command; - } - public Command BuildPublishCommand() { - var command = new Command("publish"); - var builder = new ApiSdk.Drives.Item.List.ContentTypes.Item.@Base.Publish.PublishRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildPostCommand()); - return command; - } - public Command BuildRefCommand() { - var command = new Command("ref"); - var builder = new ApiSdk.Drives.Item.List.ContentTypes.Item.@Base.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildDeleteCommand()); - command.AddCommand(builder.BuildGetCommand()); - command.AddCommand(builder.BuildPutCommand()); - return command; - } - public Command BuildUnpublishCommand() { - var command = new Command("unpublish"); - var builder = new ApiSdk.Drives.Item.List.ContentTypes.Item.@Base.Unpublish.UnpublishRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildPostCommand()); - return command; - } - /// - /// Instantiates a new BaseRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public BaseRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/drives/{drive_id}/list/contentTypes/{contentType_id}/base{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Parent contentType from which this content type is derived. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Parent contentType from which this content type is derived. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Builds and executes requests for operations under \drives\{drive-id}\list\contentTypes\{contentType-id}\base\microsoft.graph.isPublished() - /// - public IsPublishedRequestBuilder IsPublished() { - return new IsPublishedRequestBuilder(PathParameters, RequestAdapter); - } - /// Parent contentType from which this content type is derived. - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs b/src/generated/Drives/Item/List/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs deleted file mode 100644 index 19fbc460e37..00000000000 --- a/src/generated/Drives/Item/List/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs +++ /dev/null @@ -1,39 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Drives.Item.List.ContentTypes.Item.@Base.CopyToDefaultContentLocation { - public class CopyToDefaultContentLocationRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string DestinationFileName { get; set; } - public ItemReference SourceFile { get; set; } - /// - /// Instantiates a new copyToDefaultContentLocationRequestBody and sets the default values. - /// - public CopyToDefaultContentLocationRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"destinationFileName", (o,n) => { (o as CopyToDefaultContentLocationRequestBody).DestinationFileName = n.GetStringValue(); } }, - {"sourceFile", (o,n) => { (o as CopyToDefaultContentLocationRequestBody).SourceFile = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("destinationFileName", DestinationFileName); - writer.WriteObjectValue("sourceFile", SourceFile); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs deleted file mode 100644 index 5a1253a11a6..00000000000 --- a/src/generated/Drives/Item/List/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs +++ /dev/null @@ -1,97 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Drives.Item.List.ContentTypes.Item.@Base.CopyToDefaultContentLocation { - /// Builds and executes requests for operations under \drives\{drive-id}\list\contentTypes\{contentType-id}\base\microsoft.graph.copyToDefaultContentLocation - public class CopyToDefaultContentLocationRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action copyToDefaultContentLocation - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action copyToDefaultContentLocation"; - // Create options for all the parameters - var driveIdOption = new Option("--drive-id", description: "key: id of drive") { - }; - driveIdOption.IsRequired = true; - command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string contentTypeId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, driveIdOption, contentTypeIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new CopyToDefaultContentLocationRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public CopyToDefaultContentLocationRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/drives/{drive_id}/list/contentTypes/{contentType_id}/base/microsoft.graph.copyToDefaultContentLocation"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action copyToDefaultContentLocation - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(CopyToDefaultContentLocationRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action copyToDefaultContentLocation - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToDefaultContentLocationRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/@Base/IsPublished/IsPublishedRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/@Base/IsPublished/IsPublishedRequestBuilder.cs deleted file mode 100644 index ca3f05e5db3..00000000000 --- a/src/generated/Drives/Item/List/ContentTypes/Item/@Base/IsPublished/IsPublishedRequestBuilder.cs +++ /dev/null @@ -1,90 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Drives.Item.List.ContentTypes.Item.@Base.IsPublished { - /// Builds and executes requests for operations under \drives\{drive-id}\list\contentTypes\{contentType-id}\base\microsoft.graph.isPublished() - public class IsPublishedRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke function isPublished - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Invoke function isPublished"; - // Create options for all the parameters - var driveIdOption = new Option("--drive-id", description: "key: id of drive") { - }; - driveIdOption.IsRequired = true; - command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - command.SetHandler(async (string driveId, string contentTypeId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteBoolValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, contentTypeIdOption); - return command; - } - /// - /// Instantiates a new IsPublishedRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public IsPublishedRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/drives/{drive_id}/list/contentTypes/{contentType_id}/base/microsoft.graph.isPublished()"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke function isPublished - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke function isPublished - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/@Base/Publish/PublishRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/@Base/Publish/PublishRequestBuilder.cs deleted file mode 100644 index b7332e4d8ff..00000000000 --- a/src/generated/Drives/Item/List/ContentTypes/Item/@Base/Publish/PublishRequestBuilder.cs +++ /dev/null @@ -1,85 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Drives.Item.List.ContentTypes.Item.@Base.Publish { - /// Builds and executes requests for operations under \drives\{drive-id}\list\contentTypes\{contentType-id}\base\microsoft.graph.publish - public class PublishRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action publish - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action publish"; - // Create options for all the parameters - var driveIdOption = new Option("--drive-id", description: "key: id of drive") { - }; - driveIdOption.IsRequired = true; - command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - command.SetHandler(async (string driveId, string contentTypeId) => { - var requestInfo = CreatePostRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, driveIdOption, contentTypeIdOption); - return command; - } - /// - /// Instantiates a new PublishRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public PublishRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/drives/{drive_id}/list/contentTypes/{contentType_id}/base/microsoft.graph.publish"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action publish - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action publish - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/@Base/Unpublish/UnpublishRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/@Base/Unpublish/UnpublishRequestBuilder.cs deleted file mode 100644 index 99c3e276e6b..00000000000 --- a/src/generated/Drives/Item/List/ContentTypes/Item/@Base/Unpublish/UnpublishRequestBuilder.cs +++ /dev/null @@ -1,85 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Drives.Item.List.ContentTypes.Item.@Base.Unpublish { - /// Builds and executes requests for operations under \drives\{drive-id}\list\contentTypes\{contentType-id}\base\microsoft.graph.unpublish - public class UnpublishRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action unpublish - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action unpublish"; - // Create options for all the parameters - var driveIdOption = new Option("--drive-id", description: "key: id of drive") { - }; - driveIdOption.IsRequired = true; - command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - command.SetHandler(async (string driveId, string contentTypeId) => { - var requestInfo = CreatePostRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, driveIdOption, contentTypeIdOption); - return command; - } - /// - /// Instantiates a new UnpublishRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public UnpublishRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/drives/{drive_id}/list/contentTypes/{contentType_id}/base/microsoft.graph.unpublish"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action unpublish - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action unpublish - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs index 349eb7bcc36..ee47dc730cf 100644 --- a/src/generated/Drives/Item/List/ContentTypes/Item/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs +++ b/src/generated/Drives/Item/List/ContentTypes/Item/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string contentTypeId, string body) => { + command.SetHandler(async (string driveId, string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, contentTypeIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AssociateWithHubSitesRequ requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action associateWithHubSites - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssociateWithHubSitesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs b/src/generated/Drives/Item/List/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs new file mode 100644 index 00000000000..9ea43cda991 --- /dev/null +++ b/src/generated/Drives/Item/List/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Drives.Item.List.ContentTypes.Item.Base.AssociateWithHubSites { + public class AssociateWithHubSitesRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public List HubSiteUrls { get; set; } + public bool? PropagateToExistingLists { get; set; } + /// + /// Instantiates a new associateWithHubSitesRequestBody and sets the default values. + /// + public AssociateWithHubSitesRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"hubSiteUrls", (o,n) => { (o as AssociateWithHubSitesRequestBody).HubSiteUrls = n.GetCollectionOfPrimitiveValues().ToList(); } }, + {"propagateToExistingLists", (o,n) => { (o as AssociateWithHubSitesRequestBody).PropagateToExistingLists = n.GetBoolValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfPrimitiveValues("hubSiteUrls", HubSiteUrls); + writer.WriteBoolValue("propagateToExistingLists", PropagateToExistingLists); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs new file mode 100644 index 00000000000..4424450f90f --- /dev/null +++ b/src/generated/Drives/Item/List/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs @@ -0,0 +1,83 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Drives.Item.List.ContentTypes.Item.Base.AssociateWithHubSites { + /// Builds and executes requests for operations under \drives\{drive-id}\list\contentTypes\{contentType-id}\base\microsoft.graph.associateWithHubSites + public class AssociateWithHubSitesRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action associateWithHubSites + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action associateWithHubSites"; + // Create options for all the parameters + var driveIdOption = new Option("--drive-id", description: "key: id of drive") { + }; + driveIdOption.IsRequired = true; + command.AddOption(driveIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string driveId, string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, driveIdOption, contentTypeIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new AssociateWithHubSitesRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AssociateWithHubSitesRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/drives/{drive_id}/list/contentTypes/{contentType_id}/base/microsoft.graph.associateWithHubSites"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action associateWithHubSites + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AssociateWithHubSitesRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/Base/BaseRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/Base/BaseRequestBuilder.cs new file mode 100644 index 00000000000..044602e96b8 --- /dev/null +++ b/src/generated/Drives/Item/List/ContentTypes/Item/Base/BaseRequestBuilder.cs @@ -0,0 +1,148 @@ +using ApiSdk.Drives.Item.List.ContentTypes.Item.Base.AssociateWithHubSites; +using ApiSdk.Drives.Item.List.ContentTypes.Item.Base.CopyToDefaultContentLocation; +using ApiSdk.Drives.Item.List.ContentTypes.Item.Base.IsPublished; +using ApiSdk.Drives.Item.List.ContentTypes.Item.Base.Publish; +using ApiSdk.Drives.Item.List.ContentTypes.Item.Base.Ref; +using ApiSdk.Drives.Item.List.ContentTypes.Item.Base.Unpublish; +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Drives.Item.List.ContentTypes.Item.Base { + /// Builds and executes requests for operations under \drives\{drive-id}\list\contentTypes\{contentType-id}\base + public class BaseRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + public Command BuildAssociateWithHubSitesCommand() { + var command = new Command("associate-with-hub-sites"); + var builder = new ApiSdk.Drives.Item.List.ContentTypes.Item.Base.AssociateWithHubSites.AssociateWithHubSitesRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildPostCommand()); + return command; + } + public Command BuildCopyToDefaultContentLocationCommand() { + var command = new Command("copy-to-default-content-location"); + var builder = new ApiSdk.Drives.Item.List.ContentTypes.Item.Base.CopyToDefaultContentLocation.CopyToDefaultContentLocationRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildPostCommand()); + return command; + } + /// + /// Parent contentType from which this content type is derived. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Parent contentType from which this content type is derived."; + // Create options for all the parameters + var driveIdOption = new Option("--drive-id", description: "key: id of drive") { + }; + driveIdOption.IsRequired = true; + command.AddOption(driveIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var selectOption = new Option("--select", description: "Select properties to be returned") { + Arity = ArgumentArity.ZeroOrMore + }; + selectOption.IsRequired = false; + command.AddOption(selectOption); + var expandOption = new Option("--expand", description: "Expand related entities") { + Arity = ArgumentArity.ZeroOrMore + }; + expandOption.IsRequired = false; + command.AddOption(expandOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string contentTypeId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Select = select; + q.Expand = expand; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, contentTypeIdOption, selectOption, expandOption, outputOption); + return command; + } + public Command BuildPublishCommand() { + var command = new Command("publish"); + var builder = new ApiSdk.Drives.Item.List.ContentTypes.Item.Base.Publish.PublishRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildPostCommand()); + return command; + } + public Command BuildRefCommand() { + var command = new Command("ref"); + var builder = new ApiSdk.Drives.Item.List.ContentTypes.Item.Base.Ref.RefRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildDeleteCommand()); + command.AddCommand(builder.BuildGetCommand()); + command.AddCommand(builder.BuildPutCommand()); + return command; + } + public Command BuildUnpublishCommand() { + var command = new Command("unpublish"); + var builder = new ApiSdk.Drives.Item.List.ContentTypes.Item.Base.Unpublish.UnpublishRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildPostCommand()); + return command; + } + /// + /// Instantiates a new BaseRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public BaseRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/drives/{drive_id}/list/contentTypes/{contentType_id}/base{?select,expand}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Parent contentType from which this content type is derived. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Builds and executes requests for operations under \drives\{drive-id}\list\contentTypes\{contentType-id}\base\microsoft.graph.isPublished() + /// + public IsPublishedRequestBuilder IsPublished() { + return new IsPublishedRequestBuilder(PathParameters, RequestAdapter); + } + /// Parent contentType from which this content type is derived. + public class GetQueryParameters : QueryParametersBase { + /// Expand related entities + public string[] Expand { get; set; } + /// Select properties to be returned + public string[] Select { get; set; } + } + } +} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs b/src/generated/Drives/Item/List/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs new file mode 100644 index 00000000000..41cd3c5856a --- /dev/null +++ b/src/generated/Drives/Item/List/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs @@ -0,0 +1,39 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Drives.Item.List.ContentTypes.Item.Base.CopyToDefaultContentLocation { + public class CopyToDefaultContentLocationRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string DestinationFileName { get; set; } + public ItemReference SourceFile { get; set; } + /// + /// Instantiates a new copyToDefaultContentLocationRequestBody and sets the default values. + /// + public CopyToDefaultContentLocationRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"destinationFileName", (o,n) => { (o as CopyToDefaultContentLocationRequestBody).DestinationFileName = n.GetStringValue(); } }, + {"sourceFile", (o,n) => { (o as CopyToDefaultContentLocationRequestBody).SourceFile = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("destinationFileName", DestinationFileName); + writer.WriteObjectValue("sourceFile", SourceFile); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs new file mode 100644 index 00000000000..f31ef1c1322 --- /dev/null +++ b/src/generated/Drives/Item/List/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs @@ -0,0 +1,83 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Drives.Item.List.ContentTypes.Item.Base.CopyToDefaultContentLocation { + /// Builds and executes requests for operations under \drives\{drive-id}\list\contentTypes\{contentType-id}\base\microsoft.graph.copyToDefaultContentLocation + public class CopyToDefaultContentLocationRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action copyToDefaultContentLocation + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action copyToDefaultContentLocation"; + // Create options for all the parameters + var driveIdOption = new Option("--drive-id", description: "key: id of drive") { + }; + driveIdOption.IsRequired = true; + command.AddOption(driveIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string driveId, string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, driveIdOption, contentTypeIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new CopyToDefaultContentLocationRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public CopyToDefaultContentLocationRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/drives/{drive_id}/list/contentTypes/{contentType_id}/base/microsoft.graph.copyToDefaultContentLocation"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action copyToDefaultContentLocation + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(CopyToDefaultContentLocationRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/Base/IsPublished/IsPublishedRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/Base/IsPublished/IsPublishedRequestBuilder.cs new file mode 100644 index 00000000000..8622c7ac83b --- /dev/null +++ b/src/generated/Drives/Item/List/ContentTypes/Item/Base/IsPublished/IsPublishedRequestBuilder.cs @@ -0,0 +1,78 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Drives.Item.List.ContentTypes.Item.Base.IsPublished { + /// Builds and executes requests for operations under \drives\{drive-id}\list\contentTypes\{contentType-id}\base\microsoft.graph.isPublished() + public class IsPublishedRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke function isPublished + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Invoke function isPublished"; + // Create options for all the parameters + var driveIdOption = new Option("--drive-id", description: "key: id of drive") { + }; + driveIdOption.IsRequired = true; + command.AddOption(driveIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string contentTypeId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, contentTypeIdOption, outputOption); + return command; + } + /// + /// Instantiates a new IsPublishedRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public IsPublishedRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/drives/{drive_id}/list/contentTypes/{contentType_id}/base/microsoft.graph.isPublished()"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke function isPublished + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/Base/Publish/PublishRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/Base/Publish/PublishRequestBuilder.cs new file mode 100644 index 00000000000..0760802ca54 --- /dev/null +++ b/src/generated/Drives/Item/List/ContentTypes/Item/Base/Publish/PublishRequestBuilder.cs @@ -0,0 +1,73 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Drives.Item.List.ContentTypes.Item.Base.Publish { + /// Builds and executes requests for operations under \drives\{drive-id}\list\contentTypes\{contentType-id}\base\microsoft.graph.publish + public class PublishRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action publish + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action publish"; + // Create options for all the parameters + var driveIdOption = new Option("--drive-id", description: "key: id of drive") { + }; + driveIdOption.IsRequired = true; + command.AddOption(driveIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + command.SetHandler(async (string driveId, string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreatePostRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, driveIdOption, contentTypeIdOption); + return command; + } + /// + /// Instantiates a new PublishRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public PublishRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/drives/{drive_id}/list/contentTypes/{contentType_id}/base/microsoft.graph.publish"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action publish + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/Base/Ref/Ref.cs b/src/generated/Drives/Item/List/ContentTypes/Item/Base/Ref/Ref.cs new file mode 100644 index 00000000000..efe72bc4e5a --- /dev/null +++ b/src/generated/Drives/Item/List/ContentTypes/Item/Base/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Drives.Item.List.ContentTypes.Item.Base.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/Base/Ref/RefRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/Base/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..6b7adf31e68 --- /dev/null +++ b/src/generated/Drives/Item/List/ContentTypes/Item/Base/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Drives.Item.List.ContentTypes.Item.Base.Ref { + /// Builds and executes requests for operations under \drives\{drive-id}\list\contentTypes\{contentType-id}\base\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Parent contentType from which this content type is derived. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Parent contentType from which this content type is derived."; + // Create options for all the parameters + var driveIdOption = new Option("--drive-id", description: "key: id of drive") { + }; + driveIdOption.IsRequired = true; + command.AddOption(driveIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + command.SetHandler(async (string driveId, string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, driveIdOption, contentTypeIdOption); + return command; + } + /// + /// Parent contentType from which this content type is derived. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Parent contentType from which this content type is derived."; + // Create options for all the parameters + var driveIdOption = new Option("--drive-id", description: "key: id of drive") { + }; + driveIdOption.IsRequired = true; + command.AddOption(driveIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string contentTypeId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, contentTypeIdOption, outputOption); + return command; + } + /// + /// Parent contentType from which this content type is derived. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Parent contentType from which this content type is derived."; + // Create options for all the parameters + var driveIdOption = new Option("--drive-id", description: "key: id of drive") { + }; + driveIdOption.IsRequired = true; + command.AddOption(driveIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string driveId, string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, driveIdOption, contentTypeIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/drives/{drive_id}/list/contentTypes/{contentType_id}/base/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Parent contentType from which this content type is derived. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Parent contentType from which this content type is derived. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Parent contentType from which this content type is derived. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Drives.Item.List.ContentTypes.Item.Base.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/Base/Unpublish/UnpublishRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/Base/Unpublish/UnpublishRequestBuilder.cs new file mode 100644 index 00000000000..e79b4af5a17 --- /dev/null +++ b/src/generated/Drives/Item/List/ContentTypes/Item/Base/Unpublish/UnpublishRequestBuilder.cs @@ -0,0 +1,73 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Drives.Item.List.ContentTypes.Item.Base.Unpublish { + /// Builds and executes requests for operations under \drives\{drive-id}\list\contentTypes\{contentType-id}\base\microsoft.graph.unpublish + public class UnpublishRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action unpublish + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action unpublish"; + // Create options for all the parameters + var driveIdOption = new Option("--drive-id", description: "key: id of drive") { + }; + driveIdOption.IsRequired = true; + command.AddOption(driveIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + command.SetHandler(async (string driveId, string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreatePostRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, driveIdOption, contentTypeIdOption); + return command; + } + /// + /// Instantiates a new UnpublishRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public UnpublishRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/drives/{drive_id}/list/contentTypes/{contentType_id}/base/microsoft.graph.unpublish"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action unpublish + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/BaseTypes/@Ref/@Ref.cs b/src/generated/Drives/Item/List/ContentTypes/Item/BaseTypes/@Ref/@Ref.cs deleted file mode 100644 index 638866f3c60..00000000000 --- a/src/generated/Drives/Item/List/ContentTypes/Item/BaseTypes/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Drives.Item.List.ContentTypes.Item.BaseTypes.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/BaseTypes/@Ref/RefRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/BaseTypes/@Ref/RefRequestBuilder.cs deleted file mode 100644 index fc8bbbef649..00000000000 --- a/src/generated/Drives/Item/List/ContentTypes/Item/BaseTypes/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,210 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Drives.Item.List.ContentTypes.Item.BaseTypes.@Ref { - /// Builds and executes requests for operations under \drives\{drive-id}\list\contentTypes\{contentType-id}\baseTypes\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The collection of content types that are ancestors of this content type. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The collection of content types that are ancestors of this content type."; - // Create options for all the parameters - var driveIdOption = new Option("--drive-id", description: "key: id of drive") { - }; - driveIdOption.IsRequired = true; - command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string driveId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The collection of content types that are ancestors of this content type. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The collection of content types that are ancestors of this content type."; - // Create options for all the parameters - var driveIdOption = new Option("--drive-id", description: "key: id of drive") { - }; - driveIdOption.IsRequired = true; - command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string contentTypeId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, contentTypeIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/drives/{drive_id}/list/contentTypes/{contentType_id}/baseTypes/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The collection of content types that are ancestors of this content type. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The collection of content types that are ancestors of this content type. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Drives.Item.List.ContentTypes.Item.BaseTypes.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The collection of content types that are ancestors of this content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of content types that are ancestors of this content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Drives.Item.List.ContentTypes.Item.BaseTypes.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The collection of content types that are ancestors of this content type. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/BaseTypes/@Ref/RefResponse.cs b/src/generated/Drives/Item/List/ContentTypes/Item/BaseTypes/@Ref/RefResponse.cs deleted file mode 100644 index 5a2e6a9ae27..00000000000 --- a/src/generated/Drives/Item/List/ContentTypes/Item/BaseTypes/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Drives.Item.List.ContentTypes.Item.BaseTypes.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/BaseTypes/AddCopy/AddCopyRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/BaseTypes/AddCopy/AddCopyRequestBuilder.cs index 8af8f4514d5..b52fa51ab7d 100644 --- a/src/generated/Drives/Item/List/ContentTypes/Item/BaseTypes/AddCopy/AddCopyRequestBuilder.cs +++ b/src/generated/Drives/Item/List/ContentTypes/Item/BaseTypes/AddCopy/AddCopyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string contentTypeId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string contentTypeId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, contentTypeIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, contentTypeIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(AddCopyRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action addCopy - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddCopyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes contentType public class AddCopyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/BaseTypes/BaseTypesRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/BaseTypes/BaseTypesRequestBuilder.cs index c38abfa26ba..3ffb3856c46 100644 --- a/src/generated/Drives/Item/List/ContentTypes/Item/BaseTypes/BaseTypesRequestBuilder.cs +++ b/src/generated/Drives/Item/List/ContentTypes/Item/BaseTypes/BaseTypesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Drives.Item.List.ContentTypes.Item.BaseTypes.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,7 +37,7 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -76,7 +76,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -87,20 +91,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Drives.Item.List.ContentTypes.Item.BaseTypes.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Drives.Item.List.ContentTypes.Item.BaseTypes.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -139,18 +138,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of content types that are ancestors of this content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of content types that are ancestors of this content type. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/BaseTypes/Ref/Ref.cs b/src/generated/Drives/Item/List/ContentTypes/Item/BaseTypes/Ref/Ref.cs new file mode 100644 index 00000000000..a106df641b3 --- /dev/null +++ b/src/generated/Drives/Item/List/ContentTypes/Item/BaseTypes/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Drives.Item.List.ContentTypes.Item.BaseTypes.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/BaseTypes/Ref/RefRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/BaseTypes/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..2fa92a6dad9 --- /dev/null +++ b/src/generated/Drives/Item/List/ContentTypes/Item/BaseTypes/Ref/RefRequestBuilder.cs @@ -0,0 +1,183 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Drives.Item.List.ContentTypes.Item.BaseTypes.Ref { + /// Builds and executes requests for operations under \drives\{drive-id}\list\contentTypes\{contentType-id}\baseTypes\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The collection of content types that are ancestors of this content type. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The collection of content types that are ancestors of this content type."; + // Create options for all the parameters + var driveIdOption = new Option("--drive-id", description: "key: id of drive") { + }; + driveIdOption.IsRequired = true; + command.AddOption(driveIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The collection of content types that are ancestors of this content type. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The collection of content types that are ancestors of this content type."; + // Create options for all the parameters + var driveIdOption = new Option("--drive-id", description: "key: id of drive") { + }; + driveIdOption.IsRequired = true; + command.AddOption(driveIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string contentTypeId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, contentTypeIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/drives/{drive_id}/list/contentTypes/{contentType_id}/baseTypes/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The collection of content types that are ancestors of this content type. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The collection of content types that are ancestors of this content type. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Drives.Item.List.ContentTypes.Item.BaseTypes.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The collection of content types that are ancestors of this content type. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/BaseTypes/Ref/RefResponse.cs b/src/generated/Drives/Item/List/ContentTypes/Item/BaseTypes/Ref/RefResponse.cs new file mode 100644 index 00000000000..2098105191a --- /dev/null +++ b/src/generated/Drives/Item/List/ContentTypes/Item/BaseTypes/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Drives.Item.List.ContentTypes.Item.BaseTypes.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/ColumnLinks/ColumnLinksRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/ColumnLinks/ColumnLinksRequestBuilder.cs index 2f4f5139d7a..e45043808d0 100644 --- a/src/generated/Drives/Item/List/ContentTypes/Item/ColumnLinks/ColumnLinksRequestBuilder.cs +++ b/src/generated/Drives/Item/List/ContentTypes/Item/ColumnLinks/ColumnLinksRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ColumnLinksRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ColumnLinkRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string contentTypeId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string contentTypeId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, contentTypeIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, contentTypeIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(ColumnLink body, Action - /// The collection of columns that are required by this content type - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of columns that are required by this content type - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ColumnLink model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of columns that are required by this content type public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/ColumnLinks/Item/ColumnLinkRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/ColumnLinks/Item/ColumnLinkRequestBuilder.cs index 28c521d9d07..8cb9d203029 100644 --- a/src/generated/Drives/Item/List/ContentTypes/Item/ColumnLinks/Item/ColumnLinkRequestBuilder.cs +++ b/src/generated/Drives/Item/List/ContentTypes/Item/ColumnLinks/Item/ColumnLinkRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnLinkIdOption = new Option("--columnlink-id", description: "key: id of columnLink") { + var columnLinkIdOption = new Option("--column-link-id", description: "key: id of columnLink") { }; columnLinkIdOption.IsRequired = true; command.AddOption(columnLinkIdOption); - command.SetHandler(async (string driveId, string contentTypeId, string columnLinkId) => { + command.SetHandler(async (string driveId, string contentTypeId, string columnLinkId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, contentTypeIdOption, columnLinkIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnLinkIdOption = new Option("--columnlink-id", description: "key: id of columnLink") { + var columnLinkIdOption = new Option("--column-link-id", description: "key: id of columnLink") { }; columnLinkIdOption.IsRequired = true; command.AddOption(columnLinkIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, string contentTypeId, string columnLinkId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string contentTypeId, string columnLinkId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, contentTypeIdOption, columnLinkIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, contentTypeIdOption, columnLinkIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnLinkIdOption = new Option("--columnlink-id", description: "key: id of columnLink") { + var columnLinkIdOption = new Option("--column-link-id", description: "key: id of columnLink") { }; columnLinkIdOption.IsRequired = true; command.AddOption(columnLinkIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string contentTypeId, string columnLinkId, string body) => { + command.SetHandler(async (string driveId, string contentTypeId, string columnLinkId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, contentTypeIdOption, columnLinkIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(ColumnLink body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of columns that are required by this content type - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of columns that are required by this content type - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of columns that are required by this content type - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ColumnLink model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of columns that are required by this content type public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/ColumnPositions/@Ref/@Ref.cs b/src/generated/Drives/Item/List/ContentTypes/Item/ColumnPositions/@Ref/@Ref.cs deleted file mode 100644 index 54ad1460f7c..00000000000 --- a/src/generated/Drives/Item/List/ContentTypes/Item/ColumnPositions/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Drives.Item.List.ContentTypes.Item.ColumnPositions.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/ColumnPositions/@Ref/RefRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/ColumnPositions/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 99810a51478..00000000000 --- a/src/generated/Drives/Item/List/ContentTypes/Item/ColumnPositions/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,210 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Drives.Item.List.ContentTypes.Item.ColumnPositions.@Ref { - /// Builds and executes requests for operations under \drives\{drive-id}\list\contentTypes\{contentType-id}\columnPositions\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Column order information in a content type. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Column order information in a content type."; - // Create options for all the parameters - var driveIdOption = new Option("--drive-id", description: "key: id of drive") { - }; - driveIdOption.IsRequired = true; - command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string driveId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Column order information in a content type. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Column order information in a content type."; - // Create options for all the parameters - var driveIdOption = new Option("--drive-id", description: "key: id of drive") { - }; - driveIdOption.IsRequired = true; - command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string contentTypeId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, contentTypeIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/drives/{drive_id}/list/contentTypes/{contentType_id}/columnPositions/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Column order information in a content type. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Column order information in a content type. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Drives.Item.List.ContentTypes.Item.ColumnPositions.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Column order information in a content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Column order information in a content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Drives.Item.List.ContentTypes.Item.ColumnPositions.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Column order information in a content type. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/ColumnPositions/@Ref/RefResponse.cs b/src/generated/Drives/Item/List/ContentTypes/Item/ColumnPositions/@Ref/RefResponse.cs deleted file mode 100644 index f5d6f56619a..00000000000 --- a/src/generated/Drives/Item/List/ContentTypes/Item/ColumnPositions/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Drives.Item.List.ContentTypes.Item.ColumnPositions.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/ColumnPositions/ColumnPositionsRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/ColumnPositions/ColumnPositionsRequestBuilder.cs index 6b400be5e18..2e44eac1f34 100644 --- a/src/generated/Drives/Item/List/ContentTypes/Item/ColumnPositions/ColumnPositionsRequestBuilder.cs +++ b/src/generated/Drives/Item/List/ContentTypes/Item/ColumnPositions/ColumnPositionsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Drives.Item.List.ContentTypes.Item.ColumnPositions.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -69,7 +69,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -80,20 +84,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Drives.Item.List.ContentTypes.Item.ColumnPositions.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Drives.Item.List.ContentTypes.Item.ColumnPositions.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -132,18 +131,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Column order information in a content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Column order information in a content type. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/ColumnPositions/Ref/Ref.cs b/src/generated/Drives/Item/List/ContentTypes/Item/ColumnPositions/Ref/Ref.cs new file mode 100644 index 00000000000..d415bc91f5e --- /dev/null +++ b/src/generated/Drives/Item/List/ContentTypes/Item/ColumnPositions/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Drives.Item.List.ContentTypes.Item.ColumnPositions.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/ColumnPositions/Ref/RefRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/ColumnPositions/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..cb62037c2d7 --- /dev/null +++ b/src/generated/Drives/Item/List/ContentTypes/Item/ColumnPositions/Ref/RefRequestBuilder.cs @@ -0,0 +1,183 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Drives.Item.List.ContentTypes.Item.ColumnPositions.Ref { + /// Builds and executes requests for operations under \drives\{drive-id}\list\contentTypes\{contentType-id}\columnPositions\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Column order information in a content type. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Column order information in a content type."; + // Create options for all the parameters + var driveIdOption = new Option("--drive-id", description: "key: id of drive") { + }; + driveIdOption.IsRequired = true; + command.AddOption(driveIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Column order information in a content type. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Column order information in a content type."; + // Create options for all the parameters + var driveIdOption = new Option("--drive-id", description: "key: id of drive") { + }; + driveIdOption.IsRequired = true; + command.AddOption(driveIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string contentTypeId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, contentTypeIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/drives/{drive_id}/list/contentTypes/{contentType_id}/columnPositions/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Column order information in a content type. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Column order information in a content type. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Drives.Item.List.ContentTypes.Item.ColumnPositions.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Column order information in a content type. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/ColumnPositions/Ref/RefResponse.cs b/src/generated/Drives/Item/List/ContentTypes/Item/ColumnPositions/Ref/RefResponse.cs new file mode 100644 index 00000000000..4814b5cdccb --- /dev/null +++ b/src/generated/Drives/Item/List/ContentTypes/Item/ColumnPositions/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Drives.Item.List.ContentTypes.Item.ColumnPositions.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/Columns/ColumnsRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/Columns/ColumnsRequestBuilder.cs index cd298c263d8..d1746f371cd 100644 --- a/src/generated/Drives/Item/List/ContentTypes/Item/Columns/ColumnsRequestBuilder.cs +++ b/src/generated/Drives/Item/List/ContentTypes/Item/Columns/ColumnsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class ColumnsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ColumnDefinitionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSourceColumnCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSourceColumnCommand()); return commands; } /// @@ -41,7 +40,7 @@ public Command BuildCreateCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string contentTypeId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string contentTypeId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, contentTypeIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, contentTypeIdOption, bodyOption, outputOption); return command; } /// @@ -77,7 +75,7 @@ public Command BuildListCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -116,7 +114,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -127,15 +129,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -190,31 +187,6 @@ public RequestInformation CreatePostRequestInformation(ColumnDefinition body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of column definitions for this contentType. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of column definitions for this contentType. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ColumnDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of column definitions for this contentType. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs index ad891724017..3105608ad54 100644 --- a/src/generated/Drives/Item/List/ContentTypes/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs +++ b/src/generated/Drives/Item/List/ContentTypes/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,19 +31,18 @@ public Command BuildDeleteCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string driveId, string contentTypeId, string columnDefinitionId) => { + command.SetHandler(async (string driveId, string contentTypeId, string columnDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, contentTypeIdOption, columnDefinitionIdOption); return command; @@ -59,11 +58,11 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, string contentTypeId, string columnDefinitionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string contentTypeId, string columnDefinitionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, contentTypeIdOption, columnDefinitionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, contentTypeIdOption, columnDefinitionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,11 +102,11 @@ public Command BuildPatchCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -116,14 +114,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string contentTypeId, string columnDefinitionId, string body) => { + command.SetHandler(async (string driveId, string contentTypeId, string columnDefinitionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, contentTypeIdOption, columnDefinitionIdOption, bodyOption); return command; @@ -202,42 +199,6 @@ public RequestInformation CreatePatchRequestInformation(ColumnDefinition body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of column definitions for this contentType. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of column definitions for this contentType. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of column definitions for this contentType. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ColumnDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of column definitions for this contentType. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/@Ref.cs b/src/generated/Drives/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/@Ref.cs deleted file mode 100644 index 98f693ad2dd..00000000000 --- a/src/generated/Drives/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Drives.Item.List.ContentTypes.Item.Columns.Item.SourceColumn.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 85c056355d1..00000000000 --- a/src/generated/Drives/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,214 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Drives.Item.List.ContentTypes.Item.Columns.Item.SourceColumn.@Ref { - /// Builds and executes requests for operations under \drives\{drive-id}\list\contentTypes\{contentType-id}\columns\{columnDefinition-id}\sourceColumn\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The source column for content type column. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var driveIdOption = new Option("--drive-id", description: "key: id of drive") { - }; - driveIdOption.IsRequired = true; - command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string driveId, string contentTypeId, string columnDefinitionId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, driveIdOption, contentTypeIdOption, columnDefinitionIdOption); - return command; - } - /// - /// The source column for content type column. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var driveIdOption = new Option("--drive-id", description: "key: id of drive") { - }; - driveIdOption.IsRequired = true; - command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string driveId, string contentTypeId, string columnDefinitionId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, contentTypeIdOption, columnDefinitionIdOption); - return command; - } - /// - /// The source column for content type column. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var driveIdOption = new Option("--drive-id", description: "key: id of drive") { - }; - driveIdOption.IsRequired = true; - command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string contentTypeId, string columnDefinitionId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, driveIdOption, contentTypeIdOption, columnDefinitionIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/drives/{drive_id}/list/contentTypes/{contentType_id}/columns/{columnDefinition_id}/sourceColumn/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The source column for content type column. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Drives.Item.List.ContentTypes.Item.Columns.Item.SourceColumn.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Drives.Item.List.ContentTypes.Item.Columns.Item.SourceColumn.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/Ref/Ref.cs b/src/generated/Drives/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/Ref/Ref.cs new file mode 100644 index 00000000000..9bd089c433d --- /dev/null +++ b/src/generated/Drives/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Drives.Item.List.ContentTypes.Item.Columns.Item.SourceColumn.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..3b8a74fac0d --- /dev/null +++ b/src/generated/Drives/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs @@ -0,0 +1,176 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Drives.Item.List.ContentTypes.Item.Columns.Item.SourceColumn.Ref { + /// Builds and executes requests for operations under \drives\{drive-id}\list\contentTypes\{contentType-id}\columns\{columnDefinition-id}\sourceColumn\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The source column for content type column. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var driveIdOption = new Option("--drive-id", description: "key: id of drive") { + }; + driveIdOption.IsRequired = true; + command.AddOption(driveIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + command.SetHandler(async (string driveId, string contentTypeId, string columnDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, driveIdOption, contentTypeIdOption, columnDefinitionIdOption); + return command; + } + /// + /// The source column for content type column. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var driveIdOption = new Option("--drive-id", description: "key: id of drive") { + }; + driveIdOption.IsRequired = true; + command.AddOption(driveIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string contentTypeId, string columnDefinitionId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, contentTypeIdOption, columnDefinitionIdOption, outputOption); + return command; + } + /// + /// The source column for content type column. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var driveIdOption = new Option("--drive-id", description: "key: id of drive") { + }; + driveIdOption.IsRequired = true; + command.AddOption(driveIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string driveId, string contentTypeId, string columnDefinitionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, driveIdOption, contentTypeIdOption, columnDefinitionIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/drives/{drive_id}/list/contentTypes/{contentType_id}/columns/{columnDefinition_id}/sourceColumn/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The source column for content type column. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The source column for content type column. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The source column for content type column. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Drives.Item.List.ContentTypes.Item.Columns.Item.SourceColumn.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs index e8946c955df..46540ecc11f 100644 --- a/src/generated/Drives/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs +++ b/src/generated/Drives/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,11 +31,11 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -49,25 +49,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, string contentTypeId, string columnDefinitionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string contentTypeId, string columnDefinitionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, contentTypeIdOption, columnDefinitionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, contentTypeIdOption, columnDefinitionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Drives.Item.List.ContentTypes.Item.Columns.Item.SourceColumn.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Drives.Item.List.ContentTypes.Item.Columns.Item.SourceColumn.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -107,18 +106,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The source column for content type column. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/ContentTypeRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/ContentTypeRequestBuilder.cs index 202f2b47d2b..d30f1375b5c 100644 --- a/src/generated/Drives/Item/List/ContentTypes/Item/ContentTypeRequestBuilder.cs +++ b/src/generated/Drives/Item/List/ContentTypes/Item/ContentTypeRequestBuilder.cs @@ -11,10 +11,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,7 +37,7 @@ public Command BuildAssociateWithHubSitesCommand() { } public Command BuildBaseCommand() { var command = new Command("base"); - var builder = new ApiSdk.Drives.Item.List.ContentTypes.Item.@Base.BaseRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Drives.Item.List.ContentTypes.Item.Base.BaseRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAssociateWithHubSitesCommand()); command.AddCommand(builder.BuildCopyToDefaultContentLocationCommand()); command.AddCommand(builder.BuildGetCommand()); @@ -57,6 +57,9 @@ public Command BuildBaseTypesCommand() { public Command BuildColumnLinksCommand() { var command = new Command("column-links"); var builder = new ApiSdk.Drives.Item.List.ContentTypes.Item.ColumnLinks.ColumnLinksRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -71,6 +74,9 @@ public Command BuildColumnPositionsCommand() { public Command BuildColumnsCommand() { var command = new Command("columns"); var builder = new ApiSdk.Drives.Item.List.ContentTypes.Item.Columns.ColumnsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -92,15 +98,14 @@ public Command BuildDeleteCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - command.SetHandler(async (string driveId, string contentTypeId) => { + command.SetHandler(async (string driveId, string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, contentTypeIdOption); return command; @@ -116,7 +121,7 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -130,20 +135,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, string contentTypeId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string contentTypeId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, contentTypeIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, contentTypeIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -157,7 +161,7 @@ public Command BuildPatchCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -165,14 +169,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string contentTypeId, string body) => { + command.SetHandler(async (string driveId, string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, contentTypeIdOption, bodyOption); return command; @@ -257,47 +260,11 @@ public RequestInformation CreatePatchRequestInformation(ContentType body, Action return requestInfo; } /// - /// The collection of content types present in this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of content types present in this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \drives\{drive-id}\list\contentTypes\{contentType-id}\microsoft.graph.isPublished() /// public IsPublishedRequestBuilder IsPublished() { return new IsPublishedRequestBuilder(PathParameters, RequestAdapter); } - /// - /// The collection of content types present in this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ContentType model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of content types present in this list. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs index a8c4225a8a8..7f2621941ca 100644 --- a/src/generated/Drives/Item/List/ContentTypes/Item/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs +++ b/src/generated/Drives/Item/List/ContentTypes/Item/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string contentTypeId, string body) => { + command.SetHandler(async (string driveId, string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, contentTypeIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CopyToDefaultContentLocat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToDefaultContentLocation - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToDefaultContentLocationRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/IsPublished/IsPublishedRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/IsPublished/IsPublishedRequestBuilder.cs index 2ea7db076e6..975b15bf1e6 100644 --- a/src/generated/Drives/Item/List/ContentTypes/Item/IsPublished/IsPublishedRequestBuilder.cs +++ b/src/generated/Drives/Item/List/ContentTypes/Item/IsPublished/IsPublishedRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,22 +29,21 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - command.SetHandler(async (string driveId, string contentTypeId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string contentTypeId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteBoolValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, contentTypeIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, contentTypeIdOption, outputOption); return command; } /// @@ -75,16 +74,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function isPublished - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/Publish/PublishRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/Publish/PublishRequestBuilder.cs index d2eecc153de..03bb7f9973b 100644 --- a/src/generated/Drives/Item/List/ContentTypes/Item/Publish/PublishRequestBuilder.cs +++ b/src/generated/Drives/Item/List/ContentTypes/Item/Publish/PublishRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - command.SetHandler(async (string driveId, string contentTypeId) => { + command.SetHandler(async (string driveId, string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, contentTypeIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action publish - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drives/Item/List/ContentTypes/Item/Unpublish/UnpublishRequestBuilder.cs b/src/generated/Drives/Item/List/ContentTypes/Item/Unpublish/UnpublishRequestBuilder.cs index 2fda7847a16..42c0b0e50e6 100644 --- a/src/generated/Drives/Item/List/ContentTypes/Item/Unpublish/UnpublishRequestBuilder.cs +++ b/src/generated/Drives/Item/List/ContentTypes/Item/Unpublish/UnpublishRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - command.SetHandler(async (string driveId, string contentTypeId) => { + command.SetHandler(async (string driveId, string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, contentTypeIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action unpublish - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drives/Item/List/Drive/DriveRequestBuilder.cs b/src/generated/Drives/Item/List/Drive/DriveRequestBuilder.cs index 709c786fe03..a1f8a55e5f3 100644 --- a/src/generated/Drives/Item/List/Drive/DriveRequestBuilder.cs +++ b/src/generated/Drives/Item/List/Drive/DriveRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,10 @@ public Command BuildDeleteCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - command.SetHandler(async (string driveId) => { + command.SetHandler(async (string driveId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption); return command; @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string body) => { + command.SetHandler(async (string driveId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Only present on document libraries. Allows access to the list as a [drive][] resource with [driveItems][driveItem]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Only present on document libraries. Allows access to the list as a [drive][] resource with [driveItems][driveItem]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Only present on document libraries. Allows access to the list as a [drive][] resource with [driveItems][driveItem]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Drive model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Only present on document libraries. Allows access to the list as a [drive][] resource with [driveItems][driveItem]. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drives/Item/List/Items/Item/Analytics/@Ref/@Ref.cs b/src/generated/Drives/Item/List/Items/Item/Analytics/@Ref/@Ref.cs deleted file mode 100644 index 271653fea71..00000000000 --- a/src/generated/Drives/Item/List/Items/Item/Analytics/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Drives.Item.List.Items.Item.Analytics.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Drives/Item/List/Items/Item/Analytics/@Ref/RefRequestBuilder.cs b/src/generated/Drives/Item/List/Items/Item/Analytics/@Ref/RefRequestBuilder.cs deleted file mode 100644 index f7044b4a134..00000000000 --- a/src/generated/Drives/Item/List/Items/Item/Analytics/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Drives.Item.List.Items.Item.Analytics.@Ref { - /// Builds and executes requests for operations under \drives\{drive-id}\list\items\{listItem-id}\analytics\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Analytics about the view activities that took place on this item. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Analytics about the view activities that took place on this item."; - // Create options for all the parameters - var driveIdOption = new Option("--drive-id", description: "key: id of drive") { - }; - driveIdOption.IsRequired = true; - command.AddOption(driveIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { - }; - listItemIdOption.IsRequired = true; - command.AddOption(listItemIdOption); - command.SetHandler(async (string driveId, string listItemId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, driveIdOption, listItemIdOption); - return command; - } - /// - /// Analytics about the view activities that took place on this item. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Analytics about the view activities that took place on this item."; - // Create options for all the parameters - var driveIdOption = new Option("--drive-id", description: "key: id of drive") { - }; - driveIdOption.IsRequired = true; - command.AddOption(driveIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { - }; - listItemIdOption.IsRequired = true; - command.AddOption(listItemIdOption); - command.SetHandler(async (string driveId, string listItemId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, listItemIdOption); - return command; - } - /// - /// Analytics about the view activities that took place on this item. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Analytics about the view activities that took place on this item."; - // Create options for all the parameters - var driveIdOption = new Option("--drive-id", description: "key: id of drive") { - }; - driveIdOption.IsRequired = true; - command.AddOption(driveIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { - }; - listItemIdOption.IsRequired = true; - command.AddOption(listItemIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string listItemId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, driveIdOption, listItemIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/drives/{drive_id}/list/items/{listItem_id}/analytics/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Analytics about the view activities that took place on this item. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Analytics about the view activities that took place on this item. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Analytics about the view activities that took place on this item. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Drives.Item.List.Items.Item.Analytics.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Drives.Item.List.Items.Item.Analytics.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Drives/Item/List/Items/Item/Analytics/AnalyticsRequestBuilder.cs b/src/generated/Drives/Item/List/Items/Item/Analytics/AnalyticsRequestBuilder.cs index c792c9ed330..4f35252d9bd 100644 --- a/src/generated/Drives/Item/List/Items/Item/Analytics/AnalyticsRequestBuilder.cs +++ b/src/generated/Drives/Item/List/Items/Item/Analytics/AnalyticsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,7 +31,7 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -45,25 +45,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, string listItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string listItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, listItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, listItemIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Drives.Item.List.Items.Item.Analytics.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Drives.Item.List.Items.Item.Analytics.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -103,18 +102,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Analytics about the view activities that took place on this item. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drives/Item/List/Items/Item/Analytics/Ref/Ref.cs b/src/generated/Drives/Item/List/Items/Item/Analytics/Ref/Ref.cs new file mode 100644 index 00000000000..4333a88e487 --- /dev/null +++ b/src/generated/Drives/Item/List/Items/Item/Analytics/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Drives.Item.List.Items.Item.Analytics.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Drives/Item/List/Items/Item/Analytics/Ref/RefRequestBuilder.cs b/src/generated/Drives/Item/List/Items/Item/Analytics/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..74b92146b32 --- /dev/null +++ b/src/generated/Drives/Item/List/Items/Item/Analytics/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Drives.Item.List.Items.Item.Analytics.Ref { + /// Builds and executes requests for operations under \drives\{drive-id}\list\items\{listItem-id}\analytics\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Analytics about the view activities that took place on this item. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Analytics about the view activities that took place on this item."; + // Create options for all the parameters + var driveIdOption = new Option("--drive-id", description: "key: id of drive") { + }; + driveIdOption.IsRequired = true; + command.AddOption(driveIdOption); + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { + }; + listItemIdOption.IsRequired = true; + command.AddOption(listItemIdOption); + command.SetHandler(async (string driveId, string listItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, driveIdOption, listItemIdOption); + return command; + } + /// + /// Analytics about the view activities that took place on this item. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Analytics about the view activities that took place on this item."; + // Create options for all the parameters + var driveIdOption = new Option("--drive-id", description: "key: id of drive") { + }; + driveIdOption.IsRequired = true; + command.AddOption(driveIdOption); + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { + }; + listItemIdOption.IsRequired = true; + command.AddOption(listItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string listItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, listItemIdOption, outputOption); + return command; + } + /// + /// Analytics about the view activities that took place on this item. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Analytics about the view activities that took place on this item."; + // Create options for all the parameters + var driveIdOption = new Option("--drive-id", description: "key: id of drive") { + }; + driveIdOption.IsRequired = true; + command.AddOption(driveIdOption); + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { + }; + listItemIdOption.IsRequired = true; + command.AddOption(listItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string driveId, string listItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, driveIdOption, listItemIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/drives/{drive_id}/list/items/{listItem_id}/analytics/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Analytics about the view activities that took place on this item. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Analytics about the view activities that took place on this item. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Analytics about the view activities that took place on this item. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Drives.Item.List.Items.Item.Analytics.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Drives/Item/List/Items/Item/DriveItem/Content/ContentRequestBuilder.cs b/src/generated/Drives/Item/List/Items/Item/DriveItem/Content/ContentRequestBuilder.cs index 73495f66633..60e4c6de7bc 100644 --- a/src/generated/Drives/Item/List/Items/Item/DriveItem/Content/ContentRequestBuilder.cs +++ b/src/generated/Drives/Item/List/Items/Item/DriveItem/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,28 +29,30 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string driveId, string listItemId, FileInfo output) => { + command.SetHandler(async (string driveId, string listItemId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, driveIdOption, listItemIdOption, outputOption); + }, driveIdOption, listItemIdOption, fileOption, outputOption); return command; } /// @@ -64,7 +66,7 @@ public Command BuildPutCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -72,12 +74,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string listItemId, FileInfo file) => { + command.SetHandler(async (string driveId, string listItemId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, listItemIdOption, bodyOption); return command; @@ -128,29 +129,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property driveItem from drives - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property driveItem in drives - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drives/Item/List/Items/Item/DriveItem/DriveItemRequestBuilder.cs b/src/generated/Drives/Item/List/Items/Item/DriveItem/DriveItemRequestBuilder.cs index a0fbf1709eb..f4e9a23af01 100644 --- a/src/generated/Drives/Item/List/Items/Item/DriveItem/DriveItemRequestBuilder.cs +++ b/src/generated/Drives/Item/List/Items/Item/DriveItem/DriveItemRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - command.SetHandler(async (string driveId, string listItemId) => { + command.SetHandler(async (string driveId, string listItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, listItemIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, string listItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string listItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, listItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, listItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,7 +101,7 @@ public Command BuildPatchCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -111,14 +109,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string listItemId, string body) => { + command.SetHandler(async (string driveId, string listItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, listItemIdOption, bodyOption); return command; @@ -190,42 +187,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// For document libraries, the driveItem relationship exposes the listItem as a [driveItem][] - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// For document libraries, the driveItem relationship exposes the listItem as a [driveItem][] - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// For document libraries, the driveItem relationship exposes the listItem as a [driveItem][] - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// For document libraries, the driveItem relationship exposes the listItem as a [driveItem][] public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drives/Item/List/Items/Item/Fields/FieldsRequestBuilder.cs b/src/generated/Drives/Item/List/Items/Item/Fields/FieldsRequestBuilder.cs index b7907412d58..dd4a0a3cf4e 100644 --- a/src/generated/Drives/Item/List/Items/Item/Fields/FieldsRequestBuilder.cs +++ b/src/generated/Drives/Item/List/Items/Item/Fields/FieldsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - command.SetHandler(async (string driveId, string listItemId) => { + command.SetHandler(async (string driveId, string listItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, listItemIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, string listItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string listItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, listItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, listItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string listItemId, string body) => { + command.SetHandler(async (string driveId, string listItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, listItemIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(FieldValueSet body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The values of the columns set on this list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The values of the columns set on this list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The values of the columns set on this list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(FieldValueSet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The values of the columns set on this list item. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drives/Item/List/Items/Item/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs b/src/generated/Drives/Item/List/Items/Item/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs index 20e7af5b449..28763bc1d2c 100644 --- a/src/generated/Drives/Item/List/Items/Item/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs +++ b/src/generated/Drives/Item/List/Items/Item/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,22 +29,21 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - command.SetHandler(async (string driveId, string listItemId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string listItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, listItemIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, listItemIdOption, outputOption); return command; } /// @@ -75,16 +74,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getActivitiesByInterval - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drives/Item/List/Items/Item/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs b/src/generated/Drives/Item/List/Items/Item/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs index 1a0fa8c2e46..7209486b109 100644 --- a/src/generated/Drives/Item/List/Items/Item/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs +++ b/src/generated/Drives/Item/List/Items/Item/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,15 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var startDateTimeOption = new Option("--startdatetime", description: "Usage: startDateTime={startDateTime}") { + var startDateTimeOption = new Option("--start-date-time", description: "Usage: startDateTime={startDateTime}") { }; startDateTimeOption.IsRequired = true; command.AddOption(startDateTimeOption); - var endDateTimeOption = new Option("--enddatetime", description: "Usage: endDateTime={endDateTime}") { + var endDateTimeOption = new Option("--end-date-time", description: "Usage: endDateTime={endDateTime}") { }; endDateTimeOption.IsRequired = true; command.AddOption(endDateTimeOption); @@ -45,18 +45,17 @@ public Command BuildGetCommand() { }; intervalOption.IsRequired = true; command.AddOption(intervalOption); - command.SetHandler(async (string driveId, string listItemId, string startDateTime, string endDateTime, string interval) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string listItemId, string startDateTime, string endDateTime, string interval, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, listItemIdOption, startDateTimeOption, endDateTimeOption, intervalOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, listItemIdOption, startDateTimeOption, endDateTimeOption, intervalOption, outputOption); return command; } /// @@ -93,16 +92,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getActivitiesByInterval - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drives/Item/List/Items/Item/ListItemRequestBuilder.cs b/src/generated/Drives/Item/List/Items/Item/ListItemRequestBuilder.cs index 7afd4ce7dac..3f4d21914a8 100644 --- a/src/generated/Drives/Item/List/Items/Item/ListItemRequestBuilder.cs +++ b/src/generated/Drives/Item/List/Items/Item/ListItemRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -43,15 +43,14 @@ public Command BuildDeleteCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - command.SetHandler(async (string driveId, string listItemId) => { + command.SetHandler(async (string driveId, string listItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, listItemIdOption); return command; @@ -84,7 +83,7 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, string listItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string listItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, listItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, listItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -125,7 +123,7 @@ public Command BuildPatchCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -133,14 +131,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string listItemId, string body) => { + command.SetHandler(async (string driveId, string listItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, listItemIdOption, bodyOption); return command; @@ -148,6 +145,9 @@ public Command BuildPatchCommand() { public Command BuildVersionsCommand() { var command = new Command("versions"); var builder = new ApiSdk.Drives.Item.List.Items.Item.Versions.VersionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -220,17 +220,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. return requestInfo; } /// - /// All items contained in the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \drives\{drive-id}\list\items\{listItem-id}\microsoft.graph.getActivitiesByInterval() /// public GetActivitiesByIntervalRequestBuilder GetActivitiesByInterval() { @@ -248,31 +237,6 @@ public GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalReques if(string.IsNullOrEmpty(startDateTime)) throw new ArgumentNullException(nameof(startDateTime)); return new GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder(PathParameters, RequestAdapter, startDateTime, endDateTime, interval); } - /// - /// All items contained in the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All items contained in the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.ListItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// All items contained in the list. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drives/Item/List/Items/Item/Versions/Item/Fields/FieldsRequestBuilder.cs b/src/generated/Drives/Item/List/Items/Item/Versions/Item/Fields/FieldsRequestBuilder.cs index 919d174e636..e29a29e60d7 100644 --- a/src/generated/Drives/Item/List/Items/Item/Versions/Item/Fields/FieldsRequestBuilder.cs +++ b/src/generated/Drives/Item/List/Items/Item/Versions/Item/Fields/FieldsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); - command.SetHandler(async (string driveId, string listItemId, string listItemVersionId) => { + command.SetHandler(async (string driveId, string listItemId, string listItemVersionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, listItemIdOption, listItemVersionIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, string listItemId, string listItemVersionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string listItemId, string listItemVersionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, listItemIdOption, listItemVersionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, listItemIdOption, listItemVersionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string listItemId, string listItemVersionId, string body) => { + command.SetHandler(async (string driveId, string listItemId, string listItemVersionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, listItemIdOption, listItemVersionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(FieldValueSet body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of the fields and values for this version of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of the fields and values for this version of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of the fields and values for this version of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(FieldValueSet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of the fields and values for this version of the list item. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drives/Item/List/Items/Item/Versions/Item/ListItemVersionRequestBuilder.cs b/src/generated/Drives/Item/List/Items/Item/Versions/Item/ListItemVersionRequestBuilder.cs index 156ca76324b..41aed2e267c 100644 --- a/src/generated/Drives/Item/List/Items/Item/Versions/Item/ListItemVersionRequestBuilder.cs +++ b/src/generated/Drives/Item/List/Items/Item/Versions/Item/ListItemVersionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -32,19 +32,18 @@ public Command BuildDeleteCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); - command.SetHandler(async (string driveId, string listItemId, string listItemVersionId) => { + command.SetHandler(async (string driveId, string listItemId, string listItemVersionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, listItemIdOption, listItemVersionIdOption); return command; @@ -68,11 +67,11 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, string listItemId, string listItemVersionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string listItemId, string listItemVersionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, listItemIdOption, listItemVersionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, listItemIdOption, listItemVersionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -113,11 +111,11 @@ public Command BuildPatchCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string listItemId, string listItemVersionId, string body) => { + command.SetHandler(async (string driveId, string listItemId, string listItemVersionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, listItemIdOption, listItemVersionIdOption, bodyOption); return command; @@ -210,42 +207,6 @@ public RequestInformation CreatePatchRequestInformation(ListItemVersion body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ListItemVersion model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of previous versions of the list item. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drives/Item/List/Items/Item/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs b/src/generated/Drives/Item/List/Items/Item/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs index 18a3047ea0b..97728abb360 100644 --- a/src/generated/Drives/Item/List/Items/Item/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs +++ b/src/generated/Drives/Item/List/Items/Item/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,19 +29,18 @@ public Command BuildPostCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); - command.SetHandler(async (string driveId, string listItemId, string listItemVersionId) => { + command.SetHandler(async (string driveId, string listItemId, string listItemVersionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, listItemIdOption, listItemVersionIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action restoreVersion - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drives/Item/List/Items/Item/Versions/VersionsRequestBuilder.cs b/src/generated/Drives/Item/List/Items/Item/Versions/VersionsRequestBuilder.cs index cd160421ae2..2521b72ec2b 100644 --- a/src/generated/Drives/Item/List/Items/Item/Versions/VersionsRequestBuilder.cs +++ b/src/generated/Drives/Item/List/Items/Item/Versions/VersionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class VersionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ListItemVersionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildFieldsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildRestoreVersionCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFieldsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRestoreVersionCommand()); return commands; } /// @@ -42,7 +41,7 @@ public Command BuildCreateCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string listItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string listItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, listItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, listItemIdOption, bodyOption, outputOption); return command; } /// @@ -78,7 +76,7 @@ public Command BuildListCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -117,7 +115,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, string listItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string listItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, listItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, listItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(ListItemVersion body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ListItemVersion model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of previous versions of the list item. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Drives/Item/List/Items/ItemsRequestBuilder.cs b/src/generated/Drives/Item/List/Items/ItemsRequestBuilder.cs index a33b01ecafc..3d432d9ffdb 100644 --- a/src/generated/Drives/Item/List/Items/ItemsRequestBuilder.cs +++ b/src/generated/Drives/Item/List/Items/ItemsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class ItemsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ListItemRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAnalyticsCommand(), - builder.BuildDeleteCommand(), - builder.BuildDriveItemCommand(), - builder.BuildFieldsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildVersionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAnalyticsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDriveItemCommand()); + commands.Add(builder.BuildFieldsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildVersionsCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, bodyOption, outputOption); return command; } /// @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -122,15 +124,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -185,31 +182,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All items contained in the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All items contained in the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.ListItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// All items contained in the list. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Drives/Item/List/ListRequestBuilder.cs b/src/generated/Drives/Item/List/ListRequestBuilder.cs index 32acd8629e6..c503f20719d 100644 --- a/src/generated/Drives/Item/List/ListRequestBuilder.cs +++ b/src/generated/Drives/Item/List/ListRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,6 +27,9 @@ public class ListRequestBuilder { public Command BuildColumnsCommand() { var command = new Command("columns"); var builder = new ApiSdk.Drives.Item.List.Columns.ColumnsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -35,6 +38,9 @@ public Command BuildContentTypesCommand() { var command = new Command("content-types"); var builder = new ApiSdk.Drives.Item.List.ContentTypes.ContentTypesRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCopyCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -50,11 +56,10 @@ public Command BuildDeleteCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - command.SetHandler(async (string driveId) => { + command.SetHandler(async (string driveId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption); return command; @@ -88,25 +93,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildItemsCommand() { var command = new Command("items"); var builder = new ApiSdk.Drives.Item.List.Items.ItemsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -126,14 +133,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string body) => { + command.SetHandler(async (string driveId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, bodyOption); return command; @@ -141,6 +147,9 @@ public Command BuildPatchCommand() { public Command BuildSubscriptionsCommand() { var command = new Command("subscriptions"); var builder = new ApiSdk.Drives.Item.List.Subscriptions.SubscriptionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -212,42 +221,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// For drives in SharePoint, the underlying document library list. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// For drives in SharePoint, the underlying document library list. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// For drives in SharePoint, the underlying document library list. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.List model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// For drives in SharePoint, the underlying document library list. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drives/Item/List/Subscriptions/Item/SubscriptionRequestBuilder.cs b/src/generated/Drives/Item/List/Subscriptions/Item/SubscriptionRequestBuilder.cs index fe0fc7efa34..20efa50146b 100644 --- a/src/generated/Drives/Item/List/Subscriptions/Item/SubscriptionRequestBuilder.cs +++ b/src/generated/Drives/Item/List/Subscriptions/Item/SubscriptionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; subscriptionIdOption.IsRequired = true; command.AddOption(subscriptionIdOption); - command.SetHandler(async (string driveId, string subscriptionId) => { + command.SetHandler(async (string driveId, string subscriptionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, subscriptionIdOption); return command; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, string subscriptionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string subscriptionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, subscriptionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, subscriptionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string subscriptionId, string body) => { + command.SetHandler(async (string driveId, string subscriptionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, subscriptionIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(Subscription body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The set of subscriptions on the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The set of subscriptions on the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The set of subscriptions on the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Subscription model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The set of subscriptions on the list. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drives/Item/List/Subscriptions/SubscriptionsRequestBuilder.cs b/src/generated/Drives/Item/List/Subscriptions/SubscriptionsRequestBuilder.cs index 9981aa7753c..1319471cb2e 100644 --- a/src/generated/Drives/Item/List/Subscriptions/SubscriptionsRequestBuilder.cs +++ b/src/generated/Drives/Item/List/Subscriptions/SubscriptionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SubscriptionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SubscriptionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(Subscription body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The set of subscriptions on the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The set of subscriptions on the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Subscription model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The set of subscriptions on the list. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Drives/Item/Recent/RecentRequestBuilder.cs b/src/generated/Drives/Item/Recent/RecentRequestBuilder.cs index 33645d92019..c4bbee877d7 100644 --- a/src/generated/Drives/Item/Recent/RecentRequestBuilder.cs +++ b/src/generated/Drives/Item/Recent/RecentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +29,17 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - command.SetHandler(async (string driveId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function recent - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drives/Item/Root/Content/ContentRequestBuilder.cs b/src/generated/Drives/Item/Root/Content/ContentRequestBuilder.cs index 605c8625aac..960b040ccf3 100644 --- a/src/generated/Drives/Item/Root/Content/ContentRequestBuilder.cs +++ b/src/generated/Drives/Item/Root/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string driveId, FileInfo output) => { + command.SetHandler(async (string driveId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, driveIdOption, outputOption); + }, driveIdOption, fileOption, outputOption); return command; } /// @@ -64,12 +66,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, FileInfo file) => { + command.SetHandler(async (string driveId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, bodyOption); return command; @@ -120,29 +121,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property root from drives - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property root in drives - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drives/Item/Root/RootRequestBuilder.cs b/src/generated/Drives/Item/Root/RootRequestBuilder.cs index 8e57a314968..f0e9a8b1c74 100644 --- a/src/generated/Drives/Item/Root/RootRequestBuilder.cs +++ b/src/generated/Drives/Item/Root/RootRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - command.SetHandler(async (string driveId) => { + command.SetHandler(async (string driveId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption); return command; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,14 +97,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string body) => { + command.SetHandler(async (string driveId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, bodyOption); return command; @@ -178,42 +175,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The root folder of the drive. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The root folder of the drive. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The root folder of the drive. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The root folder of the drive. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drives/Item/SearchWithQ/SearchWithQRequestBuilder.cs b/src/generated/Drives/Item/SearchWithQ/SearchWithQRequestBuilder.cs index b55d4d4ca5e..744e04e22fc 100644 --- a/src/generated/Drives/Item/SearchWithQ/SearchWithQRequestBuilder.cs +++ b/src/generated/Drives/Item/SearchWithQ/SearchWithQRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +33,17 @@ public Command BuildGetCommand() { }; qOption.IsRequired = true; command.AddOption(qOption); - command.SetHandler(async (string driveId, string q) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string q, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, qOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, qOption, outputOption); return command; } /// @@ -77,16 +76,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function search - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drives/Item/SharedWithMe/SharedWithMeRequestBuilder.cs b/src/generated/Drives/Item/SharedWithMe/SharedWithMeRequestBuilder.cs index 396bc090d71..820d0cd2f33 100644 --- a/src/generated/Drives/Item/SharedWithMe/SharedWithMeRequestBuilder.cs +++ b/src/generated/Drives/Item/SharedWithMe/SharedWithMeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +29,17 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - command.SetHandler(async (string driveId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function sharedWithMe - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drives/Item/Special/Item/Content/ContentRequestBuilder.cs b/src/generated/Drives/Item/Special/Item/Content/ContentRequestBuilder.cs index 928aea66e71..488c58be2ab 100644 --- a/src/generated/Drives/Item/Special/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Drives/Item/Special/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,28 +29,30 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string driveId, string driveItemId, FileInfo output) => { + command.SetHandler(async (string driveId, string driveItemId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, driveIdOption, driveItemIdOption, outputOption); + }, driveIdOption, driveItemIdOption, fileOption, outputOption); return command; } /// @@ -64,7 +66,7 @@ public Command BuildPutCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -72,12 +74,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string driveItemId, FileInfo file) => { + command.SetHandler(async (string driveId, string driveItemId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, driveItemIdOption, bodyOption); return command; @@ -128,29 +129,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property special from drives - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property special in drives - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Drives/Item/Special/Item/DriveItemRequestBuilder.cs b/src/generated/Drives/Item/Special/Item/DriveItemRequestBuilder.cs index 93248eae153..c496846a6a5 100644 --- a/src/generated/Drives/Item/Special/Item/DriveItemRequestBuilder.cs +++ b/src/generated/Drives/Item/Special/Item/DriveItemRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveId, string driveItemId) => { + command.SetHandler(async (string driveId, string driveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, driveItemIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, string driveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string driveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, driveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, driveItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,7 +101,7 @@ public Command BuildPatchCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -111,14 +109,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string driveItemId, string body) => { + command.SetHandler(async (string driveId, string driveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, driveItemIdOption, bodyOption); return command; @@ -190,42 +187,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of common folders available in OneDrive. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of common folders available in OneDrive. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of common folders available in OneDrive. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of common folders available in OneDrive. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Drives/Item/Special/SpecialRequestBuilder.cs b/src/generated/Drives/Item/Special/SpecialRequestBuilder.cs index 2377bc7b86a..57719578016 100644 --- a/src/generated/Drives/Item/Special/SpecialRequestBuilder.cs +++ b/src/generated/Drives/Item/Special/SpecialRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class SpecialRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DriveItemRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, bodyOption, outputOption); return command; } /// @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of common folders available in OneDrive. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of common folders available in OneDrive. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of common folders available in OneDrive. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Classes/ClassesRequestBuilder.cs b/src/generated/Education/Classes/ClassesRequestBuilder.cs index 421f242facd..284e01b45d5 100644 --- a/src/generated/Education/Classes/ClassesRequestBuilder.cs +++ b/src/generated/Education/Classes/ClassesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,19 +23,18 @@ public class ClassesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EducationClassRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAssignmentCategoriesCommand(), - builder.BuildAssignmentDefaultsCommand(), - builder.BuildAssignmentsCommand(), - builder.BuildAssignmentSettingsCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildGroupCommand(), - builder.BuildMembersCommand(), - builder.BuildPatchCommand(), - builder.BuildSchoolsCommand(), - builder.BuildTeachersCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAssignmentCategoriesCommand()); + commands.Add(builder.BuildAssignmentDefaultsCommand()); + commands.Add(builder.BuildAssignmentsCommand()); + commands.Add(builder.BuildAssignmentSettingsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildGroupCommand()); + commands.Add(builder.BuildMembersCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSchoolsCommand()); + commands.Add(builder.BuildTeachersCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -188,31 +185,6 @@ public RequestInformation CreatePostRequestInformation(EducationClass body, Acti public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// Get classes from education - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to classes for education - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EducationClass model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get classes from education public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Classes/Delta/DeltaRequestBuilder.cs b/src/generated/Education/Classes/Delta/DeltaRequestBuilder.cs index 38a278519c8..0848ce2dfa6 100644 --- a/src/generated/Education/Classes/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Education/Classes/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Education/Classes/Item/AssignmentCategories/AssignmentCategoriesRequestBuilder.cs b/src/generated/Education/Classes/Item/AssignmentCategories/AssignmentCategoriesRequestBuilder.cs index 154bea1f1e0..4e466dd05ba 100644 --- a/src/generated/Education/Classes/Item/AssignmentCategories/AssignmentCategoriesRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/AssignmentCategories/AssignmentCategoriesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AssignmentCategoriesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EducationCategoryRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Create new navigation property to assignmentCategories for education"; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationClassId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Get assignmentCategories from education"; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationClassId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(EducationCategory body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get assignmentCategories from education - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to assignmentCategories for education - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EducationCategory model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get assignmentCategories from education public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Classes/Item/AssignmentCategories/Item/EducationCategoryRequestBuilder.cs b/src/generated/Education/Classes/Item/AssignmentCategories/Item/EducationCategoryRequestBuilder.cs index 116dcd91dee..29dc71d0bb4 100644 --- a/src/generated/Education/Classes/Item/AssignmentCategories/Item/EducationCategoryRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/AssignmentCategories/Item/EducationCategoryRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property assignmentCategories for education"; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationCategoryIdOption = new Option("--educationcategory-id", description: "key: id of educationCategory") { + var educationCategoryIdOption = new Option("--education-category-id", description: "key: id of educationCategory") { }; educationCategoryIdOption.IsRequired = true; command.AddOption(educationCategoryIdOption); - command.SetHandler(async (string educationClassId, string educationCategoryId) => { + command.SetHandler(async (string educationClassId, string educationCategoryId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationClassIdOption, educationCategoryIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get assignmentCategories from education"; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationCategoryIdOption = new Option("--educationcategory-id", description: "key: id of educationCategory") { + var educationCategoryIdOption = new Option("--education-category-id", description: "key: id of educationCategory") { }; educationCategoryIdOption.IsRequired = true; command.AddOption(educationCategoryIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationClassId, string educationCategoryId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationCategoryId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationCategoryIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationCategoryIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property assignmentCategories in education"; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationCategoryIdOption = new Option("--educationcategory-id", description: "key: id of educationCategory") { + var educationCategoryIdOption = new Option("--education-category-id", description: "key: id of educationCategory") { }; educationCategoryIdOption.IsRequired = true; command.AddOption(educationCategoryIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationClassId, string educationCategoryId, string body) => { + command.SetHandler(async (string educationClassId, string educationCategoryId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationClassIdOption, educationCategoryIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(EducationCategory body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property assignmentCategories for education - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get assignmentCategories from education - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property assignmentCategories in education - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationCategory model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get assignmentCategories from education public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Classes/Item/AssignmentDefaults/AssignmentDefaultsRequestBuilder.cs b/src/generated/Education/Classes/Item/AssignmentDefaults/AssignmentDefaultsRequestBuilder.cs index 036b8fa8b4f..d0d7a868af6 100644 --- a/src/generated/Education/Classes/Item/AssignmentDefaults/AssignmentDefaultsRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/AssignmentDefaults/AssignmentDefaultsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property assignmentDefaults for education"; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - command.SetHandler(async (string educationClassId) => { + command.SetHandler(async (string educationClassId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationClassIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get assignmentDefaults from education"; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationClassId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property assignmentDefaults in education"; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationClassId, string body) => { + command.SetHandler(async (string educationClassId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationClassIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(EducationAssignmentDefau requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property assignmentDefaults for education - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get assignmentDefaults from education - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property assignmentDefaults in education - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationAssignmentDefaults model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get assignmentDefaults from education public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Classes/Item/AssignmentSettings/AssignmentSettingsRequestBuilder.cs b/src/generated/Education/Classes/Item/AssignmentSettings/AssignmentSettingsRequestBuilder.cs index 663d4fe9ec8..747807e857c 100644 --- a/src/generated/Education/Classes/Item/AssignmentSettings/AssignmentSettingsRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/AssignmentSettings/AssignmentSettingsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property assignmentSettings for education"; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - command.SetHandler(async (string educationClassId) => { + command.SetHandler(async (string educationClassId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationClassIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get assignmentSettings from education"; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationClassId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property assignmentSettings in education"; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationClassId, string body) => { + command.SetHandler(async (string educationClassId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationClassIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(EducationAssignmentSetti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property assignmentSettings for education - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get assignmentSettings from education - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property assignmentSettings in education - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationAssignmentSettings model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get assignmentSettings from education public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Classes/Item/Assignments/AssignmentsRequestBuilder.cs b/src/generated/Education/Classes/Item/Assignments/AssignmentsRequestBuilder.cs index 755e75ada85..fb4f657cdec 100644 --- a/src/generated/Education/Classes/Item/Assignments/AssignmentsRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Assignments/AssignmentsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,17 +22,16 @@ public class AssignmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EducationAssignmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCategoriesCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildPublishCommand(), - builder.BuildResourcesCommand(), - builder.BuildRubricCommand(), - builder.BuildSetUpResourcesFolderCommand(), - builder.BuildSubmissionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCategoriesCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPublishCommand()); + commands.Add(builder.BuildResourcesCommand()); + commands.Add(builder.BuildRubricCommand()); + commands.Add(builder.BuildSetUpResourcesFolderCommand()); + commands.Add(builder.BuildSubmissionsCommand()); return commands; } /// @@ -42,7 +41,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "All assignments associated with this class. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationClassId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, bodyOption, outputOption); return command; } /// @@ -74,7 +72,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "All assignments associated with this class. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); @@ -113,7 +111,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationClassId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -124,15 +126,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -187,31 +184,6 @@ public RequestInformation CreatePostRequestInformation(EducationAssignment body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All assignments associated with this class. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All assignments associated with this class. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EducationAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// All assignments associated with this class. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Classes/Item/Assignments/Item/Categories/CategoriesRequestBuilder.cs b/src/generated/Education/Classes/Item/Assignments/Item/Categories/CategoriesRequestBuilder.cs index 972acef99ae..70dc26e6d42 100644 --- a/src/generated/Education/Classes/Item/Assignments/Item/Categories/CategoriesRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Assignments/Item/Categories/CategoriesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class CategoriesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EducationCategoryRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,11 +35,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "When set, enables users to easily find assignments of a given type. Read-only. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationAssignmentId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationAssignmentIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationAssignmentIdOption, bodyOption, outputOption); return command; } /// @@ -72,11 +70,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "When set, enables users to easily find assignments of a given type. Read-only. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationAssignmentId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationAssignmentIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationAssignmentIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(EducationCategory body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// When set, enables users to easily find assignments of a given type. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// When set, enables users to easily find assignments of a given type. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EducationCategory model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// When set, enables users to easily find assignments of a given type. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Classes/Item/Assignments/Item/Categories/Item/EducationCategoryRequestBuilder.cs b/src/generated/Education/Classes/Item/Assignments/Item/Categories/Item/EducationCategoryRequestBuilder.cs index 0677ab3e2aa..9f0805fd11f 100644 --- a/src/generated/Education/Classes/Item/Assignments/Item/Categories/Item/EducationCategoryRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Assignments/Item/Categories/Item/EducationCategoryRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "When set, enables users to easily find assignments of a given type. Read-only. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationCategoryIdOption = new Option("--educationcategory-id", description: "key: id of educationCategory") { + var educationCategoryIdOption = new Option("--education-category-id", description: "key: id of educationCategory") { }; educationCategoryIdOption.IsRequired = true; command.AddOption(educationCategoryIdOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationCategoryId) => { + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationCategoryId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationClassIdOption, educationAssignmentIdOption, educationCategoryIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "When set, enables users to easily find assignments of a given type. Read-only. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationCategoryIdOption = new Option("--educationcategory-id", description: "key: id of educationCategory") { + var educationCategoryIdOption = new Option("--education-category-id", description: "key: id of educationCategory") { }; educationCategoryIdOption.IsRequired = true; command.AddOption(educationCategoryIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationCategoryId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationCategoryId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationAssignmentIdOption, educationCategoryIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationAssignmentIdOption, educationCategoryIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "When set, enables users to easily find assignments of a given type. Read-only. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationCategoryIdOption = new Option("--educationcategory-id", description: "key: id of educationCategory") { + var educationCategoryIdOption = new Option("--education-category-id", description: "key: id of educationCategory") { }; educationCategoryIdOption.IsRequired = true; command.AddOption(educationCategoryIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationCategoryId, string body) => { + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationCategoryId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationClassIdOption, educationAssignmentIdOption, educationCategoryIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(EducationCategory body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// When set, enables users to easily find assignments of a given type. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// When set, enables users to easily find assignments of a given type. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// When set, enables users to easily find assignments of a given type. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationCategory model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// When set, enables users to easily find assignments of a given type. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Classes/Item/Assignments/Item/EducationAssignmentRequestBuilder.cs b/src/generated/Education/Classes/Item/Assignments/Item/EducationAssignmentRequestBuilder.cs index 30f8fbf4fa0..69baca122be 100644 --- a/src/generated/Education/Classes/Item/Assignments/Item/EducationAssignmentRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Assignments/Item/EducationAssignmentRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,6 +28,9 @@ public class EducationAssignmentRequestBuilder { public Command BuildCategoriesCommand() { var command = new Command("categories"); var builder = new ApiSdk.Education.Classes.Item.Assignments.Item.Categories.CategoriesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -39,19 +42,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "All assignments associated with this class. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId) => { + command.SetHandler(async (string educationClassId, string educationAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationClassIdOption, educationAssignmentIdOption); return command; @@ -63,11 +65,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "All assignments associated with this class. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -81,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationAssignmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,11 +105,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "All assignments associated with this class. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -116,14 +117,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string body) => { + command.SetHandler(async (string educationClassId, string educationAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationClassIdOption, educationAssignmentIdOption, bodyOption); return command; @@ -137,6 +137,9 @@ public Command BuildPublishCommand() { public Command BuildResourcesCommand() { var command = new Command("resources"); var builder = new ApiSdk.Education.Classes.Item.Assignments.Item.Resources.ResourcesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -158,6 +161,9 @@ public Command BuildSetUpResourcesFolderCommand() { public Command BuildSubmissionsCommand() { var command = new Command("submissions"); var builder = new ApiSdk.Education.Classes.Item.Assignments.Item.Submissions.SubmissionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -229,42 +235,6 @@ public RequestInformation CreatePatchRequestInformation(EducationAssignment body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All assignments associated with this class. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All assignments associated with this class. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All assignments associated with this class. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// All assignments associated with this class. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Classes/Item/Assignments/Item/Publish/PublishRequestBuilder.cs b/src/generated/Education/Classes/Item/Assignments/Item/Publish/PublishRequestBuilder.cs index 883c64e2326..39e78fbce6a 100644 --- a/src/generated/Education/Classes/Item/Assignments/Item/Publish/PublishRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Assignments/Item/Publish/PublishRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action publish"; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationAssignmentId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationAssignmentIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationAssignmentIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action publish - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes educationAssignment public class PublishResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Education/Classes/Item/Assignments/Item/Resources/Item/EducationAssignmentResourceRequestBuilder.cs b/src/generated/Education/Classes/Item/Assignments/Item/Resources/Item/EducationAssignmentResourceRequestBuilder.cs index a18820c880c..60c32fd21b3 100644 --- a/src/generated/Education/Classes/Item/Assignments/Item/Resources/Item/EducationAssignmentResourceRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Assignments/Item/Resources/Item/EducationAssignmentResourceRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationAssignmentResourceIdOption = new Option("--educationassignmentresource-id", description: "key: id of educationAssignmentResource") { + var educationAssignmentResourceIdOption = new Option("--education-assignment-resource-id", description: "key: id of educationAssignmentResource") { }; educationAssignmentResourceIdOption.IsRequired = true; command.AddOption(educationAssignmentResourceIdOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationAssignmentResourceId) => { + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationAssignmentResourceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationClassIdOption, educationAssignmentIdOption, educationAssignmentResourceIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationAssignmentResourceIdOption = new Option("--educationassignmentresource-id", description: "key: id of educationAssignmentResource") { + var educationAssignmentResourceIdOption = new Option("--education-assignment-resource-id", description: "key: id of educationAssignmentResource") { }; educationAssignmentResourceIdOption.IsRequired = true; command.AddOption(educationAssignmentResourceIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationAssignmentResourceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationAssignmentResourceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationAssignmentIdOption, educationAssignmentResourceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationAssignmentIdOption, educationAssignmentResourceIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationAssignmentResourceIdOption = new Option("--educationassignmentresource-id", description: "key: id of educationAssignmentResource") { + var educationAssignmentResourceIdOption = new Option("--education-assignment-resource-id", description: "key: id of educationAssignmentResource") { }; educationAssignmentResourceIdOption.IsRequired = true; command.AddOption(educationAssignmentResourceIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationAssignmentResourceId, string body) => { + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationAssignmentResourceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationClassIdOption, educationAssignmentIdOption, educationAssignmentResourceIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(EducationAssignmentResou requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationAssignmentResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Classes/Item/Assignments/Item/Resources/ResourcesRequestBuilder.cs b/src/generated/Education/Classes/Item/Assignments/Item/Resources/ResourcesRequestBuilder.cs index 80a31a4c5e2..36b2cffff17 100644 --- a/src/generated/Education/Classes/Item/Assignments/Item/Resources/ResourcesRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Assignments/Item/Resources/ResourcesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ResourcesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EducationAssignmentResourceRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,11 +35,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationAssignmentId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationAssignmentIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationAssignmentIdOption, bodyOption, outputOption); return command; } /// @@ -72,11 +70,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationAssignmentId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationAssignmentIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationAssignmentIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(EducationAssignmentResour requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EducationAssignmentResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Classes/Item/Assignments/Item/Rubric/RubricRequestBuilder.cs b/src/generated/Education/Classes/Item/Assignments/Item/Rubric/RubricRequestBuilder.cs index 5324137a6ec..33eb58afc3c 100644 --- a/src/generated/Education/Classes/Item/Assignments/Item/Rubric/RubricRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Assignments/Item/Rubric/RubricRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "When set, the grading rubric attached to this assignment."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId) => { + command.SetHandler(async (string educationClassId, string educationAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationClassIdOption, educationAssignmentIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "When set, the grading rubric attached to this assignment."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationAssignmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "When set, the grading rubric attached to this assignment."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string body) => { + command.SetHandler(async (string educationClassId, string educationAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationClassIdOption, educationAssignmentIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(EducationRubric body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// When set, the grading rubric attached to this assignment. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// When set, the grading rubric attached to this assignment. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// When set, the grading rubric attached to this assignment. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationRubric model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// When set, the grading rubric attached to this assignment. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Classes/Item/Assignments/Item/SetUpResourcesFolder/SetUpResourcesFolderRequestBuilder.cs b/src/generated/Education/Classes/Item/Assignments/Item/SetUpResourcesFolder/SetUpResourcesFolderRequestBuilder.cs index 9f67728226c..b6b5620a676 100644 --- a/src/generated/Education/Classes/Item/Assignments/Item/SetUpResourcesFolder/SetUpResourcesFolderRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Assignments/Item/SetUpResourcesFolder/SetUpResourcesFolderRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setUpResourcesFolder"; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationAssignmentId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationAssignmentIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationAssignmentIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action setUpResourcesFolder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes educationAssignment public class SetUpResourcesFolderResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/@Return/ReturnRequestBuilder.cs b/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/@Return/ReturnRequestBuilder.cs deleted file mode 100644 index 16657980768..00000000000 --- a/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/@Return/ReturnRequestBuilder.cs +++ /dev/null @@ -1,125 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Education.Classes.Item.Assignments.Item.Submissions.Item.@Return { - /// Builds and executes requests for operations under \education\classes\{educationClass-id}\assignments\{educationAssignment-id}\submissions\{educationSubmission-id}\microsoft.graph.return - public class ReturnRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action return - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action return"; - // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { - }; - educationClassIdOption.IsRequired = true; - command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { - }; - educationAssignmentIdOption.IsRequired = true; - command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { - }; - educationSubmissionIdOption.IsRequired = true; - command.AddOption(educationSubmissionIdOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId) => { - var requestInfo = CreatePostRequestInformation(q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption); - return command; - } - /// - /// Instantiates a new ReturnRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public ReturnRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/education/classes/{educationClass_id}/assignments/{educationAssignment_id}/submissions/{educationSubmission_id}/microsoft.graph.return"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action return - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action return - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes educationSubmission - public class ReturnResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type educationSubmission - public EducationSubmission EducationSubmission { get; set; } - /// - /// Instantiates a new returnResponse and sets the default values. - /// - public ReturnResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"educationSubmission", (o,n) => { (o as ReturnResponse).EducationSubmission = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("educationSubmission", EducationSubmission); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/EducationSubmissionRequestBuilder.cs b/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/EducationSubmissionRequestBuilder.cs index 815e8ebeda1..b674bb564ff 100644 --- a/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/EducationSubmissionRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/EducationSubmissionRequestBuilder.cs @@ -9,10 +9,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,23 +34,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId) => { + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); @@ -84,25 +83,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOutcomesCommand() { var command = new Command("outcomes"); var builder = new ApiSdk.Education.Classes.Item.Assignments.Item.Submissions.Item.Outcomes.OutcomesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -114,15 +115,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); @@ -130,14 +131,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string body) => { + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, bodyOption); return command; @@ -151,13 +151,16 @@ public Command BuildReassignCommand() { public Command BuildResourcesCommand() { var command = new Command("resources"); var builder = new ApiSdk.Education.Classes.Item.Assignments.Item.Submissions.Item.Resources.ResourcesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; } public Command BuildReturnCommand() { var command = new Command("return"); - var builder = new ApiSdk.Education.Classes.Item.Assignments.Item.Submissions.Item.@Return.ReturnRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Education.Classes.Item.Assignments.Item.Submissions.Item.Return.ReturnRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } @@ -176,6 +179,9 @@ public Command BuildSubmitCommand() { public Command BuildSubmittedResourcesCommand() { var command = new Command("submitted-resources"); var builder = new ApiSdk.Education.Classes.Item.Assignments.Item.Submissions.Item.SubmittedResources.SubmittedResourcesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -253,42 +259,6 @@ public RequestInformation CreatePatchRequestInformation(EducationSubmission body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationSubmission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Outcomes/Item/EducationOutcomeRequestBuilder.cs b/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Outcomes/Item/EducationOutcomeRequestBuilder.cs index b0a1c9cacb0..ac95f378fa0 100644 --- a/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Outcomes/Item/EducationOutcomeRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Outcomes/Item/EducationOutcomeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,27 +26,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-Write. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - var educationOutcomeIdOption = new Option("--educationoutcome-id", description: "key: id of educationOutcome") { + var educationOutcomeIdOption = new Option("--education-outcome-id", description: "key: id of educationOutcome") { }; educationOutcomeIdOption.IsRequired = true; command.AddOption(educationOutcomeIdOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string educationOutcomeId) => { + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string educationOutcomeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, educationOutcomeIdOption); return command; @@ -58,19 +57,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-Write. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - var educationOutcomeIdOption = new Option("--educationoutcome-id", description: "key: id of educationOutcome") { + var educationOutcomeIdOption = new Option("--education-outcome-id", description: "key: id of educationOutcome") { }; educationOutcomeIdOption.IsRequired = true; command.AddOption(educationOutcomeIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string educationOutcomeId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string educationOutcomeId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, educationOutcomeIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, educationOutcomeIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,19 +105,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-Write. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - var educationOutcomeIdOption = new Option("--educationoutcome-id", description: "key: id of educationOutcome") { + var educationOutcomeIdOption = new Option("--education-outcome-id", description: "key: id of educationOutcome") { }; educationOutcomeIdOption.IsRequired = true; command.AddOption(educationOutcomeIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string educationOutcomeId, string body) => { + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string educationOutcomeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, educationOutcomeIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(EducationOutcome body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-Write. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-Write. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-Write. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationOutcome model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-Write. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Outcomes/OutcomesRequestBuilder.cs b/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Outcomes/OutcomesRequestBuilder.cs index d1c21db70d5..fd767792b1c 100644 --- a/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Outcomes/OutcomesRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Outcomes/OutcomesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class OutcomesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EducationOutcomeRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,15 +35,15 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Read-Write. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, bodyOption, outputOption); return command; } /// @@ -76,15 +74,15 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Read-Write. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(EducationOutcome body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-Write. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-Write. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EducationOutcome model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-Write. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Reassign/ReassignRequestBuilder.cs b/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Reassign/ReassignRequestBuilder.cs index 2955b7da10f..e98fa40fdec 100644 --- a/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Reassign/ReassignRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Reassign/ReassignRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action reassign"; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action reassign - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes educationSubmission public class ReassignResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Resources/Item/EducationSubmissionResourceRequestBuilder.cs b/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Resources/Item/EducationSubmissionResourceRequestBuilder.cs index 6b0522713c7..f58a924d055 100644 --- a/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Resources/Item/EducationSubmissionResourceRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Resources/Item/EducationSubmissionResourceRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,27 +26,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - var educationSubmissionResourceIdOption = new Option("--educationsubmissionresource-id", description: "key: id of educationSubmissionResource") { + var educationSubmissionResourceIdOption = new Option("--education-submission-resource-id", description: "key: id of educationSubmissionResource") { }; educationSubmissionResourceIdOption.IsRequired = true; command.AddOption(educationSubmissionResourceIdOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId) => { + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, educationSubmissionResourceIdOption); return command; @@ -58,19 +57,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - var educationSubmissionResourceIdOption = new Option("--educationsubmissionresource-id", description: "key: id of educationSubmissionResource") { + var educationSubmissionResourceIdOption = new Option("--education-submission-resource-id", description: "key: id of educationSubmissionResource") { }; educationSubmissionResourceIdOption.IsRequired = true; command.AddOption(educationSubmissionResourceIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, educationSubmissionResourceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, educationSubmissionResourceIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,19 +105,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - var educationSubmissionResourceIdOption = new Option("--educationsubmissionresource-id", description: "key: id of educationSubmissionResource") { + var educationSubmissionResourceIdOption = new Option("--education-submission-resource-id", description: "key: id of educationSubmissionResource") { }; educationSubmissionResourceIdOption.IsRequired = true; command.AddOption(educationSubmissionResourceIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, string body) => { + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, educationSubmissionResourceIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(EducationSubmissionResou requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationSubmissionResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Resources/ResourcesRequestBuilder.cs b/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Resources/ResourcesRequestBuilder.cs index 6d4c0d274df..39de46b1683 100644 --- a/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Resources/ResourcesRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Resources/ResourcesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ResourcesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EducationSubmissionResourceRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,15 +35,15 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, bodyOption, outputOption); return command; } /// @@ -76,15 +74,15 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(EducationSubmissionResour requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EducationSubmissionResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Return/ReturnRequestBuilder.cs b/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Return/ReturnRequestBuilder.cs new file mode 100644 index 00000000000..e65e7fbd571 --- /dev/null +++ b/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Return/ReturnRequestBuilder.cs @@ -0,0 +1,113 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Education.Classes.Item.Assignments.Item.Submissions.Item.Return { + /// Builds and executes requests for operations under \education\classes\{educationClass-id}\assignments\{educationAssignment-id}\submissions\{educationSubmission-id}\microsoft.graph.return + public class ReturnRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action return + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action return"; + // Create options for all the parameters + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { + }; + educationClassIdOption.IsRequired = true; + command.AddOption(educationClassIdOption); + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { + }; + educationAssignmentIdOption.IsRequired = true; + command.AddOption(educationAssignmentIdOption); + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { + }; + educationSubmissionIdOption.IsRequired = true; + command.AddOption(educationSubmissionIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreatePostRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, outputOption); + return command; + } + /// + /// Instantiates a new ReturnRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public ReturnRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/education/classes/{educationClass_id}/assignments/{educationAssignment_id}/submissions/{educationSubmission_id}/microsoft.graph.return"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action return + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes educationSubmission + public class ReturnResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type educationSubmission + public EducationSubmission EducationSubmission { get; set; } + /// + /// Instantiates a new returnResponse and sets the default values. + /// + public ReturnResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"educationSubmission", (o,n) => { (o as ReturnResponse).EducationSubmission = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("educationSubmission", EducationSubmission); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/SetUpResourcesFolder/SetUpResourcesFolderRequestBuilder.cs b/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/SetUpResourcesFolder/SetUpResourcesFolderRequestBuilder.cs index 8c879ee73e0..bb8493dde02 100644 --- a/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/SetUpResourcesFolder/SetUpResourcesFolderRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/SetUpResourcesFolder/SetUpResourcesFolderRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setUpResourcesFolder"; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action setUpResourcesFolder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes educationSubmission public class SetUpResourcesFolderResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Submit/SubmitRequestBuilder.cs b/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Submit/SubmitRequestBuilder.cs index 1e23f958795..2e18032f288 100644 --- a/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Submit/SubmitRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Submit/SubmitRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action submit"; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action submit - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes educationSubmission public class SubmitResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/SubmittedResources/Item/EducationSubmissionResourceRequestBuilder.cs b/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/SubmittedResources/Item/EducationSubmissionResourceRequestBuilder.cs index 5d3cb10e843..9e528113c39 100644 --- a/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/SubmittedResources/Item/EducationSubmissionResourceRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/SubmittedResources/Item/EducationSubmissionResourceRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,27 +26,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - var educationSubmissionResourceIdOption = new Option("--educationsubmissionresource-id", description: "key: id of educationSubmissionResource") { + var educationSubmissionResourceIdOption = new Option("--education-submission-resource-id", description: "key: id of educationSubmissionResource") { }; educationSubmissionResourceIdOption.IsRequired = true; command.AddOption(educationSubmissionResourceIdOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId) => { + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, educationSubmissionResourceIdOption); return command; @@ -58,19 +57,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - var educationSubmissionResourceIdOption = new Option("--educationsubmissionresource-id", description: "key: id of educationSubmissionResource") { + var educationSubmissionResourceIdOption = new Option("--education-submission-resource-id", description: "key: id of educationSubmissionResource") { }; educationSubmissionResourceIdOption.IsRequired = true; command.AddOption(educationSubmissionResourceIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, educationSubmissionResourceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, educationSubmissionResourceIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,19 +105,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - var educationSubmissionResourceIdOption = new Option("--educationsubmissionresource-id", description: "key: id of educationSubmissionResource") { + var educationSubmissionResourceIdOption = new Option("--education-submission-resource-id", description: "key: id of educationSubmissionResource") { }; educationSubmissionResourceIdOption.IsRequired = true; command.AddOption(educationSubmissionResourceIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, string body) => { + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, educationSubmissionResourceIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(EducationSubmissionResou requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationSubmissionResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/SubmittedResources/SubmittedResourcesRequestBuilder.cs b/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/SubmittedResources/SubmittedResourcesRequestBuilder.cs index 24ea960c318..465c58e2de9 100644 --- a/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/SubmittedResources/SubmittedResourcesRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/SubmittedResources/SubmittedResourcesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SubmittedResourcesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EducationSubmissionResourceRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,15 +35,15 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, bodyOption, outputOption); return command; } /// @@ -76,15 +74,15 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(EducationSubmissionResour requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EducationSubmissionResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Unsubmit/UnsubmitRequestBuilder.cs b/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Unsubmit/UnsubmitRequestBuilder.cs index 6ac9fc03d10..cb7a7f2b44b 100644 --- a/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Unsubmit/UnsubmitRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Assignments/Item/Submissions/Item/Unsubmit/UnsubmitRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action unsubmit"; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationAssignmentId, string educationSubmissionId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationAssignmentIdOption, educationSubmissionIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action unsubmit - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes educationSubmission public class UnsubmitResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Education/Classes/Item/Assignments/Item/Submissions/SubmissionsRequestBuilder.cs b/src/generated/Education/Classes/Item/Assignments/Item/Submissions/SubmissionsRequestBuilder.cs index 09e2cdf5ed5..472e6500879 100644 --- a/src/generated/Education/Classes/Item/Assignments/Item/Submissions/SubmissionsRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Assignments/Item/Submissions/SubmissionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,19 +22,18 @@ public class SubmissionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EducationSubmissionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOutcomesCommand(), - builder.BuildPatchCommand(), - builder.BuildReassignCommand(), - builder.BuildResourcesCommand(), - builder.BuildReturnCommand(), - builder.BuildSetUpResourcesFolderCommand(), - builder.BuildSubmitCommand(), - builder.BuildSubmittedResourcesCommand(), - builder.BuildUnsubmitCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOutcomesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildReassignCommand()); + commands.Add(builder.BuildResourcesCommand()); + commands.Add(builder.BuildReturnCommand()); + commands.Add(builder.BuildSetUpResourcesFolderCommand()); + commands.Add(builder.BuildSubmitCommand()); + commands.Add(builder.BuildSubmittedResourcesCommand()); + commands.Add(builder.BuildUnsubmitCommand()); return commands; } /// @@ -44,11 +43,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationAssignmentId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationAssignmentIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationAssignmentIdOption, bodyOption, outputOption); return command; } /// @@ -80,11 +78,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationClassId, string educationAssignmentId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string educationAssignmentId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, educationAssignmentIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, educationAssignmentIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(EducationSubmission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EducationSubmission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Classes/Item/EducationClassRequestBuilder.cs b/src/generated/Education/Classes/Item/EducationClassRequestBuilder.cs index b2a9c4901b9..2c01925aa31 100644 --- a/src/generated/Education/Classes/Item/EducationClassRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/EducationClassRequestBuilder.cs @@ -9,10 +9,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,6 +30,9 @@ public class EducationClassRequestBuilder { public Command BuildAssignmentCategoriesCommand() { var command = new Command("assignment-categories"); var builder = new ApiSdk.Education.Classes.Item.AssignmentCategories.AssignmentCategoriesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -45,6 +48,9 @@ public Command BuildAssignmentDefaultsCommand() { public Command BuildAssignmentsCommand() { var command = new Command("assignments"); var builder = new ApiSdk.Education.Classes.Item.Assignments.AssignmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -64,15 +70,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property classes for education"; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - command.SetHandler(async (string educationClassId) => { + command.SetHandler(async (string educationClassId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationClassIdOption); return command; @@ -84,7 +89,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get classes from education"; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); @@ -98,20 +103,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationClassId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildGroupCommand() { @@ -135,7 +139,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property classes in education"; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); @@ -143,14 +147,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationClassId, string body) => { + command.SetHandler(async (string educationClassId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationClassIdOption, bodyOption); return command; @@ -236,42 +239,6 @@ public RequestInformation CreatePatchRequestInformation(EducationClass body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property classes for education - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get classes from education - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property classes in education - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationClass model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get classes from education public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Classes/Item/Group/@Ref/@Ref.cs b/src/generated/Education/Classes/Item/Group/@Ref/@Ref.cs deleted file mode 100644 index fff54ca5af7..00000000000 --- a/src/generated/Education/Classes/Item/Group/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Education.Classes.Item.Group.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Education/Classes/Item/Group/@Ref/RefRequestBuilder.cs b/src/generated/Education/Classes/Item/Group/@Ref/RefRequestBuilder.cs deleted file mode 100644 index ae42e84ed5d..00000000000 --- a/src/generated/Education/Classes/Item/Group/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Education.Classes.Item.Group.@Ref { - /// Builds and executes requests for operations under \education\classes\{educationClass-id}\group\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The underlying Microsoft 365 group object. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The underlying Microsoft 365 group object."; - // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { - }; - educationClassIdOption.IsRequired = true; - command.AddOption(educationClassIdOption); - command.SetHandler(async (string educationClassId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, educationClassIdOption); - return command; - } - /// - /// The underlying Microsoft 365 group object. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The underlying Microsoft 365 group object."; - // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { - }; - educationClassIdOption.IsRequired = true; - command.AddOption(educationClassIdOption); - command.SetHandler(async (string educationClassId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption); - return command; - } - /// - /// The underlying Microsoft 365 group object. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The underlying Microsoft 365 group object."; - // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { - }; - educationClassIdOption.IsRequired = true; - command.AddOption(educationClassIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string educationClassId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, educationClassIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/education/classes/{educationClass_id}/group/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The underlying Microsoft 365 group object. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The underlying Microsoft 365 group object. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The underlying Microsoft 365 group object. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Education.Classes.Item.Group.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The underlying Microsoft 365 group object. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The underlying Microsoft 365 group object. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The underlying Microsoft 365 group object. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Education.Classes.Item.Group.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Education/Classes/Item/Group/GroupRequestBuilder.cs b/src/generated/Education/Classes/Item/Group/GroupRequestBuilder.cs index 38f0818c1c5..5f78e9ed142 100644 --- a/src/generated/Education/Classes/Item/Group/GroupRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Group/GroupRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The underlying Microsoft 365 group object."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationClassId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Education.Classes.Item.Group.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Education.Classes.Item.Group.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The underlying Microsoft 365 group object. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The underlying Microsoft 365 group object. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Classes/Item/Group/Ref/Ref.cs b/src/generated/Education/Classes/Item/Group/Ref/Ref.cs new file mode 100644 index 00000000000..c5971e4c6fa --- /dev/null +++ b/src/generated/Education/Classes/Item/Group/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Education.Classes.Item.Group.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Education/Classes/Item/Group/Ref/RefRequestBuilder.cs b/src/generated/Education/Classes/Item/Group/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..3fd85d387fb --- /dev/null +++ b/src/generated/Education/Classes/Item/Group/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Education.Classes.Item.Group.Ref { + /// Builds and executes requests for operations under \education\classes\{educationClass-id}\group\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The underlying Microsoft 365 group object. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The underlying Microsoft 365 group object."; + // Create options for all the parameters + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { + }; + educationClassIdOption.IsRequired = true; + command.AddOption(educationClassIdOption); + command.SetHandler(async (string educationClassId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, educationClassIdOption); + return command; + } + /// + /// The underlying Microsoft 365 group object. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The underlying Microsoft 365 group object."; + // Create options for all the parameters + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { + }; + educationClassIdOption.IsRequired = true; + command.AddOption(educationClassIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, outputOption); + return command; + } + /// + /// The underlying Microsoft 365 group object. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The underlying Microsoft 365 group object."; + // Create options for all the parameters + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { + }; + educationClassIdOption.IsRequired = true; + command.AddOption(educationClassIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string educationClassId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, educationClassIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/education/classes/{educationClass_id}/group/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The underlying Microsoft 365 group object. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The underlying Microsoft 365 group object. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The underlying Microsoft 365 group object. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Education.Classes.Item.Group.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Education/Classes/Item/Members/@Ref/@Ref.cs b/src/generated/Education/Classes/Item/Members/@Ref/@Ref.cs deleted file mode 100644 index 7d93c45d9be..00000000000 --- a/src/generated/Education/Classes/Item/Members/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Education.Classes.Item.Members.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Education/Classes/Item/Members/@Ref/RefRequestBuilder.cs b/src/generated/Education/Classes/Item/Members/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 91a6aef3c4e..00000000000 --- a/src/generated/Education/Classes/Item/Members/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Education.Classes.Item.Members.@Ref { - /// Builds and executes requests for operations under \education\classes\{educationClass-id}\members\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// All users in the class. Nullable. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "All users in the class. Nullable."; - // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { - }; - educationClassIdOption.IsRequired = true; - command.AddOption(educationClassIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string educationClassId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// All users in the class. Nullable. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "All users in the class. Nullable."; - // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { - }; - educationClassIdOption.IsRequired = true; - command.AddOption(educationClassIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string educationClassId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/education/classes/{educationClass_id}/members/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// All users in the class. Nullable. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// All users in the class. Nullable. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Education.Classes.Item.Members.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// All users in the class. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All users in the class. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Education.Classes.Item.Members.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// All users in the class. Nullable. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Education/Classes/Item/Members/@Ref/RefResponse.cs b/src/generated/Education/Classes/Item/Members/@Ref/RefResponse.cs deleted file mode 100644 index 1e14994818a..00000000000 --- a/src/generated/Education/Classes/Item/Members/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Education.Classes.Item.Members.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Education/Classes/Item/Members/Delta/DeltaRequestBuilder.cs b/src/generated/Education/Classes/Item/Members/Delta/DeltaRequestBuilder.cs index 0d40b27f671..eebaf0429d2 100644 --- a/src/generated/Education/Classes/Item/Members/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Members/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,22 +25,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - command.SetHandler(async (string educationClassId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Education/Classes/Item/Members/MembersRequestBuilder.cs b/src/generated/Education/Classes/Item/Members/MembersRequestBuilder.cs index 1707b3740b7..0f3fce9def6 100644 --- a/src/generated/Education/Classes/Item/Members/MembersRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Members/MembersRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Education.Classes.Item.Members.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "All users in the class. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); @@ -66,7 +66,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationClassId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -77,20 +81,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Education.Classes.Item.Members.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Education.Classes.Item.Members.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -135,18 +134,6 @@ public RequestInformation CreateGetRequestInformation(Action public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// All users in the class. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// All users in the class. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Classes/Item/Members/Ref/Ref.cs b/src/generated/Education/Classes/Item/Members/Ref/Ref.cs new file mode 100644 index 00000000000..f7cf06b5f6b --- /dev/null +++ b/src/generated/Education/Classes/Item/Members/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Education.Classes.Item.Members.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Education/Classes/Item/Members/Ref/RefRequestBuilder.cs b/src/generated/Education/Classes/Item/Members/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..6e5161f5c6f --- /dev/null +++ b/src/generated/Education/Classes/Item/Members/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Education.Classes.Item.Members.Ref { + /// Builds and executes requests for operations under \education\classes\{educationClass-id}\members\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// All users in the class. Nullable. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "All users in the class. Nullable."; + // Create options for all the parameters + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { + }; + educationClassIdOption.IsRequired = true; + command.AddOption(educationClassIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// All users in the class. Nullable. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "All users in the class. Nullable."; + // Create options for all the parameters + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { + }; + educationClassIdOption.IsRequired = true; + command.AddOption(educationClassIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/education/classes/{educationClass_id}/members/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// All users in the class. Nullable. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// All users in the class. Nullable. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Education.Classes.Item.Members.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// All users in the class. Nullable. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Education/Classes/Item/Members/Ref/RefResponse.cs b/src/generated/Education/Classes/Item/Members/Ref/RefResponse.cs new file mode 100644 index 00000000000..632b1a44e4f --- /dev/null +++ b/src/generated/Education/Classes/Item/Members/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Education.Classes.Item.Members.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Education/Classes/Item/Schools/@Ref/@Ref.cs b/src/generated/Education/Classes/Item/Schools/@Ref/@Ref.cs deleted file mode 100644 index a45b7c4d83a..00000000000 --- a/src/generated/Education/Classes/Item/Schools/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Education.Classes.Item.Schools.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Education/Classes/Item/Schools/@Ref/RefRequestBuilder.cs b/src/generated/Education/Classes/Item/Schools/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 91fa90596fd..00000000000 --- a/src/generated/Education/Classes/Item/Schools/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Education.Classes.Item.Schools.@Ref { - /// Builds and executes requests for operations under \education\classes\{educationClass-id}\schools\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// All schools that this class is associated with. Nullable. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "All schools that this class is associated with. Nullable."; - // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { - }; - educationClassIdOption.IsRequired = true; - command.AddOption(educationClassIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string educationClassId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// All schools that this class is associated with. Nullable. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "All schools that this class is associated with. Nullable."; - // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { - }; - educationClassIdOption.IsRequired = true; - command.AddOption(educationClassIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string educationClassId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/education/classes/{educationClass_id}/schools/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// All schools that this class is associated with. Nullable. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// All schools that this class is associated with. Nullable. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Education.Classes.Item.Schools.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// All schools that this class is associated with. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All schools that this class is associated with. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Education.Classes.Item.Schools.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// All schools that this class is associated with. Nullable. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Education/Classes/Item/Schools/@Ref/RefResponse.cs b/src/generated/Education/Classes/Item/Schools/@Ref/RefResponse.cs deleted file mode 100644 index 9ce6bd6d30d..00000000000 --- a/src/generated/Education/Classes/Item/Schools/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Education.Classes.Item.Schools.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Education/Classes/Item/Schools/Delta/DeltaRequestBuilder.cs b/src/generated/Education/Classes/Item/Schools/Delta/DeltaRequestBuilder.cs index bb1a6b1cabf..5e091787a58 100644 --- a/src/generated/Education/Classes/Item/Schools/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Schools/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,22 +25,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - command.SetHandler(async (string educationClassId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Education/Classes/Item/Schools/Ref/Ref.cs b/src/generated/Education/Classes/Item/Schools/Ref/Ref.cs new file mode 100644 index 00000000000..262a05ea00d --- /dev/null +++ b/src/generated/Education/Classes/Item/Schools/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Education.Classes.Item.Schools.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Education/Classes/Item/Schools/Ref/RefRequestBuilder.cs b/src/generated/Education/Classes/Item/Schools/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..dcf085e54e0 --- /dev/null +++ b/src/generated/Education/Classes/Item/Schools/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Education.Classes.Item.Schools.Ref { + /// Builds and executes requests for operations under \education\classes\{educationClass-id}\schools\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// All schools that this class is associated with. Nullable. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "All schools that this class is associated with. Nullable."; + // Create options for all the parameters + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { + }; + educationClassIdOption.IsRequired = true; + command.AddOption(educationClassIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// All schools that this class is associated with. Nullable. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "All schools that this class is associated with. Nullable."; + // Create options for all the parameters + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { + }; + educationClassIdOption.IsRequired = true; + command.AddOption(educationClassIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/education/classes/{educationClass_id}/schools/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// All schools that this class is associated with. Nullable. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// All schools that this class is associated with. Nullable. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Education.Classes.Item.Schools.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// All schools that this class is associated with. Nullable. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Education/Classes/Item/Schools/Ref/RefResponse.cs b/src/generated/Education/Classes/Item/Schools/Ref/RefResponse.cs new file mode 100644 index 00000000000..9a8791fabe8 --- /dev/null +++ b/src/generated/Education/Classes/Item/Schools/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Education.Classes.Item.Schools.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Education/Classes/Item/Schools/SchoolsRequestBuilder.cs b/src/generated/Education/Classes/Item/Schools/SchoolsRequestBuilder.cs index 9836530d185..3865d9babe3 100644 --- a/src/generated/Education/Classes/Item/Schools/SchoolsRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Schools/SchoolsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Education.Classes.Item.Schools.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "All schools that this class is associated with. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); @@ -66,7 +66,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationClassId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -77,20 +81,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Education.Classes.Item.Schools.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Education.Classes.Item.Schools.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -135,18 +134,6 @@ public RequestInformation CreateGetRequestInformation(Action public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// All schools that this class is associated with. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// All schools that this class is associated with. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Classes/Item/Teachers/@Ref/@Ref.cs b/src/generated/Education/Classes/Item/Teachers/@Ref/@Ref.cs deleted file mode 100644 index 0fa05891805..00000000000 --- a/src/generated/Education/Classes/Item/Teachers/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Education.Classes.Item.Teachers.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Education/Classes/Item/Teachers/@Ref/RefRequestBuilder.cs b/src/generated/Education/Classes/Item/Teachers/@Ref/RefRequestBuilder.cs deleted file mode 100644 index e9d2d908cbc..00000000000 --- a/src/generated/Education/Classes/Item/Teachers/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Education.Classes.Item.Teachers.@Ref { - /// Builds and executes requests for operations under \education\classes\{educationClass-id}\teachers\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// All teachers in the class. Nullable. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "All teachers in the class. Nullable."; - // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { - }; - educationClassIdOption.IsRequired = true; - command.AddOption(educationClassIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string educationClassId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// All teachers in the class. Nullable. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "All teachers in the class. Nullable."; - // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { - }; - educationClassIdOption.IsRequired = true; - command.AddOption(educationClassIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string educationClassId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/education/classes/{educationClass_id}/teachers/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// All teachers in the class. Nullable. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// All teachers in the class. Nullable. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Education.Classes.Item.Teachers.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// All teachers in the class. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All teachers in the class. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Education.Classes.Item.Teachers.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// All teachers in the class. Nullable. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Education/Classes/Item/Teachers/@Ref/RefResponse.cs b/src/generated/Education/Classes/Item/Teachers/@Ref/RefResponse.cs deleted file mode 100644 index 82a8ba08b22..00000000000 --- a/src/generated/Education/Classes/Item/Teachers/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Education.Classes.Item.Teachers.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Education/Classes/Item/Teachers/Delta/DeltaRequestBuilder.cs b/src/generated/Education/Classes/Item/Teachers/Delta/DeltaRequestBuilder.cs index b36aae2f114..4a8c7dd0c98 100644 --- a/src/generated/Education/Classes/Item/Teachers/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Teachers/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,22 +25,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); - command.SetHandler(async (string educationClassId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Education/Classes/Item/Teachers/Ref/Ref.cs b/src/generated/Education/Classes/Item/Teachers/Ref/Ref.cs new file mode 100644 index 00000000000..2c9fbd2853c --- /dev/null +++ b/src/generated/Education/Classes/Item/Teachers/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Education.Classes.Item.Teachers.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Education/Classes/Item/Teachers/Ref/RefRequestBuilder.cs b/src/generated/Education/Classes/Item/Teachers/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..d8a74a29e0f --- /dev/null +++ b/src/generated/Education/Classes/Item/Teachers/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Education.Classes.Item.Teachers.Ref { + /// Builds and executes requests for operations under \education\classes\{educationClass-id}\teachers\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// All teachers in the class. Nullable. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "All teachers in the class. Nullable."; + // Create options for all the parameters + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { + }; + educationClassIdOption.IsRequired = true; + command.AddOption(educationClassIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// All teachers in the class. Nullable. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "All teachers in the class. Nullable."; + // Create options for all the parameters + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { + }; + educationClassIdOption.IsRequired = true; + command.AddOption(educationClassIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/education/classes/{educationClass_id}/teachers/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// All teachers in the class. Nullable. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// All teachers in the class. Nullable. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Education.Classes.Item.Teachers.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// All teachers in the class. Nullable. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Education/Classes/Item/Teachers/Ref/RefResponse.cs b/src/generated/Education/Classes/Item/Teachers/Ref/RefResponse.cs new file mode 100644 index 00000000000..3237fdde504 --- /dev/null +++ b/src/generated/Education/Classes/Item/Teachers/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Education.Classes.Item.Teachers.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Education/Classes/Item/Teachers/TeachersRequestBuilder.cs b/src/generated/Education/Classes/Item/Teachers/TeachersRequestBuilder.cs index 26fde4ae07a..320998d4aea 100644 --- a/src/generated/Education/Classes/Item/Teachers/TeachersRequestBuilder.cs +++ b/src/generated/Education/Classes/Item/Teachers/TeachersRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Education.Classes.Item.Teachers.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "All teachers in the class. Nullable."; // Create options for all the parameters - var educationClassIdOption = new Option("--educationclass-id", description: "key: id of educationClass") { + var educationClassIdOption = new Option("--education-class-id", description: "key: id of educationClass") { }; educationClassIdOption.IsRequired = true; command.AddOption(educationClassIdOption); @@ -66,7 +66,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationClassId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationClassId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -77,20 +81,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationClassIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationClassIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Education.Classes.Item.Teachers.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Education.Classes.Item.Teachers.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -135,18 +134,6 @@ public RequestInformation CreateGetRequestInformation(Action public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// All teachers in the class. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// All teachers in the class. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/EducationRequestBuilder.cs b/src/generated/Education/EducationRequestBuilder.cs index 161afe6f10b..41267a68666 100644 --- a/src/generated/Education/EducationRequestBuilder.cs +++ b/src/generated/Education/EducationRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,6 +26,9 @@ public class EducationRequestBuilder { public Command BuildClassesCommand() { var command = new Command("classes"); var builder = new ApiSdk.Education.Classes.ClassesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -47,20 +50,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } public Command BuildMeCommand() { @@ -88,14 +90,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -103,6 +104,9 @@ public Command BuildPatchCommand() { public Command BuildSchoolsCommand() { var command = new Command("schools"); var builder = new ApiSdk.Education.Schools.SchoolsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -110,6 +114,9 @@ public Command BuildSchoolsCommand() { public Command BuildUsersCommand() { var command = new Command("users"); var builder = new ApiSdk.Education.Users.UsersRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -154,7 +161,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft.Graph.Education body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(EducationRoot body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -166,31 +173,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get education - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update education - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Education model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get education public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Me/Assignments/AssignmentsRequestBuilder.cs b/src/generated/Education/Me/Assignments/AssignmentsRequestBuilder.cs index 4efcc6432fa..4adf1829555 100644 --- a/src/generated/Education/Me/Assignments/AssignmentsRequestBuilder.cs +++ b/src/generated/Education/Me/Assignments/AssignmentsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,17 +22,16 @@ public class AssignmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EducationAssignmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCategoriesCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildPublishCommand(), - builder.BuildResourcesCommand(), - builder.BuildRubricCommand(), - builder.BuildSetUpResourcesFolderCommand(), - builder.BuildSubmissionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCategoriesCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPublishCommand()); + commands.Add(builder.BuildResourcesCommand()); + commands.Add(builder.BuildRubricCommand()); + commands.Add(builder.BuildSetUpResourcesFolderCommand()); + commands.Add(builder.BuildSubmissionsCommand()); return commands; } /// @@ -46,21 +45,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -105,7 +103,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -116,15 +118,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -179,31 +176,6 @@ public RequestInformation CreatePostRequestInformation(EducationAssignment body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of assignments for the user. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of assignments for the user. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EducationAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// List of assignments for the user. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Me/Assignments/Item/Categories/CategoriesRequestBuilder.cs b/src/generated/Education/Me/Assignments/Item/Categories/CategoriesRequestBuilder.cs index b140331f3f5..278db56dcd0 100644 --- a/src/generated/Education/Me/Assignments/Item/Categories/CategoriesRequestBuilder.cs +++ b/src/generated/Education/Me/Assignments/Item/Categories/CategoriesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class CategoriesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EducationCategoryRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "When set, enables users to easily find assignments of a given type. Read-only. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationAssignmentId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationAssignmentId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationAssignmentIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationAssignmentIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "When set, enables users to easily find assignments of a given type. Read-only. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationAssignmentId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationAssignmentId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationAssignmentIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationAssignmentIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(EducationCategory body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// When set, enables users to easily find assignments of a given type. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// When set, enables users to easily find assignments of a given type. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EducationCategory model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// When set, enables users to easily find assignments of a given type. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Me/Assignments/Item/Categories/Item/EducationCategoryRequestBuilder.cs b/src/generated/Education/Me/Assignments/Item/Categories/Item/EducationCategoryRequestBuilder.cs index e6ec213b97e..0e4f2b6e959 100644 --- a/src/generated/Education/Me/Assignments/Item/Categories/Item/EducationCategoryRequestBuilder.cs +++ b/src/generated/Education/Me/Assignments/Item/Categories/Item/EducationCategoryRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "When set, enables users to easily find assignments of a given type. Read-only. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationCategoryIdOption = new Option("--educationcategory-id", description: "key: id of educationCategory") { + var educationCategoryIdOption = new Option("--education-category-id", description: "key: id of educationCategory") { }; educationCategoryIdOption.IsRequired = true; command.AddOption(educationCategoryIdOption); - command.SetHandler(async (string educationAssignmentId, string educationCategoryId) => { + command.SetHandler(async (string educationAssignmentId, string educationCategoryId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationAssignmentIdOption, educationCategoryIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "When set, enables users to easily find assignments of a given type. Read-only. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationCategoryIdOption = new Option("--educationcategory-id", description: "key: id of educationCategory") { + var educationCategoryIdOption = new Option("--education-category-id", description: "key: id of educationCategory") { }; educationCategoryIdOption.IsRequired = true; command.AddOption(educationCategoryIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationAssignmentId, string educationCategoryId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationAssignmentId, string educationCategoryId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationAssignmentIdOption, educationCategoryIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationAssignmentIdOption, educationCategoryIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "When set, enables users to easily find assignments of a given type. Read-only. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationCategoryIdOption = new Option("--educationcategory-id", description: "key: id of educationCategory") { + var educationCategoryIdOption = new Option("--education-category-id", description: "key: id of educationCategory") { }; educationCategoryIdOption.IsRequired = true; command.AddOption(educationCategoryIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationAssignmentId, string educationCategoryId, string body) => { + command.SetHandler(async (string educationAssignmentId, string educationCategoryId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationAssignmentIdOption, educationCategoryIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(EducationCategory body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// When set, enables users to easily find assignments of a given type. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// When set, enables users to easily find assignments of a given type. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// When set, enables users to easily find assignments of a given type. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationCategory model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// When set, enables users to easily find assignments of a given type. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Me/Assignments/Item/EducationAssignmentRequestBuilder.cs b/src/generated/Education/Me/Assignments/Item/EducationAssignmentRequestBuilder.cs index c3a46e6aa64..ee5781a2d87 100644 --- a/src/generated/Education/Me/Assignments/Item/EducationAssignmentRequestBuilder.cs +++ b/src/generated/Education/Me/Assignments/Item/EducationAssignmentRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,6 +28,9 @@ public class EducationAssignmentRequestBuilder { public Command BuildCategoriesCommand() { var command = new Command("categories"); var builder = new ApiSdk.Education.Me.Assignments.Item.Categories.CategoriesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -39,15 +42,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "List of assignments for the user. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - command.SetHandler(async (string educationAssignmentId) => { + command.SetHandler(async (string educationAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationAssignmentIdOption); return command; @@ -59,7 +61,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "List of assignments for the user. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -73,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationAssignmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -96,7 +97,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "List of assignments for the user. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -104,14 +105,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationAssignmentId, string body) => { + command.SetHandler(async (string educationAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationAssignmentIdOption, bodyOption); return command; @@ -125,6 +125,9 @@ public Command BuildPublishCommand() { public Command BuildResourcesCommand() { var command = new Command("resources"); var builder = new ApiSdk.Education.Me.Assignments.Item.Resources.ResourcesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -146,6 +149,9 @@ public Command BuildSetUpResourcesFolderCommand() { public Command BuildSubmissionsCommand() { var command = new Command("submissions"); var builder = new ApiSdk.Education.Me.Assignments.Item.Submissions.SubmissionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -217,42 +223,6 @@ public RequestInformation CreatePatchRequestInformation(EducationAssignment body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of assignments for the user. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of assignments for the user. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of assignments for the user. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// List of assignments for the user. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Me/Assignments/Item/Publish/PublishRequestBuilder.cs b/src/generated/Education/Me/Assignments/Item/Publish/PublishRequestBuilder.cs index 55e35e85ae7..6e0868a7c79 100644 --- a/src/generated/Education/Me/Assignments/Item/Publish/PublishRequestBuilder.cs +++ b/src/generated/Education/Me/Assignments/Item/Publish/PublishRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action publish"; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - command.SetHandler(async (string educationAssignmentId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationAssignmentId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationAssignmentIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationAssignmentIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action publish - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes educationAssignment public class PublishResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Education/Me/Assignments/Item/Resources/Item/EducationAssignmentResourceRequestBuilder.cs b/src/generated/Education/Me/Assignments/Item/Resources/Item/EducationAssignmentResourceRequestBuilder.cs index feb2bccb6c4..28e41cf3bb8 100644 --- a/src/generated/Education/Me/Assignments/Item/Resources/Item/EducationAssignmentResourceRequestBuilder.cs +++ b/src/generated/Education/Me/Assignments/Item/Resources/Item/EducationAssignmentResourceRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationAssignmentResourceIdOption = new Option("--educationassignmentresource-id", description: "key: id of educationAssignmentResource") { + var educationAssignmentResourceIdOption = new Option("--education-assignment-resource-id", description: "key: id of educationAssignmentResource") { }; educationAssignmentResourceIdOption.IsRequired = true; command.AddOption(educationAssignmentResourceIdOption); - command.SetHandler(async (string educationAssignmentId, string educationAssignmentResourceId) => { + command.SetHandler(async (string educationAssignmentId, string educationAssignmentResourceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationAssignmentIdOption, educationAssignmentResourceIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationAssignmentResourceIdOption = new Option("--educationassignmentresource-id", description: "key: id of educationAssignmentResource") { + var educationAssignmentResourceIdOption = new Option("--education-assignment-resource-id", description: "key: id of educationAssignmentResource") { }; educationAssignmentResourceIdOption.IsRequired = true; command.AddOption(educationAssignmentResourceIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationAssignmentId, string educationAssignmentResourceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationAssignmentId, string educationAssignmentResourceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationAssignmentIdOption, educationAssignmentResourceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationAssignmentIdOption, educationAssignmentResourceIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationAssignmentResourceIdOption = new Option("--educationassignmentresource-id", description: "key: id of educationAssignmentResource") { + var educationAssignmentResourceIdOption = new Option("--education-assignment-resource-id", description: "key: id of educationAssignmentResource") { }; educationAssignmentResourceIdOption.IsRequired = true; command.AddOption(educationAssignmentResourceIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationAssignmentId, string educationAssignmentResourceId, string body) => { + command.SetHandler(async (string educationAssignmentId, string educationAssignmentResourceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationAssignmentIdOption, educationAssignmentResourceIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(EducationAssignmentResou requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationAssignmentResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Me/Assignments/Item/Resources/ResourcesRequestBuilder.cs b/src/generated/Education/Me/Assignments/Item/Resources/ResourcesRequestBuilder.cs index e32b647efcf..105e6b2bb84 100644 --- a/src/generated/Education/Me/Assignments/Item/Resources/ResourcesRequestBuilder.cs +++ b/src/generated/Education/Me/Assignments/Item/Resources/ResourcesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ResourcesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EducationAssignmentResourceRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationAssignmentId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationAssignmentId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationAssignmentIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationAssignmentIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationAssignmentId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationAssignmentId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationAssignmentIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationAssignmentIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(EducationAssignmentResour requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EducationAssignmentResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Me/Assignments/Item/Rubric/RubricRequestBuilder.cs b/src/generated/Education/Me/Assignments/Item/Rubric/RubricRequestBuilder.cs index 123a82feddb..523f22c5ba2 100644 --- a/src/generated/Education/Me/Assignments/Item/Rubric/RubricRequestBuilder.cs +++ b/src/generated/Education/Me/Assignments/Item/Rubric/RubricRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "When set, the grading rubric attached to this assignment."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - command.SetHandler(async (string educationAssignmentId) => { + command.SetHandler(async (string educationAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationAssignmentIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "When set, the grading rubric attached to this assignment."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationAssignmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "When set, the grading rubric attached to this assignment."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationAssignmentId, string body) => { + command.SetHandler(async (string educationAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationAssignmentIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(EducationRubric body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// When set, the grading rubric attached to this assignment. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// When set, the grading rubric attached to this assignment. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// When set, the grading rubric attached to this assignment. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationRubric model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// When set, the grading rubric attached to this assignment. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Me/Assignments/Item/SetUpResourcesFolder/SetUpResourcesFolderRequestBuilder.cs b/src/generated/Education/Me/Assignments/Item/SetUpResourcesFolder/SetUpResourcesFolderRequestBuilder.cs index b840e6a30c7..2ea5258c732 100644 --- a/src/generated/Education/Me/Assignments/Item/SetUpResourcesFolder/SetUpResourcesFolderRequestBuilder.cs +++ b/src/generated/Education/Me/Assignments/Item/SetUpResourcesFolder/SetUpResourcesFolderRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setUpResourcesFolder"; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - command.SetHandler(async (string educationAssignmentId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationAssignmentId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationAssignmentIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationAssignmentIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action setUpResourcesFolder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes educationAssignment public class SetUpResourcesFolderResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Education/Me/Assignments/Item/Submissions/Item/@Return/ReturnRequestBuilder.cs b/src/generated/Education/Me/Assignments/Item/Submissions/Item/@Return/ReturnRequestBuilder.cs deleted file mode 100644 index e241213ea57..00000000000 --- a/src/generated/Education/Me/Assignments/Item/Submissions/Item/@Return/ReturnRequestBuilder.cs +++ /dev/null @@ -1,121 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Education.Me.Assignments.Item.Submissions.Item.@Return { - /// Builds and executes requests for operations under \education\me\assignments\{educationAssignment-id}\submissions\{educationSubmission-id}\microsoft.graph.return - public class ReturnRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action return - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action return"; - // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { - }; - educationAssignmentIdOption.IsRequired = true; - command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { - }; - educationSubmissionIdOption.IsRequired = true; - command.AddOption(educationSubmissionIdOption); - command.SetHandler(async (string educationAssignmentId, string educationSubmissionId) => { - var requestInfo = CreatePostRequestInformation(q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationAssignmentIdOption, educationSubmissionIdOption); - return command; - } - /// - /// Instantiates a new ReturnRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public ReturnRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/education/me/assignments/{educationAssignment_id}/submissions/{educationSubmission_id}/microsoft.graph.return"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action return - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action return - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes educationSubmission - public class ReturnResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type educationSubmission - public EducationSubmission EducationSubmission { get; set; } - /// - /// Instantiates a new returnResponse and sets the default values. - /// - public ReturnResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"educationSubmission", (o,n) => { (o as ReturnResponse).EducationSubmission = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("educationSubmission", EducationSubmission); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Education/Me/Assignments/Item/Submissions/Item/EducationSubmissionRequestBuilder.cs b/src/generated/Education/Me/Assignments/Item/Submissions/Item/EducationSubmissionRequestBuilder.cs index d382b4cccf0..fd6dd5b559c 100644 --- a/src/generated/Education/Me/Assignments/Item/Submissions/Item/EducationSubmissionRequestBuilder.cs +++ b/src/generated/Education/Me/Assignments/Item/Submissions/Item/EducationSubmissionRequestBuilder.cs @@ -9,10 +9,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - command.SetHandler(async (string educationAssignmentId, string educationSubmissionId) => { + command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationAssignmentIdOption, educationSubmissionIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); @@ -76,25 +75,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationAssignmentIdOption, educationSubmissionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationAssignmentIdOption, educationSubmissionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOutcomesCommand() { var command = new Command("outcomes"); var builder = new ApiSdk.Education.Me.Assignments.Item.Submissions.Item.Outcomes.OutcomesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -106,11 +107,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); @@ -118,14 +119,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string body) => { + command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationAssignmentIdOption, educationSubmissionIdOption, bodyOption); return command; @@ -139,13 +139,16 @@ public Command BuildReassignCommand() { public Command BuildResourcesCommand() { var command = new Command("resources"); var builder = new ApiSdk.Education.Me.Assignments.Item.Submissions.Item.Resources.ResourcesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; } public Command BuildReturnCommand() { var command = new Command("return"); - var builder = new ApiSdk.Education.Me.Assignments.Item.Submissions.Item.@Return.ReturnRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Education.Me.Assignments.Item.Submissions.Item.Return.ReturnRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } @@ -164,6 +167,9 @@ public Command BuildSubmitCommand() { public Command BuildSubmittedResourcesCommand() { var command = new Command("submitted-resources"); var builder = new ApiSdk.Education.Me.Assignments.Item.Submissions.Item.SubmittedResources.SubmittedResourcesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -241,42 +247,6 @@ public RequestInformation CreatePatchRequestInformation(EducationSubmission body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationSubmission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Me/Assignments/Item/Submissions/Item/Outcomes/Item/EducationOutcomeRequestBuilder.cs b/src/generated/Education/Me/Assignments/Item/Submissions/Item/Outcomes/Item/EducationOutcomeRequestBuilder.cs index 46b6a8e67bc..7c9c49f12f4 100644 --- a/src/generated/Education/Me/Assignments/Item/Submissions/Item/Outcomes/Item/EducationOutcomeRequestBuilder.cs +++ b/src/generated/Education/Me/Assignments/Item/Submissions/Item/Outcomes/Item/EducationOutcomeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-Write. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - var educationOutcomeIdOption = new Option("--educationoutcome-id", description: "key: id of educationOutcome") { + var educationOutcomeIdOption = new Option("--education-outcome-id", description: "key: id of educationOutcome") { }; educationOutcomeIdOption.IsRequired = true; command.AddOption(educationOutcomeIdOption); - command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string educationOutcomeId) => { + command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string educationOutcomeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationAssignmentIdOption, educationSubmissionIdOption, educationOutcomeIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-Write. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - var educationOutcomeIdOption = new Option("--educationoutcome-id", description: "key: id of educationOutcome") { + var educationOutcomeIdOption = new Option("--education-outcome-id", description: "key: id of educationOutcome") { }; educationOutcomeIdOption.IsRequired = true; command.AddOption(educationOutcomeIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string educationOutcomeId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string educationOutcomeId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationAssignmentIdOption, educationSubmissionIdOption, educationOutcomeIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationAssignmentIdOption, educationSubmissionIdOption, educationOutcomeIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-Write. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - var educationOutcomeIdOption = new Option("--educationoutcome-id", description: "key: id of educationOutcome") { + var educationOutcomeIdOption = new Option("--education-outcome-id", description: "key: id of educationOutcome") { }; educationOutcomeIdOption.IsRequired = true; command.AddOption(educationOutcomeIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string educationOutcomeId, string body) => { + command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string educationOutcomeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationAssignmentIdOption, educationSubmissionIdOption, educationOutcomeIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(EducationOutcome body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-Write. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-Write. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-Write. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationOutcome model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-Write. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Me/Assignments/Item/Submissions/Item/Outcomes/OutcomesRequestBuilder.cs b/src/generated/Education/Me/Assignments/Item/Submissions/Item/Outcomes/OutcomesRequestBuilder.cs index 6b9cd966603..a4eec014c4d 100644 --- a/src/generated/Education/Me/Assignments/Item/Submissions/Item/Outcomes/OutcomesRequestBuilder.cs +++ b/src/generated/Education/Me/Assignments/Item/Submissions/Item/Outcomes/OutcomesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class OutcomesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EducationOutcomeRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,11 +35,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Read-Write. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationAssignmentIdOption, educationSubmissionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationAssignmentIdOption, educationSubmissionIdOption, bodyOption, outputOption); return command; } /// @@ -72,11 +70,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Read-Write. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationAssignmentIdOption, educationSubmissionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationAssignmentIdOption, educationSubmissionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(EducationOutcome body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-Write. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-Write. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EducationOutcome model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-Write. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Me/Assignments/Item/Submissions/Item/Reassign/ReassignRequestBuilder.cs b/src/generated/Education/Me/Assignments/Item/Submissions/Item/Reassign/ReassignRequestBuilder.cs index 12a1c18673f..b11fdca300b 100644 --- a/src/generated/Education/Me/Assignments/Item/Submissions/Item/Reassign/ReassignRequestBuilder.cs +++ b/src/generated/Education/Me/Assignments/Item/Submissions/Item/Reassign/ReassignRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action reassign"; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - command.SetHandler(async (string educationAssignmentId, string educationSubmissionId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationAssignmentIdOption, educationSubmissionIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationAssignmentIdOption, educationSubmissionIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action reassign - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes educationSubmission public class ReassignResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Education/Me/Assignments/Item/Submissions/Item/Resources/Item/EducationSubmissionResourceRequestBuilder.cs b/src/generated/Education/Me/Assignments/Item/Submissions/Item/Resources/Item/EducationSubmissionResourceRequestBuilder.cs index faa8a5fa40f..f64a615da5c 100644 --- a/src/generated/Education/Me/Assignments/Item/Submissions/Item/Resources/Item/EducationSubmissionResourceRequestBuilder.cs +++ b/src/generated/Education/Me/Assignments/Item/Submissions/Item/Resources/Item/EducationSubmissionResourceRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - var educationSubmissionResourceIdOption = new Option("--educationsubmissionresource-id", description: "key: id of educationSubmissionResource") { + var educationSubmissionResourceIdOption = new Option("--education-submission-resource-id", description: "key: id of educationSubmissionResource") { }; educationSubmissionResourceIdOption.IsRequired = true; command.AddOption(educationSubmissionResourceIdOption); - command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId) => { + command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationAssignmentIdOption, educationSubmissionIdOption, educationSubmissionResourceIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - var educationSubmissionResourceIdOption = new Option("--educationsubmissionresource-id", description: "key: id of educationSubmissionResource") { + var educationSubmissionResourceIdOption = new Option("--education-submission-resource-id", description: "key: id of educationSubmissionResource") { }; educationSubmissionResourceIdOption.IsRequired = true; command.AddOption(educationSubmissionResourceIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationAssignmentIdOption, educationSubmissionIdOption, educationSubmissionResourceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationAssignmentIdOption, educationSubmissionIdOption, educationSubmissionResourceIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - var educationSubmissionResourceIdOption = new Option("--educationsubmissionresource-id", description: "key: id of educationSubmissionResource") { + var educationSubmissionResourceIdOption = new Option("--education-submission-resource-id", description: "key: id of educationSubmissionResource") { }; educationSubmissionResourceIdOption.IsRequired = true; command.AddOption(educationSubmissionResourceIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, string body) => { + command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationAssignmentIdOption, educationSubmissionIdOption, educationSubmissionResourceIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(EducationSubmissionResou requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationSubmissionResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Me/Assignments/Item/Submissions/Item/Resources/ResourcesRequestBuilder.cs b/src/generated/Education/Me/Assignments/Item/Submissions/Item/Resources/ResourcesRequestBuilder.cs index f521d21a969..0af6e12298d 100644 --- a/src/generated/Education/Me/Assignments/Item/Submissions/Item/Resources/ResourcesRequestBuilder.cs +++ b/src/generated/Education/Me/Assignments/Item/Submissions/Item/Resources/ResourcesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ResourcesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EducationSubmissionResourceRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,11 +35,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationAssignmentIdOption, educationSubmissionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationAssignmentIdOption, educationSubmissionIdOption, bodyOption, outputOption); return command; } /// @@ -72,11 +70,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationAssignmentIdOption, educationSubmissionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationAssignmentIdOption, educationSubmissionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(EducationSubmissionResour requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EducationSubmissionResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Me/Assignments/Item/Submissions/Item/Return/ReturnRequestBuilder.cs b/src/generated/Education/Me/Assignments/Item/Submissions/Item/Return/ReturnRequestBuilder.cs new file mode 100644 index 00000000000..2532e2a247c --- /dev/null +++ b/src/generated/Education/Me/Assignments/Item/Submissions/Item/Return/ReturnRequestBuilder.cs @@ -0,0 +1,109 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Education.Me.Assignments.Item.Submissions.Item.Return { + /// Builds and executes requests for operations under \education\me\assignments\{educationAssignment-id}\submissions\{educationSubmission-id}\microsoft.graph.return + public class ReturnRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action return + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action return"; + // Create options for all the parameters + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { + }; + educationAssignmentIdOption.IsRequired = true; + command.AddOption(educationAssignmentIdOption); + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { + }; + educationSubmissionIdOption.IsRequired = true; + command.AddOption(educationSubmissionIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreatePostRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationAssignmentIdOption, educationSubmissionIdOption, outputOption); + return command; + } + /// + /// Instantiates a new ReturnRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public ReturnRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/education/me/assignments/{educationAssignment_id}/submissions/{educationSubmission_id}/microsoft.graph.return"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action return + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes educationSubmission + public class ReturnResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type educationSubmission + public EducationSubmission EducationSubmission { get; set; } + /// + /// Instantiates a new returnResponse and sets the default values. + /// + public ReturnResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"educationSubmission", (o,n) => { (o as ReturnResponse).EducationSubmission = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("educationSubmission", EducationSubmission); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Education/Me/Assignments/Item/Submissions/Item/SetUpResourcesFolder/SetUpResourcesFolderRequestBuilder.cs b/src/generated/Education/Me/Assignments/Item/Submissions/Item/SetUpResourcesFolder/SetUpResourcesFolderRequestBuilder.cs index 537ddf2d682..9be6d3f93f1 100644 --- a/src/generated/Education/Me/Assignments/Item/Submissions/Item/SetUpResourcesFolder/SetUpResourcesFolderRequestBuilder.cs +++ b/src/generated/Education/Me/Assignments/Item/Submissions/Item/SetUpResourcesFolder/SetUpResourcesFolderRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setUpResourcesFolder"; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - command.SetHandler(async (string educationAssignmentId, string educationSubmissionId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationAssignmentIdOption, educationSubmissionIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationAssignmentIdOption, educationSubmissionIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action setUpResourcesFolder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes educationSubmission public class SetUpResourcesFolderResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Education/Me/Assignments/Item/Submissions/Item/Submit/SubmitRequestBuilder.cs b/src/generated/Education/Me/Assignments/Item/Submissions/Item/Submit/SubmitRequestBuilder.cs index 4775d8db8b3..3da921ea4ac 100644 --- a/src/generated/Education/Me/Assignments/Item/Submissions/Item/Submit/SubmitRequestBuilder.cs +++ b/src/generated/Education/Me/Assignments/Item/Submissions/Item/Submit/SubmitRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action submit"; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - command.SetHandler(async (string educationAssignmentId, string educationSubmissionId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationAssignmentIdOption, educationSubmissionIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationAssignmentIdOption, educationSubmissionIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action submit - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes educationSubmission public class SubmitResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Education/Me/Assignments/Item/Submissions/Item/SubmittedResources/Item/EducationSubmissionResourceRequestBuilder.cs b/src/generated/Education/Me/Assignments/Item/Submissions/Item/SubmittedResources/Item/EducationSubmissionResourceRequestBuilder.cs index b748f53c2d5..9afc3482cd7 100644 --- a/src/generated/Education/Me/Assignments/Item/Submissions/Item/SubmittedResources/Item/EducationSubmissionResourceRequestBuilder.cs +++ b/src/generated/Education/Me/Assignments/Item/Submissions/Item/SubmittedResources/Item/EducationSubmissionResourceRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - var educationSubmissionResourceIdOption = new Option("--educationsubmissionresource-id", description: "key: id of educationSubmissionResource") { + var educationSubmissionResourceIdOption = new Option("--education-submission-resource-id", description: "key: id of educationSubmissionResource") { }; educationSubmissionResourceIdOption.IsRequired = true; command.AddOption(educationSubmissionResourceIdOption); - command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId) => { + command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationAssignmentIdOption, educationSubmissionIdOption, educationSubmissionResourceIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - var educationSubmissionResourceIdOption = new Option("--educationsubmissionresource-id", description: "key: id of educationSubmissionResource") { + var educationSubmissionResourceIdOption = new Option("--education-submission-resource-id", description: "key: id of educationSubmissionResource") { }; educationSubmissionResourceIdOption.IsRequired = true; command.AddOption(educationSubmissionResourceIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationAssignmentIdOption, educationSubmissionIdOption, educationSubmissionResourceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationAssignmentIdOption, educationSubmissionIdOption, educationSubmissionResourceIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - var educationSubmissionResourceIdOption = new Option("--educationsubmissionresource-id", description: "key: id of educationSubmissionResource") { + var educationSubmissionResourceIdOption = new Option("--education-submission-resource-id", description: "key: id of educationSubmissionResource") { }; educationSubmissionResourceIdOption.IsRequired = true; command.AddOption(educationSubmissionResourceIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, string body) => { + command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationAssignmentIdOption, educationSubmissionIdOption, educationSubmissionResourceIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(EducationSubmissionResou requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationSubmissionResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Me/Assignments/Item/Submissions/Item/SubmittedResources/SubmittedResourcesRequestBuilder.cs b/src/generated/Education/Me/Assignments/Item/Submissions/Item/SubmittedResources/SubmittedResourcesRequestBuilder.cs index 392062e461f..8b4bc9398bb 100644 --- a/src/generated/Education/Me/Assignments/Item/Submissions/Item/SubmittedResources/SubmittedResourcesRequestBuilder.cs +++ b/src/generated/Education/Me/Assignments/Item/Submissions/Item/SubmittedResources/SubmittedResourcesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SubmittedResourcesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EducationSubmissionResourceRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,11 +35,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationAssignmentIdOption, educationSubmissionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationAssignmentIdOption, educationSubmissionIdOption, bodyOption, outputOption); return command; } /// @@ -72,11 +70,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationAssignmentIdOption, educationSubmissionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationAssignmentIdOption, educationSubmissionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(EducationSubmissionResour requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EducationSubmissionResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Me/Assignments/Item/Submissions/Item/Unsubmit/UnsubmitRequestBuilder.cs b/src/generated/Education/Me/Assignments/Item/Submissions/Item/Unsubmit/UnsubmitRequestBuilder.cs index 92e53a939f0..2dfa3efc0d7 100644 --- a/src/generated/Education/Me/Assignments/Item/Submissions/Item/Unsubmit/UnsubmitRequestBuilder.cs +++ b/src/generated/Education/Me/Assignments/Item/Submissions/Item/Unsubmit/UnsubmitRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action unsubmit"; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - command.SetHandler(async (string educationAssignmentId, string educationSubmissionId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationAssignmentId, string educationSubmissionId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationAssignmentIdOption, educationSubmissionIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationAssignmentIdOption, educationSubmissionIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action unsubmit - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes educationSubmission public class UnsubmitResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Education/Me/Assignments/Item/Submissions/SubmissionsRequestBuilder.cs b/src/generated/Education/Me/Assignments/Item/Submissions/SubmissionsRequestBuilder.cs index 67211cc499f..6454eda455e 100644 --- a/src/generated/Education/Me/Assignments/Item/Submissions/SubmissionsRequestBuilder.cs +++ b/src/generated/Education/Me/Assignments/Item/Submissions/SubmissionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,19 +22,18 @@ public class SubmissionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EducationSubmissionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOutcomesCommand(), - builder.BuildPatchCommand(), - builder.BuildReassignCommand(), - builder.BuildResourcesCommand(), - builder.BuildReturnCommand(), - builder.BuildSetUpResourcesFolderCommand(), - builder.BuildSubmitCommand(), - builder.BuildSubmittedResourcesCommand(), - builder.BuildUnsubmitCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOutcomesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildReassignCommand()); + commands.Add(builder.BuildResourcesCommand()); + commands.Add(builder.BuildReturnCommand()); + commands.Add(builder.BuildSetUpResourcesFolderCommand()); + commands.Add(builder.BuildSubmitCommand()); + commands.Add(builder.BuildSubmittedResourcesCommand()); + commands.Add(builder.BuildUnsubmitCommand()); return commands; } /// @@ -44,7 +43,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationAssignmentId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationAssignmentId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationAssignmentIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationAssignmentIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable."; // Create options for all the parameters - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationAssignmentId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationAssignmentId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationAssignmentIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationAssignmentIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(EducationSubmission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EducationSubmission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Me/Classes/@Ref/@Ref.cs b/src/generated/Education/Me/Classes/@Ref/@Ref.cs deleted file mode 100644 index 020a3caa5b8..00000000000 --- a/src/generated/Education/Me/Classes/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Education.Me.Classes.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Education/Me/Classes/@Ref/RefRequestBuilder.cs b/src/generated/Education/Me/Classes/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 07f7b83c305..00000000000 --- a/src/generated/Education/Me/Classes/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,194 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Education.Me.Classes.@Ref { - /// Builds and executes requests for operations under \education\me\classes\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Classes to which the user belongs. Nullable. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Classes to which the user belongs. Nullable."; - // Create options for all the parameters - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Classes to which the user belongs. Nullable. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Classes to which the user belongs. Nullable."; - // Create options for all the parameters - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/education/me/classes/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Classes to which the user belongs. Nullable. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Classes to which the user belongs. Nullable. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Education.Me.Classes.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Classes to which the user belongs. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Classes to which the user belongs. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Education.Me.Classes.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Classes to which the user belongs. Nullable. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Education/Me/Classes/@Ref/RefResponse.cs b/src/generated/Education/Me/Classes/@Ref/RefResponse.cs deleted file mode 100644 index 2a3077799a9..00000000000 --- a/src/generated/Education/Me/Classes/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Education.Me.Classes.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Education/Me/Classes/ClassesRequestBuilder.cs b/src/generated/Education/Me/Classes/ClassesRequestBuilder.cs index 075a3267254..e4ebb8c1fe7 100644 --- a/src/generated/Education/Me/Classes/ClassesRequestBuilder.cs +++ b/src/generated/Education/Me/Classes/ClassesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Education.Me.Classes.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -62,7 +62,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -73,20 +77,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Education.Me.Classes.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Education.Me.Classes.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -131,18 +130,6 @@ public RequestInformation CreateGetRequestInformation(Action public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// Classes to which the user belongs. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Classes to which the user belongs. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Me/Classes/Delta/DeltaRequestBuilder.cs b/src/generated/Education/Me/Classes/Delta/DeltaRequestBuilder.cs index f51abf42b17..c939d7bc03c 100644 --- a/src/generated/Education/Me/Classes/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Education/Me/Classes/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Education/Me/Classes/Ref/Ref.cs b/src/generated/Education/Me/Classes/Ref/Ref.cs new file mode 100644 index 00000000000..139fa34aa3e --- /dev/null +++ b/src/generated/Education/Me/Classes/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Education.Me.Classes.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Education/Me/Classes/Ref/RefRequestBuilder.cs b/src/generated/Education/Me/Classes/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..607a759835c --- /dev/null +++ b/src/generated/Education/Me/Classes/Ref/RefRequestBuilder.cs @@ -0,0 +1,167 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Education.Me.Classes.Ref { + /// Builds and executes requests for operations under \education\me\classes\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Classes to which the user belongs. Nullable. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Classes to which the user belongs. Nullable."; + // Create options for all the parameters + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Classes to which the user belongs. Nullable. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Classes to which the user belongs. Nullable."; + // Create options for all the parameters + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/education/me/classes/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Classes to which the user belongs. Nullable. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Classes to which the user belongs. Nullable. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Education.Me.Classes.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Classes to which the user belongs. Nullable. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Education/Me/Classes/Ref/RefResponse.cs b/src/generated/Education/Me/Classes/Ref/RefResponse.cs new file mode 100644 index 00000000000..416ea9e1a82 --- /dev/null +++ b/src/generated/Education/Me/Classes/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Education.Me.Classes.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Education/Me/MeRequestBuilder.cs b/src/generated/Education/Me/MeRequestBuilder.cs index 12cfd9d0d5a..44095988ccc 100644 --- a/src/generated/Education/Me/MeRequestBuilder.cs +++ b/src/generated/Education/Me/MeRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,6 +28,9 @@ public class MeRequestBuilder { public Command BuildAssignmentsCommand() { var command = new Command("assignments"); var builder = new ApiSdk.Education.Me.Assignments.AssignmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -46,11 +49,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property me for education"; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -72,20 +74,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -99,14 +100,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -114,6 +114,9 @@ public Command BuildPatchCommand() { public Command BuildRubricsCommand() { var command = new Command("rubrics"); var builder = new ApiSdk.Education.Me.Rubrics.RubricsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -206,42 +209,6 @@ public RequestInformation CreatePatchRequestInformation(EducationUser body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property me for education - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get me from education - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property me in education - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationUser model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get me from education public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Me/Rubrics/Item/EducationRubricRequestBuilder.cs b/src/generated/Education/Me/Rubrics/Item/EducationRubricRequestBuilder.cs index ffc10010199..a9839db2290 100644 --- a/src/generated/Education/Me/Rubrics/Item/EducationRubricRequestBuilder.cs +++ b/src/generated/Education/Me/Rubrics/Item/EducationRubricRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property rubrics for education"; // Create options for all the parameters - var educationRubricIdOption = new Option("--educationrubric-id", description: "key: id of educationRubric") { + var educationRubricIdOption = new Option("--education-rubric-id", description: "key: id of educationRubric") { }; educationRubricIdOption.IsRequired = true; command.AddOption(educationRubricIdOption); - command.SetHandler(async (string educationRubricId) => { + command.SetHandler(async (string educationRubricId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationRubricIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get rubrics from education"; // Create options for all the parameters - var educationRubricIdOption = new Option("--educationrubric-id", description: "key: id of educationRubric") { + var educationRubricIdOption = new Option("--education-rubric-id", description: "key: id of educationRubric") { }; educationRubricIdOption.IsRequired = true; command.AddOption(educationRubricIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationRubricId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationRubricId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationRubricIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationRubricIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property rubrics in education"; // Create options for all the parameters - var educationRubricIdOption = new Option("--educationrubric-id", description: "key: id of educationRubric") { + var educationRubricIdOption = new Option("--education-rubric-id", description: "key: id of educationRubric") { }; educationRubricIdOption.IsRequired = true; command.AddOption(educationRubricIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationRubricId, string body) => { + command.SetHandler(async (string educationRubricId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationRubricIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(EducationRubric body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property rubrics for education - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get rubrics from education - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property rubrics in education - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationRubric model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get rubrics from education public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Me/Rubrics/RubricsRequestBuilder.cs b/src/generated/Education/Me/Rubrics/RubricsRequestBuilder.cs index 1874bb6d130..fea694f24e3 100644 --- a/src/generated/Education/Me/Rubrics/RubricsRequestBuilder.cs +++ b/src/generated/Education/Me/Rubrics/RubricsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class RubricsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EducationRubricRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(EducationRubric body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get rubrics from education - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to rubrics for education - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EducationRubric model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get rubrics from education public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Me/Schools/@Ref/@Ref.cs b/src/generated/Education/Me/Schools/@Ref/@Ref.cs deleted file mode 100644 index 6786a1c394b..00000000000 --- a/src/generated/Education/Me/Schools/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Education.Me.Schools.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Education/Me/Schools/@Ref/RefRequestBuilder.cs b/src/generated/Education/Me/Schools/@Ref/RefRequestBuilder.cs deleted file mode 100644 index d9e5eaa71a7..00000000000 --- a/src/generated/Education/Me/Schools/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,194 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Education.Me.Schools.@Ref { - /// Builds and executes requests for operations under \education\me\schools\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Schools to which the user belongs. Nullable. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Schools to which the user belongs. Nullable."; - // Create options for all the parameters - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Schools to which the user belongs. Nullable. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Schools to which the user belongs. Nullable."; - // Create options for all the parameters - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/education/me/schools/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Schools to which the user belongs. Nullable. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Schools to which the user belongs. Nullable. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Education.Me.Schools.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Schools to which the user belongs. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Schools to which the user belongs. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Education.Me.Schools.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Schools to which the user belongs. Nullable. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Education/Me/Schools/@Ref/RefResponse.cs b/src/generated/Education/Me/Schools/@Ref/RefResponse.cs deleted file mode 100644 index 7423ffa6cbc..00000000000 --- a/src/generated/Education/Me/Schools/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Education.Me.Schools.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Education/Me/Schools/Delta/DeltaRequestBuilder.cs b/src/generated/Education/Me/Schools/Delta/DeltaRequestBuilder.cs index 5c0d3de094d..762e49acc7c 100644 --- a/src/generated/Education/Me/Schools/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Education/Me/Schools/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Education/Me/Schools/Ref/Ref.cs b/src/generated/Education/Me/Schools/Ref/Ref.cs new file mode 100644 index 00000000000..1d437097ba1 --- /dev/null +++ b/src/generated/Education/Me/Schools/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Education.Me.Schools.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Education/Me/Schools/Ref/RefRequestBuilder.cs b/src/generated/Education/Me/Schools/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..3aee266d6be --- /dev/null +++ b/src/generated/Education/Me/Schools/Ref/RefRequestBuilder.cs @@ -0,0 +1,167 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Education.Me.Schools.Ref { + /// Builds and executes requests for operations under \education\me\schools\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Schools to which the user belongs. Nullable. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Schools to which the user belongs. Nullable."; + // Create options for all the parameters + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Schools to which the user belongs. Nullable. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Schools to which the user belongs. Nullable."; + // Create options for all the parameters + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/education/me/schools/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Schools to which the user belongs. Nullable. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Schools to which the user belongs. Nullable. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Education.Me.Schools.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Schools to which the user belongs. Nullable. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Education/Me/Schools/Ref/RefResponse.cs b/src/generated/Education/Me/Schools/Ref/RefResponse.cs new file mode 100644 index 00000000000..6b432abf3e3 --- /dev/null +++ b/src/generated/Education/Me/Schools/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Education.Me.Schools.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Education/Me/Schools/SchoolsRequestBuilder.cs b/src/generated/Education/Me/Schools/SchoolsRequestBuilder.cs index 54fb312e08c..2020dc7ee6d 100644 --- a/src/generated/Education/Me/Schools/SchoolsRequestBuilder.cs +++ b/src/generated/Education/Me/Schools/SchoolsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Education.Me.Schools.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -62,7 +62,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -73,20 +77,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Education.Me.Schools.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Education.Me.Schools.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -131,18 +130,6 @@ public RequestInformation CreateGetRequestInformation(Action public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// Schools to which the user belongs. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Schools to which the user belongs. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Me/TaughtClasses/@Ref/@Ref.cs b/src/generated/Education/Me/TaughtClasses/@Ref/@Ref.cs deleted file mode 100644 index 18ce88644bc..00000000000 --- a/src/generated/Education/Me/TaughtClasses/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Education.Me.TaughtClasses.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Education/Me/TaughtClasses/@Ref/RefRequestBuilder.cs b/src/generated/Education/Me/TaughtClasses/@Ref/RefRequestBuilder.cs deleted file mode 100644 index a829dae1c91..00000000000 --- a/src/generated/Education/Me/TaughtClasses/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,194 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Education.Me.TaughtClasses.@Ref { - /// Builds and executes requests for operations under \education\me\taughtClasses\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Classes for which the user is a teacher. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Classes for which the user is a teacher."; - // Create options for all the parameters - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Classes for which the user is a teacher. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Classes for which the user is a teacher."; - // Create options for all the parameters - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/education/me/taughtClasses/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Classes for which the user is a teacher. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Classes for which the user is a teacher. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Education.Me.TaughtClasses.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Classes for which the user is a teacher. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Classes for which the user is a teacher. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Education.Me.TaughtClasses.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Classes for which the user is a teacher. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Education/Me/TaughtClasses/@Ref/RefResponse.cs b/src/generated/Education/Me/TaughtClasses/@Ref/RefResponse.cs deleted file mode 100644 index f5ee05d7330..00000000000 --- a/src/generated/Education/Me/TaughtClasses/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Education.Me.TaughtClasses.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Education/Me/TaughtClasses/Delta/DeltaRequestBuilder.cs b/src/generated/Education/Me/TaughtClasses/Delta/DeltaRequestBuilder.cs index 9b8c162609e..c24f74ad794 100644 --- a/src/generated/Education/Me/TaughtClasses/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Education/Me/TaughtClasses/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Education/Me/TaughtClasses/Ref/Ref.cs b/src/generated/Education/Me/TaughtClasses/Ref/Ref.cs new file mode 100644 index 00000000000..6237072d319 --- /dev/null +++ b/src/generated/Education/Me/TaughtClasses/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Education.Me.TaughtClasses.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Education/Me/TaughtClasses/Ref/RefRequestBuilder.cs b/src/generated/Education/Me/TaughtClasses/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..9a215b5dab8 --- /dev/null +++ b/src/generated/Education/Me/TaughtClasses/Ref/RefRequestBuilder.cs @@ -0,0 +1,167 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Education.Me.TaughtClasses.Ref { + /// Builds and executes requests for operations under \education\me\taughtClasses\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Classes for which the user is a teacher. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Classes for which the user is a teacher."; + // Create options for all the parameters + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Classes for which the user is a teacher. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Classes for which the user is a teacher."; + // Create options for all the parameters + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/education/me/taughtClasses/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Classes for which the user is a teacher. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Classes for which the user is a teacher. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Education.Me.TaughtClasses.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Classes for which the user is a teacher. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Education/Me/TaughtClasses/Ref/RefResponse.cs b/src/generated/Education/Me/TaughtClasses/Ref/RefResponse.cs new file mode 100644 index 00000000000..b051a5c923f --- /dev/null +++ b/src/generated/Education/Me/TaughtClasses/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Education.Me.TaughtClasses.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Education/Me/TaughtClasses/TaughtClassesRequestBuilder.cs b/src/generated/Education/Me/TaughtClasses/TaughtClassesRequestBuilder.cs index 2d4d63ee868..d92a6c3d1cf 100644 --- a/src/generated/Education/Me/TaughtClasses/TaughtClassesRequestBuilder.cs +++ b/src/generated/Education/Me/TaughtClasses/TaughtClassesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Education.Me.TaughtClasses.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -62,7 +62,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -73,20 +77,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Education.Me.TaughtClasses.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Education.Me.TaughtClasses.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -131,18 +130,6 @@ public RequestInformation CreateGetRequestInformation(Action public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// Classes for which the user is a teacher. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Classes for which the user is a teacher. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Me/User/@Ref/@Ref.cs b/src/generated/Education/Me/User/@Ref/@Ref.cs deleted file mode 100644 index c0d4426ed8d..00000000000 --- a/src/generated/Education/Me/User/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Education.Me.User.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Education/Me/User/@Ref/RefRequestBuilder.cs b/src/generated/Education/Me/User/@Ref/RefRequestBuilder.cs deleted file mode 100644 index c017172703f..00000000000 --- a/src/generated/Education/Me/User/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,178 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Education.Me.User.@Ref { - /// Builds and executes requests for operations under \education\me\user\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The directory user corresponding to this user. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The directory user corresponding to this user."; - // Create options for all the parameters - command.SetHandler(async () => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }); - return command; - } - /// - /// The directory user corresponding to this user. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The directory user corresponding to this user."; - // Create options for all the parameters - command.SetHandler(async () => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); - return command; - } - /// - /// The directory user corresponding to this user. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The directory user corresponding to this user."; - // Create options for all the parameters - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/education/me/user/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The directory user corresponding to this user. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The directory user corresponding to this user. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The directory user corresponding to this user. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Education.Me.User.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The directory user corresponding to this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The directory user corresponding to this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The directory user corresponding to this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Education.Me.User.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Education/Me/User/Ref/Ref.cs b/src/generated/Education/Me/User/Ref/Ref.cs new file mode 100644 index 00000000000..016aa72a2a2 --- /dev/null +++ b/src/generated/Education/Me/User/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Education.Me.User.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Education/Me/User/Ref/RefRequestBuilder.cs b/src/generated/Education/Me/User/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..7850eb8fde1 --- /dev/null +++ b/src/generated/Education/Me/User/Ref/RefRequestBuilder.cs @@ -0,0 +1,140 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Education.Me.User.Ref { + /// Builds and executes requests for operations under \education\me\user\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The directory user corresponding to this user. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The directory user corresponding to this user."; + // Create options for all the parameters + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }); + return command; + } + /// + /// The directory user corresponding to this user. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The directory user corresponding to this user."; + // Create options for all the parameters + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); + return command; + } + /// + /// The directory user corresponding to this user. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The directory user corresponding to this user."; + // Create options for all the parameters + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/education/me/user/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The directory user corresponding to this user. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The directory user corresponding to this user. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The directory user corresponding to this user. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Education.Me.User.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Education/Me/User/UserRequestBuilder.cs b/src/generated/Education/Me/User/UserRequestBuilder.cs index 14ac53a2b1d..54446f1b579 100644 --- a/src/generated/Education/Me/User/UserRequestBuilder.cs +++ b/src/generated/Education/Me/User/UserRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,25 +37,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Education.Me.User.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Education.Me.User.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -95,18 +94,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The directory user corresponding to this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The directory user corresponding to this user. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Schools/Delta/DeltaRequestBuilder.cs b/src/generated/Education/Schools/Delta/DeltaRequestBuilder.cs index b1a761b690c..d68672bd29d 100644 --- a/src/generated/Education/Schools/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Education/Schools/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Education/Schools/Item/AdministrativeUnit/@Ref/@Ref.cs b/src/generated/Education/Schools/Item/AdministrativeUnit/@Ref/@Ref.cs deleted file mode 100644 index f40de7369ea..00000000000 --- a/src/generated/Education/Schools/Item/AdministrativeUnit/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Education.Schools.Item.AdministrativeUnit.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Education/Schools/Item/AdministrativeUnit/@Ref/RefRequestBuilder.cs b/src/generated/Education/Schools/Item/AdministrativeUnit/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 5f7e4c953af..00000000000 --- a/src/generated/Education/Schools/Item/AdministrativeUnit/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Education.Schools.Item.AdministrativeUnit.@Ref { - /// Builds and executes requests for operations under \education\schools\{educationSchool-id}\administrativeUnit\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The underlying administrativeUnit for this school. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The underlying administrativeUnit for this school."; - // Create options for all the parameters - var educationSchoolIdOption = new Option("--educationschool-id", description: "key: id of educationSchool") { - }; - educationSchoolIdOption.IsRequired = true; - command.AddOption(educationSchoolIdOption); - command.SetHandler(async (string educationSchoolId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, educationSchoolIdOption); - return command; - } - /// - /// The underlying administrativeUnit for this school. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The underlying administrativeUnit for this school."; - // Create options for all the parameters - var educationSchoolIdOption = new Option("--educationschool-id", description: "key: id of educationSchool") { - }; - educationSchoolIdOption.IsRequired = true; - command.AddOption(educationSchoolIdOption); - command.SetHandler(async (string educationSchoolId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationSchoolIdOption); - return command; - } - /// - /// The underlying administrativeUnit for this school. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The underlying administrativeUnit for this school."; - // Create options for all the parameters - var educationSchoolIdOption = new Option("--educationschool-id", description: "key: id of educationSchool") { - }; - educationSchoolIdOption.IsRequired = true; - command.AddOption(educationSchoolIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string educationSchoolId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, educationSchoolIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/education/schools/{educationSchool_id}/administrativeUnit/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The underlying administrativeUnit for this school. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The underlying administrativeUnit for this school. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The underlying administrativeUnit for this school. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Education.Schools.Item.AdministrativeUnit.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The underlying administrativeUnit for this school. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The underlying administrativeUnit for this school. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The underlying administrativeUnit for this school. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Education.Schools.Item.AdministrativeUnit.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Education/Schools/Item/AdministrativeUnit/AdministrativeUnitRequestBuilder.cs b/src/generated/Education/Schools/Item/AdministrativeUnit/AdministrativeUnitRequestBuilder.cs index 6cf6e6b760c..32e93979ae8 100644 --- a/src/generated/Education/Schools/Item/AdministrativeUnit/AdministrativeUnitRequestBuilder.cs +++ b/src/generated/Education/Schools/Item/AdministrativeUnit/AdministrativeUnitRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The underlying administrativeUnit for this school."; // Create options for all the parameters - var educationSchoolIdOption = new Option("--educationschool-id", description: "key: id of educationSchool") { + var educationSchoolIdOption = new Option("--education-school-id", description: "key: id of educationSchool") { }; educationSchoolIdOption.IsRequired = true; command.AddOption(educationSchoolIdOption); @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationSchoolId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationSchoolId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationSchoolIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationSchoolIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Education.Schools.Item.AdministrativeUnit.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Education.Schools.Item.AdministrativeUnit.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The underlying administrativeUnit for this school. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The underlying administrativeUnit for this school. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Schools/Item/AdministrativeUnit/Ref/Ref.cs b/src/generated/Education/Schools/Item/AdministrativeUnit/Ref/Ref.cs new file mode 100644 index 00000000000..cedd2ee7305 --- /dev/null +++ b/src/generated/Education/Schools/Item/AdministrativeUnit/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Education.Schools.Item.AdministrativeUnit.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Education/Schools/Item/AdministrativeUnit/Ref/RefRequestBuilder.cs b/src/generated/Education/Schools/Item/AdministrativeUnit/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..aed9a621b5b --- /dev/null +++ b/src/generated/Education/Schools/Item/AdministrativeUnit/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Education.Schools.Item.AdministrativeUnit.Ref { + /// Builds and executes requests for operations under \education\schools\{educationSchool-id}\administrativeUnit\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The underlying administrativeUnit for this school. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The underlying administrativeUnit for this school."; + // Create options for all the parameters + var educationSchoolIdOption = new Option("--education-school-id", description: "key: id of educationSchool") { + }; + educationSchoolIdOption.IsRequired = true; + command.AddOption(educationSchoolIdOption); + command.SetHandler(async (string educationSchoolId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, educationSchoolIdOption); + return command; + } + /// + /// The underlying administrativeUnit for this school. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The underlying administrativeUnit for this school."; + // Create options for all the parameters + var educationSchoolIdOption = new Option("--education-school-id", description: "key: id of educationSchool") { + }; + educationSchoolIdOption.IsRequired = true; + command.AddOption(educationSchoolIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationSchoolId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationSchoolIdOption, outputOption); + return command; + } + /// + /// The underlying administrativeUnit for this school. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The underlying administrativeUnit for this school."; + // Create options for all the parameters + var educationSchoolIdOption = new Option("--education-school-id", description: "key: id of educationSchool") { + }; + educationSchoolIdOption.IsRequired = true; + command.AddOption(educationSchoolIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string educationSchoolId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, educationSchoolIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/education/schools/{educationSchool_id}/administrativeUnit/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The underlying administrativeUnit for this school. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The underlying administrativeUnit for this school. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The underlying administrativeUnit for this school. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Education.Schools.Item.AdministrativeUnit.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Education/Schools/Item/Classes/@Ref/@Ref.cs b/src/generated/Education/Schools/Item/Classes/@Ref/@Ref.cs deleted file mode 100644 index 19d63e5a070..00000000000 --- a/src/generated/Education/Schools/Item/Classes/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Education.Schools.Item.Classes.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Education/Schools/Item/Classes/@Ref/RefRequestBuilder.cs b/src/generated/Education/Schools/Item/Classes/@Ref/RefRequestBuilder.cs deleted file mode 100644 index ae7653b3b3b..00000000000 --- a/src/generated/Education/Schools/Item/Classes/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Education.Schools.Item.Classes.@Ref { - /// Builds and executes requests for operations under \education\schools\{educationSchool-id}\classes\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Classes taught at the school. Nullable. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Classes taught at the school. Nullable."; - // Create options for all the parameters - var educationSchoolIdOption = new Option("--educationschool-id", description: "key: id of educationSchool") { - }; - educationSchoolIdOption.IsRequired = true; - command.AddOption(educationSchoolIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string educationSchoolId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationSchoolIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Classes taught at the school. Nullable. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Classes taught at the school. Nullable."; - // Create options for all the parameters - var educationSchoolIdOption = new Option("--educationschool-id", description: "key: id of educationSchool") { - }; - educationSchoolIdOption.IsRequired = true; - command.AddOption(educationSchoolIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string educationSchoolId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationSchoolIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/education/schools/{educationSchool_id}/classes/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Classes taught at the school. Nullable. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Classes taught at the school. Nullable. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Education.Schools.Item.Classes.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Classes taught at the school. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Classes taught at the school. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Education.Schools.Item.Classes.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Classes taught at the school. Nullable. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Education/Schools/Item/Classes/@Ref/RefResponse.cs b/src/generated/Education/Schools/Item/Classes/@Ref/RefResponse.cs deleted file mode 100644 index a683d8e0ada..00000000000 --- a/src/generated/Education/Schools/Item/Classes/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Education.Schools.Item.Classes.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Education/Schools/Item/Classes/ClassesRequestBuilder.cs b/src/generated/Education/Schools/Item/Classes/ClassesRequestBuilder.cs index db9e4419c3b..cdc3bede959 100644 --- a/src/generated/Education/Schools/Item/Classes/ClassesRequestBuilder.cs +++ b/src/generated/Education/Schools/Item/Classes/ClassesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Education.Schools.Item.Classes.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Classes taught at the school. Nullable."; // Create options for all the parameters - var educationSchoolIdOption = new Option("--educationschool-id", description: "key: id of educationSchool") { + var educationSchoolIdOption = new Option("--education-school-id", description: "key: id of educationSchool") { }; educationSchoolIdOption.IsRequired = true; command.AddOption(educationSchoolIdOption); @@ -66,7 +66,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationSchoolId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationSchoolId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -77,20 +81,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationSchoolIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationSchoolIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Education.Schools.Item.Classes.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Education.Schools.Item.Classes.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -135,18 +134,6 @@ public RequestInformation CreateGetRequestInformation(Action public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// Classes taught at the school. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Classes taught at the school. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Schools/Item/Classes/Delta/DeltaRequestBuilder.cs b/src/generated/Education/Schools/Item/Classes/Delta/DeltaRequestBuilder.cs index ab2e698fab6..535d663aa9c 100644 --- a/src/generated/Education/Schools/Item/Classes/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Education/Schools/Item/Classes/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,22 +25,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - var educationSchoolIdOption = new Option("--educationschool-id", description: "key: id of educationSchool") { + var educationSchoolIdOption = new Option("--education-school-id", description: "key: id of educationSchool") { }; educationSchoolIdOption.IsRequired = true; command.AddOption(educationSchoolIdOption); - command.SetHandler(async (string educationSchoolId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationSchoolId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationSchoolIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationSchoolIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Education/Schools/Item/Classes/Ref/Ref.cs b/src/generated/Education/Schools/Item/Classes/Ref/Ref.cs new file mode 100644 index 00000000000..1fe5500987d --- /dev/null +++ b/src/generated/Education/Schools/Item/Classes/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Education.Schools.Item.Classes.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Education/Schools/Item/Classes/Ref/RefRequestBuilder.cs b/src/generated/Education/Schools/Item/Classes/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..fcd40c3e6cc --- /dev/null +++ b/src/generated/Education/Schools/Item/Classes/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Education.Schools.Item.Classes.Ref { + /// Builds and executes requests for operations under \education\schools\{educationSchool-id}\classes\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Classes taught at the school. Nullable. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Classes taught at the school. Nullable."; + // Create options for all the parameters + var educationSchoolIdOption = new Option("--education-school-id", description: "key: id of educationSchool") { + }; + educationSchoolIdOption.IsRequired = true; + command.AddOption(educationSchoolIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationSchoolId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationSchoolIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Classes taught at the school. Nullable. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Classes taught at the school. Nullable."; + // Create options for all the parameters + var educationSchoolIdOption = new Option("--education-school-id", description: "key: id of educationSchool") { + }; + educationSchoolIdOption.IsRequired = true; + command.AddOption(educationSchoolIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationSchoolId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationSchoolIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/education/schools/{educationSchool_id}/classes/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Classes taught at the school. Nullable. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Classes taught at the school. Nullable. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Education.Schools.Item.Classes.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Classes taught at the school. Nullable. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Education/Schools/Item/Classes/Ref/RefResponse.cs b/src/generated/Education/Schools/Item/Classes/Ref/RefResponse.cs new file mode 100644 index 00000000000..b7b43406bbb --- /dev/null +++ b/src/generated/Education/Schools/Item/Classes/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Education.Schools.Item.Classes.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Education/Schools/Item/EducationSchoolRequestBuilder.cs b/src/generated/Education/Schools/Item/EducationSchoolRequestBuilder.cs index e58c4fd73ba..2d0259a0f8c 100644 --- a/src/generated/Education/Schools/Item/EducationSchoolRequestBuilder.cs +++ b/src/generated/Education/Schools/Item/EducationSchoolRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -43,15 +43,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property schools for education"; // Create options for all the parameters - var educationSchoolIdOption = new Option("--educationschool-id", description: "key: id of educationSchool") { + var educationSchoolIdOption = new Option("--education-school-id", description: "key: id of educationSchool") { }; educationSchoolIdOption.IsRequired = true; command.AddOption(educationSchoolIdOption); - command.SetHandler(async (string educationSchoolId) => { + command.SetHandler(async (string educationSchoolId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationSchoolIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get schools from education"; // Create options for all the parameters - var educationSchoolIdOption = new Option("--educationschool-id", description: "key: id of educationSchool") { + var educationSchoolIdOption = new Option("--education-school-id", description: "key: id of educationSchool") { }; educationSchoolIdOption.IsRequired = true; command.AddOption(educationSchoolIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationSchoolId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationSchoolId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationSchoolIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationSchoolIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -100,7 +98,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property schools in education"; // Create options for all the parameters - var educationSchoolIdOption = new Option("--educationschool-id", description: "key: id of educationSchool") { + var educationSchoolIdOption = new Option("--education-school-id", description: "key: id of educationSchool") { }; educationSchoolIdOption.IsRequired = true; command.AddOption(educationSchoolIdOption); @@ -108,14 +106,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationSchoolId, string body) => { + command.SetHandler(async (string educationSchoolId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationSchoolIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(EducationSchool body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property schools for education - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get schools from education - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property schools in education - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationSchool model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get schools from education public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Schools/Item/Users/@Ref/@Ref.cs b/src/generated/Education/Schools/Item/Users/@Ref/@Ref.cs deleted file mode 100644 index 34653ab49ea..00000000000 --- a/src/generated/Education/Schools/Item/Users/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Education.Schools.Item.Users.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Education/Schools/Item/Users/@Ref/RefRequestBuilder.cs b/src/generated/Education/Schools/Item/Users/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 654999bb098..00000000000 --- a/src/generated/Education/Schools/Item/Users/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Education.Schools.Item.Users.@Ref { - /// Builds and executes requests for operations under \education\schools\{educationSchool-id}\users\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Users in the school. Nullable. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Users in the school. Nullable."; - // Create options for all the parameters - var educationSchoolIdOption = new Option("--educationschool-id", description: "key: id of educationSchool") { - }; - educationSchoolIdOption.IsRequired = true; - command.AddOption(educationSchoolIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string educationSchoolId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationSchoolIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Users in the school. Nullable. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Users in the school. Nullable."; - // Create options for all the parameters - var educationSchoolIdOption = new Option("--educationschool-id", description: "key: id of educationSchool") { - }; - educationSchoolIdOption.IsRequired = true; - command.AddOption(educationSchoolIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string educationSchoolId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationSchoolIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/education/schools/{educationSchool_id}/users/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Users in the school. Nullable. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Users in the school. Nullable. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Education.Schools.Item.Users.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Users in the school. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Users in the school. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Education.Schools.Item.Users.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Users in the school. Nullable. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Education/Schools/Item/Users/@Ref/RefResponse.cs b/src/generated/Education/Schools/Item/Users/@Ref/RefResponse.cs deleted file mode 100644 index 851ad138a69..00000000000 --- a/src/generated/Education/Schools/Item/Users/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Education.Schools.Item.Users.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Education/Schools/Item/Users/Delta/DeltaRequestBuilder.cs b/src/generated/Education/Schools/Item/Users/Delta/DeltaRequestBuilder.cs index 98fec0bd698..3c2c0307c17 100644 --- a/src/generated/Education/Schools/Item/Users/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Education/Schools/Item/Users/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,22 +25,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - var educationSchoolIdOption = new Option("--educationschool-id", description: "key: id of educationSchool") { + var educationSchoolIdOption = new Option("--education-school-id", description: "key: id of educationSchool") { }; educationSchoolIdOption.IsRequired = true; command.AddOption(educationSchoolIdOption); - command.SetHandler(async (string educationSchoolId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationSchoolId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationSchoolIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationSchoolIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Education/Schools/Item/Users/Ref/Ref.cs b/src/generated/Education/Schools/Item/Users/Ref/Ref.cs new file mode 100644 index 00000000000..5ae8e9c1076 --- /dev/null +++ b/src/generated/Education/Schools/Item/Users/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Education.Schools.Item.Users.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Education/Schools/Item/Users/Ref/RefRequestBuilder.cs b/src/generated/Education/Schools/Item/Users/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..24ad5e1a74a --- /dev/null +++ b/src/generated/Education/Schools/Item/Users/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Education.Schools.Item.Users.Ref { + /// Builds and executes requests for operations under \education\schools\{educationSchool-id}\users\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Users in the school. Nullable. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Users in the school. Nullable."; + // Create options for all the parameters + var educationSchoolIdOption = new Option("--education-school-id", description: "key: id of educationSchool") { + }; + educationSchoolIdOption.IsRequired = true; + command.AddOption(educationSchoolIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationSchoolId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationSchoolIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Users in the school. Nullable. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Users in the school. Nullable."; + // Create options for all the parameters + var educationSchoolIdOption = new Option("--education-school-id", description: "key: id of educationSchool") { + }; + educationSchoolIdOption.IsRequired = true; + command.AddOption(educationSchoolIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationSchoolId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationSchoolIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/education/schools/{educationSchool_id}/users/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Users in the school. Nullable. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Users in the school. Nullable. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Education.Schools.Item.Users.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Users in the school. Nullable. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Education/Schools/Item/Users/Ref/RefResponse.cs b/src/generated/Education/Schools/Item/Users/Ref/RefResponse.cs new file mode 100644 index 00000000000..f428841d4f3 --- /dev/null +++ b/src/generated/Education/Schools/Item/Users/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Education.Schools.Item.Users.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Education/Schools/Item/Users/UsersRequestBuilder.cs b/src/generated/Education/Schools/Item/Users/UsersRequestBuilder.cs index 55809d27c2c..82943a42086 100644 --- a/src/generated/Education/Schools/Item/Users/UsersRequestBuilder.cs +++ b/src/generated/Education/Schools/Item/Users/UsersRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Education.Schools.Item.Users.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Users in the school. Nullable."; // Create options for all the parameters - var educationSchoolIdOption = new Option("--educationschool-id", description: "key: id of educationSchool") { + var educationSchoolIdOption = new Option("--education-school-id", description: "key: id of educationSchool") { }; educationSchoolIdOption.IsRequired = true; command.AddOption(educationSchoolIdOption); @@ -66,7 +66,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationSchoolId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationSchoolId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -77,20 +81,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationSchoolIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationSchoolIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Education.Schools.Item.Users.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Education.Schools.Item.Users.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -135,18 +134,6 @@ public RequestInformation CreateGetRequestInformation(Action public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// Users in the school. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Users in the school. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Schools/SchoolsRequestBuilder.cs b/src/generated/Education/Schools/SchoolsRequestBuilder.cs index 2e5d048b863..01e0b16198b 100644 --- a/src/generated/Education/Schools/SchoolsRequestBuilder.cs +++ b/src/generated/Education/Schools/SchoolsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,14 +23,13 @@ public class SchoolsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EducationSchoolRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAdministrativeUnitCommand(), - builder.BuildClassesCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildUsersCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAdministrativeUnitCommand()); + commands.Add(builder.BuildClassesCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildUsersCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -103,7 +101,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -114,15 +116,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -183,31 +180,6 @@ public RequestInformation CreatePostRequestInformation(EducationSchool body, Act public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// Get schools from education - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to schools for education - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EducationSchool model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get schools from education public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Users/Delta/DeltaRequestBuilder.cs b/src/generated/Education/Users/Delta/DeltaRequestBuilder.cs index 6c03b194fab..3cc0cf5ab35 100644 --- a/src/generated/Education/Users/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Education/Users/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Education/Users/Item/Assignments/AssignmentsRequestBuilder.cs b/src/generated/Education/Users/Item/Assignments/AssignmentsRequestBuilder.cs index 08a1a041ce6..27e2edfdf9a 100644 --- a/src/generated/Education/Users/Item/Assignments/AssignmentsRequestBuilder.cs +++ b/src/generated/Education/Users/Item/Assignments/AssignmentsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,17 +22,16 @@ public class AssignmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EducationAssignmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCategoriesCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildPublishCommand(), - builder.BuildResourcesCommand(), - builder.BuildRubricCommand(), - builder.BuildSetUpResourcesFolderCommand(), - builder.BuildSubmissionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCategoriesCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPublishCommand()); + commands.Add(builder.BuildResourcesCommand()); + commands.Add(builder.BuildRubricCommand()); + commands.Add(builder.BuildSetUpResourcesFolderCommand()); + commands.Add(builder.BuildSubmissionsCommand()); return commands; } /// @@ -42,7 +41,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "List of assignments for the user. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationUserId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, bodyOption, outputOption); return command; } /// @@ -74,7 +72,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "List of assignments for the user. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); @@ -113,7 +111,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationUserId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -124,15 +126,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -187,31 +184,6 @@ public RequestInformation CreatePostRequestInformation(EducationAssignment body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of assignments for the user. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of assignments for the user. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EducationAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// List of assignments for the user. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Users/Item/Assignments/Item/Categories/CategoriesRequestBuilder.cs b/src/generated/Education/Users/Item/Assignments/Item/Categories/CategoriesRequestBuilder.cs index 57a37d57647..eecc7b7e3c4 100644 --- a/src/generated/Education/Users/Item/Assignments/Item/Categories/CategoriesRequestBuilder.cs +++ b/src/generated/Education/Users/Item/Assignments/Item/Categories/CategoriesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class CategoriesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EducationCategoryRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,11 +35,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "When set, enables users to easily find assignments of a given type. Read-only. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationAssignmentId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationAssignmentIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationAssignmentIdOption, bodyOption, outputOption); return command; } /// @@ -72,11 +70,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "When set, enables users to easily find assignments of a given type. Read-only. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationAssignmentId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationAssignmentIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationAssignmentIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(EducationCategory body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// When set, enables users to easily find assignments of a given type. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// When set, enables users to easily find assignments of a given type. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EducationCategory model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// When set, enables users to easily find assignments of a given type. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Users/Item/Assignments/Item/Categories/Item/EducationCategoryRequestBuilder.cs b/src/generated/Education/Users/Item/Assignments/Item/Categories/Item/EducationCategoryRequestBuilder.cs index c5931fc4240..39d09b875e4 100644 --- a/src/generated/Education/Users/Item/Assignments/Item/Categories/Item/EducationCategoryRequestBuilder.cs +++ b/src/generated/Education/Users/Item/Assignments/Item/Categories/Item/EducationCategoryRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "When set, enables users to easily find assignments of a given type. Read-only. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationCategoryIdOption = new Option("--educationcategory-id", description: "key: id of educationCategory") { + var educationCategoryIdOption = new Option("--education-category-id", description: "key: id of educationCategory") { }; educationCategoryIdOption.IsRequired = true; command.AddOption(educationCategoryIdOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationCategoryId) => { + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationCategoryId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationUserIdOption, educationAssignmentIdOption, educationCategoryIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "When set, enables users to easily find assignments of a given type. Read-only. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationCategoryIdOption = new Option("--educationcategory-id", description: "key: id of educationCategory") { + var educationCategoryIdOption = new Option("--education-category-id", description: "key: id of educationCategory") { }; educationCategoryIdOption.IsRequired = true; command.AddOption(educationCategoryIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationCategoryId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationCategoryId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationAssignmentIdOption, educationCategoryIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationAssignmentIdOption, educationCategoryIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "When set, enables users to easily find assignments of a given type. Read-only. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationCategoryIdOption = new Option("--educationcategory-id", description: "key: id of educationCategory") { + var educationCategoryIdOption = new Option("--education-category-id", description: "key: id of educationCategory") { }; educationCategoryIdOption.IsRequired = true; command.AddOption(educationCategoryIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationCategoryId, string body) => { + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationCategoryId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationUserIdOption, educationAssignmentIdOption, educationCategoryIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(EducationCategory body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// When set, enables users to easily find assignments of a given type. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// When set, enables users to easily find assignments of a given type. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// When set, enables users to easily find assignments of a given type. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationCategory model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// When set, enables users to easily find assignments of a given type. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Users/Item/Assignments/Item/EducationAssignmentRequestBuilder.cs b/src/generated/Education/Users/Item/Assignments/Item/EducationAssignmentRequestBuilder.cs index 9b7d85c3770..570773d58c8 100644 --- a/src/generated/Education/Users/Item/Assignments/Item/EducationAssignmentRequestBuilder.cs +++ b/src/generated/Education/Users/Item/Assignments/Item/EducationAssignmentRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,6 +28,9 @@ public class EducationAssignmentRequestBuilder { public Command BuildCategoriesCommand() { var command = new Command("categories"); var builder = new ApiSdk.Education.Users.Item.Assignments.Item.Categories.CategoriesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -39,19 +42,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "List of assignments for the user. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId) => { + command.SetHandler(async (string educationUserId, string educationAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationUserIdOption, educationAssignmentIdOption); return command; @@ -63,11 +65,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "List of assignments for the user. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -81,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationAssignmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,11 +105,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "List of assignments for the user. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -116,14 +117,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string body) => { + command.SetHandler(async (string educationUserId, string educationAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationUserIdOption, educationAssignmentIdOption, bodyOption); return command; @@ -137,6 +137,9 @@ public Command BuildPublishCommand() { public Command BuildResourcesCommand() { var command = new Command("resources"); var builder = new ApiSdk.Education.Users.Item.Assignments.Item.Resources.ResourcesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -158,6 +161,9 @@ public Command BuildSetUpResourcesFolderCommand() { public Command BuildSubmissionsCommand() { var command = new Command("submissions"); var builder = new ApiSdk.Education.Users.Item.Assignments.Item.Submissions.SubmissionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -229,42 +235,6 @@ public RequestInformation CreatePatchRequestInformation(EducationAssignment body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of assignments for the user. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of assignments for the user. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of assignments for the user. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// List of assignments for the user. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Users/Item/Assignments/Item/Publish/PublishRequestBuilder.cs b/src/generated/Education/Users/Item/Assignments/Item/Publish/PublishRequestBuilder.cs index 7ae6ef8085e..b17647088cc 100644 --- a/src/generated/Education/Users/Item/Assignments/Item/Publish/PublishRequestBuilder.cs +++ b/src/generated/Education/Users/Item/Assignments/Item/Publish/PublishRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action publish"; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationAssignmentId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationAssignmentIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationAssignmentIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action publish - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes educationAssignment public class PublishResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Education/Users/Item/Assignments/Item/Resources/Item/EducationAssignmentResourceRequestBuilder.cs b/src/generated/Education/Users/Item/Assignments/Item/Resources/Item/EducationAssignmentResourceRequestBuilder.cs index 50bd60abd2b..bccd7d7a857 100644 --- a/src/generated/Education/Users/Item/Assignments/Item/Resources/Item/EducationAssignmentResourceRequestBuilder.cs +++ b/src/generated/Education/Users/Item/Assignments/Item/Resources/Item/EducationAssignmentResourceRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationAssignmentResourceIdOption = new Option("--educationassignmentresource-id", description: "key: id of educationAssignmentResource") { + var educationAssignmentResourceIdOption = new Option("--education-assignment-resource-id", description: "key: id of educationAssignmentResource") { }; educationAssignmentResourceIdOption.IsRequired = true; command.AddOption(educationAssignmentResourceIdOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationAssignmentResourceId) => { + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationAssignmentResourceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationUserIdOption, educationAssignmentIdOption, educationAssignmentResourceIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationAssignmentResourceIdOption = new Option("--educationassignmentresource-id", description: "key: id of educationAssignmentResource") { + var educationAssignmentResourceIdOption = new Option("--education-assignment-resource-id", description: "key: id of educationAssignmentResource") { }; educationAssignmentResourceIdOption.IsRequired = true; command.AddOption(educationAssignmentResourceIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationAssignmentResourceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationAssignmentResourceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationAssignmentIdOption, educationAssignmentResourceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationAssignmentIdOption, educationAssignmentResourceIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationAssignmentResourceIdOption = new Option("--educationassignmentresource-id", description: "key: id of educationAssignmentResource") { + var educationAssignmentResourceIdOption = new Option("--education-assignment-resource-id", description: "key: id of educationAssignmentResource") { }; educationAssignmentResourceIdOption.IsRequired = true; command.AddOption(educationAssignmentResourceIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationAssignmentResourceId, string body) => { + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationAssignmentResourceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationUserIdOption, educationAssignmentIdOption, educationAssignmentResourceIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(EducationAssignmentResou requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationAssignmentResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Users/Item/Assignments/Item/Resources/ResourcesRequestBuilder.cs b/src/generated/Education/Users/Item/Assignments/Item/Resources/ResourcesRequestBuilder.cs index 6ecf88ca502..f6c4883bb2b 100644 --- a/src/generated/Education/Users/Item/Assignments/Item/Resources/ResourcesRequestBuilder.cs +++ b/src/generated/Education/Users/Item/Assignments/Item/Resources/ResourcesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ResourcesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EducationAssignmentResourceRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,11 +35,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationAssignmentId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationAssignmentIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationAssignmentIdOption, bodyOption, outputOption); return command; } /// @@ -72,11 +70,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationAssignmentId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationAssignmentIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationAssignmentIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(EducationAssignmentResour requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EducationAssignmentResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Learning objects that are associated with this assignment. Only teachers can modify this list. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Users/Item/Assignments/Item/Rubric/RubricRequestBuilder.cs b/src/generated/Education/Users/Item/Assignments/Item/Rubric/RubricRequestBuilder.cs index a3a470ed474..582bd2a6d8f 100644 --- a/src/generated/Education/Users/Item/Assignments/Item/Rubric/RubricRequestBuilder.cs +++ b/src/generated/Education/Users/Item/Assignments/Item/Rubric/RubricRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "When set, the grading rubric attached to this assignment."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId) => { + command.SetHandler(async (string educationUserId, string educationAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationUserIdOption, educationAssignmentIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "When set, the grading rubric attached to this assignment."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationAssignmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "When set, the grading rubric attached to this assignment."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string body) => { + command.SetHandler(async (string educationUserId, string educationAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationUserIdOption, educationAssignmentIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(EducationRubric body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// When set, the grading rubric attached to this assignment. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// When set, the grading rubric attached to this assignment. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// When set, the grading rubric attached to this assignment. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationRubric model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// When set, the grading rubric attached to this assignment. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Users/Item/Assignments/Item/SetUpResourcesFolder/SetUpResourcesFolderRequestBuilder.cs b/src/generated/Education/Users/Item/Assignments/Item/SetUpResourcesFolder/SetUpResourcesFolderRequestBuilder.cs index c662624ac73..a065eb9e97c 100644 --- a/src/generated/Education/Users/Item/Assignments/Item/SetUpResourcesFolder/SetUpResourcesFolderRequestBuilder.cs +++ b/src/generated/Education/Users/Item/Assignments/Item/SetUpResourcesFolder/SetUpResourcesFolderRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setUpResourcesFolder"; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationAssignmentId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationAssignmentIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationAssignmentIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action setUpResourcesFolder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes educationAssignment public class SetUpResourcesFolderResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/@Return/ReturnRequestBuilder.cs b/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/@Return/ReturnRequestBuilder.cs deleted file mode 100644 index 2092513b805..00000000000 --- a/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/@Return/ReturnRequestBuilder.cs +++ /dev/null @@ -1,125 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Education.Users.Item.Assignments.Item.Submissions.Item.@Return { - /// Builds and executes requests for operations under \education\users\{educationUser-id}\assignments\{educationAssignment-id}\submissions\{educationSubmission-id}\microsoft.graph.return - public class ReturnRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action return - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action return"; - // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { - }; - educationUserIdOption.IsRequired = true; - command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { - }; - educationAssignmentIdOption.IsRequired = true; - command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { - }; - educationSubmissionIdOption.IsRequired = true; - command.AddOption(educationSubmissionIdOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId) => { - var requestInfo = CreatePostRequestInformation(q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption); - return command; - } - /// - /// Instantiates a new ReturnRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public ReturnRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/education/users/{educationUser_id}/assignments/{educationAssignment_id}/submissions/{educationSubmission_id}/microsoft.graph.return"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action return - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action return - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes educationSubmission - public class ReturnResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type educationSubmission - public EducationSubmission EducationSubmission { get; set; } - /// - /// Instantiates a new returnResponse and sets the default values. - /// - public ReturnResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"educationSubmission", (o,n) => { (o as ReturnResponse).EducationSubmission = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("educationSubmission", EducationSubmission); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/EducationSubmissionRequestBuilder.cs b/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/EducationSubmissionRequestBuilder.cs index 50389e73838..8906e83a258 100644 --- a/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/EducationSubmissionRequestBuilder.cs +++ b/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/EducationSubmissionRequestBuilder.cs @@ -9,10 +9,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,23 +34,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId) => { + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); @@ -84,25 +83,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOutcomesCommand() { var command = new Command("outcomes"); var builder = new ApiSdk.Education.Users.Item.Assignments.Item.Submissions.Item.Outcomes.OutcomesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -114,15 +115,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); @@ -130,14 +131,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string body) => { + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, bodyOption); return command; @@ -151,13 +151,16 @@ public Command BuildReassignCommand() { public Command BuildResourcesCommand() { var command = new Command("resources"); var builder = new ApiSdk.Education.Users.Item.Assignments.Item.Submissions.Item.Resources.ResourcesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; } public Command BuildReturnCommand() { var command = new Command("return"); - var builder = new ApiSdk.Education.Users.Item.Assignments.Item.Submissions.Item.@Return.ReturnRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Education.Users.Item.Assignments.Item.Submissions.Item.Return.ReturnRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } @@ -176,6 +179,9 @@ public Command BuildSubmitCommand() { public Command BuildSubmittedResourcesCommand() { var command = new Command("submitted-resources"); var builder = new ApiSdk.Education.Users.Item.Assignments.Item.Submissions.Item.SubmittedResources.SubmittedResourcesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -253,42 +259,6 @@ public RequestInformation CreatePatchRequestInformation(EducationSubmission body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationSubmission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Outcomes/Item/EducationOutcomeRequestBuilder.cs b/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Outcomes/Item/EducationOutcomeRequestBuilder.cs index 38c69503203..6f53f5e26b7 100644 --- a/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Outcomes/Item/EducationOutcomeRequestBuilder.cs +++ b/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Outcomes/Item/EducationOutcomeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,27 +26,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-Write. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - var educationOutcomeIdOption = new Option("--educationoutcome-id", description: "key: id of educationOutcome") { + var educationOutcomeIdOption = new Option("--education-outcome-id", description: "key: id of educationOutcome") { }; educationOutcomeIdOption.IsRequired = true; command.AddOption(educationOutcomeIdOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string educationOutcomeId) => { + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string educationOutcomeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, educationOutcomeIdOption); return command; @@ -58,19 +57,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-Write. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - var educationOutcomeIdOption = new Option("--educationoutcome-id", description: "key: id of educationOutcome") { + var educationOutcomeIdOption = new Option("--education-outcome-id", description: "key: id of educationOutcome") { }; educationOutcomeIdOption.IsRequired = true; command.AddOption(educationOutcomeIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string educationOutcomeId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string educationOutcomeId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, educationOutcomeIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, educationOutcomeIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,19 +105,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-Write. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - var educationOutcomeIdOption = new Option("--educationoutcome-id", description: "key: id of educationOutcome") { + var educationOutcomeIdOption = new Option("--education-outcome-id", description: "key: id of educationOutcome") { }; educationOutcomeIdOption.IsRequired = true; command.AddOption(educationOutcomeIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string educationOutcomeId, string body) => { + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string educationOutcomeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, educationOutcomeIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(EducationOutcome body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-Write. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-Write. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-Write. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationOutcome model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-Write. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Outcomes/OutcomesRequestBuilder.cs b/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Outcomes/OutcomesRequestBuilder.cs index 9ff5d6bffff..e7756c59ed4 100644 --- a/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Outcomes/OutcomesRequestBuilder.cs +++ b/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Outcomes/OutcomesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class OutcomesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EducationOutcomeRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,15 +35,15 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Read-Write. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, bodyOption, outputOption); return command; } /// @@ -76,15 +74,15 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Read-Write. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(EducationOutcome body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-Write. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-Write. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EducationOutcome model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-Write. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Reassign/ReassignRequestBuilder.cs b/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Reassign/ReassignRequestBuilder.cs index 150c014fa22..4032bee2211 100644 --- a/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Reassign/ReassignRequestBuilder.cs +++ b/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Reassign/ReassignRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action reassign"; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action reassign - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes educationSubmission public class ReassignResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Resources/Item/EducationSubmissionResourceRequestBuilder.cs b/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Resources/Item/EducationSubmissionResourceRequestBuilder.cs index 8817bfbd888..4467e808e9a 100644 --- a/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Resources/Item/EducationSubmissionResourceRequestBuilder.cs +++ b/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Resources/Item/EducationSubmissionResourceRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,27 +26,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - var educationSubmissionResourceIdOption = new Option("--educationsubmissionresource-id", description: "key: id of educationSubmissionResource") { + var educationSubmissionResourceIdOption = new Option("--education-submission-resource-id", description: "key: id of educationSubmissionResource") { }; educationSubmissionResourceIdOption.IsRequired = true; command.AddOption(educationSubmissionResourceIdOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId) => { + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, educationSubmissionResourceIdOption); return command; @@ -58,19 +57,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - var educationSubmissionResourceIdOption = new Option("--educationsubmissionresource-id", description: "key: id of educationSubmissionResource") { + var educationSubmissionResourceIdOption = new Option("--education-submission-resource-id", description: "key: id of educationSubmissionResource") { }; educationSubmissionResourceIdOption.IsRequired = true; command.AddOption(educationSubmissionResourceIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, educationSubmissionResourceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, educationSubmissionResourceIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,19 +105,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - var educationSubmissionResourceIdOption = new Option("--educationsubmissionresource-id", description: "key: id of educationSubmissionResource") { + var educationSubmissionResourceIdOption = new Option("--education-submission-resource-id", description: "key: id of educationSubmissionResource") { }; educationSubmissionResourceIdOption.IsRequired = true; command.AddOption(educationSubmissionResourceIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, string body) => { + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, educationSubmissionResourceIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(EducationSubmissionResou requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationSubmissionResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Resources/ResourcesRequestBuilder.cs b/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Resources/ResourcesRequestBuilder.cs index 19cebb85bfe..5fe6d49bf21 100644 --- a/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Resources/ResourcesRequestBuilder.cs +++ b/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Resources/ResourcesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ResourcesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EducationSubmissionResourceRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,15 +35,15 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, bodyOption, outputOption); return command; } /// @@ -76,15 +74,15 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(EducationSubmissionResour requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EducationSubmissionResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Return/ReturnRequestBuilder.cs b/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Return/ReturnRequestBuilder.cs new file mode 100644 index 00000000000..65b302b9d35 --- /dev/null +++ b/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Return/ReturnRequestBuilder.cs @@ -0,0 +1,113 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Education.Users.Item.Assignments.Item.Submissions.Item.Return { + /// Builds and executes requests for operations under \education\users\{educationUser-id}\assignments\{educationAssignment-id}\submissions\{educationSubmission-id}\microsoft.graph.return + public class ReturnRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action return + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action return"; + // Create options for all the parameters + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { + }; + educationUserIdOption.IsRequired = true; + command.AddOption(educationUserIdOption); + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { + }; + educationAssignmentIdOption.IsRequired = true; + command.AddOption(educationAssignmentIdOption); + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { + }; + educationSubmissionIdOption.IsRequired = true; + command.AddOption(educationSubmissionIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreatePostRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, outputOption); + return command; + } + /// + /// Instantiates a new ReturnRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public ReturnRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/education/users/{educationUser_id}/assignments/{educationAssignment_id}/submissions/{educationSubmission_id}/microsoft.graph.return"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action return + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes educationSubmission + public class ReturnResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type educationSubmission + public EducationSubmission EducationSubmission { get; set; } + /// + /// Instantiates a new returnResponse and sets the default values. + /// + public ReturnResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"educationSubmission", (o,n) => { (o as ReturnResponse).EducationSubmission = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("educationSubmission", EducationSubmission); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/SetUpResourcesFolder/SetUpResourcesFolderRequestBuilder.cs b/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/SetUpResourcesFolder/SetUpResourcesFolderRequestBuilder.cs index 53f8819ca52..439de4c2531 100644 --- a/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/SetUpResourcesFolder/SetUpResourcesFolderRequestBuilder.cs +++ b/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/SetUpResourcesFolder/SetUpResourcesFolderRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setUpResourcesFolder"; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action setUpResourcesFolder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes educationSubmission public class SetUpResourcesFolderResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Submit/SubmitRequestBuilder.cs b/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Submit/SubmitRequestBuilder.cs index 3901e962979..3444edd1704 100644 --- a/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Submit/SubmitRequestBuilder.cs +++ b/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Submit/SubmitRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action submit"; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action submit - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes educationSubmission public class SubmitResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/SubmittedResources/Item/EducationSubmissionResourceRequestBuilder.cs b/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/SubmittedResources/Item/EducationSubmissionResourceRequestBuilder.cs index 510d69e10b9..81720058119 100644 --- a/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/SubmittedResources/Item/EducationSubmissionResourceRequestBuilder.cs +++ b/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/SubmittedResources/Item/EducationSubmissionResourceRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,27 +26,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - var educationSubmissionResourceIdOption = new Option("--educationsubmissionresource-id", description: "key: id of educationSubmissionResource") { + var educationSubmissionResourceIdOption = new Option("--education-submission-resource-id", description: "key: id of educationSubmissionResource") { }; educationSubmissionResourceIdOption.IsRequired = true; command.AddOption(educationSubmissionResourceIdOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId) => { + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, educationSubmissionResourceIdOption); return command; @@ -58,19 +57,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - var educationSubmissionResourceIdOption = new Option("--educationsubmissionresource-id", description: "key: id of educationSubmissionResource") { + var educationSubmissionResourceIdOption = new Option("--education-submission-resource-id", description: "key: id of educationSubmissionResource") { }; educationSubmissionResourceIdOption.IsRequired = true; command.AddOption(educationSubmissionResourceIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, educationSubmissionResourceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, educationSubmissionResourceIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,19 +105,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - var educationSubmissionResourceIdOption = new Option("--educationsubmissionresource-id", description: "key: id of educationSubmissionResource") { + var educationSubmissionResourceIdOption = new Option("--education-submission-resource-id", description: "key: id of educationSubmissionResource") { }; educationSubmissionResourceIdOption.IsRequired = true; command.AddOption(educationSubmissionResourceIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, string body) => { + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string educationSubmissionResourceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, educationSubmissionResourceIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(EducationSubmissionResou requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationSubmissionResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/SubmittedResources/SubmittedResourcesRequestBuilder.cs b/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/SubmittedResources/SubmittedResourcesRequestBuilder.cs index 1449afd3932..84f194deaf6 100644 --- a/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/SubmittedResources/SubmittedResourcesRequestBuilder.cs +++ b/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/SubmittedResources/SubmittedResourcesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SubmittedResourcesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EducationSubmissionResourceRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,15 +35,15 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, bodyOption, outputOption); return command; } /// @@ -76,15 +74,15 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(EducationSubmissionResour requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EducationSubmissionResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Unsubmit/UnsubmitRequestBuilder.cs b/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Unsubmit/UnsubmitRequestBuilder.cs index 088e4f2469a..0a3ac658348 100644 --- a/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Unsubmit/UnsubmitRequestBuilder.cs +++ b/src/generated/Education/Users/Item/Assignments/Item/Submissions/Item/Unsubmit/UnsubmitRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action unsubmit"; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); - var educationSubmissionIdOption = new Option("--educationsubmission-id", description: "key: id of educationSubmission") { + var educationSubmissionIdOption = new Option("--education-submission-id", description: "key: id of educationSubmission") { }; educationSubmissionIdOption.IsRequired = true; command.AddOption(educationSubmissionIdOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationAssignmentId, string educationSubmissionId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationAssignmentIdOption, educationSubmissionIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action unsubmit - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes educationSubmission public class UnsubmitResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Education/Users/Item/Assignments/Item/Submissions/SubmissionsRequestBuilder.cs b/src/generated/Education/Users/Item/Assignments/Item/Submissions/SubmissionsRequestBuilder.cs index 5b2ab77eb0f..4922d5f801f 100644 --- a/src/generated/Education/Users/Item/Assignments/Item/Submissions/SubmissionsRequestBuilder.cs +++ b/src/generated/Education/Users/Item/Assignments/Item/Submissions/SubmissionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,19 +22,18 @@ public class SubmissionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EducationSubmissionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOutcomesCommand(), - builder.BuildPatchCommand(), - builder.BuildReassignCommand(), - builder.BuildResourcesCommand(), - builder.BuildReturnCommand(), - builder.BuildSetUpResourcesFolderCommand(), - builder.BuildSubmitCommand(), - builder.BuildSubmittedResourcesCommand(), - builder.BuildUnsubmitCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOutcomesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildReassignCommand()); + commands.Add(builder.BuildResourcesCommand()); + commands.Add(builder.BuildReturnCommand()); + commands.Add(builder.BuildSetUpResourcesFolderCommand()); + commands.Add(builder.BuildSubmitCommand()); + commands.Add(builder.BuildSubmittedResourcesCommand()); + commands.Add(builder.BuildUnsubmitCommand()); return commands; } /// @@ -44,11 +43,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationAssignmentId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationAssignmentIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationAssignmentIdOption, bodyOption, outputOption); return command; } /// @@ -80,11 +78,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationAssignmentIdOption = new Option("--educationassignment-id", description: "key: id of educationAssignment") { + var educationAssignmentIdOption = new Option("--education-assignment-id", description: "key: id of educationAssignment") { }; educationAssignmentIdOption.IsRequired = true; command.AddOption(educationAssignmentIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationUserId, string educationAssignmentId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationAssignmentId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationAssignmentIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationAssignmentIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(EducationSubmission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EducationSubmission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Once published, there is a submission object for each student representing their work and grade. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Users/Item/Classes/@Ref/@Ref.cs b/src/generated/Education/Users/Item/Classes/@Ref/@Ref.cs deleted file mode 100644 index 56f7815a882..00000000000 --- a/src/generated/Education/Users/Item/Classes/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Education.Users.Item.Classes.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Education/Users/Item/Classes/@Ref/RefRequestBuilder.cs b/src/generated/Education/Users/Item/Classes/@Ref/RefRequestBuilder.cs deleted file mode 100644 index a1fb0756d44..00000000000 --- a/src/generated/Education/Users/Item/Classes/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Education.Users.Item.Classes.@Ref { - /// Builds and executes requests for operations under \education\users\{educationUser-id}\classes\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Classes to which the user belongs. Nullable. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Classes to which the user belongs. Nullable."; - // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { - }; - educationUserIdOption.IsRequired = true; - command.AddOption(educationUserIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string educationUserId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Classes to which the user belongs. Nullable. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Classes to which the user belongs. Nullable."; - // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { - }; - educationUserIdOption.IsRequired = true; - command.AddOption(educationUserIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string educationUserId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/education/users/{educationUser_id}/classes/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Classes to which the user belongs. Nullable. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Classes to which the user belongs. Nullable. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Education.Users.Item.Classes.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Classes to which the user belongs. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Classes to which the user belongs. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Education.Users.Item.Classes.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Classes to which the user belongs. Nullable. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Education/Users/Item/Classes/@Ref/RefResponse.cs b/src/generated/Education/Users/Item/Classes/@Ref/RefResponse.cs deleted file mode 100644 index 6a69032e635..00000000000 --- a/src/generated/Education/Users/Item/Classes/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Education.Users.Item.Classes.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Education/Users/Item/Classes/ClassesRequestBuilder.cs b/src/generated/Education/Users/Item/Classes/ClassesRequestBuilder.cs index 97e562d04bb..35ff6d24007 100644 --- a/src/generated/Education/Users/Item/Classes/ClassesRequestBuilder.cs +++ b/src/generated/Education/Users/Item/Classes/ClassesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Education.Users.Item.Classes.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Classes to which the user belongs. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); @@ -66,7 +66,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationUserId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -77,20 +81,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Education.Users.Item.Classes.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Education.Users.Item.Classes.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -135,18 +134,6 @@ public RequestInformation CreateGetRequestInformation(Action public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// Classes to which the user belongs. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Classes to which the user belongs. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Users/Item/Classes/Delta/DeltaRequestBuilder.cs b/src/generated/Education/Users/Item/Classes/Delta/DeltaRequestBuilder.cs index 7ae0659d642..f137dd05dd8 100644 --- a/src/generated/Education/Users/Item/Classes/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Education/Users/Item/Classes/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,22 +25,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - command.SetHandler(async (string educationUserId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Education/Users/Item/Classes/Ref/Ref.cs b/src/generated/Education/Users/Item/Classes/Ref/Ref.cs new file mode 100644 index 00000000000..b4d5480ad37 --- /dev/null +++ b/src/generated/Education/Users/Item/Classes/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Education.Users.Item.Classes.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Education/Users/Item/Classes/Ref/RefRequestBuilder.cs b/src/generated/Education/Users/Item/Classes/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..e516580c85e --- /dev/null +++ b/src/generated/Education/Users/Item/Classes/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Education.Users.Item.Classes.Ref { + /// Builds and executes requests for operations under \education\users\{educationUser-id}\classes\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Classes to which the user belongs. Nullable. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Classes to which the user belongs. Nullable."; + // Create options for all the parameters + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { + }; + educationUserIdOption.IsRequired = true; + command.AddOption(educationUserIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Classes to which the user belongs. Nullable. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Classes to which the user belongs. Nullable."; + // Create options for all the parameters + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { + }; + educationUserIdOption.IsRequired = true; + command.AddOption(educationUserIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/education/users/{educationUser_id}/classes/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Classes to which the user belongs. Nullable. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Classes to which the user belongs. Nullable. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Education.Users.Item.Classes.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Classes to which the user belongs. Nullable. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Education/Users/Item/Classes/Ref/RefResponse.cs b/src/generated/Education/Users/Item/Classes/Ref/RefResponse.cs new file mode 100644 index 00000000000..00767d362e9 --- /dev/null +++ b/src/generated/Education/Users/Item/Classes/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Education.Users.Item.Classes.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Education/Users/Item/EducationUserRequestBuilder.cs b/src/generated/Education/Users/Item/EducationUserRequestBuilder.cs index 96530579019..f27a3c5c75f 100644 --- a/src/generated/Education/Users/Item/EducationUserRequestBuilder.cs +++ b/src/generated/Education/Users/Item/EducationUserRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,6 +28,9 @@ public class EducationUserRequestBuilder { public Command BuildAssignmentsCommand() { var command = new Command("assignments"); var builder = new ApiSdk.Education.Users.Item.Assignments.AssignmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -46,15 +49,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property users for education"; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - command.SetHandler(async (string educationUserId) => { + command.SetHandler(async (string educationUserId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationUserIdOption); return command; @@ -66,7 +68,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get users from education"; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); @@ -80,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationUserId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,7 +104,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property users in education"; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); @@ -111,14 +112,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationUserId, string body) => { + command.SetHandler(async (string educationUserId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationUserIdOption, bodyOption); return command; @@ -126,6 +126,9 @@ public Command BuildPatchCommand() { public Command BuildRubricsCommand() { var command = new Command("rubrics"); var builder = new ApiSdk.Education.Users.Item.Rubrics.RubricsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -218,42 +221,6 @@ public RequestInformation CreatePatchRequestInformation(EducationUser body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property users for education - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get users from education - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property users in education - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationUser model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get users from education public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Users/Item/Rubrics/Item/EducationRubricRequestBuilder.cs b/src/generated/Education/Users/Item/Rubrics/Item/EducationRubricRequestBuilder.cs index cb0f0a6602d..8afc9bb32f1 100644 --- a/src/generated/Education/Users/Item/Rubrics/Item/EducationRubricRequestBuilder.cs +++ b/src/generated/Education/Users/Item/Rubrics/Item/EducationRubricRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property rubrics for education"; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationRubricIdOption = new Option("--educationrubric-id", description: "key: id of educationRubric") { + var educationRubricIdOption = new Option("--education-rubric-id", description: "key: id of educationRubric") { }; educationRubricIdOption.IsRequired = true; command.AddOption(educationRubricIdOption); - command.SetHandler(async (string educationUserId, string educationRubricId) => { + command.SetHandler(async (string educationUserId, string educationRubricId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationUserIdOption, educationRubricIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get rubrics from education"; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationRubricIdOption = new Option("--educationrubric-id", description: "key: id of educationRubric") { + var educationRubricIdOption = new Option("--education-rubric-id", description: "key: id of educationRubric") { }; educationRubricIdOption.IsRequired = true; command.AddOption(educationRubricIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationUserId, string educationRubricId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string educationRubricId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, educationRubricIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, educationRubricIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property rubrics in education"; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - var educationRubricIdOption = new Option("--educationrubric-id", description: "key: id of educationRubric") { + var educationRubricIdOption = new Option("--education-rubric-id", description: "key: id of educationRubric") { }; educationRubricIdOption.IsRequired = true; command.AddOption(educationRubricIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationUserId, string educationRubricId, string body) => { + command.SetHandler(async (string educationUserId, string educationRubricId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, educationUserIdOption, educationRubricIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(EducationRubric body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property rubrics for education - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get rubrics from education - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property rubrics in education - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EducationRubric model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get rubrics from education public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Users/Item/Rubrics/RubricsRequestBuilder.cs b/src/generated/Education/Users/Item/Rubrics/RubricsRequestBuilder.cs index 0ab65c6e501..37fc9a2350d 100644 --- a/src/generated/Education/Users/Item/Rubrics/RubricsRequestBuilder.cs +++ b/src/generated/Education/Users/Item/Rubrics/RubricsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class RubricsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EducationRubricRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Create new navigation property to rubrics for education"; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string educationUserId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Get rubrics from education"; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationUserId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(EducationRubric body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get rubrics from education - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to rubrics for education - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EducationRubric model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get rubrics from education public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Users/Item/Schools/@Ref/@Ref.cs b/src/generated/Education/Users/Item/Schools/@Ref/@Ref.cs deleted file mode 100644 index 683749bef05..00000000000 --- a/src/generated/Education/Users/Item/Schools/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Education.Users.Item.Schools.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Education/Users/Item/Schools/@Ref/RefRequestBuilder.cs b/src/generated/Education/Users/Item/Schools/@Ref/RefRequestBuilder.cs deleted file mode 100644 index d1cb89c7d6e..00000000000 --- a/src/generated/Education/Users/Item/Schools/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Education.Users.Item.Schools.@Ref { - /// Builds and executes requests for operations under \education\users\{educationUser-id}\schools\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Schools to which the user belongs. Nullable. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Schools to which the user belongs. Nullable."; - // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { - }; - educationUserIdOption.IsRequired = true; - command.AddOption(educationUserIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string educationUserId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Schools to which the user belongs. Nullable. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Schools to which the user belongs. Nullable."; - // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { - }; - educationUserIdOption.IsRequired = true; - command.AddOption(educationUserIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string educationUserId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/education/users/{educationUser_id}/schools/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Schools to which the user belongs. Nullable. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Schools to which the user belongs. Nullable. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Education.Users.Item.Schools.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Schools to which the user belongs. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Schools to which the user belongs. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Education.Users.Item.Schools.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Schools to which the user belongs. Nullable. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Education/Users/Item/Schools/@Ref/RefResponse.cs b/src/generated/Education/Users/Item/Schools/@Ref/RefResponse.cs deleted file mode 100644 index 9a0746e8bd8..00000000000 --- a/src/generated/Education/Users/Item/Schools/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Education.Users.Item.Schools.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Education/Users/Item/Schools/Delta/DeltaRequestBuilder.cs b/src/generated/Education/Users/Item/Schools/Delta/DeltaRequestBuilder.cs index 753fe4fdca0..36dab7d231d 100644 --- a/src/generated/Education/Users/Item/Schools/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Education/Users/Item/Schools/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,22 +25,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - command.SetHandler(async (string educationUserId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Education/Users/Item/Schools/Ref/Ref.cs b/src/generated/Education/Users/Item/Schools/Ref/Ref.cs new file mode 100644 index 00000000000..c1ed7ede5c1 --- /dev/null +++ b/src/generated/Education/Users/Item/Schools/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Education.Users.Item.Schools.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Education/Users/Item/Schools/Ref/RefRequestBuilder.cs b/src/generated/Education/Users/Item/Schools/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..3510c30f217 --- /dev/null +++ b/src/generated/Education/Users/Item/Schools/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Education.Users.Item.Schools.Ref { + /// Builds and executes requests for operations under \education\users\{educationUser-id}\schools\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Schools to which the user belongs. Nullable. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Schools to which the user belongs. Nullable."; + // Create options for all the parameters + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { + }; + educationUserIdOption.IsRequired = true; + command.AddOption(educationUserIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Schools to which the user belongs. Nullable. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Schools to which the user belongs. Nullable."; + // Create options for all the parameters + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { + }; + educationUserIdOption.IsRequired = true; + command.AddOption(educationUserIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/education/users/{educationUser_id}/schools/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Schools to which the user belongs. Nullable. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Schools to which the user belongs. Nullable. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Education.Users.Item.Schools.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Schools to which the user belongs. Nullable. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Education/Users/Item/Schools/Ref/RefResponse.cs b/src/generated/Education/Users/Item/Schools/Ref/RefResponse.cs new file mode 100644 index 00000000000..8e995ad3238 --- /dev/null +++ b/src/generated/Education/Users/Item/Schools/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Education.Users.Item.Schools.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Education/Users/Item/Schools/SchoolsRequestBuilder.cs b/src/generated/Education/Users/Item/Schools/SchoolsRequestBuilder.cs index bdf3266ade5..574ab667806 100644 --- a/src/generated/Education/Users/Item/Schools/SchoolsRequestBuilder.cs +++ b/src/generated/Education/Users/Item/Schools/SchoolsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Education.Users.Item.Schools.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Schools to which the user belongs. Nullable."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); @@ -66,7 +66,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationUserId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -77,20 +81,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Education.Users.Item.Schools.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Education.Users.Item.Schools.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -135,18 +134,6 @@ public RequestInformation CreateGetRequestInformation(Action public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// Schools to which the user belongs. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Schools to which the user belongs. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Users/Item/TaughtClasses/@Ref/@Ref.cs b/src/generated/Education/Users/Item/TaughtClasses/@Ref/@Ref.cs deleted file mode 100644 index e4f6e5b19f8..00000000000 --- a/src/generated/Education/Users/Item/TaughtClasses/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Education.Users.Item.TaughtClasses.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Education/Users/Item/TaughtClasses/@Ref/RefRequestBuilder.cs b/src/generated/Education/Users/Item/TaughtClasses/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 7ddc0c08748..00000000000 --- a/src/generated/Education/Users/Item/TaughtClasses/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Education.Users.Item.TaughtClasses.@Ref { - /// Builds and executes requests for operations under \education\users\{educationUser-id}\taughtClasses\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Classes for which the user is a teacher. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Classes for which the user is a teacher."; - // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { - }; - educationUserIdOption.IsRequired = true; - command.AddOption(educationUserIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string educationUserId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Classes for which the user is a teacher. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Classes for which the user is a teacher."; - // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { - }; - educationUserIdOption.IsRequired = true; - command.AddOption(educationUserIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string educationUserId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/education/users/{educationUser_id}/taughtClasses/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Classes for which the user is a teacher. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Classes for which the user is a teacher. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Education.Users.Item.TaughtClasses.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Classes for which the user is a teacher. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Classes for which the user is a teacher. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Education.Users.Item.TaughtClasses.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Classes for which the user is a teacher. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Education/Users/Item/TaughtClasses/@Ref/RefResponse.cs b/src/generated/Education/Users/Item/TaughtClasses/@Ref/RefResponse.cs deleted file mode 100644 index 801a6e48a7b..00000000000 --- a/src/generated/Education/Users/Item/TaughtClasses/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Education.Users.Item.TaughtClasses.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Education/Users/Item/TaughtClasses/Delta/DeltaRequestBuilder.cs b/src/generated/Education/Users/Item/TaughtClasses/Delta/DeltaRequestBuilder.cs index 6b8eb70b43c..a0cbf44369f 100644 --- a/src/generated/Education/Users/Item/TaughtClasses/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Education/Users/Item/TaughtClasses/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,22 +25,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); - command.SetHandler(async (string educationUserId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Education/Users/Item/TaughtClasses/Ref/Ref.cs b/src/generated/Education/Users/Item/TaughtClasses/Ref/Ref.cs new file mode 100644 index 00000000000..9a8e84e81d7 --- /dev/null +++ b/src/generated/Education/Users/Item/TaughtClasses/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Education.Users.Item.TaughtClasses.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Education/Users/Item/TaughtClasses/Ref/RefRequestBuilder.cs b/src/generated/Education/Users/Item/TaughtClasses/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..c5dc9cb72aa --- /dev/null +++ b/src/generated/Education/Users/Item/TaughtClasses/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Education.Users.Item.TaughtClasses.Ref { + /// Builds and executes requests for operations under \education\users\{educationUser-id}\taughtClasses\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Classes for which the user is a teacher. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Classes for which the user is a teacher."; + // Create options for all the parameters + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { + }; + educationUserIdOption.IsRequired = true; + command.AddOption(educationUserIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Classes for which the user is a teacher. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Classes for which the user is a teacher."; + // Create options for all the parameters + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { + }; + educationUserIdOption.IsRequired = true; + command.AddOption(educationUserIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/education/users/{educationUser_id}/taughtClasses/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Classes for which the user is a teacher. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Classes for which the user is a teacher. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Education.Users.Item.TaughtClasses.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Classes for which the user is a teacher. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Education/Users/Item/TaughtClasses/Ref/RefResponse.cs b/src/generated/Education/Users/Item/TaughtClasses/Ref/RefResponse.cs new file mode 100644 index 00000000000..498bfee0722 --- /dev/null +++ b/src/generated/Education/Users/Item/TaughtClasses/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Education.Users.Item.TaughtClasses.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Education/Users/Item/TaughtClasses/TaughtClassesRequestBuilder.cs b/src/generated/Education/Users/Item/TaughtClasses/TaughtClassesRequestBuilder.cs index 88a51f67b23..98e494c0b7d 100644 --- a/src/generated/Education/Users/Item/TaughtClasses/TaughtClassesRequestBuilder.cs +++ b/src/generated/Education/Users/Item/TaughtClasses/TaughtClassesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Education.Users.Item.TaughtClasses.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Classes for which the user is a teacher."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); @@ -66,7 +66,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationUserId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -77,20 +81,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Education.Users.Item.TaughtClasses.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Education.Users.Item.TaughtClasses.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -135,18 +134,6 @@ public RequestInformation CreateGetRequestInformation(Action public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// Classes for which the user is a teacher. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Classes for which the user is a teacher. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Education/Users/Item/User/@Ref/@Ref.cs b/src/generated/Education/Users/Item/User/@Ref/@Ref.cs deleted file mode 100644 index 5b9a54fae4d..00000000000 --- a/src/generated/Education/Users/Item/User/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Education.Users.Item.User.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Education/Users/Item/User/@Ref/RefRequestBuilder.cs b/src/generated/Education/Users/Item/User/@Ref/RefRequestBuilder.cs deleted file mode 100644 index ca2032d8b86..00000000000 --- a/src/generated/Education/Users/Item/User/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Education.Users.Item.User.@Ref { - /// Builds and executes requests for operations under \education\users\{educationUser-id}\user\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The directory user corresponding to this user. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The directory user corresponding to this user."; - // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { - }; - educationUserIdOption.IsRequired = true; - command.AddOption(educationUserIdOption); - command.SetHandler(async (string educationUserId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, educationUserIdOption); - return command; - } - /// - /// The directory user corresponding to this user. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The directory user corresponding to this user."; - // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { - }; - educationUserIdOption.IsRequired = true; - command.AddOption(educationUserIdOption); - command.SetHandler(async (string educationUserId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption); - return command; - } - /// - /// The directory user corresponding to this user. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The directory user corresponding to this user."; - // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { - }; - educationUserIdOption.IsRequired = true; - command.AddOption(educationUserIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string educationUserId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, educationUserIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/education/users/{educationUser_id}/user/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The directory user corresponding to this user. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The directory user corresponding to this user. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The directory user corresponding to this user. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Education.Users.Item.User.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The directory user corresponding to this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The directory user corresponding to this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The directory user corresponding to this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Education.Users.Item.User.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Education/Users/Item/User/Ref/Ref.cs b/src/generated/Education/Users/Item/User/Ref/Ref.cs new file mode 100644 index 00000000000..fdc716a3526 --- /dev/null +++ b/src/generated/Education/Users/Item/User/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Education.Users.Item.User.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Education/Users/Item/User/Ref/RefRequestBuilder.cs b/src/generated/Education/Users/Item/User/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..01a1ed10810 --- /dev/null +++ b/src/generated/Education/Users/Item/User/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Education.Users.Item.User.Ref { + /// Builds and executes requests for operations under \education\users\{educationUser-id}\user\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The directory user corresponding to this user. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The directory user corresponding to this user."; + // Create options for all the parameters + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { + }; + educationUserIdOption.IsRequired = true; + command.AddOption(educationUserIdOption); + command.SetHandler(async (string educationUserId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, educationUserIdOption); + return command; + } + /// + /// The directory user corresponding to this user. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The directory user corresponding to this user."; + // Create options for all the parameters + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { + }; + educationUserIdOption.IsRequired = true; + command.AddOption(educationUserIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, outputOption); + return command; + } + /// + /// The directory user corresponding to this user. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The directory user corresponding to this user."; + // Create options for all the parameters + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { + }; + educationUserIdOption.IsRequired = true; + command.AddOption(educationUserIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string educationUserId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, educationUserIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/education/users/{educationUser_id}/user/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The directory user corresponding to this user. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The directory user corresponding to this user. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The directory user corresponding to this user. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Education.Users.Item.User.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Education/Users/Item/User/UserRequestBuilder.cs b/src/generated/Education/Users/Item/User/UserRequestBuilder.cs index 431819ec127..65f1feab769 100644 --- a/src/generated/Education/Users/Item/User/UserRequestBuilder.cs +++ b/src/generated/Education/Users/Item/User/UserRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The directory user corresponding to this user."; // Create options for all the parameters - var educationUserIdOption = new Option("--educationuser-id", description: "key: id of educationUser") { + var educationUserIdOption = new Option("--education-user-id", description: "key: id of educationUser") { }; educationUserIdOption.IsRequired = true; command.AddOption(educationUserIdOption); @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string educationUserId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string educationUserId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, educationUserIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, educationUserIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Education.Users.Item.User.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Education.Users.Item.User.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The directory user corresponding to this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The directory user corresponding to this user. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Education/Users/UsersRequestBuilder.cs b/src/generated/Education/Users/UsersRequestBuilder.cs index 751c33e6ed8..eb95464d92e 100644 --- a/src/generated/Education/Users/UsersRequestBuilder.cs +++ b/src/generated/Education/Users/UsersRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,17 +23,16 @@ public class UsersRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EducationUserRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAssignmentsCommand(), - builder.BuildClassesCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildRubricsCommand(), - builder.BuildSchoolsCommand(), - builder.BuildTaughtClassesCommand(), - builder.BuildUserCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAssignmentsCommand()); + commands.Add(builder.BuildClassesCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRubricsCommand()); + commands.Add(builder.BuildSchoolsCommand()); + commands.Add(builder.BuildTaughtClassesCommand()); + commands.Add(builder.BuildUserCommand()); return commands; } /// @@ -47,21 +46,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -106,7 +104,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -117,15 +119,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -186,31 +183,6 @@ public RequestInformation CreatePostRequestInformation(EducationUser body, Actio public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// Get users from education - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to users for education - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EducationUser model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get users from education public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/External/Connections/ConnectionsRequestBuilder.cs b/src/generated/External/Connections/ConnectionsRequestBuilder.cs index f0478d49a21..881a585cdf1 100644 --- a/src/generated/External/Connections/ConnectionsRequestBuilder.cs +++ b/src/generated/External/Connections/ConnectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph.ExternalConnectors; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ConnectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExternalConnectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(ExternalConnection body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get connections from external - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to connections for external - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ExternalConnection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get connections from external public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/External/Connections/Item/ExternalConnectionRequestBuilder.cs b/src/generated/External/Connections/Item/ExternalConnectionRequestBuilder.cs index 11e05aab1c9..6a48e214556 100644 --- a/src/generated/External/Connections/Item/ExternalConnectionRequestBuilder.cs +++ b/src/generated/External/Connections/Item/ExternalConnectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph.ExternalConnectors; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property connections for external"; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); - command.SetHandler(async (string externalConnectionId) => { + command.SetHandler(async (string externalConnectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, externalConnectionIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get connections from external"; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string externalConnectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string externalConnectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, externalConnectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, externalConnectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property connections in external"; // Create options for all the parameters - var externalConnectionIdOption = new Option("--externalconnection-id", description: "key: id of externalConnection") { + var externalConnectionIdOption = new Option("--external-connection-id", description: "key: id of externalConnection") { }; externalConnectionIdOption.IsRequired = true; command.AddOption(externalConnectionIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string externalConnectionId, string body) => { + command.SetHandler(async (string externalConnectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, externalConnectionIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ExternalConnection body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property connections for external - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get connections from external - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property connections in external - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ExternalConnection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get connections from external public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/External/ExternalRequestBuilder.cs b/src/generated/External/ExternalRequestBuilder.cs index 626e3cea439..44f441c94c8 100644 --- a/src/generated/External/ExternalRequestBuilder.cs +++ b/src/generated/External/ExternalRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph.ExternalConnectors; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,6 +23,9 @@ public class ExternalRequestBuilder { public Command BuildConnectionsCommand() { var command = new Command("connections"); var builder = new ApiSdk.External.Connections.ConnectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -44,20 +47,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -71,14 +73,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -135,31 +136,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get external - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update external - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.ExternalConnectors.External model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get external public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/GraphClient.cs b/src/generated/GraphClient.cs index 990e10e6fcb..84bb018d44f 100644 --- a/src/generated/GraphClient.cs +++ b/src/generated/GraphClient.cs @@ -68,11 +68,11 @@ using ApiSdk.Workbooks; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using Microsoft.Kiota.Serialization.Json; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -98,6 +98,9 @@ public Command BuildAdminCommand() { public Command BuildAgreementAcceptancesCommand() { var command = new Command("agreement-acceptances"); var builder = new ApiSdk.AgreementAcceptances.AgreementAcceptancesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -105,6 +108,9 @@ public Command BuildAgreementAcceptancesCommand() { public Command BuildAgreementsCommand() { var command = new Command("agreements"); var builder = new ApiSdk.Agreements.AgreementsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -120,6 +126,9 @@ public Command BuildAppCatalogsCommand() { public Command BuildApplicationsCommand() { var command = new Command("applications"); var builder = new ApiSdk.Applications.ApplicationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildGetAvailableExtensionPropertiesCommand()); command.AddCommand(builder.BuildGetByIdsCommand()); @@ -130,6 +139,9 @@ public Command BuildApplicationsCommand() { public Command BuildApplicationTemplatesCommand() { var command = new Command("application-templates"); var builder = new ApiSdk.ApplicationTemplates.ApplicationTemplatesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -148,6 +160,9 @@ public Command BuildAuditLogsCommand() { public Command BuildAuthenticationMethodConfigurationsCommand() { var command = new Command("authentication-method-configurations"); var builder = new ApiSdk.AuthenticationMethodConfigurations.AuthenticationMethodConfigurationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -171,6 +186,9 @@ public Command BuildBrandingCommand() { public Command BuildCertificateBasedAuthConfigurationCommand() { var command = new Command("certificate-based-auth-configuration"); var builder = new ApiSdk.CertificateBasedAuthConfiguration.CertificateBasedAuthConfigurationRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -178,84 +196,13 @@ public Command BuildCertificateBasedAuthConfigurationCommand() { public Command BuildChatsCommand() { var command = new Command("chats"); var builder = new ApiSdk.Chats.ChatsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; } - public Command BuildCommand() { - var command = new RootCommand(); - command.Description = "Instantiates a new GraphClient and sets the default values."; - command.AddCommand(BuildAdminCommand()); - command.AddCommand(BuildAgreementAcceptancesCommand()); - command.AddCommand(BuildAgreementsCommand()); - command.AddCommand(BuildAppCatalogsCommand()); - command.AddCommand(BuildApplicationsCommand()); - command.AddCommand(BuildApplicationTemplatesCommand()); - command.AddCommand(BuildAuditLogsCommand()); - command.AddCommand(BuildAuthenticationMethodConfigurationsCommand()); - command.AddCommand(BuildAuthenticationMethodsPolicyCommand()); - command.AddCommand(BuildBrandingCommand()); - command.AddCommand(BuildCertificateBasedAuthConfigurationCommand()); - command.AddCommand(BuildChatsCommand()); - command.AddCommand(BuildCommunicationsCommand()); - command.AddCommand(BuildComplianceCommand()); - command.AddCommand(BuildConnectionsCommand()); - command.AddCommand(BuildContactsCommand()); - command.AddCommand(BuildContractsCommand()); - command.AddCommand(BuildDataPolicyOperationsCommand()); - command.AddCommand(BuildDeviceAppManagementCommand()); - command.AddCommand(BuildDeviceManagementCommand()); - command.AddCommand(BuildDevicesCommand()); - command.AddCommand(BuildDirectoryCommand()); - command.AddCommand(BuildDirectoryObjectsCommand()); - command.AddCommand(BuildDirectoryRolesCommand()); - command.AddCommand(BuildDirectoryRoleTemplatesCommand()); - command.AddCommand(BuildDomainDnsRecordsCommand()); - command.AddCommand(BuildDomainsCommand()); - command.AddCommand(BuildDriveCommand()); - command.AddCommand(BuildDrivesCommand()); - command.AddCommand(BuildEducationCommand()); - command.AddCommand(BuildExternalCommand()); - command.AddCommand(BuildGetCommand()); - command.AddCommand(BuildGroupLifecyclePoliciesCommand()); - command.AddCommand(BuildGroupsCommand()); - command.AddCommand(BuildGroupSettingsCommand()); - command.AddCommand(BuildGroupSettingTemplatesCommand()); - command.AddCommand(BuildIdentityCommand()); - command.AddCommand(BuildIdentityGovernanceCommand()); - command.AddCommand(BuildIdentityProtectionCommand()); - command.AddCommand(BuildIdentityProvidersCommand()); - command.AddCommand(BuildInformationProtectionCommand()); - command.AddCommand(BuildInvitationsCommand()); - command.AddCommand(BuildLocalizationsCommand()); - command.AddCommand(BuildMeCommand()); - command.AddCommand(BuildOauth2PermissionGrantsCommand()); - command.AddCommand(BuildOrganizationCommand()); - command.AddCommand(BuildPermissionGrantsCommand()); - command.AddCommand(BuildPlacesCommand()); - command.AddCommand(BuildPlannerCommand()); - command.AddCommand(BuildPoliciesCommand()); - command.AddCommand(BuildPrintCommand()); - command.AddCommand(BuildPrivacyCommand()); - command.AddCommand(BuildReportsCommand()); - command.AddCommand(BuildRoleManagementCommand()); - command.AddCommand(BuildSchemaExtensionsCommand()); - command.AddCommand(BuildScopedRoleMembershipsCommand()); - command.AddCommand(BuildSearchCommand()); - command.AddCommand(BuildSecurityCommand()); - command.AddCommand(BuildServicePrincipalsCommand()); - command.AddCommand(BuildSharesCommand()); - command.AddCommand(BuildSitesCommand()); - command.AddCommand(BuildSolutionsCommand()); - command.AddCommand(BuildSubscribedSkusCommand()); - command.AddCommand(BuildSubscriptionsCommand()); - command.AddCommand(BuildTeamsCommand()); - command.AddCommand(BuildTeamsTemplatesCommand()); - command.AddCommand(BuildTeamworkCommand()); - command.AddCommand(BuildUsersCommand()); - command.AddCommand(BuildWorkbooksCommand()); - return command; - } public Command BuildCommunicationsCommand() { var command = new Command("communications"); var builder = new ApiSdk.Communications.CommunicationsRequestBuilder(PathParameters, RequestAdapter); @@ -278,6 +225,9 @@ public Command BuildComplianceCommand() { public Command BuildConnectionsCommand() { var command = new Command("connections"); var builder = new ApiSdk.Connections.ConnectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -285,6 +235,9 @@ public Command BuildConnectionsCommand() { public Command BuildContactsCommand() { var command = new Command("contacts"); var builder = new ApiSdk.Contacts.ContactsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildGetAvailableExtensionPropertiesCommand()); command.AddCommand(builder.BuildGetByIdsCommand()); @@ -295,6 +248,9 @@ public Command BuildContactsCommand() { public Command BuildContractsCommand() { var command = new Command("contracts"); var builder = new ApiSdk.Contracts.ContractsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildGetAvailableExtensionPropertiesCommand()); command.AddCommand(builder.BuildGetByIdsCommand()); @@ -305,6 +261,9 @@ public Command BuildContractsCommand() { public Command BuildDataPolicyOperationsCommand() { var command = new Command("data-policy-operations"); var builder = new ApiSdk.DataPolicyOperations.DataPolicyOperationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -372,6 +331,9 @@ public Command BuildDeviceManagementCommand() { public Command BuildDevicesCommand() { var command = new Command("devices"); var builder = new ApiSdk.Devices.DevicesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildGetAvailableExtensionPropertiesCommand()); command.AddCommand(builder.BuildGetByIdsCommand()); @@ -391,6 +353,9 @@ public Command BuildDirectoryCommand() { public Command BuildDirectoryObjectsCommand() { var command = new Command("directory-objects"); var builder = new ApiSdk.DirectoryObjects.DirectoryObjectsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildGetAvailableExtensionPropertiesCommand()); command.AddCommand(builder.BuildGetByIdsCommand()); @@ -401,6 +366,9 @@ public Command BuildDirectoryObjectsCommand() { public Command BuildDirectoryRolesCommand() { var command = new Command("directory-roles"); var builder = new ApiSdk.DirectoryRoles.DirectoryRolesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildGetAvailableExtensionPropertiesCommand()); command.AddCommand(builder.BuildGetByIdsCommand()); @@ -411,6 +379,9 @@ public Command BuildDirectoryRolesCommand() { public Command BuildDirectoryRoleTemplatesCommand() { var command = new Command("directory-role-templates"); var builder = new ApiSdk.DirectoryRoleTemplates.DirectoryRoleTemplatesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildGetAvailableExtensionPropertiesCommand()); command.AddCommand(builder.BuildGetByIdsCommand()); @@ -421,6 +392,9 @@ public Command BuildDirectoryRoleTemplatesCommand() { public Command BuildDomainDnsRecordsCommand() { var command = new Command("domain-dns-records"); var builder = new ApiSdk.DomainDnsRecords.DomainDnsRecordsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -428,6 +402,9 @@ public Command BuildDomainDnsRecordsCommand() { public Command BuildDomainsCommand() { var command = new Command("domains"); var builder = new ApiSdk.Domains.DomainsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -448,6 +425,9 @@ public Command BuildDriveCommand() { public Command BuildDrivesCommand() { var command = new Command("drives"); var builder = new ApiSdk.Drives.DrivesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -474,11 +454,10 @@ public Command BuildExternalCommand() { public Command BuildGetCommand() { var command = new Command("get"); // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -486,6 +465,9 @@ public Command BuildGetCommand() { public Command BuildGroupLifecyclePoliciesCommand() { var command = new Command("group-lifecycle-policies"); var builder = new ApiSdk.GroupLifecyclePolicies.GroupLifecyclePoliciesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -493,6 +475,9 @@ public Command BuildGroupLifecyclePoliciesCommand() { public Command BuildGroupsCommand() { var command = new Command("groups"); var builder = new ApiSdk.Groups.GroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildGetAvailableExtensionPropertiesCommand()); command.AddCommand(builder.BuildGetByIdsCommand()); @@ -503,6 +488,9 @@ public Command BuildGroupsCommand() { public Command BuildGroupSettingsCommand() { var command = new Command("group-settings"); var builder = new ApiSdk.GroupSettings.GroupSettingsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -510,6 +498,9 @@ public Command BuildGroupSettingsCommand() { public Command BuildGroupSettingTemplatesCommand() { var command = new Command("group-setting-templates"); var builder = new ApiSdk.GroupSettingTemplates.GroupSettingTemplatesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildGetAvailableExtensionPropertiesCommand()); command.AddCommand(builder.BuildGetByIdsCommand()); @@ -552,6 +543,9 @@ public Command BuildIdentityProtectionCommand() { public Command BuildIdentityProvidersCommand() { var command = new Command("identity-providers"); var builder = new ApiSdk.IdentityProviders.IdentityProvidersRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -568,6 +562,9 @@ public Command BuildInformationProtectionCommand() { public Command BuildInvitationsCommand() { var command = new Command("invitations"); var builder = new ApiSdk.Invitations.InvitationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -575,6 +572,9 @@ public Command BuildInvitationsCommand() { public Command BuildLocalizationsCommand() { var command = new Command("localizations"); var builder = new ApiSdk.Localizations.LocalizationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -651,6 +651,9 @@ public Command BuildMeCommand() { public Command BuildOauth2PermissionGrantsCommand() { var command = new Command("oauth2-permission-grants"); var builder = new ApiSdk.Oauth2PermissionGrants.Oauth2PermissionGrantsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -658,6 +661,9 @@ public Command BuildOauth2PermissionGrantsCommand() { public Command BuildOrganizationCommand() { var command = new Command("organization"); var builder = new ApiSdk.Organization.OrganizationRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildGetAvailableExtensionPropertiesCommand()); command.AddCommand(builder.BuildGetByIdsCommand()); @@ -668,6 +674,9 @@ public Command BuildOrganizationCommand() { public Command BuildPermissionGrantsCommand() { var command = new Command("permission-grants"); var builder = new ApiSdk.PermissionGrants.PermissionGrantsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildGetAvailableExtensionPropertiesCommand()); command.AddCommand(builder.BuildGetByIdsCommand()); @@ -678,6 +687,9 @@ public Command BuildPermissionGrantsCommand() { public Command BuildPlacesCommand() { var command = new Command("places"); var builder = new ApiSdk.Places.PlacesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -753,9 +765,89 @@ public Command BuildRoleManagementCommand() { command.AddCommand(builder.BuildPatchCommand()); return command; } + /// + /// Instantiates a new GraphClient and sets the default values. + /// + public Command BuildRootCommand() { + var command = new RootCommand(); + command.Description = "Instantiates a new GraphClient and sets the default values."; + command.AddCommand(BuildAdminCommand()); + command.AddCommand(BuildAgreementAcceptancesCommand()); + command.AddCommand(BuildAgreementsCommand()); + command.AddCommand(BuildAppCatalogsCommand()); + command.AddCommand(BuildApplicationsCommand()); + command.AddCommand(BuildApplicationTemplatesCommand()); + command.AddCommand(BuildAuditLogsCommand()); + command.AddCommand(BuildAuthenticationMethodConfigurationsCommand()); + command.AddCommand(BuildAuthenticationMethodsPolicyCommand()); + command.AddCommand(BuildBrandingCommand()); + command.AddCommand(BuildCertificateBasedAuthConfigurationCommand()); + command.AddCommand(BuildChatsCommand()); + command.AddCommand(BuildCommunicationsCommand()); + command.AddCommand(BuildComplianceCommand()); + command.AddCommand(BuildConnectionsCommand()); + command.AddCommand(BuildContactsCommand()); + command.AddCommand(BuildContractsCommand()); + command.AddCommand(BuildDataPolicyOperationsCommand()); + command.AddCommand(BuildDeviceAppManagementCommand()); + command.AddCommand(BuildDeviceManagementCommand()); + command.AddCommand(BuildDevicesCommand()); + command.AddCommand(BuildDirectoryCommand()); + command.AddCommand(BuildDirectoryObjectsCommand()); + command.AddCommand(BuildDirectoryRolesCommand()); + command.AddCommand(BuildDirectoryRoleTemplatesCommand()); + command.AddCommand(BuildDomainDnsRecordsCommand()); + command.AddCommand(BuildDomainsCommand()); + command.AddCommand(BuildDriveCommand()); + command.AddCommand(BuildDrivesCommand()); + command.AddCommand(BuildEducationCommand()); + command.AddCommand(BuildExternalCommand()); + command.AddCommand(BuildGetCommand()); + command.AddCommand(BuildGroupLifecyclePoliciesCommand()); + command.AddCommand(BuildGroupsCommand()); + command.AddCommand(BuildGroupSettingsCommand()); + command.AddCommand(BuildGroupSettingTemplatesCommand()); + command.AddCommand(BuildIdentityCommand()); + command.AddCommand(BuildIdentityGovernanceCommand()); + command.AddCommand(BuildIdentityProtectionCommand()); + command.AddCommand(BuildIdentityProvidersCommand()); + command.AddCommand(BuildInformationProtectionCommand()); + command.AddCommand(BuildInvitationsCommand()); + command.AddCommand(BuildLocalizationsCommand()); + command.AddCommand(BuildMeCommand()); + command.AddCommand(BuildOauth2PermissionGrantsCommand()); + command.AddCommand(BuildOrganizationCommand()); + command.AddCommand(BuildPermissionGrantsCommand()); + command.AddCommand(BuildPlacesCommand()); + command.AddCommand(BuildPlannerCommand()); + command.AddCommand(BuildPoliciesCommand()); + command.AddCommand(BuildPrintCommand()); + command.AddCommand(BuildPrivacyCommand()); + command.AddCommand(BuildReportsCommand()); + command.AddCommand(BuildRoleManagementCommand()); + command.AddCommand(BuildSchemaExtensionsCommand()); + command.AddCommand(BuildScopedRoleMembershipsCommand()); + command.AddCommand(BuildSearchCommand()); + command.AddCommand(BuildSecurityCommand()); + command.AddCommand(BuildServicePrincipalsCommand()); + command.AddCommand(BuildSharesCommand()); + command.AddCommand(BuildSitesCommand()); + command.AddCommand(BuildSolutionsCommand()); + command.AddCommand(BuildSubscribedSkusCommand()); + command.AddCommand(BuildSubscriptionsCommand()); + command.AddCommand(BuildTeamsCommand()); + command.AddCommand(BuildTeamsTemplatesCommand()); + command.AddCommand(BuildTeamworkCommand()); + command.AddCommand(BuildUsersCommand()); + command.AddCommand(BuildWorkbooksCommand()); + return command; + } public Command BuildSchemaExtensionsCommand() { var command = new Command("schema-extensions"); var builder = new ApiSdk.SchemaExtensions.SchemaExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -763,6 +855,9 @@ public Command BuildSchemaExtensionsCommand() { public Command BuildScopedRoleMembershipsCommand() { var command = new Command("scoped-role-memberships"); var builder = new ApiSdk.ScopedRoleMemberships.ScopedRoleMembershipsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -788,6 +883,9 @@ public Command BuildSecurityCommand() { public Command BuildServicePrincipalsCommand() { var command = new Command("service-principals"); var builder = new ApiSdk.ServicePrincipals.ServicePrincipalsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildGetAvailableExtensionPropertiesCommand()); command.AddCommand(builder.BuildGetByIdsCommand()); @@ -798,6 +896,9 @@ public Command BuildServicePrincipalsCommand() { public Command BuildSharesCommand() { var command = new Command("shares"); var builder = new ApiSdk.Shares.SharesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -806,6 +907,9 @@ public Command BuildSitesCommand() { var command = new Command("sites"); var builder = new ApiSdk.Sites.SitesRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); command.AddCommand(builder.BuildRemoveCommand()); @@ -823,6 +927,9 @@ public Command BuildSolutionsCommand() { public Command BuildSubscribedSkusCommand() { var command = new Command("subscribed-skus"); var builder = new ApiSdk.SubscribedSkus.SubscribedSkusRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -830,6 +937,9 @@ public Command BuildSubscribedSkusCommand() { public Command BuildSubscriptionsCommand() { var command = new Command("subscriptions"); var builder = new ApiSdk.Subscriptions.SubscriptionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -837,6 +947,9 @@ public Command BuildSubscriptionsCommand() { public Command BuildTeamsCommand() { var command = new Command("teams"); var builder = new ApiSdk.Teams.TeamsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -844,6 +957,9 @@ public Command BuildTeamsCommand() { public Command BuildTeamsTemplatesCommand() { var command = new Command("teams-templates"); var builder = new ApiSdk.TeamsTemplates.TeamsTemplatesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -859,6 +975,9 @@ public Command BuildTeamworkCommand() { public Command BuildUsersCommand() { var command = new Command("users"); var builder = new ApiSdk.Users.UsersRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildGetAvailableExtensionPropertiesCommand()); command.AddCommand(builder.BuildGetByIdsCommand()); @@ -869,6 +988,9 @@ public Command BuildUsersCommand() { public Command BuildWorkbooksCommand() { var command = new Command("workbooks"); var builder = new ApiSdk.Workbooks.WorkbooksRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -896,9 +1018,5 @@ public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/GroupLifecyclePolicies/GroupLifecyclePoliciesRequestBuilder.cs b/src/generated/GroupLifecyclePolicies/GroupLifecyclePoliciesRequestBuilder.cs index 96a47e5909b..d092aaa9b97 100644 --- a/src/generated/GroupLifecyclePolicies/GroupLifecyclePoliciesRequestBuilder.cs +++ b/src/generated/GroupLifecyclePolicies/GroupLifecyclePoliciesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class GroupLifecyclePoliciesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new GroupLifecyclePolicyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAddGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildRemoveGroupCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAddGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRemoveGroupCommand()); return commands; } /// @@ -42,21 +41,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -101,7 +99,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -112,15 +114,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -175,31 +172,6 @@ public RequestInformation CreatePostRequestInformation(GroupLifecyclePolicy body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get entities from groupLifecyclePolicies - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to groupLifecyclePolicies - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GroupLifecyclePolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from groupLifecyclePolicies public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/GroupLifecyclePolicies/Item/AddGroup/AddGroupRequestBuilder.cs b/src/generated/GroupLifecyclePolicies/Item/AddGroup/AddGroupRequestBuilder.cs index 11ff1d5a1b6..b6b19601ac1 100644 --- a/src/generated/GroupLifecyclePolicies/Item/AddGroup/AddGroupRequestBuilder.cs +++ b/src/generated/GroupLifecyclePolicies/Item/AddGroup/AddGroupRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action addGroup"; // Create options for all the parameters - var groupLifecyclePolicyIdOption = new Option("--grouplifecyclepolicy-id", description: "key: id of groupLifecyclePolicy") { + var groupLifecyclePolicyIdOption = new Option("--group-lifecycle-policy-id", description: "key: id of groupLifecyclePolicy") { }; groupLifecyclePolicyIdOption.IsRequired = true; command.AddOption(groupLifecyclePolicyIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupLifecyclePolicyId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupLifecyclePolicyId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteBoolValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupLifecyclePolicyIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupLifecyclePolicyIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(AddGroupRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action addGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/GroupLifecyclePolicies/Item/GroupLifecyclePolicyRequestBuilder.cs b/src/generated/GroupLifecyclePolicies/Item/GroupLifecyclePolicyRequestBuilder.cs index 249695add40..285981a6cd1 100644 --- a/src/generated/GroupLifecyclePolicies/Item/GroupLifecyclePolicyRequestBuilder.cs +++ b/src/generated/GroupLifecyclePolicies/Item/GroupLifecyclePolicyRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete entity from groupLifecyclePolicies"; // Create options for all the parameters - var groupLifecyclePolicyIdOption = new Option("--grouplifecyclepolicy-id", description: "key: id of groupLifecyclePolicy") { + var groupLifecyclePolicyIdOption = new Option("--group-lifecycle-policy-id", description: "key: id of groupLifecyclePolicy") { }; groupLifecyclePolicyIdOption.IsRequired = true; command.AddOption(groupLifecyclePolicyIdOption); - command.SetHandler(async (string groupLifecyclePolicyId) => { + command.SetHandler(async (string groupLifecyclePolicyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupLifecyclePolicyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get entity from groupLifecyclePolicies by key"; // Create options for all the parameters - var groupLifecyclePolicyIdOption = new Option("--grouplifecyclepolicy-id", description: "key: id of groupLifecyclePolicy") { + var groupLifecyclePolicyIdOption = new Option("--group-lifecycle-policy-id", description: "key: id of groupLifecyclePolicy") { }; groupLifecyclePolicyIdOption.IsRequired = true; command.AddOption(groupLifecyclePolicyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupLifecyclePolicyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupLifecyclePolicyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupLifecyclePolicyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupLifecyclePolicyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,7 +89,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update entity in groupLifecyclePolicies"; // Create options for all the parameters - var groupLifecyclePolicyIdOption = new Option("--grouplifecyclepolicy-id", description: "key: id of groupLifecyclePolicy") { + var groupLifecyclePolicyIdOption = new Option("--group-lifecycle-policy-id", description: "key: id of groupLifecyclePolicy") { }; groupLifecyclePolicyIdOption.IsRequired = true; command.AddOption(groupLifecyclePolicyIdOption); @@ -99,14 +97,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupLifecyclePolicyId, string body) => { + command.SetHandler(async (string groupLifecyclePolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupLifecyclePolicyIdOption, bodyOption); return command; @@ -184,42 +181,6 @@ public RequestInformation CreatePatchRequestInformation(GroupLifecyclePolicy bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from groupLifecyclePolicies - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from groupLifecyclePolicies by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in groupLifecyclePolicies - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(GroupLifecyclePolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from groupLifecyclePolicies by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/GroupLifecyclePolicies/Item/RemoveGroup/RemoveGroupRequestBuilder.cs b/src/generated/GroupLifecyclePolicies/Item/RemoveGroup/RemoveGroupRequestBuilder.cs index aefc5d779b1..33204eee06b 100644 --- a/src/generated/GroupLifecyclePolicies/Item/RemoveGroup/RemoveGroupRequestBuilder.cs +++ b/src/generated/GroupLifecyclePolicies/Item/RemoveGroup/RemoveGroupRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action removeGroup"; // Create options for all the parameters - var groupLifecyclePolicyIdOption = new Option("--grouplifecyclepolicy-id", description: "key: id of groupLifecyclePolicy") { + var groupLifecyclePolicyIdOption = new Option("--group-lifecycle-policy-id", description: "key: id of groupLifecyclePolicy") { }; groupLifecyclePolicyIdOption.IsRequired = true; command.AddOption(groupLifecyclePolicyIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupLifecyclePolicyId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupLifecyclePolicyId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteBoolValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupLifecyclePolicyIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupLifecyclePolicyIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(RemoveGroupRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action removeGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RemoveGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/GroupSettingTemplates/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs b/src/generated/GroupSettingTemplates/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs deleted file mode 100644 index 23116d167bc..00000000000 --- a/src/generated/GroupSettingTemplates/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs +++ /dev/null @@ -1,45 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.GroupSettingTemplates.GetAvailableExtensionProperties { - public class GetAvailableExtensionProperties : DirectoryObject, IParsable { - /// Display name of the application object on which this extension property is defined. Read-only. - public string AppDisplayName { get; set; } - /// Specifies the data type of the value the extension property can hold. Following values are supported. Not nullable. Binary - 256 bytes maximumBooleanDateTime - Must be specified in ISO 8601 format. Will be stored in UTC.Integer - 32-bit value.LargeInteger - 64-bit value.String - 256 characters maximum - public string DataType { get; set; } - /// Indicates if this extension property was sycned from onpremises directory using Azure AD Connect. Read-only. - public bool? IsSyncedFromOnPremises { get; set; } - /// Name of the extension property. Not nullable. - public string Name { get; set; } - /// Following values are supported. Not nullable. UserGroupOrganizationDeviceApplication - public List TargetObjects { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"appDisplayName", (o,n) => { (o as GetAvailableExtensionProperties).AppDisplayName = n.GetStringValue(); } }, - {"dataType", (o,n) => { (o as GetAvailableExtensionProperties).DataType = n.GetStringValue(); } }, - {"isSyncedFromOnPremises", (o,n) => { (o as GetAvailableExtensionProperties).IsSyncedFromOnPremises = n.GetBoolValue(); } }, - {"name", (o,n) => { (o as GetAvailableExtensionProperties).Name = n.GetStringValue(); } }, - {"targetObjects", (o,n) => { (o as GetAvailableExtensionProperties).TargetObjects = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteStringValue("appDisplayName", AppDisplayName); - writer.WriteStringValue("dataType", DataType); - writer.WriteBoolValue("isSyncedFromOnPremises", IsSyncedFromOnPremises); - writer.WriteStringValue("name", Name); - writer.WriteCollectionOfPrimitiveValues("targetObjects", TargetObjects); - } - } -} diff --git a/src/generated/GroupSettingTemplates/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs b/src/generated/GroupSettingTemplates/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs index 03e13ebafd0..d71c4731a85 100644 --- a/src/generated/GroupSettingTemplates/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs +++ b/src/generated/GroupSettingTemplates/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(GetAvailableExtensionProp requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getAvailableExtensionProperties - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetAvailableExtensionPropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/GroupSettingTemplates/GetByIds/GetByIds.cs b/src/generated/GroupSettingTemplates/GetByIds/GetByIds.cs deleted file mode 100644 index 11e40e007e4..00000000000 --- a/src/generated/GroupSettingTemplates/GetByIds/GetByIds.cs +++ /dev/null @@ -1,28 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.GroupSettingTemplates.GetByIds { - public class GetByIds : Entity, IParsable { - public DateTimeOffset? DeletedDateTime { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"deletedDateTime", (o,n) => { (o as GetByIds).DeletedDateTime = n.GetDateTimeOffsetValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteDateTimeOffsetValue("deletedDateTime", DeletedDateTime); - } - } -} diff --git a/src/generated/GroupSettingTemplates/GetByIds/GetByIdsRequestBuilder.cs b/src/generated/GroupSettingTemplates/GetByIds/GetByIdsRequestBuilder.cs index 366a16910ab..9258b241017 100644 --- a/src/generated/GroupSettingTemplates/GetByIds/GetByIdsRequestBuilder.cs +++ b/src/generated/GroupSettingTemplates/GetByIds/GetByIdsRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(GetByIdsRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getByIds - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetByIdsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/GroupSettingTemplates/GroupSettingTemplatesRequestBuilder.cs b/src/generated/GroupSettingTemplates/GroupSettingTemplatesRequestBuilder.cs index cb4d1bdb65d..8379edfb0bc 100644 --- a/src/generated/GroupSettingTemplates/GroupSettingTemplatesRequestBuilder.cs +++ b/src/generated/GroupSettingTemplates/GroupSettingTemplatesRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,16 +25,15 @@ public class GroupSettingTemplatesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new GroupSettingTemplateRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCheckMemberGroupsCommand(), - builder.BuildCheckMemberObjectsCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildGetMemberGroupsCommand(), - builder.BuildGetMemberObjectsCommand(), - builder.BuildPatchCommand(), - builder.BuildRestoreCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCheckMemberGroupsCommand()); + commands.Add(builder.BuildCheckMemberObjectsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildGetMemberGroupsCommand()); + commands.Add(builder.BuildGetMemberObjectsCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRestoreCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } public Command BuildGetAvailableExtensionPropertiesCommand() { @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -130,15 +132,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildValidatePropertiesCommand() { @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(GroupSettingTemplate body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get entities from groupSettingTemplates - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to groupSettingTemplates - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GroupSettingTemplate model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from groupSettingTemplates public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/GroupSettingTemplates/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs b/src/generated/GroupSettingTemplates/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs index 0c05a464edc..3aff30c57f3 100644 --- a/src/generated/GroupSettingTemplates/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs +++ b/src/generated/GroupSettingTemplates/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action checkMemberGroups"; // Create options for all the parameters - var groupSettingTemplateIdOption = new Option("--groupsettingtemplate-id", description: "key: id of groupSettingTemplate") { + var groupSettingTemplateIdOption = new Option("--group-setting-template-id", description: "key: id of groupSettingTemplate") { }; groupSettingTemplateIdOption.IsRequired = true; command.AddOption(groupSettingTemplateIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupSettingTemplateId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupSettingTemplateId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupSettingTemplateIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupSettingTemplateIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberGroupsRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/GroupSettingTemplates/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs b/src/generated/GroupSettingTemplates/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs index 55edc80bd29..8fca7ae58fd 100644 --- a/src/generated/GroupSettingTemplates/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs +++ b/src/generated/GroupSettingTemplates/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action checkMemberObjects"; // Create options for all the parameters - var groupSettingTemplateIdOption = new Option("--groupsettingtemplate-id", description: "key: id of groupSettingTemplate") { + var groupSettingTemplateIdOption = new Option("--group-setting-template-id", description: "key: id of groupSettingTemplate") { }; groupSettingTemplateIdOption.IsRequired = true; command.AddOption(groupSettingTemplateIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupSettingTemplateId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupSettingTemplateId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupSettingTemplateIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupSettingTemplateIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberObjectsRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/GroupSettingTemplates/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs b/src/generated/GroupSettingTemplates/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs index 1039f30ab49..d22c44147f3 100644 --- a/src/generated/GroupSettingTemplates/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs +++ b/src/generated/GroupSettingTemplates/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action getMemberGroups"; // Create options for all the parameters - var groupSettingTemplateIdOption = new Option("--groupsettingtemplate-id", description: "key: id of groupSettingTemplate") { + var groupSettingTemplateIdOption = new Option("--group-setting-template-id", description: "key: id of groupSettingTemplate") { }; groupSettingTemplateIdOption.IsRequired = true; command.AddOption(groupSettingTemplateIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupSettingTemplateId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupSettingTemplateId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupSettingTemplateIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupSettingTemplateIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberGroupsRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/GroupSettingTemplates/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs b/src/generated/GroupSettingTemplates/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs index 21b92b8ec11..ab2a2bf9537 100644 --- a/src/generated/GroupSettingTemplates/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs +++ b/src/generated/GroupSettingTemplates/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action getMemberObjects"; // Create options for all the parameters - var groupSettingTemplateIdOption = new Option("--groupsettingtemplate-id", description: "key: id of groupSettingTemplate") { + var groupSettingTemplateIdOption = new Option("--group-setting-template-id", description: "key: id of groupSettingTemplate") { }; groupSettingTemplateIdOption.IsRequired = true; command.AddOption(groupSettingTemplateIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupSettingTemplateId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupSettingTemplateId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupSettingTemplateIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupSettingTemplateIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberObjectsRequestBo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/GroupSettingTemplates/Item/GroupSettingTemplateRequestBuilder.cs b/src/generated/GroupSettingTemplates/Item/GroupSettingTemplateRequestBuilder.cs index 234ffbfd01f..fd608472e7e 100644 --- a/src/generated/GroupSettingTemplates/Item/GroupSettingTemplateRequestBuilder.cs +++ b/src/generated/GroupSettingTemplates/Item/GroupSettingTemplateRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -43,15 +43,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete entity from groupSettingTemplates"; // Create options for all the parameters - var groupSettingTemplateIdOption = new Option("--groupsettingtemplate-id", description: "key: id of groupSettingTemplate") { + var groupSettingTemplateIdOption = new Option("--group-setting-template-id", description: "key: id of groupSettingTemplate") { }; groupSettingTemplateIdOption.IsRequired = true; command.AddOption(groupSettingTemplateIdOption); - command.SetHandler(async (string groupSettingTemplateId) => { + command.SetHandler(async (string groupSettingTemplateId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupSettingTemplateIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get entity from groupSettingTemplates by key"; // Create options for all the parameters - var groupSettingTemplateIdOption = new Option("--groupsettingtemplate-id", description: "key: id of groupSettingTemplate") { + var groupSettingTemplateIdOption = new Option("--group-setting-template-id", description: "key: id of groupSettingTemplate") { }; groupSettingTemplateIdOption.IsRequired = true; command.AddOption(groupSettingTemplateIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupSettingTemplateId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupSettingTemplateId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupSettingTemplateIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupSettingTemplateIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildGetMemberGroupsCommand() { @@ -112,7 +110,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update entity in groupSettingTemplates"; // Create options for all the parameters - var groupSettingTemplateIdOption = new Option("--groupsettingtemplate-id", description: "key: id of groupSettingTemplate") { + var groupSettingTemplateIdOption = new Option("--group-setting-template-id", description: "key: id of groupSettingTemplate") { }; groupSettingTemplateIdOption.IsRequired = true; command.AddOption(groupSettingTemplateIdOption); @@ -120,14 +118,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupSettingTemplateId, string body) => { + command.SetHandler(async (string groupSettingTemplateId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupSettingTemplateIdOption, bodyOption); return command; @@ -205,42 +202,6 @@ public RequestInformation CreatePatchRequestInformation(GroupSettingTemplate bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from groupSettingTemplates - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from groupSettingTemplates by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in groupSettingTemplates - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(GroupSettingTemplate model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from groupSettingTemplates by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/GroupSettingTemplates/Item/Restore/RestoreRequestBuilder.cs b/src/generated/GroupSettingTemplates/Item/Restore/RestoreRequestBuilder.cs index c6775f885a7..9c7603d9975 100644 --- a/src/generated/GroupSettingTemplates/Item/Restore/RestoreRequestBuilder.cs +++ b/src/generated/GroupSettingTemplates/Item/Restore/RestoreRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action restore"; // Create options for all the parameters - var groupSettingTemplateIdOption = new Option("--groupsettingtemplate-id", description: "key: id of groupSettingTemplate") { + var groupSettingTemplateIdOption = new Option("--group-setting-template-id", description: "key: id of groupSettingTemplate") { }; groupSettingTemplateIdOption.IsRequired = true; command.AddOption(groupSettingTemplateIdOption); - command.SetHandler(async (string groupSettingTemplateId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupSettingTemplateId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupSettingTemplateIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupSettingTemplateIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action restore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes directoryObject public class RestoreResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/GroupSettingTemplates/ValidateProperties/ValidatePropertiesRequestBuilder.cs b/src/generated/GroupSettingTemplates/ValidateProperties/ValidatePropertiesRequestBuilder.cs index 4ca84678ad0..8ca23f9a32f 100644 --- a/src/generated/GroupSettingTemplates/ValidateProperties/ValidatePropertiesRequestBuilder.cs +++ b/src/generated/GroupSettingTemplates/ValidateProperties/ValidatePropertiesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,14 +29,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -72,18 +71,5 @@ public RequestInformation CreatePostRequestInformation(ValidatePropertiesRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action validateProperties - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ValidatePropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/GroupSettings/GroupSettingsRequestBuilder.cs b/src/generated/GroupSettings/GroupSettingsRequestBuilder.cs index ec766bb4a6f..a41b80f6a54 100644 --- a/src/generated/GroupSettings/GroupSettingsRequestBuilder.cs +++ b/src/generated/GroupSettings/GroupSettingsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class GroupSettingsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new GroupSettingRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(GroupSetting body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get entities from groupSettings - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to groupSettings - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GroupSetting model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from groupSettings public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/GroupSettings/Item/GroupSettingRequestBuilder.cs b/src/generated/GroupSettings/Item/GroupSettingRequestBuilder.cs index cc83e0e792c..d0b683d2c87 100644 --- a/src/generated/GroupSettings/Item/GroupSettingRequestBuilder.cs +++ b/src/generated/GroupSettings/Item/GroupSettingRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete entity from groupSettings"; // Create options for all the parameters - var groupSettingIdOption = new Option("--groupsetting-id", description: "key: id of groupSetting") { + var groupSettingIdOption = new Option("--group-setting-id", description: "key: id of groupSetting") { }; groupSettingIdOption.IsRequired = true; command.AddOption(groupSettingIdOption); - command.SetHandler(async (string groupSettingId) => { + command.SetHandler(async (string groupSettingId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupSettingIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get entity from groupSettings by key"; // Create options for all the parameters - var groupSettingIdOption = new Option("--groupsetting-id", description: "key: id of groupSetting") { + var groupSettingIdOption = new Option("--group-setting-id", description: "key: id of groupSetting") { }; groupSettingIdOption.IsRequired = true; command.AddOption(groupSettingIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupSettingId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupSettingId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupSettingIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupSettingIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update entity in groupSettings"; // Create options for all the parameters - var groupSettingIdOption = new Option("--groupsetting-id", description: "key: id of groupSetting") { + var groupSettingIdOption = new Option("--group-setting-id", description: "key: id of groupSetting") { }; groupSettingIdOption.IsRequired = true; command.AddOption(groupSettingIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupSettingId, string body) => { + command.SetHandler(async (string groupSettingId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupSettingIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(GroupSetting body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from groupSettings - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from groupSettings by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in groupSettings - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(GroupSetting model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from groupSettings by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Delta/DeltaRequestBuilder.cs b/src/generated/Groups/Delta/DeltaRequestBuilder.cs index ade8403c653..de7005c6e6a 100644 --- a/src/generated/Groups/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Groups/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs b/src/generated/Groups/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs deleted file mode 100644 index d7db17f5558..00000000000 --- a/src/generated/Groups/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs +++ /dev/null @@ -1,45 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.GetAvailableExtensionProperties { - public class GetAvailableExtensionProperties : DirectoryObject, IParsable { - /// Display name of the application object on which this extension property is defined. Read-only. - public string AppDisplayName { get; set; } - /// Specifies the data type of the value the extension property can hold. Following values are supported. Not nullable. Binary - 256 bytes maximumBooleanDateTime - Must be specified in ISO 8601 format. Will be stored in UTC.Integer - 32-bit value.LargeInteger - 64-bit value.String - 256 characters maximum - public string DataType { get; set; } - /// Indicates if this extension property was sycned from onpremises directory using Azure AD Connect. Read-only. - public bool? IsSyncedFromOnPremises { get; set; } - /// Name of the extension property. Not nullable. - public string Name { get; set; } - /// Following values are supported. Not nullable. UserGroupOrganizationDeviceApplication - public List TargetObjects { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"appDisplayName", (o,n) => { (o as GetAvailableExtensionProperties).AppDisplayName = n.GetStringValue(); } }, - {"dataType", (o,n) => { (o as GetAvailableExtensionProperties).DataType = n.GetStringValue(); } }, - {"isSyncedFromOnPremises", (o,n) => { (o as GetAvailableExtensionProperties).IsSyncedFromOnPremises = n.GetBoolValue(); } }, - {"name", (o,n) => { (o as GetAvailableExtensionProperties).Name = n.GetStringValue(); } }, - {"targetObjects", (o,n) => { (o as GetAvailableExtensionProperties).TargetObjects = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteStringValue("appDisplayName", AppDisplayName); - writer.WriteStringValue("dataType", DataType); - writer.WriteBoolValue("isSyncedFromOnPremises", IsSyncedFromOnPremises); - writer.WriteStringValue("name", Name); - writer.WriteCollectionOfPrimitiveValues("targetObjects", TargetObjects); - } - } -} diff --git a/src/generated/Groups/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs b/src/generated/Groups/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs index afec0a5384c..278030a39cd 100644 --- a/src/generated/Groups/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs +++ b/src/generated/Groups/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(GetAvailableExtensionProp requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getAvailableExtensionProperties - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetAvailableExtensionPropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/GetByIds/GetByIds.cs b/src/generated/Groups/GetByIds/GetByIds.cs deleted file mode 100644 index b163f25a0f1..00000000000 --- a/src/generated/Groups/GetByIds/GetByIds.cs +++ /dev/null @@ -1,28 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.GetByIds { - public class GetByIds : Entity, IParsable { - public DateTimeOffset? DeletedDateTime { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"deletedDateTime", (o,n) => { (o as GetByIds).DeletedDateTime = n.GetDateTimeOffsetValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteDateTimeOffsetValue("deletedDateTime", DeletedDateTime); - } - } -} diff --git a/src/generated/Groups/GetByIds/GetByIdsRequestBuilder.cs b/src/generated/Groups/GetByIds/GetByIdsRequestBuilder.cs index 85459b28817..ab84c11a5e8 100644 --- a/src/generated/Groups/GetByIds/GetByIdsRequestBuilder.cs +++ b/src/generated/Groups/GetByIds/GetByIdsRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(GetByIdsRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getByIds - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetByIdsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/GroupsRequestBuilder.cs b/src/generated/Groups/GroupsRequestBuilder.cs index 4876cb91f30..a1eae07464e 100644 --- a/src/generated/Groups/GroupsRequestBuilder.cs +++ b/src/generated/Groups/GroupsRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,52 +26,51 @@ public class GroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new GroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptedSendersCommand(), - builder.BuildAddFavoriteCommand(), - builder.BuildAppRoleAssignmentsCommand(), - builder.BuildAssignLicenseCommand(), - builder.BuildCalendarCommand(), - builder.BuildCalendarViewCommand(), - builder.BuildCheckGrantedPermissionsForAppCommand(), - builder.BuildCheckMemberGroupsCommand(), - builder.BuildCheckMemberObjectsCommand(), - builder.BuildConversationsCommand(), - builder.BuildCreatedOnBehalfOfCommand(), - builder.BuildDeleteCommand(), - builder.BuildDriveCommand(), - builder.BuildDrivesCommand(), - builder.BuildEventsCommand(), - builder.BuildExtensionsCommand(), - builder.BuildGetCommand(), - builder.BuildGetMemberGroupsCommand(), - builder.BuildGetMemberObjectsCommand(), - builder.BuildGroupLifecyclePoliciesCommand(), - builder.BuildMemberOfCommand(), - builder.BuildMembersCommand(), - builder.BuildMembersWithLicenseErrorsCommand(), - builder.BuildOnenoteCommand(), - builder.BuildOwnersCommand(), - builder.BuildPatchCommand(), - builder.BuildPermissionGrantsCommand(), - builder.BuildPhotoCommand(), - builder.BuildPhotosCommand(), - builder.BuildPlannerCommand(), - builder.BuildRejectedSendersCommand(), - builder.BuildRemoveFavoriteCommand(), - builder.BuildRenewCommand(), - builder.BuildResetUnseenCountCommand(), - builder.BuildRestoreCommand(), - builder.BuildSettingsCommand(), - builder.BuildSitesCommand(), - builder.BuildSubscribeByMailCommand(), - builder.BuildTeamCommand(), - builder.BuildThreadsCommand(), - builder.BuildTransitiveMemberOfCommand(), - builder.BuildTransitiveMembersCommand(), - builder.BuildUnsubscribeByMailCommand(), - builder.BuildValidatePropertiesCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptedSendersCommand()); + commands.Add(builder.BuildAddFavoriteCommand()); + commands.Add(builder.BuildAppRoleAssignmentsCommand()); + commands.Add(builder.BuildAssignLicenseCommand()); + commands.Add(builder.BuildCalendarCommand()); + commands.Add(builder.BuildCalendarViewCommand()); + commands.Add(builder.BuildCheckGrantedPermissionsForAppCommand()); + commands.Add(builder.BuildCheckMemberGroupsCommand()); + commands.Add(builder.BuildCheckMemberObjectsCommand()); + commands.Add(builder.BuildConversationsCommand()); + commands.Add(builder.BuildCreatedOnBehalfOfCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDriveCommand()); + commands.Add(builder.BuildDrivesCommand()); + commands.Add(builder.BuildEventsCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildGetMemberGroupsCommand()); + commands.Add(builder.BuildGetMemberObjectsCommand()); + commands.Add(builder.BuildGroupLifecyclePoliciesCommand()); + commands.Add(builder.BuildMemberOfCommand()); + commands.Add(builder.BuildMembersCommand()); + commands.Add(builder.BuildMembersWithLicenseErrorsCommand()); + commands.Add(builder.BuildOnenoteCommand()); + commands.Add(builder.BuildOwnersCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPermissionGrantsCommand()); + commands.Add(builder.BuildPhotoCommand()); + commands.Add(builder.BuildPhotosCommand()); + commands.Add(builder.BuildPlannerCommand()); + commands.Add(builder.BuildRejectedSendersCommand()); + commands.Add(builder.BuildRemoveFavoriteCommand()); + commands.Add(builder.BuildRenewCommand()); + commands.Add(builder.BuildResetUnseenCountCommand()); + commands.Add(builder.BuildRestoreCommand()); + commands.Add(builder.BuildSettingsCommand()); + commands.Add(builder.BuildSitesCommand()); + commands.Add(builder.BuildSubscribeByMailCommand()); + commands.Add(builder.BuildTeamCommand()); + commands.Add(builder.BuildThreadsCommand()); + commands.Add(builder.BuildTransitiveMemberOfCommand()); + commands.Add(builder.BuildTransitiveMembersCommand()); + commands.Add(builder.BuildUnsubscribeByMailCommand()); + commands.Add(builder.BuildValidatePropertiesCommand()); return commands; } /// @@ -85,21 +84,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } public Command BuildGetAvailableExtensionPropertiesCommand() { @@ -156,7 +154,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -167,15 +169,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildValidatePropertiesCommand() { @@ -242,31 +239,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// Get entities from groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Group model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from groups public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/AcceptedSenders/@Ref/@Ref.cs b/src/generated/Groups/Item/AcceptedSenders/@Ref/@Ref.cs deleted file mode 100644 index e5468d7d082..00000000000 --- a/src/generated/Groups/Item/AcceptedSenders/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.AcceptedSenders.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Groups/Item/AcceptedSenders/@Ref/RefRequestBuilder.cs b/src/generated/Groups/Item/AcceptedSenders/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 90d63dc1945..00000000000 --- a/src/generated/Groups/Item/AcceptedSenders/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,195 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Groups.Item.AcceptedSenders.@Ref { - /// Builds and executes requests for operations under \groups\{group-id}\acceptedSenders\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The list of users or groups that are allowed to create post's or calendar events in this group. If this list is non-empty then only users or groups listed here are allowed to post. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The list of users or groups that are allowed to create post's or calendar events in this group. If this list is non-empty then only users or groups listed here are allowed to post."; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string groupId, int? top, int? skip, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The list of users or groups that are allowed to create post's or calendar events in this group. If this list is non-empty then only users or groups listed here are allowed to post. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The list of users or groups that are allowed to create post's or calendar events in this group. If this list is non-empty then only users or groups listed here are allowed to post."; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/groups/{group_id}/acceptedSenders/$ref{?top,skip,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The list of users or groups that are allowed to create post's or calendar events in this group. If this list is non-empty then only users or groups listed here are allowed to post. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The list of users or groups that are allowed to create post's or calendar events in this group. If this list is non-empty then only users or groups listed here are allowed to post. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Groups.Item.AcceptedSenders.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The list of users or groups that are allowed to create post's or calendar events in this group. If this list is non-empty then only users or groups listed here are allowed to post. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of users or groups that are allowed to create post's or calendar events in this group. If this list is non-empty then only users or groups listed here are allowed to post. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Groups.Item.AcceptedSenders.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The list of users or groups that are allowed to create post's or calendar events in this group. If this list is non-empty then only users or groups listed here are allowed to post. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Groups/Item/AcceptedSenders/@Ref/RefResponse.cs b/src/generated/Groups/Item/AcceptedSenders/@Ref/RefResponse.cs deleted file mode 100644 index 504b1f1efba..00000000000 --- a/src/generated/Groups/Item/AcceptedSenders/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.AcceptedSenders.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Groups/Item/AcceptedSenders/AcceptedSendersRequestBuilder.cs b/src/generated/Groups/Item/AcceptedSenders/AcceptedSendersRequestBuilder.cs index ebc251a6bf8..c674d672739 100644 --- a/src/generated/Groups/Item/AcceptedSenders/AcceptedSendersRequestBuilder.cs +++ b/src/generated/Groups/Item/AcceptedSenders/AcceptedSendersRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Groups.Item.AcceptedSenders.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -56,7 +56,11 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -65,20 +69,15 @@ public Command BuildGetCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Groups.Item.AcceptedSenders.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Groups.Item.AcceptedSenders.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -117,18 +116,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of users or groups that are allowed to create post's or calendar events in this group. If this list is non-empty then only users or groups listed here are allowed to post. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of users or groups that are allowed to create post's or calendar events in this group. If this list is non-empty then only users or groups listed here are allowed to post. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/AcceptedSenders/Ref/Ref.cs b/src/generated/Groups/Item/AcceptedSenders/Ref/Ref.cs new file mode 100644 index 00000000000..d1fbe7c5ed9 --- /dev/null +++ b/src/generated/Groups/Item/AcceptedSenders/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Groups.Item.AcceptedSenders.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Groups/Item/AcceptedSenders/Ref/RefRequestBuilder.cs b/src/generated/Groups/Item/AcceptedSenders/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..7b6a6862302 --- /dev/null +++ b/src/generated/Groups/Item/AcceptedSenders/Ref/RefRequestBuilder.cs @@ -0,0 +1,168 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Groups.Item.AcceptedSenders.Ref { + /// Builds and executes requests for operations under \groups\{group-id}\acceptedSenders\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The list of users or groups that are allowed to create post's or calendar events in this group. If this list is non-empty then only users or groups listed here are allowed to post. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The list of users or groups that are allowed to create post's or calendar events in this group. If this list is non-empty then only users or groups listed here are allowed to post."; + // Create options for all the parameters + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The list of users or groups that are allowed to create post's or calendar events in this group. If this list is non-empty then only users or groups listed here are allowed to post. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The list of users or groups that are allowed to create post's or calendar events in this group. If this list is non-empty then only users or groups listed here are allowed to post."; + // Create options for all the parameters + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/groups/{group_id}/acceptedSenders/$ref{?top,skip,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The list of users or groups that are allowed to create post's or calendar events in this group. If this list is non-empty then only users or groups listed here are allowed to post. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The list of users or groups that are allowed to create post's or calendar events in this group. If this list is non-empty then only users or groups listed here are allowed to post. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Groups.Item.AcceptedSenders.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The list of users or groups that are allowed to create post's or calendar events in this group. If this list is non-empty then only users or groups listed here are allowed to post. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Groups/Item/AcceptedSenders/Ref/RefResponse.cs b/src/generated/Groups/Item/AcceptedSenders/Ref/RefResponse.cs new file mode 100644 index 00000000000..8391505bb74 --- /dev/null +++ b/src/generated/Groups/Item/AcceptedSenders/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Groups.Item.AcceptedSenders.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Groups/Item/AddFavorite/AddFavoriteRequestBuilder.cs b/src/generated/Groups/Item/AddFavorite/AddFavoriteRequestBuilder.cs index 2453a1eed1e..b65efe401bd 100644 --- a/src/generated/Groups/Item/AddFavorite/AddFavoriteRequestBuilder.cs +++ b/src/generated/Groups/Item/AddFavorite/AddFavoriteRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,10 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - command.SetHandler(async (string groupId) => { + command.SetHandler(async (string groupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action addFavorite - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/AppRoleAssignments/AppRoleAssignmentsRequestBuilder.cs b/src/generated/Groups/Item/AppRoleAssignments/AppRoleAssignmentsRequestBuilder.cs index a2d26a347f0..5ae03868614 100644 --- a/src/generated/Groups/Item/AppRoleAssignments/AppRoleAssignmentsRequestBuilder.cs +++ b/src/generated/Groups/Item/AppRoleAssignments/AppRoleAssignmentsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AppRoleAssignmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AppRoleAssignmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(AppRoleAssignment body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the app roles a group has been granted for an application. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the app roles a group has been granted for an application. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AppRoleAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the app roles a group has been granted for an application. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/AppRoleAssignments/Item/AppRoleAssignmentRequestBuilder.cs b/src/generated/Groups/Item/AppRoleAssignments/Item/AppRoleAssignmentRequestBuilder.cs index d0845bb621d..2c1584dcf26 100644 --- a/src/generated/Groups/Item/AppRoleAssignments/Item/AppRoleAssignmentRequestBuilder.cs +++ b/src/generated/Groups/Item/AppRoleAssignments/Item/AppRoleAssignmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var appRoleAssignmentIdOption = new Option("--approleassignment-id", description: "key: id of appRoleAssignment") { + var appRoleAssignmentIdOption = new Option("--app-role-assignment-id", description: "key: id of appRoleAssignment") { }; appRoleAssignmentIdOption.IsRequired = true; command.AddOption(appRoleAssignmentIdOption); - command.SetHandler(async (string groupId, string appRoleAssignmentId) => { + command.SetHandler(async (string groupId, string appRoleAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, appRoleAssignmentIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var appRoleAssignmentIdOption = new Option("--approleassignment-id", description: "key: id of appRoleAssignment") { + var appRoleAssignmentIdOption = new Option("--app-role-assignment-id", description: "key: id of appRoleAssignment") { }; appRoleAssignmentIdOption.IsRequired = true; command.AddOption(appRoleAssignmentIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string appRoleAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string appRoleAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, appRoleAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, appRoleAssignmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var appRoleAssignmentIdOption = new Option("--approleassignment-id", description: "key: id of appRoleAssignment") { + var appRoleAssignmentIdOption = new Option("--app-role-assignment-id", description: "key: id of appRoleAssignment") { }; appRoleAssignmentIdOption.IsRequired = true; command.AddOption(appRoleAssignmentIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string appRoleAssignmentId, string body) => { + command.SetHandler(async (string groupId, string appRoleAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, appRoleAssignmentIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(AppRoleAssignment body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the app roles a group has been granted for an application. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the app roles a group has been granted for an application. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the app roles a group has been granted for an application. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AppRoleAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the app roles a group has been granted for an application. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/AssignLicense/AssignLicenseRequestBuilder.cs b/src/generated/Groups/Item/AssignLicense/AssignLicenseRequestBuilder.cs index 3882e7d9da6..4d843a79099 100644 --- a/src/generated/Groups/Item/AssignLicense/AssignLicenseRequestBuilder.cs +++ b/src/generated/Groups/Item/AssignLicense/AssignLicenseRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(AssignLicenseRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assignLicense - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignLicenseRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes group public class AssignLicenseResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs b/src/generated/Groups/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs index 74491811db9..c5ab5a7707c 100644 --- a/src/generated/Groups/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +33,17 @@ public Command BuildGetCommand() { }; UserOption.IsRequired = true; command.AddOption(UserOption); - command.SetHandler(async (string groupId, string User) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string User, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, UserOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, UserOption, outputOption); return command; } /// @@ -77,16 +76,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function allowedCalendarSharingRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs index 6c48c7885f2..5b6cde10a5c 100644 --- a/src/generated/Groups/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class CalendarPermissionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new CalendarPermissionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -98,7 +96,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -107,15 +109,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -170,31 +167,6 @@ public RequestInformation CreatePostRequestInformation(CalendarPermission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CalendarPermission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions of the users with whom the calendar is shared. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs index 398ab7ff1b7..b358be2b0b2 100644 --- a/src/generated/Groups/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); - command.SetHandler(async (string groupId, string calendarPermissionId) => { + command.SetHandler(async (string groupId, string calendarPermissionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, calendarPermissionIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); @@ -63,19 +62,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string calendarPermissionId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string calendarPermissionId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, calendarPermissionIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, calendarPermissionIdOption, selectOption, outputOption); return command; } /// @@ -89,7 +87,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); @@ -97,14 +95,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string calendarPermissionId, string body) => { + command.SetHandler(async (string groupId, string calendarPermissionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, calendarPermissionIdOption, bodyOption); return command; @@ -176,42 +173,6 @@ public RequestInformation CreatePatchRequestInformation(CalendarPermission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(CalendarPermission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions of the users with whom the calendar is shared. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Groups/Item/Calendar/CalendarRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarRequestBuilder.cs index 18bc3927a6c..669e30cef43 100644 --- a/src/generated/Groups/Item/Calendar/CalendarRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,6 +37,9 @@ public AllowedCalendarSharingRolesWithUserRequestBuilder AllowedCalendarSharingR public Command BuildCalendarPermissionsCommand() { var command = new Command("calendar-permissions"); var builder = new ApiSdk.Groups.Item.Calendar.CalendarPermissions.CalendarPermissionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -44,6 +47,9 @@ public Command BuildCalendarPermissionsCommand() { public Command BuildCalendarViewCommand() { var command = new Command("calendar-view"); var builder = new ApiSdk.Groups.Item.Calendar.CalendarView.CalendarViewRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -59,11 +65,10 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - command.SetHandler(async (string groupId) => { + command.SetHandler(async (string groupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption); return command; @@ -71,6 +76,9 @@ public Command BuildDeleteCommand() { public Command BuildEventsCommand() { var command = new Command("events"); var builder = new ApiSdk.Groups.Item.Calendar.Events.EventsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -91,19 +99,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, selectOption, outputOption); return command; } public Command BuildGetScheduleCommand() { @@ -115,6 +122,9 @@ public Command BuildGetScheduleCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Groups.Item.Calendar.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + command.SetHandler(async (string groupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, bodyOption); return command; @@ -149,6 +158,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Groups.Item.Calendar.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -220,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The group's calendar. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The group's calendar. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The group's calendar. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The group's calendar. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Groups/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs index c31d59f0b67..f469fcc324c 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,24 +23,23 @@ public class CalendarViewRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildAttachmentsCommand(), - builder.BuildCalendarCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildExtensionsCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildInstancesCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildAttachmentsCommand()); + commands.Add(builder.BuildCalendarCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInstancesCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -58,21 +57,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -86,11 +84,11 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var startDateTimeOption = new Option("--startdatetime", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { + var startDateTimeOption = new Option("--start-date-time", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { }; startDateTimeOption.IsRequired = true; command.AddOption(startDateTimeOption); - var endDateTimeOption = new Option("--enddatetime", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { + var endDateTimeOption = new Option("--end-date-time", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { }; endDateTimeOption.IsRequired = true; command.AddOption(endDateTimeOption); @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string startDateTime, string endDateTime, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string startDateTime, string endDateTime, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { if (!String.IsNullOrEmpty(startDateTime)) q.StartDateTime = startDateTime; if (!String.IsNullOrEmpty(endDateTime)) q.EndDateTime = endDateTime; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, startDateTimeOption, endDateTimeOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, startDateTimeOption, endDateTimeOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -182,7 +179,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -200,31 +197,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Calendar/CalendarView/CalendarViewResponse.cs b/src/generated/Groups/Item/Calendar/CalendarView/CalendarViewResponse.cs index 37212f5ba19..5c334b600cb 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/CalendarViewResponse.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/CalendarViewResponse.cs @@ -9,7 +9,7 @@ public class CalendarViewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new calendarViewResponse and sets the default values. /// @@ -22,7 +22,7 @@ public CalendarViewResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as CalendarViewResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Delta/Delta.cs b/src/generated/Groups/Item/Calendar/CalendarView/Delta/Delta.cs deleted file mode 100644 index 47652cdd59c..00000000000 --- a/src/generated/Groups/Item/Calendar/CalendarView/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.Calendar.CalendarView.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs index 88496d7c9ff..1a5f08ec0f6 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +30,17 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - command.SetHandler(async (string groupId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs index 6e9526117b1..de917539cc4 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs index cc22506cb41..856cf2a4fa9 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class AttachmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttachmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } public Command BuildCreateUploadSessionCommand() { @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(Attachment body, Action - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index 3fd6b0ae68a..7f414c4fb72 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs index 5c0dfa7ed11..910ebdf21c8 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; attachmentIdOption.IsRequired = true; command.AddOption(attachmentIdOption); - command.SetHandler(async (string groupId, string eventId, string attachmentId) => { + command.SetHandler(async (string groupId, string eventId, string attachmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, attachmentIdOption); return command; @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, string attachmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string attachmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string attachmentId, string body) => { + command.SetHandler(async (string groupId, string eventId, string attachmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, attachmentIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Attachment body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs index efbb1c28247..f8d22926c17 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,18 +37,17 @@ public Command BuildGetCommand() { }; UserOption.IsRequired = true; command.AddOption(UserOption); - command.SetHandler(async (string groupId, string eventId, string User) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string User, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, UserOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, UserOption, outputOption); return command; } /// @@ -81,16 +80,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function allowedCalendarSharingRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/Calendar/CalendarRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/Calendar/CalendarRequestBuilder.cs index 9c3487db2fa..8872c537d43 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/Calendar/CalendarRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/Calendar/CalendarRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,11 +44,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string groupId, string eventId) => { + command.SetHandler(async (string groupId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption); return command; @@ -73,19 +72,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, selectOption, outputOption); return command; } public Command BuildGetScheduleCommand() { @@ -113,14 +111,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -192,42 +189,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar that contains the event. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs index 9116d1131f1..723be49a014 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,21 +37,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -85,18 +84,5 @@ public RequestInformation CreatePostRequestInformation(GetScheduleRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSchedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetScheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs index e7bf015b6dd..b6d9cece7d3 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs index f832f35414d..0359b0df0df 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs index de587971e42..c7601db624c 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,11 +33,10 @@ public Command BuildPostCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string groupId, string eventId) => { + command.SetHandler(async (string groupId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs index b21808cb39b..1b41f627be8 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs @@ -14,10 +14,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,6 +41,9 @@ public Command BuildAcceptCommand() { public Command BuildAttachmentsCommand() { var command = new Command("attachments"); var builder = new ApiSdk.Groups.Item.Calendar.CalendarView.Item.Attachments.AttachmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateUploadSessionCommand()); command.AddCommand(builder.BuildListCommand()); @@ -82,11 +85,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string groupId, string eventId) => { + command.SetHandler(async (string groupId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption); return command; @@ -100,6 +102,9 @@ public Command BuildDismissReminderCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Groups.Item.Calendar.CalendarView.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -125,11 +130,11 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var startDateTimeOption = new Option("--startdatetime", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { + var startDateTimeOption = new Option("--start-date-time", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { }; startDateTimeOption.IsRequired = true; command.AddOption(startDateTimeOption); - var endDateTimeOption = new Option("--enddatetime", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { + var endDateTimeOption = new Option("--end-date-time", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { }; endDateTimeOption.IsRequired = true; command.AddOption(endDateTimeOption); @@ -138,26 +143,28 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, string startDateTime, string endDateTime, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string startDateTime, string endDateTime, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { if (!String.IsNullOrEmpty(startDateTime)) q.StartDateTime = startDateTime; if (!String.IsNullOrEmpty(endDateTime)) q.EndDateTime = endDateTime; q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, startDateTimeOption, endDateTimeOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, startDateTimeOption, endDateTimeOption, selectOption, outputOption); return command; } public Command BuildInstancesCommand() { var command = new Command("instances"); var builder = new ApiSdk.Groups.Item.Calendar.CalendarView.Item.Instances.InstancesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -165,6 +172,9 @@ public Command BuildInstancesCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Groups.Item.Calendar.CalendarView.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -188,14 +198,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -203,6 +212,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Groups.Item.Calendar.CalendarView.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -274,7 +286,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -286,42 +298,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00 diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs index d5871b90009..9d134a19ff0 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs index b1af0085dbb..d6b0cb2473f 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string groupId, string eventId, string extensionId) => { + command.SetHandler(async (string groupId, string eventId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, extensionIdOption); return command; @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string extensionId, string body) => { + command.SetHandler(async (string groupId, string eventId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, extensionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs index f5cab62195d..59d9cbe11a2 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Delta/Delta.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Delta/Delta.cs deleted file mode 100644 index ef42e7a1d7e..00000000000 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.Calendar.CalendarView.Item.Instances.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs index a48f4032e11..ce2ef03b591 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +34,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string groupId, string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, outputOption); return command; } /// @@ -75,16 +75,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/InstancesRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/InstancesRequestBuilder.cs index d328e2811e4..d9be42a7c1a 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/InstancesRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/InstancesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class InstancesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -114,7 +112,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -174,7 +171,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/InstancesResponse.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/InstancesResponse.cs index 89e1f7fa65f..c43ed5a3e9d 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/InstancesResponse.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/InstancesResponse.cs @@ -9,7 +9,7 @@ public class InstancesResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new instancesResponse and sets the default values. /// @@ -22,7 +22,7 @@ public InstancesResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as InstancesResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs index 5d7722a82d2..c3dd86b1635 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs index 0ec5477c58c..6d435c80302 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs index 18733946801..4f6b2975e68 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs index 853fe25e1b7..41b0d21fd5c 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,11 +37,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string groupId, string eventId, string eventId1) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/EventRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/EventRequestBuilder.cs index 681bb8bb0a9..1893cbfe6b1 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/EventRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -63,11 +63,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string groupId, string eventId, string eventId1) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option); return command; @@ -108,19 +107,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -146,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -225,7 +222,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -237,42 +234,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs index 135dd757a26..a4a11413bac 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index b98e33cac32..6ec437c714f 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index 80b3c187e56..3d0c5f6fdb3 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 3ac300891e1..cb919418716 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 62338be0b84..1f818812472 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index b6c29bec569..2714c024200 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 1343f9569e7..382eb571936 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 32c58a1b5a8..94473b8f63a 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Groups/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index 04149695cc3..962f1cc4d5c 100644 --- a/src/generated/Groups/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/Events/Delta/Delta.cs b/src/generated/Groups/Item/Calendar/Events/Delta/Delta.cs deleted file mode 100644 index 7d86bae2c26..00000000000 --- a/src/generated/Groups/Item/Calendar/Events/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.Calendar.Events.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Groups/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs index a28e4f1c863..985cf57a5bd 100644 --- a/src/generated/Groups/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +30,17 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - command.SetHandler(async (string groupId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/Events/EventsRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/EventsRequestBuilder.cs index 777d7fc4e7d..66a912f6525 100644 --- a/src/generated/Groups/Item/Calendar/Events/EventsRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/EventsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,24 +23,23 @@ public class EventsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildAttachmentsCommand(), - builder.BuildCalendarCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildExtensionsCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildInstancesCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildAttachmentsCommand()); + commands.Add(builder.BuildCalendarCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInstancesCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -58,21 +57,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -112,7 +110,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -172,7 +169,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -190,31 +187,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The events in the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Calendar/Events/EventsResponse.cs b/src/generated/Groups/Item/Calendar/Events/EventsResponse.cs index 4321d37bb30..edf52c3c342 100644 --- a/src/generated/Groups/Item/Calendar/Events/EventsResponse.cs +++ b/src/generated/Groups/Item/Calendar/Events/EventsResponse.cs @@ -9,7 +9,7 @@ public class EventsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new eventsResponse and sets the default values. /// @@ -22,7 +22,7 @@ public EventsResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as EventsResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Groups/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs index 8345de63123..dea57e6ece3 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/Events/Item/Attachments/AttachmentsRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/Attachments/AttachmentsRequestBuilder.cs index 2ef102f4a30..1d1576a7bb4 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/Attachments/AttachmentsRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/Attachments/AttachmentsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class AttachmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttachmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } public Command BuildCreateUploadSessionCommand() { @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(Attachment body, Action - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Calendar/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index 56b5512f344..1c5eb75a99d 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Calendar/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs index a98dcfd7e8b..c9fd3f6de10 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; attachmentIdOption.IsRequired = true; command.AddOption(attachmentIdOption); - command.SetHandler(async (string groupId, string eventId, string attachmentId) => { + command.SetHandler(async (string groupId, string eventId, string attachmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, attachmentIdOption); return command; @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, string attachmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string attachmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string attachmentId, string body) => { + command.SetHandler(async (string groupId, string eventId, string attachmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, attachmentIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Attachment body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Calendar/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs index 70a11d9d1e3..64507ef086d 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,18 +37,17 @@ public Command BuildGetCommand() { }; UserOption.IsRequired = true; command.AddOption(UserOption); - command.SetHandler(async (string groupId, string eventId, string User) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string User, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, UserOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, UserOption, outputOption); return command; } /// @@ -81,16 +80,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function allowedCalendarSharingRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/Events/Item/Calendar/CalendarRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/Calendar/CalendarRequestBuilder.cs index ea47332d788..72083490093 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/Calendar/CalendarRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/Calendar/CalendarRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,11 +44,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string groupId, string eventId) => { + command.SetHandler(async (string groupId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption); return command; @@ -73,19 +72,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, selectOption, outputOption); return command; } public Command BuildGetScheduleCommand() { @@ -113,14 +111,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -192,42 +189,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar that contains the event. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Groups/Item/Calendar/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs index 573ad2f2f16..3e7ea15608e 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,21 +37,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -85,18 +84,5 @@ public RequestInformation CreatePostRequestInformation(GetScheduleRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSchedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetScheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs index 45677162284..6e885601da8 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs index 1ed4c36b827..64e960a7495 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs index 7b3a0125270..b5545c92ae2 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,11 +33,10 @@ public Command BuildPostCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string groupId, string eventId) => { + command.SetHandler(async (string groupId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/Events/Item/EventRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/EventRequestBuilder.cs index 079e43f602a..3a9f9b26df8 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/EventRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/EventRequestBuilder.cs @@ -14,10 +14,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,6 +41,9 @@ public Command BuildAcceptCommand() { public Command BuildAttachmentsCommand() { var command = new Command("attachments"); var builder = new ApiSdk.Groups.Item.Calendar.Events.Item.Attachments.AttachmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateUploadSessionCommand()); command.AddCommand(builder.BuildListCommand()); @@ -82,11 +85,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string groupId, string eventId) => { + command.SetHandler(async (string groupId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption); return command; @@ -100,6 +102,9 @@ public Command BuildDismissReminderCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Groups.Item.Calendar.Events.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -130,24 +135,26 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, selectOption, outputOption); return command; } public Command BuildInstancesCommand() { var command = new Command("instances"); var builder = new ApiSdk.Groups.Item.Calendar.Events.Item.Instances.InstancesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -155,6 +162,9 @@ public Command BuildInstancesCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Groups.Item.Calendar.Events.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -178,14 +188,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -193,6 +202,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Groups.Item.Calendar.Events.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -264,7 +276,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -276,42 +288,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The events in the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Groups/Item/Calendar/Events/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/Extensions/ExtensionsRequestBuilder.cs index f5c295963d4..07aee587b9b 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Calendar/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs index 9ff6e77a558..fb6a510ec06 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string groupId, string eventId, string extensionId) => { + command.SetHandler(async (string groupId, string eventId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, extensionIdOption); return command; @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string extensionId, string body) => { + command.SetHandler(async (string groupId, string eventId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, extensionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs index 6fbf0b49517..766e83c4011 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/Events/Item/Instances/Delta/Delta.cs b/src/generated/Groups/Item/Calendar/Events/Item/Instances/Delta/Delta.cs deleted file mode 100644 index f862d9dc676..00000000000 --- a/src/generated/Groups/Item/Calendar/Events/Item/Instances/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.Calendar.Events.Item.Instances.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Groups/Item/Calendar/Events/Item/Instances/Delta/DeltaRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/Instances/Delta/DeltaRequestBuilder.cs index 9edf8db51f1..00ec34e7942 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/Instances/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/Instances/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +34,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string groupId, string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, outputOption); return command; } /// @@ -75,16 +75,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/Events/Item/Instances/InstancesRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/Instances/InstancesRequestBuilder.cs index b4cca4c8def..270639291b9 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/Instances/InstancesRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/Instances/InstancesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class InstancesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -114,7 +112,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -174,7 +171,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Calendar/Events/Item/Instances/InstancesResponse.cs b/src/generated/Groups/Item/Calendar/Events/Item/Instances/InstancesResponse.cs index 1f2b55cffb9..abdf05accf9 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/Instances/InstancesResponse.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/Instances/InstancesResponse.cs @@ -9,7 +9,7 @@ public class InstancesResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new instancesResponse and sets the default values. /// @@ -22,7 +22,7 @@ public InstancesResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as InstancesResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs index ba285c21a62..527587df52c 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs index cecde0903e0..f39b95118e2 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs index 3d089a7771c..5d24a320aba 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs index 674e7f0ea73..bff4e22b774 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,11 +37,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string groupId, string eventId, string eventId1) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/EventRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/EventRequestBuilder.cs index e146fc4c49c..cd82a3d8dd2 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/EventRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -63,11 +63,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string groupId, string eventId, string eventId1) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option); return command; @@ -108,19 +107,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -146,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -225,7 +222,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -237,42 +234,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs index 3d954141d3a..4720c06e73a 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 3dd6bb25e64..1ed9fcd1133 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index 45493d788b6..c3c9c33395e 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index ed916dce0de..283926b5a9d 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Calendar/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 6ff0b6ea732..72318f73e31 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Calendar/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 6626d7ab121..8f4e1685bbd 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Calendar/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 6f59c257983..2f88800d6e6 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 84406170af6..4cb6893a1f7 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Groups/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index 6a09cbde380..7a905346d44 100644 --- a/src/generated/Groups/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs b/src/generated/Groups/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs index 429448d25a9..c56a16f6bb6 100644 --- a/src/generated/Groups/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetScheduleRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSchedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetScheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Groups/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 465abc718d4..ba12c9cd2c9 100644 --- a/src/generated/Groups/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string groupId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string groupId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string groupId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Groups/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 46c02749e8e..4e85e383f7f 100644 --- a/src/generated/Groups/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Groups/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 9ee6658566c..c3a4a0e70ac 100644 --- a/src/generated/Groups/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string groupId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string groupId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string groupId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Groups/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 62fe5524235..c837a479acc 100644 --- a/src/generated/Groups/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Groups/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/CalendarView/CalendarViewRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/CalendarViewRequestBuilder.cs index af6179f3ad5..1ff23c11943 100644 --- a/src/generated/Groups/Item/CalendarView/CalendarViewRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/CalendarViewRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,24 +23,23 @@ public class CalendarViewRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildAttachmentsCommand(), - builder.BuildCalendarCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildExtensionsCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildInstancesCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildAttachmentsCommand()); + commands.Add(builder.BuildCalendarCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInstancesCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -58,21 +57,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -86,11 +84,11 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var startDateTimeOption = new Option("--startdatetime", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { + var startDateTimeOption = new Option("--start-date-time", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { }; startDateTimeOption.IsRequired = true; command.AddOption(startDateTimeOption); - var endDateTimeOption = new Option("--enddatetime", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { + var endDateTimeOption = new Option("--end-date-time", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { }; endDateTimeOption.IsRequired = true; command.AddOption(endDateTimeOption); @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string startDateTime, string endDateTime, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string startDateTime, string endDateTime, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { if (!String.IsNullOrEmpty(startDateTime)) q.StartDateTime = startDateTime; if (!String.IsNullOrEmpty(endDateTime)) q.EndDateTime = endDateTime; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, startDateTimeOption, endDateTimeOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, startDateTimeOption, endDateTimeOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -182,7 +179,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -200,31 +197,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The calendar view for the calendar. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/CalendarView/CalendarViewResponse.cs b/src/generated/Groups/Item/CalendarView/CalendarViewResponse.cs index c5ca3ed417e..ed1f58d2baf 100644 --- a/src/generated/Groups/Item/CalendarView/CalendarViewResponse.cs +++ b/src/generated/Groups/Item/CalendarView/CalendarViewResponse.cs @@ -9,7 +9,7 @@ public class CalendarViewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new calendarViewResponse and sets the default values. /// @@ -22,7 +22,7 @@ public CalendarViewResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as CalendarViewResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Groups/Item/CalendarView/Delta/Delta.cs b/src/generated/Groups/Item/CalendarView/Delta/Delta.cs deleted file mode 100644 index a0caca374f9..00000000000 --- a/src/generated/Groups/Item/CalendarView/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.CalendarView.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Groups/Item/CalendarView/Delta/DeltaRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Delta/DeltaRequestBuilder.cs index 9a1525c1050..bc45ae932de 100644 --- a/src/generated/Groups/Item/CalendarView/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +30,17 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - command.SetHandler(async (string groupId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Accept/AcceptRequestBuilder.cs index 3d90a773e26..91cf853cf4c 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs index 4fcaaa43c14..910c557cbb1 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class AttachmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttachmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } public Command BuildCreateUploadSessionCommand() { @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(Attachment body, Action - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index ba59ce8e7a6..9d6b937510a 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs index 44d72b691b0..0fdfd4cf8cc 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; attachmentIdOption.IsRequired = true; command.AddOption(attachmentIdOption); - command.SetHandler(async (string groupId, string eventId, string attachmentId) => { + command.SetHandler(async (string groupId, string eventId, string attachmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, attachmentIdOption); return command; @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, string attachmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string attachmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string attachmentId, string body) => { + command.SetHandler(async (string groupId, string eventId, string attachmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, attachmentIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Attachment body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs index f29862b660a..dffd1177833 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,18 +37,17 @@ public Command BuildGetCommand() { }; UserOption.IsRequired = true; command.AddOption(UserOption); - command.SetHandler(async (string groupId, string eventId, string User) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string User, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, UserOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, UserOption, outputOption); return command; } /// @@ -81,16 +80,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function allowedCalendarSharingRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs index 0f941267d48..37e43c7318b 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class CalendarPermissionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new CalendarPermissionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -106,7 +104,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -115,15 +117,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -178,31 +175,6 @@ public RequestInformation CreatePostRequestInformation(CalendarPermission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CalendarPermission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions of the users with whom the calendar is shared. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs index ea7b078d5d7..34cc567b84e 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); - command.SetHandler(async (string groupId, string eventId, string calendarPermissionId) => { + command.SetHandler(async (string groupId, string eventId, string calendarPermissionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, calendarPermissionIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); @@ -71,19 +70,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, string calendarPermissionId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string calendarPermissionId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, calendarPermissionIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, calendarPermissionIdOption, selectOption, outputOption); return command; } /// @@ -101,7 +99,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); @@ -109,14 +107,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string calendarPermissionId, string body) => { + command.SetHandler(async (string groupId, string eventId, string calendarPermissionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, calendarPermissionIdOption, bodyOption); return command; @@ -188,42 +185,6 @@ public RequestInformation CreatePatchRequestInformation(CalendarPermission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(CalendarPermission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions of the users with whom the calendar is shared. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarRequestBuilder.cs index acbf9dafd85..6c513f89afa 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,6 +37,9 @@ public AllowedCalendarSharingRolesWithUserRequestBuilder AllowedCalendarSharingR public Command BuildCalendarPermissionsCommand() { var command = new Command("calendar-permissions"); var builder = new ApiSdk.Groups.Item.CalendarView.Item.Calendar.CalendarPermissions.CalendarPermissionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -44,6 +47,9 @@ public Command BuildCalendarPermissionsCommand() { public Command BuildCalendarViewCommand() { var command = new Command("calendar-view"); var builder = new ApiSdk.Groups.Item.CalendarView.Item.Calendar.CalendarView.CalendarViewRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -63,11 +69,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string groupId, string eventId) => { + command.SetHandler(async (string groupId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption); return command; @@ -75,6 +80,9 @@ public Command BuildDeleteCommand() { public Command BuildEventsCommand() { var command = new Command("events"); var builder = new ApiSdk.Groups.Item.CalendarView.Item.Calendar.Events.EventsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -99,19 +107,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, selectOption, outputOption); return command; } public Command BuildGetScheduleCommand() { @@ -123,6 +130,9 @@ public Command BuildGetScheduleCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Groups.Item.CalendarView.Item.Calendar.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -146,14 +156,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -161,6 +170,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Groups.Item.CalendarView.Item.Calendar.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -232,42 +244,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar that contains the event. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs index 4e45deb1c99..da18de410b0 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class CalendarViewRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -114,7 +112,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -174,7 +171,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/CalendarViewResponse.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/CalendarViewResponse.cs index 9b65a756a7b..c432b671152 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/CalendarViewResponse.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/CalendarViewResponse.cs @@ -9,7 +9,7 @@ public class CalendarViewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new calendarViewResponse and sets the default values. /// @@ -22,7 +22,7 @@ public CalendarViewResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as CalendarViewResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Delta/Delta.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Delta/Delta.cs deleted file mode 100644 index 8ef247c1e4f..00000000000 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.CalendarView.Item.Calendar.CalendarView.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs index c0b815108aa..099b4c8b25e 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +34,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string groupId, string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, outputOption); return command; } /// @@ -75,16 +75,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs index 7bc3828db3e..a87784beb38 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs index 357eea70837..baae2293f9c 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs index 0a4b84ee92b..fe7661c231c 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs index 2887d3a209e..87fd3235b8f 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,11 +37,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string groupId, string eventId, string eventId1) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs index 89197c0ffa0..67878c1ef1f 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -63,11 +63,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string groupId, string eventId, string eventId1) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option); return command; @@ -108,19 +107,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -146,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -225,7 +222,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -237,42 +234,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs index 9b5916473fe..e15c1886a02 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 2391e553d8a..77848f465aa 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index 38ad7c7feda..58c68810f4a 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Delta/Delta.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Delta/Delta.cs deleted file mode 100644 index 836a87bea3f..00000000000 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.CalendarView.Item.Calendar.Events.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs index adf29260a53..7b2f9718ab7 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +34,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string groupId, string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, outputOption); return command; } /// @@ -75,16 +75,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/EventsRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/EventsRequestBuilder.cs index da2dbee4424..8cb6ce3836f 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/EventsRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/EventsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class EventsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -114,7 +112,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -174,7 +171,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The events in the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/EventsResponse.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/EventsResponse.cs index 4465f2ad02e..a7fb59cad9a 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/EventsResponse.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/EventsResponse.cs @@ -9,7 +9,7 @@ public class EventsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new eventsResponse and sets the default values. /// @@ -22,7 +22,7 @@ public EventsResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as EventsResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs index 581982142f3..ee5cf31580c 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs index 9a433a53949..03fdcb891f2 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs index e5a2b583689..f7fc96c8767 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs index 6f622351d91..fa2fe297919 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,11 +37,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string groupId, string eventId, string eventId1) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/EventRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/EventRequestBuilder.cs index f72c9c51993..52eb6f7d9ea 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/EventRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -63,11 +63,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string groupId, string eventId, string eventId1) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option); return command; @@ -108,19 +107,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -146,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -225,7 +222,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -237,42 +234,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The events in the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs index ed03e248906..f85f16d6136 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index ea345e2a9a0..02ce680e406 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index 958cac00374..a77ba8e37a9 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs index c84eb827774..d9e13a64faf 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,21 +37,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -85,18 +84,5 @@ public RequestInformation CreatePostRequestInformation(GetScheduleRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSchedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetScheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 9108eb02406..3243c1bcc03 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 8c76ca46712..895f8366cbe 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 30bb4a6ed45..f8da9e0acde 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/CalendarView/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index bd9d8a98059..a52ca926c12 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs index 2e48b8817c2..c49bd76fc06 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Decline/DeclineRequestBuilder.cs index a78ed2bf763..cf80f524f67 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs index dfb614baa5e..94907388c44 100644 --- a/src/generated/Groups/Item/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,11 +33,10 @@ public Command BuildPostCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string groupId, string eventId) => { + command.SetHandler(async (string groupId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/EventRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/EventRequestBuilder.cs index da3344e0630..96906fbce1e 100644 --- a/src/generated/Groups/Item/CalendarView/Item/EventRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/EventRequestBuilder.cs @@ -14,10 +14,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,6 +41,9 @@ public Command BuildAcceptCommand() { public Command BuildAttachmentsCommand() { var command = new Command("attachments"); var builder = new ApiSdk.Groups.Item.CalendarView.Item.Attachments.AttachmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateUploadSessionCommand()); command.AddCommand(builder.BuildListCommand()); @@ -87,11 +90,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string groupId, string eventId) => { + command.SetHandler(async (string groupId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption); return command; @@ -105,6 +107,9 @@ public Command BuildDismissReminderCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Groups.Item.CalendarView.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -130,11 +135,11 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var startDateTimeOption = new Option("--startdatetime", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { + var startDateTimeOption = new Option("--start-date-time", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { }; startDateTimeOption.IsRequired = true; command.AddOption(startDateTimeOption); - var endDateTimeOption = new Option("--enddatetime", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { + var endDateTimeOption = new Option("--end-date-time", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { }; endDateTimeOption.IsRequired = true; command.AddOption(endDateTimeOption); @@ -143,26 +148,28 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, string startDateTime, string endDateTime, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string startDateTime, string endDateTime, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { if (!String.IsNullOrEmpty(startDateTime)) q.StartDateTime = startDateTime; if (!String.IsNullOrEmpty(endDateTime)) q.EndDateTime = endDateTime; q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, startDateTimeOption, endDateTimeOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, startDateTimeOption, endDateTimeOption, selectOption, outputOption); return command; } public Command BuildInstancesCommand() { var command = new Command("instances"); var builder = new ApiSdk.Groups.Item.CalendarView.Item.Instances.InstancesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -170,6 +177,9 @@ public Command BuildInstancesCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Groups.Item.CalendarView.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -193,14 +203,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -208,6 +217,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Groups.Item.CalendarView.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -279,7 +291,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -291,42 +303,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The calendar view for the calendar. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Read-only. public class GetQueryParameters : QueryParametersBase { /// The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00 diff --git a/src/generated/Groups/Item/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs index a547a0df88a..358d785cb29 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs index a1ce2ee90ce..dec53c3390e 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string groupId, string eventId, string extensionId) => { + command.SetHandler(async (string groupId, string eventId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, extensionIdOption); return command; @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string extensionId, string body) => { + command.SetHandler(async (string groupId, string eventId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, extensionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/CalendarView/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Forward/ForwardRequestBuilder.cs index 5a4cd93bafa..351dcc7b6da 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Instances/Delta/Delta.cs b/src/generated/Groups/Item/CalendarView/Item/Instances/Delta/Delta.cs deleted file mode 100644 index 557d61e29d9..00000000000 --- a/src/generated/Groups/Item/CalendarView/Item/Instances/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.CalendarView.Item.Instances.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Groups/Item/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs index 5957d8435d0..c1cb8c73004 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +34,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string groupId, string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, outputOption); return command; } /// @@ -75,16 +75,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Instances/InstancesRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Instances/InstancesRequestBuilder.cs index dedee070299..325d3423c08 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Instances/InstancesRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Instances/InstancesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class InstancesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -114,7 +112,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -174,7 +171,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/CalendarView/Item/Instances/InstancesResponse.cs b/src/generated/Groups/Item/CalendarView/Item/Instances/InstancesResponse.cs index 0d0bda4d9ee..4b79b3d26db 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Instances/InstancesResponse.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Instances/InstancesResponse.cs @@ -9,7 +9,7 @@ public class InstancesResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new instancesResponse and sets the default values. /// @@ -22,7 +22,7 @@ public InstancesResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as InstancesResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs index 7f2df3317c5..3c011d77a4f 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs index 1f1a223b15f..64cf8aaa994 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs index 44d3744dde3..1ef6ac9d4f3 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs index ce35520a5ae..b559ec6172c 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,11 +37,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string groupId, string eventId, string eventId1) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Instances/Item/EventRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Instances/Item/EventRequestBuilder.cs index 4c4a6d20326..f1d911846f2 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Instances/Item/EventRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Instances/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -63,11 +63,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string groupId, string eventId, string eventId1) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option); return command; @@ -108,19 +107,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -146,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -225,7 +222,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -237,42 +234,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Groups/Item/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs index 5973a0ea34c..3495a17b1fe 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index bf45428186f..4a7380e4f47 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index cba5b937515..ad022bb422a 100644 --- a/src/generated/Groups/Item/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 7bad2344341..82caf5b45a0 100644 --- a/src/generated/Groups/Item/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 097ab28f01c..90432096dc8 100644 --- a/src/generated/Groups/Item/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 91309e93a5d..986c3875304 100644 --- a/src/generated/Groups/Item/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 59de7e27049..1f0e299e867 100644 --- a/src/generated/Groups/Item/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 567af0cd535..1cf71a0dadc 100644 --- a/src/generated/Groups/Item/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Groups/Item/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index a82158e229a..abda38e0e29 100644 --- a/src/generated/Groups/Item/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Groups/Item/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CheckGrantedPermissionsForApp/CheckGrantedPermissionsForAppRequestBuilder.cs b/src/generated/Groups/Item/CheckGrantedPermissionsForApp/CheckGrantedPermissionsForAppRequestBuilder.cs index 44d369b240f..76471c46f17 100644 --- a/src/generated/Groups/Item/CheckGrantedPermissionsForApp/CheckGrantedPermissionsForAppRequestBuilder.cs +++ b/src/generated/Groups/Item/CheckGrantedPermissionsForApp/CheckGrantedPermissionsForAppRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +29,17 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - command.SetHandler(async (string groupId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action checkGrantedPermissionsForApp - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs b/src/generated/Groups/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs index a1a0356f67b..be715a759ec 100644 --- a/src/generated/Groups/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs +++ b/src/generated/Groups/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberGroupsRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs b/src/generated/Groups/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs index 986733dcb65..f17b8991188 100644 --- a/src/generated/Groups/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs +++ b/src/generated/Groups/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberObjectsRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Conversations/ConversationsRequestBuilder.cs b/src/generated/Groups/Item/Conversations/ConversationsRequestBuilder.cs index 59e0763b9bc..3df2ed93235 100644 --- a/src/generated/Groups/Item/Conversations/ConversationsRequestBuilder.cs +++ b/src/generated/Groups/Item/Conversations/ConversationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class ConversationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ConversationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildThreadsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildThreadsCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -103,7 +101,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -113,15 +115,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -176,31 +173,6 @@ public RequestInformation CreatePostRequestInformation(Conversation body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The group's conversations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The group's conversations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Conversation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The group's conversations. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Conversations/Item/ConversationRequestBuilder.cs b/src/generated/Groups/Item/Conversations/Item/ConversationRequestBuilder.cs index adeb9d1b38d..b734edd6981 100644 --- a/src/generated/Groups/Item/Conversations/Item/ConversationRequestBuilder.cs +++ b/src/generated/Groups/Item/Conversations/Item/ConversationRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,11 +35,10 @@ public Command BuildDeleteCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - command.SetHandler(async (string groupId, string conversationId) => { + command.SetHandler(async (string groupId, string conversationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationIdOption); return command; @@ -64,19 +63,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string conversationId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationIdOption, selectOption, outputOption); return command; } /// @@ -98,14 +96,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationId, string body) => { + command.SetHandler(async (string groupId, string conversationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationIdOption, bodyOption); return command; @@ -113,6 +110,9 @@ public Command BuildPatchCommand() { public Command BuildThreadsCommand() { var command = new Command("threads"); var builder = new ApiSdk.Groups.Item.Conversations.Item.Threads.ThreadsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -184,42 +184,6 @@ public RequestInformation CreatePatchRequestInformation(Conversation body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The group's conversations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The group's conversations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The group's conversations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Conversation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The group's conversations. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Groups/Item/Conversations/Item/Threads/Item/ConversationThreadRequestBuilder.cs b/src/generated/Groups/Item/Conversations/Item/Threads/Item/ConversationThreadRequestBuilder.cs index 873a01cc3ee..ddfc156aa53 100644 --- a/src/generated/Groups/Item/Conversations/Item/Threads/Item/ConversationThreadRequestBuilder.cs +++ b/src/generated/Groups/Item/Conversations/Item/Threads/Item/ConversationThreadRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -36,15 +36,14 @@ public Command BuildDeleteCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId) => { + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationIdOption, conversationThreadIdOption); return command; @@ -64,7 +63,7 @@ public Command BuildGetCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -78,20 +77,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationIdOption, conversationThreadIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationIdOption, conversationThreadIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,7 +107,7 @@ public Command BuildPatchCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -117,14 +115,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string body) => { + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationIdOption, conversationThreadIdOption, bodyOption); return command; @@ -132,6 +129,9 @@ public Command BuildPatchCommand() { public Command BuildPostsCommand() { var command = new Command("posts"); var builder = new ApiSdk.Groups.Item.Conversations.Item.Threads.Item.Posts.PostsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -209,42 +209,6 @@ public RequestInformation CreatePatchRequestInformation(ConversationThread body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of all the conversation threads in the conversation. A navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of all the conversation threads in the conversation. A navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of all the conversation threads in the conversation. A navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ConversationThread model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of all the conversation threads in the conversation. A navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Attachments/AttachmentsRequestBuilder.cs b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Attachments/AttachmentsRequestBuilder.cs index 96cee7efc12..719f0b88e50 100644 --- a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Attachments/AttachmentsRequestBuilder.cs +++ b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Attachments/AttachmentsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class AttachmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttachmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,7 +44,7 @@ public Command BuildCreateCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -57,21 +56,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, bodyOption, outputOption); return command; } public Command BuildCreateUploadSessionCommand() { @@ -95,7 +93,7 @@ public Command BuildListCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -134,7 +132,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -144,15 +146,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -207,31 +204,6 @@ public RequestInformation CreatePostRequestInformation(Attachment body, Action - /// The collection of fileAttachment, itemAttachment, and referenceAttachment attachments for the post. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of fileAttachment, itemAttachment, and referenceAttachment attachments for the post. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of fileAttachment, itemAttachment, and referenceAttachment attachments for the post. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index 160631c5d5d..65bc04c225c 100644 --- a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,7 +34,7 @@ public Command BuildPostCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Attachments/Item/AttachmentRequestBuilder.cs b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Attachments/Item/AttachmentRequestBuilder.cs index a4f0549d5bf..ae5128980b8 100644 --- a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Attachments/Item/AttachmentRequestBuilder.cs +++ b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Attachments/Item/AttachmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,7 +34,7 @@ public Command BuildDeleteCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -46,11 +46,10 @@ public Command BuildDeleteCommand() { }; attachmentIdOption.IsRequired = true; command.AddOption(attachmentIdOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string attachmentId) => { + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string attachmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, attachmentIdOption); return command; @@ -70,7 +69,7 @@ public Command BuildGetCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -92,20 +91,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string attachmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string attachmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, attachmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, attachmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -123,7 +121,7 @@ public Command BuildPatchCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -139,14 +137,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string attachmentId, string body) => { + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string attachmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, attachmentIdOption, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(Attachment body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of fileAttachment, itemAttachment, and referenceAttachment attachments for the post. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of fileAttachment, itemAttachment, and referenceAttachment attachments for the post. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of fileAttachment, itemAttachment, and referenceAttachment attachments for the post. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of fileAttachment, itemAttachment, and referenceAttachment attachments for the post. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Extensions/ExtensionsRequestBuilder.cs index f53ec8c577a..022e1be873a 100644 --- a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,7 +43,7 @@ public Command BuildCreateCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, bodyOption, outputOption); return command; } /// @@ -88,7 +86,7 @@ public Command BuildListCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -127,7 +125,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -137,15 +139,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -200,31 +197,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the post. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the post. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the post. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Extensions/Item/ExtensionRequestBuilder.cs index df477c5624b..e039e0f0f4f 100644 --- a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,7 +34,7 @@ public Command BuildDeleteCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -46,11 +46,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string extensionId) => { + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, extensionIdOption); return command; @@ -70,7 +69,7 @@ public Command BuildGetCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -92,20 +91,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -123,7 +121,7 @@ public Command BuildPatchCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -139,14 +137,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string extensionId, string body) => { + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, extensionIdOption, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the post. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the post. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the post. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the post. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Forward/ForwardRequestBuilder.cs index c30d5be34ab..1fd2480196b 100644 --- a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,7 +33,7 @@ public Command BuildPostCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string body) => { + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/InReplyTo/Forward/ForwardRequestBuilder.cs b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/InReplyTo/Forward/ForwardRequestBuilder.cs index 214b1f32c6e..50e2e9dd45e 100644 --- a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/InReplyTo/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/InReplyTo/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,7 +33,7 @@ public Command BuildPostCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string body) => { + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/InReplyTo/InReplyToRequestBuilder.cs b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/InReplyTo/InReplyToRequestBuilder.cs index dccafc5fca9..c168b88d446 100644 --- a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/InReplyTo/InReplyToRequestBuilder.cs +++ b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/InReplyTo/InReplyToRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -36,7 +36,7 @@ public Command BuildDeleteCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -44,11 +44,10 @@ public Command BuildDeleteCommand() { }; postIdOption.IsRequired = true; command.AddOption(postIdOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId) => { + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption); return command; @@ -74,7 +73,7 @@ public Command BuildGetCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -92,20 +91,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -123,7 +121,7 @@ public Command BuildPatchCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -135,14 +133,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string body) => { + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(Post body, Action - /// The earlier post that this post is replying to in the conversationThread. Read-only. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The earlier post that this post is replying to in the conversationThread. Read-only. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The earlier post that this post is replying to in the conversationThread. Read-only. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Post model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The earlier post that this post is replying to in the conversationThread. Read-only. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/InReplyTo/Reply/ReplyRequestBuilder.cs b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/InReplyTo/Reply/ReplyRequestBuilder.cs index fbcbb8005b6..292d560742b 100644 --- a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/InReplyTo/Reply/ReplyRequestBuilder.cs +++ b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/InReplyTo/Reply/ReplyRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,7 +33,7 @@ public Command BuildPostCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string body) => { + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ReplyRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action reply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ReplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index a9dc390e1da..f56bfefd9bd 100644 --- a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,7 +34,7 @@ public Command BuildDeleteCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -42,15 +42,14 @@ public Command BuildDeleteCommand() { }; postIdOption.IsRequired = true; command.AddOption(postIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -70,7 +69,7 @@ public Command BuildGetCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -78,7 +77,7 @@ public Command BuildGetCommand() { }; postIdOption.IsRequired = true; command.AddOption(postIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -92,20 +91,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -123,7 +121,7 @@ public Command BuildPatchCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -131,7 +129,7 @@ public Command BuildPatchCommand() { }; postIdOption.IsRequired = true; command.AddOption(postIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -139,14 +137,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the post. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the post. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the post. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the post. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index d23be566dee..310f3607152 100644 --- a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,7 +43,7 @@ public Command BuildCreateCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, bodyOption, outputOption); return command; } /// @@ -88,7 +86,7 @@ public Command BuildListCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -131,7 +129,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -142,15 +144,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -205,31 +202,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the post. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the post. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the post. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/PostRequestBuilder.cs b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/PostRequestBuilder.cs index b3604af408b..bc4883cd4ba 100644 --- a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/PostRequestBuilder.cs +++ b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/PostRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,6 +29,9 @@ public class PostRequestBuilder { public Command BuildAttachmentsCommand() { var command = new Command("attachments"); var builder = new ApiSdk.Groups.Item.Conversations.Item.Threads.Item.Posts.Item.Attachments.AttachmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateUploadSessionCommand()); command.AddCommand(builder.BuildListCommand()); @@ -49,7 +52,7 @@ public Command BuildDeleteCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -57,11 +60,10 @@ public Command BuildDeleteCommand() { }; postIdOption.IsRequired = true; command.AddOption(postIdOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId) => { + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption); return command; @@ -69,6 +71,9 @@ public Command BuildDeleteCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Groups.Item.Conversations.Item.Threads.Item.Posts.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -94,7 +99,7 @@ public Command BuildGetCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -112,20 +117,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildInReplyToCommand() { @@ -141,6 +145,9 @@ public Command BuildInReplyToCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Groups.Item.Conversations.Item.Threads.Item.Posts.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -160,7 +167,7 @@ public Command BuildPatchCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -172,14 +179,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string body) => { + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, bodyOption); return command; @@ -193,6 +199,9 @@ public Command BuildReplyCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Groups.Item.Conversations.Item.Threads.Item.Posts.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -264,42 +273,6 @@ public RequestInformation CreatePatchRequestInformation(Post body, Action - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Post model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Reply/ReplyRequestBuilder.cs b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Reply/ReplyRequestBuilder.cs index 9b8ec22e788..50a90bb3bc7 100644 --- a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Reply/ReplyRequestBuilder.cs +++ b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/Reply/ReplyRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,7 +33,7 @@ public Command BuildPostCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string body) => { + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ReplyRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action reply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ReplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 3c6911c792c..25b5e8acbf0 100644 --- a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,7 +34,7 @@ public Command BuildDeleteCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -42,15 +42,14 @@ public Command BuildDeleteCommand() { }; postIdOption.IsRequired = true; command.AddOption(postIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -70,7 +69,7 @@ public Command BuildGetCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -78,7 +77,7 @@ public Command BuildGetCommand() { }; postIdOption.IsRequired = true; command.AddOption(postIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -92,20 +91,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -123,7 +121,7 @@ public Command BuildPatchCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -131,7 +129,7 @@ public Command BuildPatchCommand() { }; postIdOption.IsRequired = true; command.AddOption(postIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -139,14 +137,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the post. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the post. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the post. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the post. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index e873bc7eb2a..75a89a918b2 100644 --- a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,7 +43,7 @@ public Command BuildCreateCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, bodyOption, outputOption); return command; } /// @@ -88,7 +86,7 @@ public Command BuildListCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -131,7 +129,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string postId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -142,15 +144,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationIdOption, conversationThreadIdOption, postIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -205,31 +202,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the post. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the post. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the post. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/PostsRequestBuilder.cs b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/PostsRequestBuilder.cs index db82f8816ac..3cffcbe25e1 100644 --- a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/PostsRequestBuilder.cs +++ b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Posts/PostsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,18 +22,17 @@ public class PostsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PostRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAttachmentsCommand(), - builder.BuildDeleteCommand(), - builder.BuildExtensionsCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildInReplyToCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildReplyCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAttachmentsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInReplyToCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildReplyCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); return commands; } /// @@ -51,7 +50,7 @@ public Command BuildCreateCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -59,21 +58,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationIdOption, conversationThreadIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationIdOption, conversationThreadIdOption, bodyOption, outputOption); return command; } /// @@ -91,7 +89,7 @@ public Command BuildListCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -126,7 +124,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationIdOption, conversationThreadIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationIdOption, conversationThreadIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(Post body, Action - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Post model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Reply/ReplyRequestBuilder.cs b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Reply/ReplyRequestBuilder.cs index 8eb1b48417c..f89640e4522 100644 --- a/src/generated/Groups/Item/Conversations/Item/Threads/Item/Reply/ReplyRequestBuilder.cs +++ b/src/generated/Groups/Item/Conversations/Item/Threads/Item/Reply/ReplyRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,7 +33,7 @@ public Command BuildPostCommand() { }; conversationIdOption.IsRequired = true; command.AddOption(conversationIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string body) => { + command.SetHandler(async (string groupId, string conversationId, string conversationThreadId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationIdOption, conversationThreadIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ReplyRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action reply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ReplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Conversations/Item/Threads/ThreadsRequestBuilder.cs b/src/generated/Groups/Item/Conversations/Item/Threads/ThreadsRequestBuilder.cs index 20986db82fa..39fcdc26246 100644 --- a/src/generated/Groups/Item/Conversations/Item/Threads/ThreadsRequestBuilder.cs +++ b/src/generated/Groups/Item/Conversations/Item/Threads/ThreadsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class ThreadsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ConversationThreadRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildPostsCommand(), - builder.BuildReplyCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPostsCommand()); + commands.Add(builder.BuildReplyCommand()); return commands; } /// @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationIdOption, bodyOption, outputOption); return command; } /// @@ -113,7 +111,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string conversationId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -186,31 +183,6 @@ public RequestInformation CreatePostRequestInformation(ConversationThread body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of all the conversation threads in the conversation. A navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of all the conversation threads in the conversation. A navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ConversationThread model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of all the conversation threads in the conversation. A navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/CreatedOnBehalfOf/@Ref/@Ref.cs b/src/generated/Groups/Item/CreatedOnBehalfOf/@Ref/@Ref.cs deleted file mode 100644 index 0f3c84aed23..00000000000 --- a/src/generated/Groups/Item/CreatedOnBehalfOf/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.CreatedOnBehalfOf.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Groups/Item/CreatedOnBehalfOf/@Ref/RefRequestBuilder.cs b/src/generated/Groups/Item/CreatedOnBehalfOf/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 19af2054a0d..00000000000 --- a/src/generated/Groups/Item/CreatedOnBehalfOf/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Groups.Item.CreatedOnBehalfOf.@Ref { - /// Builds and executes requests for operations under \groups\{group-id}\createdOnBehalfOf\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The user (or application) that created the group. Note: This is not set if the user is an administrator. Read-only. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The user (or application) that created the group. Note: This is not set if the user is an administrator. Read-only."; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - command.SetHandler(async (string groupId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, groupIdOption); - return command; - } - /// - /// The user (or application) that created the group. Note: This is not set if the user is an administrator. Read-only. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The user (or application) that created the group. Note: This is not set if the user is an administrator. Read-only."; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - command.SetHandler(async (string groupId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption); - return command; - } - /// - /// The user (or application) that created the group. Note: This is not set if the user is an administrator. Read-only. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The user (or application) that created the group. Note: This is not set if the user is an administrator. Read-only."; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, groupIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/groups/{group_id}/createdOnBehalfOf/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The user (or application) that created the group. Note: This is not set if the user is an administrator. Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The user (or application) that created the group. Note: This is not set if the user is an administrator. Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The user (or application) that created the group. Note: This is not set if the user is an administrator. Read-only. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Groups.Item.CreatedOnBehalfOf.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The user (or application) that created the group. Note: This is not set if the user is an administrator. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user (or application) that created the group. Note: This is not set if the user is an administrator. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user (or application) that created the group. Note: This is not set if the user is an administrator. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Groups.Item.CreatedOnBehalfOf.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Groups/Item/CreatedOnBehalfOf/CreatedOnBehalfOfRequestBuilder.cs b/src/generated/Groups/Item/CreatedOnBehalfOf/CreatedOnBehalfOfRequestBuilder.cs index d34d612d8dd..bbd1e86d422 100644 --- a/src/generated/Groups/Item/CreatedOnBehalfOf/CreatedOnBehalfOfRequestBuilder.cs +++ b/src/generated/Groups/Item/CreatedOnBehalfOf/CreatedOnBehalfOfRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Groups.Item.CreatedOnBehalfOf.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Groups.Item.CreatedOnBehalfOf.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user (or application) that created the group. Note: This is not set if the user is an administrator. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The user (or application) that created the group. Note: This is not set if the user is an administrator. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/CreatedOnBehalfOf/Ref/Ref.cs b/src/generated/Groups/Item/CreatedOnBehalfOf/Ref/Ref.cs new file mode 100644 index 00000000000..ab6e5ea77e0 --- /dev/null +++ b/src/generated/Groups/Item/CreatedOnBehalfOf/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Groups.Item.CreatedOnBehalfOf.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Groups/Item/CreatedOnBehalfOf/Ref/RefRequestBuilder.cs b/src/generated/Groups/Item/CreatedOnBehalfOf/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..5cb0fa28ed5 --- /dev/null +++ b/src/generated/Groups/Item/CreatedOnBehalfOf/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Groups.Item.CreatedOnBehalfOf.Ref { + /// Builds and executes requests for operations under \groups\{group-id}\createdOnBehalfOf\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The user (or application) that created the group. Note: This is not set if the user is an administrator. Read-only. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The user (or application) that created the group. Note: This is not set if the user is an administrator. Read-only."; + // Create options for all the parameters + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + command.SetHandler(async (string groupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, groupIdOption); + return command; + } + /// + /// The user (or application) that created the group. Note: This is not set if the user is an administrator. Read-only. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The user (or application) that created the group. Note: This is not set if the user is an administrator. Read-only."; + // Create options for all the parameters + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, outputOption); + return command; + } + /// + /// The user (or application) that created the group. Note: This is not set if the user is an administrator. Read-only. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The user (or application) that created the group. Note: This is not set if the user is an administrator. Read-only."; + // Create options for all the parameters + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string groupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, groupIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/groups/{group_id}/createdOnBehalfOf/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The user (or application) that created the group. Note: This is not set if the user is an administrator. Read-only. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The user (or application) that created the group. Note: This is not set if the user is an administrator. Read-only. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The user (or application) that created the group. Note: This is not set if the user is an administrator. Read-only. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Groups.Item.CreatedOnBehalfOf.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Groups/Item/Drive/DriveRequestBuilder.cs b/src/generated/Groups/Item/Drive/DriveRequestBuilder.cs index 3d5205cb7f1..74707c2f872 100644 --- a/src/generated/Groups/Item/Drive/DriveRequestBuilder.cs +++ b/src/generated/Groups/Item/Drive/DriveRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,10 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - command.SetHandler(async (string groupId) => { + command.SetHandler(async (string groupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption); return command; @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + command.SetHandler(async (string groupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The group's default drive. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The group's default drive. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The group's default drive. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Drive model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The group's default drive. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Drives/DrivesRequestBuilder.cs b/src/generated/Groups/Item/Drives/DrivesRequestBuilder.cs index 5475d89dc9a..8105b0fafaf 100644 --- a/src/generated/Groups/Item/Drives/DrivesRequestBuilder.cs +++ b/src/generated/Groups/Item/Drives/DrivesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DrivesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DriveRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The group's drives. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The group's drives. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Drive model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The group's drives. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Drives/Item/DriveRequestBuilder.cs b/src/generated/Groups/Item/Drives/Item/DriveRequestBuilder.cs index 0a0b8a6a64b..29e3468ce65 100644 --- a/src/generated/Groups/Item/Drives/Item/DriveRequestBuilder.cs +++ b/src/generated/Groups/Item/Drives/Item/DriveRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - command.SetHandler(async (string groupId, string driveId) => { + command.SetHandler(async (string groupId, string driveId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, driveIdOption); return command; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string driveId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string driveId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, driveIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, driveIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string driveId, string body) => { + command.SetHandler(async (string groupId, string driveId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, driveIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The group's drives. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The group's drives. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The group's drives. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Drive model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The group's drives. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Events/Delta/Delta.cs b/src/generated/Groups/Item/Events/Delta/Delta.cs deleted file mode 100644 index 88790ae588a..00000000000 --- a/src/generated/Groups/Item/Events/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.Events.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Groups/Item/Events/Delta/DeltaRequestBuilder.cs b/src/generated/Groups/Item/Events/Delta/DeltaRequestBuilder.cs index 58e6f4086f1..c8e4f749228 100644 --- a/src/generated/Groups/Item/Events/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +30,17 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - command.SetHandler(async (string groupId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/EventsRequestBuilder.cs b/src/generated/Groups/Item/Events/EventsRequestBuilder.cs index 1da25f18c80..040e8dfa35c 100644 --- a/src/generated/Groups/Item/Events/EventsRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/EventsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,24 +23,23 @@ public class EventsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildAttachmentsCommand(), - builder.BuildCalendarCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildExtensionsCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildInstancesCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildAttachmentsCommand()); + commands.Add(builder.BuildCalendarCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInstancesCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -58,21 +57,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -112,7 +110,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -172,7 +169,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -190,31 +187,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The group's events. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The group's events. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The group's events. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Events/EventsResponse.cs b/src/generated/Groups/Item/Events/EventsResponse.cs index 8d8beee7b95..f7ee5f816ef 100644 --- a/src/generated/Groups/Item/Events/EventsResponse.cs +++ b/src/generated/Groups/Item/Events/EventsResponse.cs @@ -9,7 +9,7 @@ public class EventsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new eventsResponse and sets the default values. /// @@ -22,7 +22,7 @@ public EventsResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as EventsResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Groups/Item/Events/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Accept/AcceptRequestBuilder.cs index 85f0676dbc4..92d6b1e7416 100644 --- a/src/generated/Groups/Item/Events/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Attachments/AttachmentsRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Attachments/AttachmentsRequestBuilder.cs index 35a28798322..9605cf449bd 100644 --- a/src/generated/Groups/Item/Events/Item/Attachments/AttachmentsRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Attachments/AttachmentsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class AttachmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttachmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } public Command BuildCreateUploadSessionCommand() { @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(Attachment body, Action - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index e197610ef0c..c392ec8ba13 100644 --- a/src/generated/Groups/Item/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs index 79b0d4a4e00..e54345ecddf 100644 --- a/src/generated/Groups/Item/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; attachmentIdOption.IsRequired = true; command.AddOption(attachmentIdOption); - command.SetHandler(async (string groupId, string eventId, string attachmentId) => { + command.SetHandler(async (string groupId, string eventId, string attachmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, attachmentIdOption); return command; @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, string attachmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string attachmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string attachmentId, string body) => { + command.SetHandler(async (string groupId, string eventId, string attachmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, attachmentIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Attachment body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs index fb9cdef4060..20a1c58545a 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,18 +37,17 @@ public Command BuildGetCommand() { }; UserOption.IsRequired = true; command.AddOption(UserOption); - command.SetHandler(async (string groupId, string eventId, string User) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string User, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, UserOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, UserOption, outputOption); return command; } /// @@ -81,16 +80,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function allowedCalendarSharingRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs index 0f6d6cec707..269022c3878 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class CalendarPermissionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new CalendarPermissionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -106,7 +104,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -115,15 +117,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -178,31 +175,6 @@ public RequestInformation CreatePostRequestInformation(CalendarPermission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CalendarPermission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions of the users with whom the calendar is shared. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Events/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs index cd6921b7f62..469cef09bc3 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); - command.SetHandler(async (string groupId, string eventId, string calendarPermissionId) => { + command.SetHandler(async (string groupId, string eventId, string calendarPermissionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, calendarPermissionIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); @@ -71,19 +70,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, string calendarPermissionId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string calendarPermissionId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, calendarPermissionIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, calendarPermissionIdOption, selectOption, outputOption); return command; } /// @@ -101,7 +99,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); @@ -109,14 +107,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string calendarPermissionId, string body) => { + command.SetHandler(async (string groupId, string eventId, string calendarPermissionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, calendarPermissionIdOption, bodyOption); return command; @@ -188,42 +185,6 @@ public RequestInformation CreatePatchRequestInformation(CalendarPermission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(CalendarPermission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions of the users with whom the calendar is shared. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Groups/Item/Events/Item/Calendar/CalendarRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/CalendarRequestBuilder.cs index b4c7c884e93..0473e4b20ef 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/CalendarRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/CalendarRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,6 +37,9 @@ public AllowedCalendarSharingRolesWithUserRequestBuilder AllowedCalendarSharingR public Command BuildCalendarPermissionsCommand() { var command = new Command("calendar-permissions"); var builder = new ApiSdk.Groups.Item.Events.Item.Calendar.CalendarPermissions.CalendarPermissionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -44,6 +47,9 @@ public Command BuildCalendarPermissionsCommand() { public Command BuildCalendarViewCommand() { var command = new Command("calendar-view"); var builder = new ApiSdk.Groups.Item.Events.Item.Calendar.CalendarView.CalendarViewRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -63,11 +69,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string groupId, string eventId) => { + command.SetHandler(async (string groupId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption); return command; @@ -75,6 +80,9 @@ public Command BuildDeleteCommand() { public Command BuildEventsCommand() { var command = new Command("events"); var builder = new ApiSdk.Groups.Item.Events.Item.Calendar.Events.EventsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -99,19 +107,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, selectOption, outputOption); return command; } public Command BuildGetScheduleCommand() { @@ -123,6 +130,9 @@ public Command BuildGetScheduleCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Groups.Item.Events.Item.Calendar.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -146,14 +156,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -161,6 +170,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Groups.Item.Events.Item.Calendar.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -232,42 +244,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar that contains the event. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs index 5a7948811a4..f828ab55258 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class CalendarViewRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -114,7 +112,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -174,7 +171,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/CalendarViewResponse.cs b/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/CalendarViewResponse.cs index 868222c3b89..95be481b040 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/CalendarViewResponse.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/CalendarViewResponse.cs @@ -9,7 +9,7 @@ public class CalendarViewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new calendarViewResponse and sets the default values. /// @@ -22,7 +22,7 @@ public CalendarViewResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as CalendarViewResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Delta/Delta.cs b/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Delta/Delta.cs deleted file mode 100644 index 4b74fad8fd0..00000000000 --- a/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.Events.Item.Calendar.CalendarView.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs index 4d7ce5d4c66..762ffde2f59 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +34,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string groupId, string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, outputOption); return command; } /// @@ -75,16 +75,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs index b721c25fac7..648a2e5f442 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs index 70074702d78..2a5cae3cecb 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs index 442731ab833..bb474334d97 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs index fd4675b689a..8a2707a3f0b 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,11 +37,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string groupId, string eventId, string eventId1) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs index b1d65df7028..89c9828ddd1 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -63,11 +63,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string groupId, string eventId, string eventId1) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option); return command; @@ -108,19 +107,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -146,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -225,7 +222,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -237,42 +234,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs index 091b90f153c..f03db0711b2 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 5aab4854f19..b44219bb46b 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index be751fe315b..e33e10f3d4a 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Calendar/Events/Delta/Delta.cs b/src/generated/Groups/Item/Events/Item/Calendar/Events/Delta/Delta.cs deleted file mode 100644 index 9d01607c959..00000000000 --- a/src/generated/Groups/Item/Events/Item/Calendar/Events/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.Events.Item.Calendar.Events.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Groups/Item/Events/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs index ca3b7b60ce4..98c745a1da7 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +34,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string groupId, string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, outputOption); return command; } /// @@ -75,16 +75,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Calendar/Events/EventsRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/Events/EventsRequestBuilder.cs index edf0f77ea28..b60d7510b40 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/Events/EventsRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/Events/EventsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class EventsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -114,7 +112,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -174,7 +171,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The events in the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Events/Item/Calendar/Events/EventsResponse.cs b/src/generated/Groups/Item/Events/Item/Calendar/Events/EventsResponse.cs index 9ca10aedc1b..76e8febe549 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/Events/EventsResponse.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/Events/EventsResponse.cs @@ -9,7 +9,7 @@ public class EventsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new eventsResponse and sets the default values. /// @@ -22,7 +22,7 @@ public EventsResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as EventsResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs index 537baafd5bd..26cb12fa156 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs index d4cd2a4f1fd..869038f33c4 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs index ce9a4e30203..dcc58cdbc91 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs index 632acf4b2ad..e7a16c06684 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,11 +37,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string groupId, string eventId, string eventId1) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/EventRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/EventRequestBuilder.cs index d0ef1c4d8d9..82a3dafe1a5 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/EventRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -63,11 +63,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string groupId, string eventId, string eventId1) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option); return command; @@ -108,19 +107,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -146,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -225,7 +222,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -237,42 +234,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The events in the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs index 8d2fe1f0666..8f62d859285 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index b44eba2859c..18d5649b4e7 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index 1265d42f3ac..f47273904d3 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs index 17bd0b7cd40..b9a0c8bc851 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,21 +37,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -85,18 +84,5 @@ public RequestInformation CreatePostRequestInformation(GetScheduleRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSchedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetScheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 92f474c9e1d..49a46b733d4 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Events/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 9ebac3a0cad..73d48a0b668 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Events/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 63084975606..411b92780dd 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Events/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 18c6b2166c8..8f46867b2ee 100644 --- a/src/generated/Groups/Item/Events/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Events/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Cancel/CancelRequestBuilder.cs index f009ae8f051..985a2ac7970 100644 --- a/src/generated/Groups/Item/Events/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Decline/DeclineRequestBuilder.cs index 41672b5d6a7..5da98ee9145 100644 --- a/src/generated/Groups/Item/Events/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs index 7e0c3db09d0..eea7bc3a115 100644 --- a/src/generated/Groups/Item/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,11 +33,10 @@ public Command BuildPostCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string groupId, string eventId) => { + command.SetHandler(async (string groupId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/EventRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/EventRequestBuilder.cs index 0625b94e3ab..d3ac31fb527 100644 --- a/src/generated/Groups/Item/Events/Item/EventRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/EventRequestBuilder.cs @@ -14,10 +14,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,6 +41,9 @@ public Command BuildAcceptCommand() { public Command BuildAttachmentsCommand() { var command = new Command("attachments"); var builder = new ApiSdk.Groups.Item.Events.Item.Attachments.AttachmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateUploadSessionCommand()); command.AddCommand(builder.BuildListCommand()); @@ -87,11 +90,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string groupId, string eventId) => { + command.SetHandler(async (string groupId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption); return command; @@ -105,6 +107,9 @@ public Command BuildDismissReminderCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Groups.Item.Events.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -135,24 +140,26 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, selectOption, outputOption); return command; } public Command BuildInstancesCommand() { var command = new Command("instances"); var builder = new ApiSdk.Groups.Item.Events.Item.Instances.InstancesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -160,6 +167,9 @@ public Command BuildInstancesCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Groups.Item.Events.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -183,14 +193,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -198,6 +207,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Groups.Item.Events.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -269,7 +281,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -281,42 +293,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The group's events. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The group's events. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The group's events. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The group's events. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Groups/Item/Events/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Extensions/ExtensionsRequestBuilder.cs index a58524e8fa9..d2ecc664d69 100644 --- a/src/generated/Groups/Item/Events/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs index 5cd501dc067..ea47ca2f504 100644 --- a/src/generated/Groups/Item/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string groupId, string eventId, string extensionId) => { + command.SetHandler(async (string groupId, string eventId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, extensionIdOption); return command; @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string extensionId, string body) => { + command.SetHandler(async (string groupId, string eventId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, extensionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Events/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Forward/ForwardRequestBuilder.cs index 3cbc8e923ec..139c11825ca 100644 --- a/src/generated/Groups/Item/Events/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Instances/Delta/Delta.cs b/src/generated/Groups/Item/Events/Item/Instances/Delta/Delta.cs deleted file mode 100644 index f35f5d50281..00000000000 --- a/src/generated/Groups/Item/Events/Item/Instances/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.Events.Item.Instances.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Groups/Item/Events/Item/Instances/Delta/DeltaRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Instances/Delta/DeltaRequestBuilder.cs index 7035f2289ff..86d9a3257d9 100644 --- a/src/generated/Groups/Item/Events/Item/Instances/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Instances/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +34,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string groupId, string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, outputOption); return command; } /// @@ -75,16 +75,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Instances/InstancesRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Instances/InstancesRequestBuilder.cs index 19b12e0b6bf..c83c0df2c54 100644 --- a/src/generated/Groups/Item/Events/Item/Instances/InstancesRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Instances/InstancesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class InstancesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -114,7 +112,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -174,7 +171,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Events/Item/Instances/InstancesResponse.cs b/src/generated/Groups/Item/Events/Item/Instances/InstancesResponse.cs index e1b5da39af0..d8d6c3bfa12 100644 --- a/src/generated/Groups/Item/Events/Item/Instances/InstancesResponse.cs +++ b/src/generated/Groups/Item/Events/Item/Instances/InstancesResponse.cs @@ -9,7 +9,7 @@ public class InstancesResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new instancesResponse and sets the default values. /// @@ -22,7 +22,7 @@ public InstancesResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as InstancesResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Groups/Item/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs index 696dac08105..4bf6a181f64 100644 --- a/src/generated/Groups/Item/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs index cd379460ee0..0e58ba27630 100644 --- a/src/generated/Groups/Item/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs index 0f2bc28a008..b59affc67e1 100644 --- a/src/generated/Groups/Item/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs index 0ae839d156c..70c352e0150 100644 --- a/src/generated/Groups/Item/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,11 +37,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string groupId, string eventId, string eventId1) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Instances/Item/EventRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Instances/Item/EventRequestBuilder.cs index 469bc941b87..d53f1db815a 100644 --- a/src/generated/Groups/Item/Events/Item/Instances/Item/EventRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Instances/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -63,11 +63,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string groupId, string eventId, string eventId1) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option); return command; @@ -108,19 +107,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -146,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -225,7 +222,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -237,42 +234,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Groups/Item/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs index 0323fe41bc0..1f50133fe62 100644 --- a/src/generated/Groups/Item/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 26909e7e355..b6553191a63 100644 --- a/src/generated/Groups/Item/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index 74a8518a078..09c8df57a20 100644 --- a/src/generated/Groups/Item/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string groupId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 7207ecdb1d1..0c629c69de9 100644 --- a/src/generated/Groups/Item/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string groupId, string eventId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index ec24ab70503..1ad8e29d214 100644 --- a/src/generated/Groups/Item/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 5caf0346e12..507b81a067f 100644 --- a/src/generated/Groups/Item/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string groupId, string eventId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index b32e1a7ba4b..338944dfa3f 100644 --- a/src/generated/Groups/Item/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 41ae748d79b..29593664129 100644 --- a/src/generated/Groups/Item/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Groups/Item/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index b2e826b897e..2048fc0a999 100644 --- a/src/generated/Groups/Item/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Groups/Item/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string eventId, string body) => { + command.SetHandler(async (string groupId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Groups/Item/Extensions/ExtensionsRequestBuilder.cs index 807ea0eaa14..1ffb2d6b6f1 100644 --- a/src/generated/Groups/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Groups/Item/Extensions/Item/ExtensionRequestBuilder.cs index c5d8ed450da..4b8577d0292 100644 --- a/src/generated/Groups/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Groups/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string groupId, string extensionId) => { + command.SetHandler(async (string groupId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, extensionIdOption); return command; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string extensionId, string body) => { + command.SetHandler(async (string groupId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, extensionIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs b/src/generated/Groups/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs index 04fad0f06e1..35b04ef4a8f 100644 --- a/src/generated/Groups/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs +++ b/src/generated/Groups/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberGroupsRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs b/src/generated/Groups/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs index c259d1c9dc2..4e850c913ab 100644 --- a/src/generated/Groups/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs +++ b/src/generated/Groups/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberObjectsRequestBo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/GroupLifecyclePolicies/GroupLifecyclePoliciesRequestBuilder.cs b/src/generated/Groups/Item/GroupLifecyclePolicies/GroupLifecyclePoliciesRequestBuilder.cs index 77cf6c8255e..2915566491e 100644 --- a/src/generated/Groups/Item/GroupLifecyclePolicies/GroupLifecyclePoliciesRequestBuilder.cs +++ b/src/generated/Groups/Item/GroupLifecyclePolicies/GroupLifecyclePoliciesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class GroupLifecyclePoliciesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new GroupLifecyclePolicyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(GroupLifecyclePolicy body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of lifecycle policies for this group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of lifecycle policies for this group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GroupLifecyclePolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of lifecycle policies for this group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/GroupLifecyclePolicies/Item/GroupLifecyclePolicyRequestBuilder.cs b/src/generated/Groups/Item/GroupLifecyclePolicies/Item/GroupLifecyclePolicyRequestBuilder.cs index 1e9b8ef04aa..c392e310dd2 100644 --- a/src/generated/Groups/Item/GroupLifecyclePolicies/Item/GroupLifecyclePolicyRequestBuilder.cs +++ b/src/generated/Groups/Item/GroupLifecyclePolicies/Item/GroupLifecyclePolicyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var groupLifecyclePolicyIdOption = new Option("--grouplifecyclepolicy-id", description: "key: id of groupLifecyclePolicy") { + var groupLifecyclePolicyIdOption = new Option("--group-lifecycle-policy-id", description: "key: id of groupLifecyclePolicy") { }; groupLifecyclePolicyIdOption.IsRequired = true; command.AddOption(groupLifecyclePolicyIdOption); - command.SetHandler(async (string groupId, string groupLifecyclePolicyId) => { + command.SetHandler(async (string groupId, string groupLifecyclePolicyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, groupLifecyclePolicyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var groupLifecyclePolicyIdOption = new Option("--grouplifecyclepolicy-id", description: "key: id of groupLifecyclePolicy") { + var groupLifecyclePolicyIdOption = new Option("--group-lifecycle-policy-id", description: "key: id of groupLifecyclePolicy") { }; groupLifecyclePolicyIdOption.IsRequired = true; command.AddOption(groupLifecyclePolicyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string groupLifecyclePolicyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string groupLifecyclePolicyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, groupLifecyclePolicyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, groupLifecyclePolicyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var groupLifecyclePolicyIdOption = new Option("--grouplifecyclepolicy-id", description: "key: id of groupLifecyclePolicy") { + var groupLifecyclePolicyIdOption = new Option("--group-lifecycle-policy-id", description: "key: id of groupLifecyclePolicy") { }; groupLifecyclePolicyIdOption.IsRequired = true; command.AddOption(groupLifecyclePolicyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string groupLifecyclePolicyId, string body) => { + command.SetHandler(async (string groupId, string groupLifecyclePolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, groupLifecyclePolicyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(GroupLifecyclePolicy bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of lifecycle policies for this group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of lifecycle policies for this group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of lifecycle policies for this group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(GroupLifecyclePolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of lifecycle policies for this group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/GroupRequestBuilder.cs b/src/generated/Groups/Item/GroupRequestBuilder.cs index dcf7852ac27..39d76e46081 100644 --- a/src/generated/Groups/Item/GroupRequestBuilder.cs +++ b/src/generated/Groups/Item/GroupRequestBuilder.cs @@ -42,10 +42,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -76,6 +76,9 @@ public Command BuildAddFavoriteCommand() { public Command BuildAppRoleAssignmentsCommand() { var command = new Command("app-role-assignments"); var builder = new ApiSdk.Groups.Item.AppRoleAssignments.AppRoleAssignmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -103,6 +106,9 @@ public Command BuildCalendarCommand() { public Command BuildCalendarViewCommand() { var command = new Command("calendar-view"); var builder = new ApiSdk.Groups.Item.CalendarView.CalendarViewRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -128,6 +134,9 @@ public Command BuildCheckMemberObjectsCommand() { public Command BuildConversationsCommand() { var command = new Command("conversations"); var builder = new ApiSdk.Groups.Item.Conversations.ConversationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -150,11 +159,10 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - command.SetHandler(async (string groupId) => { + command.SetHandler(async (string groupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption); return command; @@ -170,6 +178,9 @@ public Command BuildDriveCommand() { public Command BuildDrivesCommand() { var command = new Command("drives"); var builder = new ApiSdk.Groups.Item.Drives.DrivesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -177,6 +188,9 @@ public Command BuildDrivesCommand() { public Command BuildEventsCommand() { var command = new Command("events"); var builder = new ApiSdk.Groups.Item.Events.EventsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -184,6 +198,9 @@ public Command BuildEventsCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Groups.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -209,20 +226,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildGetMemberGroupsCommand() { @@ -240,6 +256,9 @@ public Command BuildGetMemberObjectsCommand() { public Command BuildGroupLifecyclePoliciesCommand() { var command = new Command("group-lifecycle-policies"); var builder = new ApiSdk.Groups.Item.GroupLifecyclePolicies.GroupLifecyclePoliciesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -301,14 +320,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + command.SetHandler(async (string groupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, bodyOption); return command; @@ -316,6 +334,9 @@ public Command BuildPatchCommand() { public Command BuildPermissionGrantsCommand() { var command = new Command("permission-grants"); var builder = new ApiSdk.Groups.Item.PermissionGrants.PermissionGrantsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -332,6 +353,9 @@ public Command BuildPhotoCommand() { public Command BuildPhotosCommand() { var command = new Command("photos"); var builder = new ApiSdk.Groups.Item.Photos.PhotosRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -379,6 +403,9 @@ public Command BuildRestoreCommand() { public Command BuildSettingsCommand() { var command = new Command("settings"); var builder = new ApiSdk.Groups.Item.Settings.SettingsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -386,6 +413,9 @@ public Command BuildSettingsCommand() { public Command BuildSitesCommand() { var command = new Command("sites"); var builder = new ApiSdk.Groups.Item.Sites.SitesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -407,6 +437,9 @@ public Command BuildTeamCommand() { public Command BuildThreadsCommand() { var command = new Command("threads"); var builder = new ApiSdk.Groups.Item.Threads.ThreadsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -504,42 +537,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from groups by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Group model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from groups by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/MemberOf/@Ref/@Ref.cs b/src/generated/Groups/Item/MemberOf/@Ref/@Ref.cs deleted file mode 100644 index d18fb26f420..00000000000 --- a/src/generated/Groups/Item/MemberOf/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.MemberOf.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Groups/Item/MemberOf/@Ref/RefRequestBuilder.cs b/src/generated/Groups/Item/MemberOf/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 8b353286b26..00000000000 --- a/src/generated/Groups/Item/MemberOf/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Groups.Item.MemberOf.@Ref { - /// Builds and executes requests for operations under \groups\{group-id}\memberOf\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Groups and administrative units that this group is a member of. HTTP Methods: GET (supported for all groups). Read-only. Nullable. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Groups and administrative units that this group is a member of. HTTP Methods: GET (supported for all groups). Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Groups and administrative units that this group is a member of. HTTP Methods: GET (supported for all groups). Read-only. Nullable. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Groups and administrative units that this group is a member of. HTTP Methods: GET (supported for all groups). Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/groups/{group_id}/memberOf/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Groups and administrative units that this group is a member of. HTTP Methods: GET (supported for all groups). Read-only. Nullable. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Groups and administrative units that this group is a member of. HTTP Methods: GET (supported for all groups). Read-only. Nullable. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Groups.Item.MemberOf.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Groups and administrative units that this group is a member of. HTTP Methods: GET (supported for all groups). Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Groups and administrative units that this group is a member of. HTTP Methods: GET (supported for all groups). Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Groups.Item.MemberOf.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Groups and administrative units that this group is a member of. HTTP Methods: GET (supported for all groups). Read-only. Nullable. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Groups/Item/MemberOf/@Ref/RefResponse.cs b/src/generated/Groups/Item/MemberOf/@Ref/RefResponse.cs deleted file mode 100644 index 22fb0075000..00000000000 --- a/src/generated/Groups/Item/MemberOf/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.MemberOf.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Groups/Item/MemberOf/MemberOfRequestBuilder.cs b/src/generated/Groups/Item/MemberOf/MemberOfRequestBuilder.cs index 3732f662338..1449fcd8f81 100644 --- a/src/generated/Groups/Item/MemberOf/MemberOfRequestBuilder.cs +++ b/src/generated/Groups/Item/MemberOf/MemberOfRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Groups.Item.MemberOf.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Groups.Item.MemberOf.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Groups.Item.MemberOf.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Groups and administrative units that this group is a member of. HTTP Methods: GET (supported for all groups). Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Groups and administrative units that this group is a member of. HTTP Methods: GET (supported for all groups). Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/MemberOf/Ref/Ref.cs b/src/generated/Groups/Item/MemberOf/Ref/Ref.cs new file mode 100644 index 00000000000..85f753a0d5e --- /dev/null +++ b/src/generated/Groups/Item/MemberOf/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Groups.Item.MemberOf.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Groups/Item/MemberOf/Ref/RefRequestBuilder.cs b/src/generated/Groups/Item/MemberOf/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..c0e8d195e69 --- /dev/null +++ b/src/generated/Groups/Item/MemberOf/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Groups.Item.MemberOf.Ref { + /// Builds and executes requests for operations under \groups\{group-id}\memberOf\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Groups and administrative units that this group is a member of. HTTP Methods: GET (supported for all groups). Read-only. Nullable. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Groups and administrative units that this group is a member of. HTTP Methods: GET (supported for all groups). Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Groups and administrative units that this group is a member of. HTTP Methods: GET (supported for all groups). Read-only. Nullable. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Groups and administrative units that this group is a member of. HTTP Methods: GET (supported for all groups). Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/groups/{group_id}/memberOf/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Groups and administrative units that this group is a member of. HTTP Methods: GET (supported for all groups). Read-only. Nullable. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Groups and administrative units that this group is a member of. HTTP Methods: GET (supported for all groups). Read-only. Nullable. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Groups.Item.MemberOf.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Groups and administrative units that this group is a member of. HTTP Methods: GET (supported for all groups). Read-only. Nullable. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Groups/Item/MemberOf/Ref/RefResponse.cs b/src/generated/Groups/Item/MemberOf/Ref/RefResponse.cs new file mode 100644 index 00000000000..33068f6600d --- /dev/null +++ b/src/generated/Groups/Item/MemberOf/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Groups.Item.MemberOf.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Groups/Item/Members/@Ref/@Ref.cs b/src/generated/Groups/Item/Members/@Ref/@Ref.cs deleted file mode 100644 index 7d2359884ef..00000000000 --- a/src/generated/Groups/Item/Members/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.Members.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Groups/Item/Members/@Ref/RefRequestBuilder.cs b/src/generated/Groups/Item/Members/@Ref/RefRequestBuilder.cs deleted file mode 100644 index f4d96996221..00000000000 --- a/src/generated/Groups/Item/Members/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Groups.Item.Members.@Ref { - /// Builds and executes requests for operations under \groups\{group-id}\members\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Users, contacts, and groups that are members of this group. HTTP Methods: GET (supported for all groups), POST (supported for security groups and mail-enabled security groups), DELETE (supported only for security groups) Read-only. Nullable. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Users, contacts, and groups that are members of this group. HTTP Methods: GET (supported for all groups), POST (supported for security groups and mail-enabled security groups), DELETE (supported only for security groups) Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Users, contacts, and groups that are members of this group. HTTP Methods: GET (supported for all groups), POST (supported for security groups and mail-enabled security groups), DELETE (supported only for security groups) Read-only. Nullable. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Users, contacts, and groups that are members of this group. HTTP Methods: GET (supported for all groups), POST (supported for security groups and mail-enabled security groups), DELETE (supported only for security groups) Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/groups/{group_id}/members/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Users, contacts, and groups that are members of this group. HTTP Methods: GET (supported for all groups), POST (supported for security groups and mail-enabled security groups), DELETE (supported only for security groups) Read-only. Nullable. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Users, contacts, and groups that are members of this group. HTTP Methods: GET (supported for all groups), POST (supported for security groups and mail-enabled security groups), DELETE (supported only for security groups) Read-only. Nullable. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Groups.Item.Members.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Users, contacts, and groups that are members of this group. HTTP Methods: GET (supported for all groups), POST (supported for security groups and mail-enabled security groups), DELETE (supported only for security groups) Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Users, contacts, and groups that are members of this group. HTTP Methods: GET (supported for all groups), POST (supported for security groups and mail-enabled security groups), DELETE (supported only for security groups) Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Groups.Item.Members.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Users, contacts, and groups that are members of this group. HTTP Methods: GET (supported for all groups), POST (supported for security groups and mail-enabled security groups), DELETE (supported only for security groups) Read-only. Nullable. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Groups/Item/Members/@Ref/RefResponse.cs b/src/generated/Groups/Item/Members/@Ref/RefResponse.cs deleted file mode 100644 index 004eb864e2b..00000000000 --- a/src/generated/Groups/Item/Members/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.Members.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Groups/Item/Members/MembersRequestBuilder.cs b/src/generated/Groups/Item/Members/MembersRequestBuilder.cs index e8cb4c20685..f2f371f3056 100644 --- a/src/generated/Groups/Item/Members/MembersRequestBuilder.cs +++ b/src/generated/Groups/Item/Members/MembersRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Groups.Item.Members.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -20,11 +20,11 @@ public class MembersRequestBuilder { /// Url template to use to build the URL for the current request builder private string UrlTemplate { get; set; } /// - /// Users, contacts, and groups that are members of this group. HTTP Methods: GET (supported for all groups), POST (supported for security groups and mail-enabled security groups), DELETE (supported only for security groups) Read-only. Nullable. Supports $expand. + /// Members of this group, who can be users, devices, other groups, or service principals. Supports the List members, Add member, and Remove member operations. Nullable. Supports $expand including nested $select. For example, /groups?$filter=startsWith(displayName,'Role')&$select=id,displayName&$expand=members($select=id,userPrincipalName,displayName). /// public Command BuildGetCommand() { var command = new Command("get"); - command.Description = "Users, contacts, and groups that are members of this group. HTTP Methods: GET (supported for all groups), POST (supported for security groups and mail-enabled security groups), DELETE (supported only for security groups) Read-only. Nullable. Supports $expand."; + command.Description = "Members of this group, who can be users, devices, other groups, or service principals. Supports the List members, Add member, and Remove member operations. Nullable. Supports $expand including nested $select. For example, /groups?$filter=startsWith(displayName,'Role')&$select=id,displayName&$expand=members($select=id,userPrincipalName,displayName)."; // Create options for all the parameters var groupIdOption = new Option("--group-id", description: "key: id of group") { }; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Groups.Item.Members.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Groups.Item.Members.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -108,7 +107,7 @@ public MembersRequestBuilder(Dictionary pathParameters, IRequest RequestAdapter = requestAdapter; } /// - /// Users, contacts, and groups that are members of this group. HTTP Methods: GET (supported for all groups), POST (supported for security groups and mail-enabled security groups), DELETE (supported only for security groups) Read-only. Nullable. Supports $expand. + /// Members of this group, who can be users, devices, other groups, or service principals. Supports the List members, Add member, and Remove member operations. Nullable. Supports $expand including nested $select. For example, /groups?$filter=startsWith(displayName,'Role')&$select=id,displayName&$expand=members($select=id,userPrincipalName,displayName). /// Request headers /// Request options /// Request query parameters @@ -128,19 +127,7 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Users, contacts, and groups that are members of this group. HTTP Methods: GET (supported for all groups), POST (supported for security groups and mail-enabled security groups), DELETE (supported only for security groups) Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Users, contacts, and groups that are members of this group. HTTP Methods: GET (supported for all groups), POST (supported for security groups and mail-enabled security groups), DELETE (supported only for security groups) Read-only. Nullable. Supports $expand. + /// Members of this group, who can be users, devices, other groups, or service principals. Supports the List members, Add member, and Remove member operations. Nullable. Supports $expand including nested $select. For example, /groups?$filter=startsWith(displayName,'Role')&$select=id,displayName&$expand=members($select=id,userPrincipalName,displayName). public class GetQueryParameters : QueryParametersBase { /// Include count of items public bool? Count { get; set; } diff --git a/src/generated/Groups/Item/Members/Ref/Ref.cs b/src/generated/Groups/Item/Members/Ref/Ref.cs new file mode 100644 index 00000000000..e39ad92145b --- /dev/null +++ b/src/generated/Groups/Item/Members/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Groups.Item.Members.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Groups/Item/Members/Ref/RefRequestBuilder.cs b/src/generated/Groups/Item/Members/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..ce05056ccf7 --- /dev/null +++ b/src/generated/Groups/Item/Members/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Groups.Item.Members.Ref { + /// Builds and executes requests for operations under \groups\{group-id}\members\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Members of this group, who can be users, devices, other groups, or service principals. Supports the List members, Add member, and Remove member operations. Nullable. Supports $expand including nested $select. For example, /groups?$filter=startsWith(displayName,'Role')&$select=id,displayName&$expand=members($select=id,userPrincipalName,displayName). + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Members of this group, who can be users, devices, other groups, or service principals. Supports the List members, Add member, and Remove member operations. Nullable. Supports $expand including nested $select. For example, /groups?$filter=startsWith(displayName,'Role')&$select=id,displayName&$expand=members($select=id,userPrincipalName,displayName)."; + // Create options for all the parameters + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Members of this group, who can be users, devices, other groups, or service principals. Supports the List members, Add member, and Remove member operations. Nullable. Supports $expand including nested $select. For example, /groups?$filter=startsWith(displayName,'Role')&$select=id,displayName&$expand=members($select=id,userPrincipalName,displayName). + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Members of this group, who can be users, devices, other groups, or service principals. Supports the List members, Add member, and Remove member operations. Nullable. Supports $expand including nested $select. For example, /groups?$filter=startsWith(displayName,'Role')&$select=id,displayName&$expand=members($select=id,userPrincipalName,displayName)."; + // Create options for all the parameters + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/groups/{group_id}/members/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Members of this group, who can be users, devices, other groups, or service principals. Supports the List members, Add member, and Remove member operations. Nullable. Supports $expand including nested $select. For example, /groups?$filter=startsWith(displayName,'Role')&$select=id,displayName&$expand=members($select=id,userPrincipalName,displayName). + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Members of this group, who can be users, devices, other groups, or service principals. Supports the List members, Add member, and Remove member operations. Nullable. Supports $expand including nested $select. For example, /groups?$filter=startsWith(displayName,'Role')&$select=id,displayName&$expand=members($select=id,userPrincipalName,displayName). + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Groups.Item.Members.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Members of this group, who can be users, devices, other groups, or service principals. Supports the List members, Add member, and Remove member operations. Nullable. Supports $expand including nested $select. For example, /groups?$filter=startsWith(displayName,'Role')&$select=id,displayName&$expand=members($select=id,userPrincipalName,displayName). + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Groups/Item/Members/Ref/RefResponse.cs b/src/generated/Groups/Item/Members/Ref/RefResponse.cs new file mode 100644 index 00000000000..f2872ddd62b --- /dev/null +++ b/src/generated/Groups/Item/Members/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Groups.Item.Members.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Groups/Item/MembersWithLicenseErrors/@Ref/@Ref.cs b/src/generated/Groups/Item/MembersWithLicenseErrors/@Ref/@Ref.cs deleted file mode 100644 index 836c57cbd05..00000000000 --- a/src/generated/Groups/Item/MembersWithLicenseErrors/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.MembersWithLicenseErrors.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Groups/Item/MembersWithLicenseErrors/@Ref/RefRequestBuilder.cs b/src/generated/Groups/Item/MembersWithLicenseErrors/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 7d1da231698..00000000000 --- a/src/generated/Groups/Item/MembersWithLicenseErrors/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Groups.Item.MembersWithLicenseErrors.@Ref { - /// Builds and executes requests for operations under \groups\{group-id}\membersWithLicenseErrors\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// A list of group members with license errors from this group-based license assignment. Read-only. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "A list of group members with license errors from this group-based license assignment. Read-only."; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// A list of group members with license errors from this group-based license assignment. Read-only. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "A list of group members with license errors from this group-based license assignment. Read-only."; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/groups/{group_id}/membersWithLicenseErrors/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// A list of group members with license errors from this group-based license assignment. Read-only. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// A list of group members with license errors from this group-based license assignment. Read-only. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Groups.Item.MembersWithLicenseErrors.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// A list of group members with license errors from this group-based license assignment. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A list of group members with license errors from this group-based license assignment. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Groups.Item.MembersWithLicenseErrors.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// A list of group members with license errors from this group-based license assignment. Read-only. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Groups/Item/MembersWithLicenseErrors/@Ref/RefResponse.cs b/src/generated/Groups/Item/MembersWithLicenseErrors/@Ref/RefResponse.cs deleted file mode 100644 index 92bf61d2241..00000000000 --- a/src/generated/Groups/Item/MembersWithLicenseErrors/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.MembersWithLicenseErrors.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Groups/Item/MembersWithLicenseErrors/MembersWithLicenseErrorsRequestBuilder.cs b/src/generated/Groups/Item/MembersWithLicenseErrors/MembersWithLicenseErrorsRequestBuilder.cs index 241bd6db891..6dd3952d814 100644 --- a/src/generated/Groups/Item/MembersWithLicenseErrors/MembersWithLicenseErrorsRequestBuilder.cs +++ b/src/generated/Groups/Item/MembersWithLicenseErrors/MembersWithLicenseErrorsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Groups.Item.MembersWithLicenseErrors.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Groups.Item.MembersWithLicenseErrors.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Groups.Item.MembersWithLicenseErrors.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A list of group members with license errors from this group-based license assignment. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A list of group members with license errors from this group-based license assignment. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/MembersWithLicenseErrors/Ref/Ref.cs b/src/generated/Groups/Item/MembersWithLicenseErrors/Ref/Ref.cs new file mode 100644 index 00000000000..08d7e4c7f6d --- /dev/null +++ b/src/generated/Groups/Item/MembersWithLicenseErrors/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Groups.Item.MembersWithLicenseErrors.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Groups/Item/MembersWithLicenseErrors/Ref/RefRequestBuilder.cs b/src/generated/Groups/Item/MembersWithLicenseErrors/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..afbbc66893d --- /dev/null +++ b/src/generated/Groups/Item/MembersWithLicenseErrors/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Groups.Item.MembersWithLicenseErrors.Ref { + /// Builds and executes requests for operations under \groups\{group-id}\membersWithLicenseErrors\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// A list of group members with license errors from this group-based license assignment. Read-only. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "A list of group members with license errors from this group-based license assignment. Read-only."; + // Create options for all the parameters + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// A list of group members with license errors from this group-based license assignment. Read-only. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "A list of group members with license errors from this group-based license assignment. Read-only."; + // Create options for all the parameters + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/groups/{group_id}/membersWithLicenseErrors/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// A list of group members with license errors from this group-based license assignment. Read-only. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// A list of group members with license errors from this group-based license assignment. Read-only. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Groups.Item.MembersWithLicenseErrors.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// A list of group members with license errors from this group-based license assignment. Read-only. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Groups/Item/MembersWithLicenseErrors/Ref/RefResponse.cs b/src/generated/Groups/Item/MembersWithLicenseErrors/Ref/RefResponse.cs new file mode 100644 index 00000000000..d72f18cc09b --- /dev/null +++ b/src/generated/Groups/Item/MembersWithLicenseErrors/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Groups.Item.MembersWithLicenseErrors.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Groups/Item/Onenote/Notebooks/GetNotebookFromWebUrl/GetNotebookFromWebUrlRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/GetNotebookFromWebUrl/GetNotebookFromWebUrlRequestBuilder.cs index a52db891530..ee3f9e51f84 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/GetNotebookFromWebUrl/GetNotebookFromWebUrlRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/GetNotebookFromWebUrl/GetNotebookFromWebUrlRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(GetNotebookFromWebUrlRequ requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getNotebookFromWebUrl - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GetNotebookFromWebUrlRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes CopyNotebookModel public class GetNotebookFromWebUrlResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Notebooks/GetRecentNotebooksWithIncludePersonalNotebooks/GetRecentNotebooksWithIncludePersonalNotebooksRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/GetRecentNotebooksWithIncludePersonalNotebooks/GetRecentNotebooksWithIncludePersonalNotebooksRequestBuilder.cs index 10ad2eef18f..b45cdcba5b7 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/GetRecentNotebooksWithIncludePersonalNotebooks/GetRecentNotebooksWithIncludePersonalNotebooksRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/GetRecentNotebooksWithIncludePersonalNotebooks/GetRecentNotebooksWithIncludePersonalNotebooksRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,22 +29,21 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var includePersonalNotebooksOption = new Option("--includepersonalnotebooks", description: "Usage: includePersonalNotebooks={includePersonalNotebooks}") { + var includePersonalNotebooksOption = new Option("--include-personal-notebooks", description: "Usage: includePersonalNotebooks={includePersonalNotebooks}") { }; includePersonalNotebooksOption.IsRequired = true; command.AddOption(includePersonalNotebooksOption); - command.SetHandler(async (string groupId, bool? includePersonalNotebooks) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, bool? includePersonalNotebooks, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, includePersonalNotebooksOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, includePersonalNotebooksOption, outputOption); return command; } /// @@ -77,16 +76,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getRecentNotebooks - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/CopyNotebook/CopyNotebookRequestBuilder.cs index 40a88d173c7..f13b302d073 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/NotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/NotebookRequestBuilder.cs index 1ca1d156cb1..569f1dccece 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/NotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/NotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -43,11 +43,10 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - command.SetHandler(async (string groupId, string notebookId) => { + command.SetHandler(async (string groupId, string notebookId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption); return command; @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string body) => { + command.SetHandler(async (string groupId, string notebookId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, bodyOption); return command; @@ -127,6 +124,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Groups.Item.Onenote.Notebooks.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,6 +134,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Groups.Item.Onenote.Notebooks.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -205,42 +208,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 278126ceb8c..2c1199b72b4 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,7 +34,7 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 30bec1a596d..fc7317d9b54 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,15 +41,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId) => { + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, sectionGroupIdOption); return command; @@ -69,7 +68,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -114,7 +112,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string body) => { + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, sectionGroupIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 8cdc7e6de27..b94d469727a 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId) => { + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, sectionGroupIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string body) => { + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, sectionGroupIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index f3029ff6921..ef24bca644c 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId) => { + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, sectionGroupIdOption); return command; @@ -66,7 +65,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -80,20 +79,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -128,7 +126,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -136,14 +134,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string body) => { + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, sectionGroupIdOption, bodyOption); return command; @@ -151,6 +148,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Groups.Item.Onenote.Notebooks.Item.SectionGroups.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -158,6 +158,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Groups.Item.Onenote.Notebooks.Item.SectionGroups.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -229,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index 6b4cf7f0da4..719bfdd18b3 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -66,11 +65,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -115,11 +113,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs index b8b14bb754d..8427733cc0a 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,7 +43,7 @@ public Command BuildCreateCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildListCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 46e4ba547ba..b6c11907c42 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index ae0b0902333..0e9067cde71 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index 96a69242c4c..233e11077ec 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -51,19 +51,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -83,11 +82,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -101,25 +100,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Groups.Item.Onenote.Notebooks.Item.SectionGroups.Item.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -156,11 +157,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -168,14 +169,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -247,42 +247,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index 99cf1c14bbf..5faab6da5d3 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,36 +33,38 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo output) => { + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); + }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, fileOption, outputOption); return command; } /// @@ -80,15 +82,15 @@ public Command BuildPutCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -96,12 +98,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file) => { + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -152,29 +153,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 22ed0b5bb0b..4f5adebbd87 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,15 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -50,21 +50,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -98,19 +97,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index 9c364a7f8f5..f4d54893444 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -53,23 +53,22 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -89,15 +88,15 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -111,20 +110,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -167,15 +165,15 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -183,14 +181,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -263,42 +260,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \groups\{group-id}\onenote\notebooks\{notebook-id}\sectionGroups\{sectionGroup-id}\sections\{onenoteSection-id}\pages\{onenotePage-id}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index 338eb32b1d5..6944c765287 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,15 +33,15 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -49,14 +49,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -92,18 +91,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 2d0147e220b..9a4e7e12d8a 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,15 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -50,21 +50,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -98,19 +97,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index d28ece7290e..1d29e709839 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,23 +41,22 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -77,15 +76,15 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -99,20 +98,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -130,15 +128,15 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -146,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -225,42 +222,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs index d5eb0d96cc6..440d5175ed8 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,15 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -50,21 +50,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -98,19 +97,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 1b1be607f2e..5bae33eed83 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,15 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -50,21 +50,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -98,19 +97,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs index fecfcbba2e7..b4110a493fb 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -48,23 +48,22 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -84,15 +83,15 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -106,20 +105,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -137,15 +135,15 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -153,14 +151,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -232,42 +229,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index 626f4ce03f9..78452ff3264 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,30 +34,29 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); return command; } /// @@ -88,17 +87,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs index e8147795f1d..237e00d8d04 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -49,11 +48,11 @@ public Command BuildCreateCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -61,21 +60,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -93,11 +91,11 @@ public Command BuildListCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -136,7 +134,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -147,15 +149,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -210,31 +207,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 0d8981ec560..e56852c9a30 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 8f9811839f6..b17307dbc6f 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,19 +41,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -73,11 +72,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -91,20 +90,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -122,11 +120,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 27d3a58d222..c404f151855 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -66,11 +65,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,11 +113,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/SectionsRequestBuilder.cs index f66c928036b..003b6babef2 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -49,7 +48,7 @@ public Command BuildCreateCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -57,21 +56,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -89,7 +87,7 @@ public Command BuildListCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -128,7 +126,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -139,15 +141,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -202,31 +199,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/SectionGroupsRequestBuilder.cs index 2452ac8a96b..3b9b769b934 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, bodyOption, outputOption); return command; } /// @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -130,15 +132,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -193,31 +190,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 12ecc0ade33..aae6dea88ef 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,7 +34,7 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index d42aa0cf442..b36ee6a4cf5 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,7 +34,7 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index febad7e07df..29ac3b094ad 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -51,15 +51,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, onenoteSectionIdOption); return command; @@ -79,7 +78,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -93,25 +92,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Groups.Item.Onenote.Notebooks.Item.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -131,7 +132,6 @@ public Command BuildParentSectionGroupCommand() { command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); command.AddCommand(builder.BuildPatchCommand()); command.AddCommand(builder.BuildSectionGroupsCommand()); command.AddCommand(builder.BuildSectionsCommand()); @@ -152,7 +152,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -160,14 +160,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -239,42 +238,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index 50181c9ee51..5348437b71c 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,32 +33,34 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, FileInfo output) => { + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); + }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, fileOption, outputOption); return command; } /// @@ -76,11 +78,11 @@ public Command BuildPutCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -88,12 +90,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, FileInfo file) => { + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -144,29 +145,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index ef78662958a..77265c5f0f0 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index 377fef8c152..5556ca6a93f 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -53,19 +53,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -85,11 +84,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -103,20 +102,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -159,11 +157,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -171,14 +169,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -251,42 +248,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \groups\{group-id}\onenote\notebooks\{notebook-id}\sections\{onenoteSection-id}\pages\{onenotePage-id}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index 39810dea343..a396547047b 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,11 +33,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 043357373a5..44bb0b65b54 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 879fb70329a..01af4ed80eb 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,19 +41,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -73,11 +72,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -91,20 +90,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -122,11 +120,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 635f1b0b5a5..f2e9a574d18 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index ef16cd2a65c..0d462753d8d 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs index ec4f77a8656..27295ad02f0 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -48,19 +48,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -80,11 +79,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -129,11 +127,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index d72d5f3a112..96897c30558 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,26 +34,25 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenotePageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/PagesRequestBuilder.cs index 40b28539981..11b62364aae 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -49,7 +48,7 @@ public Command BuildCreateCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -57,21 +56,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -89,7 +87,7 @@ public Command BuildListCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -128,7 +126,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -139,15 +141,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -202,31 +199,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 159968e5be4..56fbbca112c 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,7 +34,7 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 6a3a9a737cb..c0ceff75081 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,15 +41,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, onenoteSectionIdOption); return command; @@ -69,7 +68,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -114,7 +112,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index eeb4532e5e0..2a02fdb77d8 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,7 +34,7 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs index 28144108a2a..7a5679f94da 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,15 +41,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, onenoteSectionIdOption); return command; @@ -69,7 +68,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -114,7 +112,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs deleted file mode 100644 index 8818b5aa36c..00000000000 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ /dev/null @@ -1,241 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Groups.Item.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup.ParentSectionGroup { - /// Builds and executes requests for operations under \groups\{group-id}\onenote\notebooks\{notebook-id}\sections\{onenoteSection-id}\parentSectionGroup\parentSectionGroup - public class ParentSectionGroupRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var notebookIdOption = new Option("--notebook-id", description: "key: id of notebook") { - }; - notebookIdOption.IsRequired = true; - command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var notebookIdOption = new Option("--notebook-id", description: "key: id of notebook") { - }; - notebookIdOption.IsRequired = true; - command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildPatchCommand() { - var command = new Command("patch"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var notebookIdOption = new Option("--notebook-id", description: "key: id of notebook") { - }; - notebookIdOption.IsRequired = true; - command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePatchRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new ParentSectionGroupRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public ParentSectionGroupRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/groups/{group_id}/onenote/notebooks/{notebook_id}/sections/{onenoteSection_id}/parentSectionGroup/parentSectionGroup{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePatchRequestInformation(SectionGroup body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PATCH, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// The section group that contains the section group. Read-only. - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 0e7510946f1..f36bb7fd236 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,15 +37,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, onenoteSectionIdOption); return command; @@ -65,7 +64,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -79,20 +78,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -104,18 +102,6 @@ public Command BuildParentNotebookCommand() { command.AddCommand(builder.BuildPatchCommand()); return command; } - public Command BuildParentSectionGroupCommand() { - var command = new Command("parent-section-group"); - var builder = new ApiSdk.Groups.Item.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup.ParentSectionGroupRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildDeleteCommand()); - command.AddCommand(builder.BuildGetCommand()); - command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); - command.AddCommand(builder.BuildPatchCommand()); - command.AddCommand(builder.BuildSectionGroupsCommand()); - command.AddCommand(builder.BuildSectionsCommand()); - return command; - } /// /// The section group that contains the section. Read-only. /// @@ -131,7 +117,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -139,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -154,6 +139,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Groups.Item.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -161,6 +149,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Groups.Item.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -232,42 +223,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs index 3bfb9e4bd13..653109ce2ff 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -66,11 +65,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,11 +113,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs index e8c0a923c3c..3ba70251743 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,7 +43,7 @@ public Command BuildCreateCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildListCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 917ab7f10a0..089d6d1e3ff 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index c356847e783..8cffadaaa25 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs index 403887a2bca..2b480e28cd6 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -48,19 +48,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenoteSectionId1) => { + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option); return command; @@ -80,11 +79,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -129,11 +127,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs index 199d7a6a257..c3c5a085ed3 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -46,7 +45,7 @@ public Command BuildCreateCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,7 +84,7 @@ public Command BuildListCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -125,7 +123,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/SectionsRequestBuilder.cs index 50e7b26fe3a..dc80f4ebaf1 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string notebookId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, bodyOption, outputOption); return command; } /// @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string notebookId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string notebookId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, notebookIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, notebookIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -194,31 +191,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Notebooks/NotebooksRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Notebooks/NotebooksRequestBuilder.cs index 8612b9cd259..6d584c9c873 100644 --- a/src/generated/Groups/Item/Onenote/Notebooks/NotebooksRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Notebooks/NotebooksRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -24,14 +24,13 @@ public class NotebooksRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new NotebookRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyNotebookCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyNotebookCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } public Command BuildGetNotebookFromWebUrlCommand() { @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -129,15 +131,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -193,18 +190,6 @@ public RequestInformation CreatePostRequestInformation(Notebook body, Action - /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \groups\{group-id}\onenote\notebooks\microsoft.graph.getRecentNotebooks(includePersonalNotebooks={includePersonalNotebooks}) /// Usage: includePersonalNotebooks={includePersonalNotebooks} /// @@ -212,19 +197,6 @@ public GetRecentNotebooksWithIncludePersonalNotebooksRequestBuilder GetRecentNot _ = includePersonalNotebooks ?? throw new ArgumentNullException(nameof(includePersonalNotebooks)); return new GetRecentNotebooksWithIncludePersonalNotebooksRequestBuilder(PathParameters, RequestAdapter, includePersonalNotebooks); } - /// - /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/OnenoteRequestBuilder.cs b/src/generated/Groups/Item/Onenote/OnenoteRequestBuilder.cs index 175b13c4932..26b7b2e77c3 100644 --- a/src/generated/Groups/Item/Onenote/OnenoteRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/OnenoteRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -36,11 +36,10 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - command.SetHandler(async (string groupId) => { + command.SetHandler(async (string groupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption); return command; @@ -66,25 +65,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildNotebooksCommand() { var command = new Command("notebooks"); var builder = new ApiSdk.Groups.Item.Onenote.Notebooks.NotebooksRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildGetNotebookFromWebUrlCommand()); command.AddCommand(builder.BuildListCommand()); @@ -93,6 +94,9 @@ public Command BuildNotebooksCommand() { public Command BuildOperationsCommand() { var command = new Command("operations"); var builder = new ApiSdk.Groups.Item.Onenote.Operations.OperationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -100,6 +104,9 @@ public Command BuildOperationsCommand() { public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Groups.Item.Onenote.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -119,14 +126,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + command.SetHandler(async (string groupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, bodyOption); return command; @@ -134,6 +140,9 @@ public Command BuildPatchCommand() { public Command BuildResourcesCommand() { var command = new Command("resources"); var builder = new ApiSdk.Groups.Item.Onenote.Resources.ResourcesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -141,6 +150,9 @@ public Command BuildResourcesCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Groups.Item.Onenote.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -148,6 +160,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Groups.Item.Onenote.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -219,42 +234,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Onenote model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Operations/Item/OnenoteOperationRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Operations/Item/OnenoteOperationRequestBuilder.cs index cc3c98d3f0a..0b10d6521b8 100644 --- a/src/generated/Groups/Item/Onenote/Operations/Item/OnenoteOperationRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Operations/Item/OnenoteOperationRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteOperationIdOption = new Option("--onenoteoperation-id", description: "key: id of onenoteOperation") { + var onenoteOperationIdOption = new Option("--onenote-operation-id", description: "key: id of onenoteOperation") { }; onenoteOperationIdOption.IsRequired = true; command.AddOption(onenoteOperationIdOption); - command.SetHandler(async (string groupId, string onenoteOperationId) => { + command.SetHandler(async (string groupId, string onenoteOperationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteOperationIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteOperationIdOption = new Option("--onenoteoperation-id", description: "key: id of onenoteOperation") { + var onenoteOperationIdOption = new Option("--onenote-operation-id", description: "key: id of onenoteOperation") { }; onenoteOperationIdOption.IsRequired = true; command.AddOption(onenoteOperationIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteOperationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteOperationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteOperationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteOperationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteOperationIdOption = new Option("--onenoteoperation-id", description: "key: id of onenoteOperation") { + var onenoteOperationIdOption = new Option("--onenote-operation-id", description: "key: id of onenoteOperation") { }; onenoteOperationIdOption.IsRequired = true; command.AddOption(onenoteOperationIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteOperationId, string body) => { + command.SetHandler(async (string groupId, string onenoteOperationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteOperationIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteOperation body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteOperation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Operations/OperationsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Operations/OperationsRequestBuilder.cs index 1f6b4b8f6af..b016daacbb2 100644 --- a/src/generated/Groups/Item/Onenote/Operations/OperationsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Operations/OperationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class OperationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteOperationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteOperation body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteOperation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/Content/ContentRequestBuilder.cs index 798ecc43444..129ebb69f4c 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,28 +29,30 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string groupId, string onenotePageId, FileInfo output) => { + command.SetHandler(async (string groupId, string onenotePageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, groupIdOption, onenotePageIdOption, outputOption); + }, groupIdOption, onenotePageIdOption, fileOption, outputOption); return command; } /// @@ -64,7 +66,7 @@ public Command BuildPutCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -72,12 +74,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, FileInfo file) => { + command.SetHandler(async (string groupId, string onenotePageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, bodyOption); return command; @@ -128,29 +129,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 265e9a0621e..d305d55d5ac 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/OnenotePageRequestBuilder.cs index 19ae4a8ffa4..c3c7f555bb0 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/OnenotePageRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -49,15 +49,14 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string onenotePageId) => { + command.SetHandler(async (string groupId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption); return command; @@ -73,7 +72,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -87,20 +86,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -144,7 +142,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -152,14 +150,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, bodyOption); return command; @@ -232,42 +229,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The pages in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The pages in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The pages in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \groups\{group-id}\onenote\pages\{onenotePage-id}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index 36ddf7aa46b..28735089792 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 5087d338d91..d2aa306f768 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 351bfe81ea9..d73d15fadc6 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,15 +39,14 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string onenotePageId) => { + command.SetHandler(async (string groupId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,7 +102,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, bodyOption); return command; @@ -127,6 +124,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Groups.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,6 +134,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Groups.Item.Onenote.Pages.Item.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -205,42 +208,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 73fe1857d69..b107e147e8a 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 9faa0ed1ec8..30c8914ae45 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,19 +37,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -65,11 +64,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,11 +108,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index b12862d9466..abc48030706 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index 5968389e75d..ab4174cd088 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -62,11 +61,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -80,20 +79,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -124,11 +122,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -136,14 +134,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -151,6 +148,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Groups.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -158,6 +158,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Groups.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -229,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index fe236380b5a..a9833b0daea 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs index 4d713f4a5d9..12c042617b9 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,11 +39,11 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -80,11 +78,11 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 2f8ac84e469..8db1c0e9f45 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index e144009fb26..1b0524939ef 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index 7437fb544eb..c8590ed1645 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,23 +47,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -79,15 +78,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -101,25 +100,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Groups.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -152,15 +153,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -168,14 +169,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -247,42 +247,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index 0eaaf46ec97..8111dc55dbb 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,40 +29,42 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, FileInfo output) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, outputOption); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, fileOption, outputOption); return command; } /// @@ -76,19 +78,19 @@ public Command BuildPutCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -96,12 +98,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, FileInfo file) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); return command; @@ -152,29 +153,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 521cdc79424..5c0544e5440 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,19 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -50,21 +50,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption, outputOption); return command; } /// @@ -98,19 +97,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index 11f9be94ad3..d43124ae30d 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,27 +47,26 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option); return command; @@ -83,19 +82,19 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -109,20 +108,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -142,19 +140,19 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -162,14 +160,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); return command; @@ -242,42 +239,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \groups\{group-id}\onenote\pages\{onenotePage-id}\parentNotebook\sectionGroups\{sectionGroup-id}\sections\{onenoteSection-id}\pages\{onenotePage-id1}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index 4f00087c7b5..1ec94abc845 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,19 +29,19 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -49,14 +49,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); return command; @@ -92,18 +91,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index c8d36ce4525..2423ed51151 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,34 +30,33 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, outputOption); return command; } /// @@ -88,17 +87,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs index c13d00449fd..744b2159c69 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -43,15 +42,15 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -59,21 +58,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -87,15 +85,15 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -134,7 +132,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -145,15 +147,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -208,31 +205,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index c85f3ad701e..36a902aa8ac 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index df5f1f2afc4..8189766f6ca 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,23 +37,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -69,15 +68,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -91,20 +90,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -118,15 +116,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 361bf000d1e..cd9907d90f3 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs index 6e0e45237e5..489efb57e99 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,11 +44,11 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -57,21 +56,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -85,11 +83,11 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -128,7 +126,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -139,15 +141,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -202,31 +199,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index 8fa582af270..5126df24c8f 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -44,7 +43,7 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -80,7 +78,7 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -130,15 +132,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -193,31 +190,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 59a45ee5562..4b439f96a87 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index ed6136bcd1c..883411531ca 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index 1b10c5fada9..2eb449d087b 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,19 +47,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -75,11 +74,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -93,25 +92,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Groups.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -131,7 +132,6 @@ public Command BuildParentSectionGroupCommand() { command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); command.AddCommand(builder.BuildPatchCommand()); command.AddCommand(builder.BuildSectionGroupsCommand()); command.AddCommand(builder.BuildSectionsCommand()); @@ -148,11 +148,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -160,14 +160,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -239,42 +238,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index 3eec340dfca..842331ac720 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,36 +29,38 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string onenotePageId1, FileInfo output) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string onenotePageId1, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, outputOption); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, fileOption, outputOption); return command; } /// @@ -72,15 +74,15 @@ public Command BuildPutCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -88,12 +90,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string onenotePageId1, FileInfo file) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string onenotePageId1, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); return command; @@ -144,29 +145,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 59ea823602d..287e2b94085 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string onenotePageId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string onenotePageId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index dd75921a4da..82e3afce17b 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,23 +47,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string onenotePageId1) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string onenotePageId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option); return command; @@ -79,15 +78,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -101,20 +100,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string onenotePageId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string onenotePageId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -134,15 +132,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -150,14 +148,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string onenotePageId1, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string onenotePageId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); return command; @@ -230,42 +227,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \groups\{group-id}\onenote\pages\{onenotePage-id}\parentNotebook\sections\{onenoteSection-id}\pages\{onenotePage-id1}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index 0183056abae..51b54671f36 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,15 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string onenotePageId1, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string onenotePageId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index 1023e529c34..fe9bfdedc28 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,30 +30,29 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string onenotePageId1) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string onenotePageId1, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs index 665c30bd109..ccf0d7b8db0 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -43,11 +42,11 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -55,21 +54,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -83,11 +81,11 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -126,7 +124,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -137,15 +139,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -200,31 +197,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 05b93ef0b73..297889fafb5 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 478285736e9..a7220d29e02 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,19 +37,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -65,11 +64,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,11 +108,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index f88f554cdcc..751feabc6a0 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs index eca075b8264..2ab969225bd 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,19 +37,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -65,11 +64,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,11 +108,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs deleted file mode 100644 index 00965ad6581..00000000000 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ /dev/null @@ -1,241 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Groups.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup.ParentSectionGroup { - /// Builds and executes requests for operations under \groups\{group-id}\onenote\pages\{onenotePage-id}\parentNotebook\sections\{onenoteSection-id}\parentSectionGroup\parentSectionGroup - public class ParentSectionGroupRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { - }; - onenotePageIdOption.IsRequired = true; - command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { - }; - onenotePageIdOption.IsRequired = true; - command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildPatchCommand() { - var command = new Command("patch"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { - }; - onenotePageIdOption.IsRequired = true; - command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePatchRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new ParentSectionGroupRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public ParentSectionGroupRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/groups/{group_id}/onenote/pages/{onenotePage_id}/parentNotebook/sections/{onenoteSection_id}/parentSectionGroup/parentSectionGroup{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePatchRequestInformation(SectionGroup body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PATCH, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// The section group that contains the section group. Read-only. - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 5297c29e982..ed22c2d9e1b 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,19 +33,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -61,11 +60,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -79,20 +78,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -104,18 +102,6 @@ public Command BuildParentNotebookCommand() { command.AddCommand(builder.BuildPatchCommand()); return command; } - public Command BuildParentSectionGroupCommand() { - var command = new Command("parent-section-group"); - var builder = new ApiSdk.Groups.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup.ParentSectionGroupRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildDeleteCommand()); - command.AddCommand(builder.BuildGetCommand()); - command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); - command.AddCommand(builder.BuildPatchCommand()); - command.AddCommand(builder.BuildSectionGroupsCommand()); - command.AddCommand(builder.BuildSectionsCommand()); - return command; - } /// /// The section group that contains the section. Read-only. /// @@ -127,11 +113,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -139,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -154,6 +139,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Groups.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -161,6 +149,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Groups.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -232,42 +223,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs index c86742c3573..cbdbd5b7446 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs index 77f883c22a3..9ee8d177100 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,11 +39,11 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -80,11 +78,11 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index b86b5a3652e..3047fe5a8ba 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index a7915a303b7..830b592e390 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs index 46b83c3712c..0449322c4f7 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,23 +44,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option); return command; @@ -76,15 +75,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -125,15 +123,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs index 1c81e81555a..492b3ad4283 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,11 +41,11 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -82,11 +80,11 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -125,7 +123,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs index e01241220a0..fb308c01db9 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,7 +44,7 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -81,7 +79,7 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -194,31 +191,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 4be08a10334..6f507b5efd2 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 6a71558b63c..bca4918e61e 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/Pages/Item/Content/ContentRequestBuilder.cs index a81d3c3522c..78d2cde694c 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,32 +29,34 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenotePageId1, FileInfo output) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenotePageId1, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, groupIdOption, onenotePageIdOption, onenotePageId1Option, outputOption); + }, groupIdOption, onenotePageIdOption, onenotePageId1Option, fileOption, outputOption); return command; } /// @@ -68,11 +70,11 @@ public Command BuildPutCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -80,12 +82,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenotePageId1, FileInfo file) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenotePageId1, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, onenotePageId1Option, bodyOption); return command; @@ -136,29 +137,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index bb301af7d5e..2752c808312 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenotePageId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenotePageId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenotePageId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenotePageId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePageRequestBuilder.cs index 78499feb5a2..dbe916cea54 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePageRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,19 +47,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - command.SetHandler(async (string groupId, string onenotePageId, string onenotePageId1) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenotePageId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, onenotePageId1Option); return command; @@ -75,11 +74,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -93,20 +92,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenotePageId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenotePageId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenotePageId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenotePageId1Option, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -126,11 +124,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -138,14 +136,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenotePageId1, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenotePageId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, onenotePageId1Option, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \groups\{group-id}\onenote\pages\{onenotePage-id}\parentSection\pages\{onenotePage-id1}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index 54c49c1703d..2c3b9d66a13 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenotePageId1, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenotePageId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, onenotePageId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/Pages/Item/Preview/PreviewRequestBuilder.cs index bb50d59d32b..38cabecff78 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,26 +30,25 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - command.SetHandler(async (string groupId, string onenotePageId, string onenotePageId1) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenotePageId1, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenotePageId1Option); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenotePageId1Option, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/Pages/PagesRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/Pages/PagesRequestBuilder.cs index 26cc25fe1c8..4aa096df595 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/Pages/PagesRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -43,7 +42,7 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -51,21 +50,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -79,7 +77,7 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -129,15 +131,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 8accda58731..da417f847ef 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/ParentNotebookRequestBuilder.cs index 955787ea9f8..1bd724b0676 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,15 +39,14 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string onenotePageId) => { + command.SetHandler(async (string groupId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,7 +102,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, bodyOption); return command; @@ -127,6 +124,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Groups.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,6 +134,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Groups.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -205,42 +208,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 73dc8fea1c6..9c6bc5a28d6 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 791125aff51..f1c3bdadf96 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,19 +37,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -65,11 +64,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,11 +108,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index dfd1aa8b1e7..2ff4aba45e4 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index ecf9ed49983..cb9ba9ed783 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -62,11 +61,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -80,20 +79,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -124,11 +122,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -136,14 +134,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -151,6 +148,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Groups.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.SectionGroups.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -158,6 +158,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Groups.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.SectionGroups.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -229,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index ad18508d6fd..c62e6a84946 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs index 18bdcfe33fa..32438b97772 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,11 +39,11 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -80,11 +78,11 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 68e2f506131..73a1d5e4e8a 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 3f4ca1f555c..54bb3720845 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index eb659625097..bb9281fbb50 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,23 +44,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -76,15 +75,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -125,15 +123,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs index d8e6749c569..e61d7a09606 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,11 +41,11 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -82,11 +80,11 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -125,7 +123,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index 64ba365312c..ad1a389307e 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -44,7 +43,7 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -80,7 +78,7 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -130,15 +132,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -193,31 +190,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index eeb2b439216..edecf1f30c3 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 1adcf4478df..c38f98b3929 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index 73e719efb34..cbc4829a6e6 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,19 +44,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -72,11 +71,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -117,11 +115,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/SectionsRequestBuilder.cs index 7489c603662..cd161678766 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,7 +41,7 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -78,7 +76,7 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -117,7 +115,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 1b08a488d42..b2c587c35f5 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs index c62f8af229f..5a6b8f5589b 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,15 +39,14 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string onenotePageId) => { + command.SetHandler(async (string groupId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,7 +102,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, bodyOption); return command; @@ -127,6 +124,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Groups.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,6 +134,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Groups.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -205,42 +208,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index 814334f60ae..db8ac5e3038 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index 0a405fcede2..13eba3d8eae 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 90728d45992..c6ded113853 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 7bd43ea111f..9b8a9b51bbf 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index 2c6d4955fbc..68de4c94b37 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,19 +44,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -72,11 +71,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -117,11 +115,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs index bd3259a08a2..bc9b2ad0455 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,7 +41,7 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -78,7 +76,7 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -117,7 +115,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs deleted file mode 100644 index 9c1872deb2b..00000000000 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ /dev/null @@ -1,229 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Groups.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.ParentSectionGroup { - /// Builds and executes requests for operations under \groups\{group-id}\onenote\pages\{onenotePage-id}\parentSection\parentSectionGroup\parentSectionGroup - public class ParentSectionGroupRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { - }; - onenotePageIdOption.IsRequired = true; - command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string onenotePageId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, groupIdOption, onenotePageIdOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { - }; - onenotePageIdOption.IsRequired = true; - command.AddOption(onenotePageIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, selectOption, expandOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildPatchCommand() { - var command = new Command("patch"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { - }; - onenotePageIdOption.IsRequired = true; - command.AddOption(onenotePageIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePatchRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, groupIdOption, onenotePageIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new ParentSectionGroupRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public ParentSectionGroupRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/groups/{group_id}/onenote/pages/{onenotePage_id}/parentSection/parentSectionGroup/parentSectionGroup{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePatchRequestInformation(SectionGroup body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PATCH, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// The section group that contains the section group. Read-only. - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 013b81a8154..8d2101f26a5 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,15 +33,14 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string onenotePageId) => { + command.SetHandler(async (string groupId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption); return command; @@ -57,7 +56,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -71,20 +70,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -98,18 +96,6 @@ public Command BuildParentNotebookCommand() { command.AddCommand(builder.BuildSectionsCommand()); return command; } - public Command BuildParentSectionGroupCommand() { - var command = new Command("parent-section-group"); - var builder = new ApiSdk.Groups.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.ParentSectionGroupRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildDeleteCommand()); - command.AddCommand(builder.BuildGetCommand()); - command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); - command.AddCommand(builder.BuildPatchCommand()); - command.AddCommand(builder.BuildSectionGroupsCommand()); - command.AddCommand(builder.BuildSectionsCommand()); - return command; - } /// /// The section group that contains the section. Read-only. /// @@ -121,7 +107,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -129,14 +115,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, bodyOption); return command; @@ -144,6 +129,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Groups.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -151,6 +139,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Groups.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -222,42 +213,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs index cd1b97ac0f2..9b397709b59 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs index 728ff2084f5..db72e11a2d2 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index a0616c6007a..a5c8a550a3c 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index d615be67e79..46ed27bd514 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs index 1ceadf0d979..c4eeb3919a5 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,19 +44,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -72,11 +71,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -117,11 +115,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/SectionsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/SectionsRequestBuilder.cs index e055799a1ae..7a5f3580a45 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,7 +41,7 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -78,7 +76,7 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -117,7 +115,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs index 3ffdb4b1aa5..83cece47c02 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,15 +47,14 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string onenotePageId) => { + command.SetHandler(async (string groupId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption); return command; @@ -71,7 +70,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -85,25 +84,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Groups.Item.Onenote.Pages.Item.ParentSection.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -125,7 +126,6 @@ public Command BuildParentSectionGroupCommand() { command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); command.AddCommand(builder.BuildPatchCommand()); command.AddCommand(builder.BuildSectionGroupsCommand()); command.AddCommand(builder.BuildSectionsCommand()); @@ -142,7 +142,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -150,14 +150,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenotePageId, string body) => { + command.SetHandler(async (string groupId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenotePageIdOption, bodyOption); return command; @@ -229,42 +228,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/Item/Preview/PreviewRequestBuilder.cs index dadf6c88b11..f36b3095595 100644 --- a/src/generated/Groups/Item/Onenote/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string onenotePageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenotePageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenotePageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenotePageIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Pages/PagesRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Pages/PagesRequestBuilder.cs index 693c06822b6..3aa27b15079 100644 --- a/src/generated/Groups/Item/Onenote/Pages/PagesRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -112,7 +110,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -186,31 +183,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The pages in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The pages in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The pages in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Resources/Item/Content/ContentRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Resources/Item/Content/ContentRequestBuilder.cs index d9037d20f0d..5bcf18506d2 100644 --- a/src/generated/Groups/Item/Onenote/Resources/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Resources/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,28 +29,30 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteResourceIdOption = new Option("--onenoteresource-id", description: "key: id of onenoteResource") { + var onenoteResourceIdOption = new Option("--onenote-resource-id", description: "key: id of onenoteResource") { }; onenoteResourceIdOption.IsRequired = true; command.AddOption(onenoteResourceIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string groupId, string onenoteResourceId, FileInfo output) => { + command.SetHandler(async (string groupId, string onenoteResourceId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, groupIdOption, onenoteResourceIdOption, outputOption); + }, groupIdOption, onenoteResourceIdOption, fileOption, outputOption); return command; } /// @@ -64,7 +66,7 @@ public Command BuildPutCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteResourceIdOption = new Option("--onenoteresource-id", description: "key: id of onenoteResource") { + var onenoteResourceIdOption = new Option("--onenote-resource-id", description: "key: id of onenoteResource") { }; onenoteResourceIdOption.IsRequired = true; command.AddOption(onenoteResourceIdOption); @@ -72,12 +74,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteResourceId, FileInfo file) => { + command.SetHandler(async (string groupId, string onenoteResourceId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteResourceIdOption, bodyOption); return command; @@ -128,29 +129,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property resources from groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property resources in groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Onenote/Resources/Item/OnenoteResourceRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Resources/Item/OnenoteResourceRequestBuilder.cs index 3f34f1b7fc8..6777bb293a4 100644 --- a/src/generated/Groups/Item/Onenote/Resources/Item/OnenoteResourceRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Resources/Item/OnenoteResourceRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteResourceIdOption = new Option("--onenoteresource-id", description: "key: id of onenoteResource") { + var onenoteResourceIdOption = new Option("--onenote-resource-id", description: "key: id of onenoteResource") { }; onenoteResourceIdOption.IsRequired = true; command.AddOption(onenoteResourceIdOption); - command.SetHandler(async (string groupId, string onenoteResourceId) => { + command.SetHandler(async (string groupId, string onenoteResourceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteResourceIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteResourceIdOption = new Option("--onenoteresource-id", description: "key: id of onenoteResource") { + var onenoteResourceIdOption = new Option("--onenote-resource-id", description: "key: id of onenoteResource") { }; onenoteResourceIdOption.IsRequired = true; command.AddOption(onenoteResourceIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteResourceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteResourceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteResourceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteResourceIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,7 +101,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteResourceIdOption = new Option("--onenoteresource-id", description: "key: id of onenoteResource") { + var onenoteResourceIdOption = new Option("--onenote-resource-id", description: "key: id of onenoteResource") { }; onenoteResourceIdOption.IsRequired = true; command.AddOption(onenoteResourceIdOption); @@ -111,14 +109,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteResourceId, string body) => { + command.SetHandler(async (string groupId, string onenoteResourceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteResourceIdOption, bodyOption); return command; @@ -190,42 +187,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteResource body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Resources/ResourcesRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Resources/ResourcesRequestBuilder.cs index 7a598a1ffe1..2b0cab643cc 100644 --- a/src/generated/Groups/Item/Onenote/Resources/ResourcesRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Resources/ResourcesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class ResourcesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteResourceRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteResource body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index c6b824a223d..e271764b045 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 93e9cf3f0a1..9dd82041677 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,15 +39,14 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string groupId, string sectionGroupId) => { + command.SetHandler(async (string groupId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,7 +102,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string body) => { + command.SetHandler(async (string groupId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, bodyOption); return command; @@ -127,6 +124,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Groups.Item.Onenote.SectionGroups.Item.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,6 +134,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Groups.Item.Onenote.SectionGroups.Item.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -205,42 +208,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index 9d0350b0f20..fded0c101fb 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string groupId, string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string groupId, string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string groupId, string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index dfc2a64babb..d3f2382d521 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index c65d021db01..e9c8af39b5b 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 17059eb84cc..7b3daabe339 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index bef563a8713..a515b8aef48 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,19 +47,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -75,11 +74,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -93,25 +92,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Groups.Item.Onenote.SectionGroups.Item.ParentNotebook.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -144,11 +145,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -156,14 +157,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -235,42 +235,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index ad0ad05c2f8..6ee2f7b6ac7 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,36 +29,38 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo output) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, fileOption, outputOption); return command; } /// @@ -72,15 +74,15 @@ public Command BuildPutCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -88,12 +90,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -144,29 +145,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 385eba2935f..5eb5e39564d 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index 4bd01b33102..b9d65e17650 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -49,23 +49,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -81,15 +80,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -103,20 +102,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -155,15 +153,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -171,14 +169,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -251,42 +248,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \groups\{group-id}\onenote\sectionGroups\{sectionGroup-id}\parentNotebook\sections\{onenoteSection-id}\pages\{onenotePage-id}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index ca3386beb36..d848c200335 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,15 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 1010a437770..fded7bd43bb 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index a4627d6274f..c217400fe2d 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,23 +37,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -69,15 +68,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -91,20 +90,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -118,15 +116,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 09e78262645..14e16bc6516 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 8f093117679..4ef327c86ff 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs index 971931a8f78..1d35add979b 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,23 +44,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -76,15 +75,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -125,15 +123,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index ac7ce111020..b992ba9fab2 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,30 +30,29 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs index d08dedd412e..824abd00775 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,11 +44,11 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -57,21 +56,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -85,11 +83,11 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -128,7 +126,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -139,15 +141,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -202,31 +199,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 2691a371067..9d72c0bb7d5 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 92cbcc1cb27..c51989a2a09 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,19 +37,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -65,11 +64,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,11 +108,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 46fff3588e1..59805b8fd86 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs index c4674ecb70a..dc8a46e08ab 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,7 +44,7 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -81,7 +79,7 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -194,31 +191,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 71022cb2225..aac346f59d7 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string groupId, string sectionGroupId) => { + command.SetHandler(async (string groupId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string body) => { + command.SetHandler(async (string groupId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/SectionGroupRequestBuilder.cs index e11526c34f4..fd0b55ffe59 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string groupId, string sectionGroupId) => { + command.SetHandler(async (string groupId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption); return command; @@ -58,7 +57,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -72,20 +71,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -118,7 +116,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -126,14 +124,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string body) => { + command.SetHandler(async (string groupId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, bodyOption); return command; @@ -141,6 +138,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Groups.Item.Onenote.SectionGroups.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -148,6 +148,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Groups.Item.Onenote.SectionGroups.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -219,42 +222,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index 53323cac6f9..ac97d34c761 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string groupId, string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string groupId, string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string groupId, string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs index d70bcc01fa9..40ba26dc107 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index d603d8e13e6..cbec8197b49 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index e4800a5722e..b7e3265c8a3 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index ca98111e5de..52f434c3f04 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,19 +47,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -75,11 +74,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -93,25 +92,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Groups.Item.Onenote.SectionGroups.Item.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -146,11 +147,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -158,14 +159,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -237,42 +237,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index 397355f519e..fced5799b8f 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,36 +29,38 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo output) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, fileOption, outputOption); return command; } /// @@ -72,15 +74,15 @@ public Command BuildPutCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -88,12 +90,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -144,29 +145,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index aeb2eed854e..0613135ed5b 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index c7ca81c4917..5913cf9368d 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -49,23 +49,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -81,15 +80,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -103,20 +102,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -157,15 +155,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -173,14 +171,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -253,42 +250,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \groups\{group-id}\onenote\sectionGroups\{sectionGroup-id}\sections\{onenoteSection-id}\pages\{onenotePage-id}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index 03d4be29ac8..54188a5375f 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,15 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 9a7fd8536de..ef5c6ae75c0 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index f2f94d79dae..70860a97818 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,23 +39,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -71,15 +70,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -93,20 +92,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -120,15 +118,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -136,14 +134,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -151,6 +148,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Groups.Item.Onenote.SectionGroups.Item.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -158,6 +158,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Groups.Item.Onenote.SectionGroups.Item.Sections.Item.Pages.Item.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -229,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index 5dbad56227c..60f388de5ee 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,27 +30,26 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string sectionGroupId1) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupId1Option); return command; @@ -66,19 +65,19 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -92,20 +91,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -119,19 +117,19 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -139,14 +137,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string sectionGroupId1, string body) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupId1Option, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index 00b90a3055a..2fed2541376 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,15 +39,15 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -84,15 +82,15 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -131,7 +129,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -142,15 +144,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -205,31 +202,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 3667df535c9..14f79c8363b 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,19 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -50,21 +50,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -98,19 +97,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 3c6e49e7759..456055883c3 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,19 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -50,21 +50,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -98,19 +97,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index 55a605e0216..665cb224ea0 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,27 +44,26 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option); return command; @@ -80,19 +79,19 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -106,20 +105,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -133,19 +131,19 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -153,14 +151,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -232,42 +229,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs index deb2cf4fd07..8147e7d0ed5 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,15 +41,15 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -58,21 +57,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -86,15 +84,15 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -133,7 +131,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -144,15 +146,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -207,31 +204,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs index f9275934e5e..d56ca01ffb8 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 67580c7bc14..02bea9ba2d9 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs index 81b3de73ba6..ac909f47ac8 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,23 +44,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -76,15 +75,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -125,15 +123,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index fe86f0599d1..6dbf91f8111 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,30 +30,29 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs index 507ccfbae45..b8d7f498f67 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,11 +44,11 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -57,21 +56,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -85,11 +83,11 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -128,7 +126,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -139,15 +141,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -202,31 +199,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 080924e7465..44242436e0f 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index d93fc580b4f..0294358c03e 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,19 +39,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -67,11 +66,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -85,20 +84,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -112,11 +110,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -124,14 +122,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -139,6 +136,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Groups.Item.Onenote.SectionGroups.Item.Sections.Item.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -146,6 +146,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Groups.Item.Onenote.SectionGroups.Item.Sections.Item.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -217,42 +220,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index 357bc923210..217da61c11a 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string sectionGroupId1) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, sectionGroupId1Option); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string sectionGroupId1, string body) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, sectionGroupId1Option, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index bc2f6f886ff..3b06152a74b 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,11 +39,11 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -80,11 +78,11 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 57b0c2b5273..5e6758511cb 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index c55755b6500..07710fba5aa 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index e39e9e1ab8a..dd4a6afee2e 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,23 +44,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option); return command; @@ -76,15 +75,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -125,15 +123,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs index 0db139e2f08..4515e7b8b56 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,11 +41,11 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -82,11 +80,11 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -125,7 +123,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index ec1dbdd3fdf..a8531101a0c 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/SectionsRequestBuilder.cs index 4847b6c5a30..fa84d909e71 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,7 +44,7 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -81,7 +79,7 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -194,31 +191,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/SectionGroups/SectionGroupsRequestBuilder.cs index 73867d774b4..df2d8b0784c 100644 --- a/src/generated/Groups/Item/Onenote/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -122,15 +124,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -185,31 +182,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 9bdf4a391f8..5fbe1fc3121 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index d3e47707cc5..9b972672449 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/OnenoteSectionRequestBuilder.cs index 18a7505e349..cf2538ee353 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,15 +47,14 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption); return command; @@ -71,7 +70,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -85,25 +84,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Groups.Item.Onenote.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -125,7 +126,6 @@ public Command BuildParentSectionGroupCommand() { command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); command.AddCommand(builder.BuildPatchCommand()); command.AddCommand(builder.BuildSectionGroupsCommand()); command.AddCommand(builder.BuildSectionsCommand()); @@ -142,7 +142,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -150,14 +150,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -229,42 +228,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index 6a10be4c8a4..1f820f749d0 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,32 +29,34 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, FileInfo output) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, fileOption, outputOption); return command; } /// @@ -68,11 +70,11 @@ public Command BuildPutCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -80,12 +82,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, FileInfo file) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -136,29 +137,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 021a7c08a34..b66f4e49098 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index 5861fa63476..17f1ad8887c 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -49,19 +49,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -77,11 +76,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -95,20 +94,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -149,11 +147,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -161,14 +159,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -241,42 +238,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \groups\{group-id}\onenote\sections\{onenoteSection-id}\pages\{onenotePage-id}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index d59f82a1ede..2687921594b 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index ffe4830d9cc..b1fde912039 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index be2d79c2149..227afde9975 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,19 +39,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -67,11 +66,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -85,20 +84,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -112,11 +110,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -124,14 +122,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -139,6 +136,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Groups.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -146,6 +146,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Groups.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -217,42 +220,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 2458b3998cf..567832e737f 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 695e413b31c..5c9db36df69 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,23 +37,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -69,15 +68,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -91,20 +90,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -118,15 +116,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 2ae35047114..d5076e858b2 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index 5a7143e0588..6c50167d965 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,23 +34,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -66,15 +65,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -88,20 +87,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -132,15 +130,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -148,14 +146,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -163,6 +160,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Groups.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -170,6 +170,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Groups.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -241,42 +244,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index 8049b1a0122..24f2e8aa80b 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,27 +30,26 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -66,19 +65,19 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -92,20 +91,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -119,19 +117,19 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -139,14 +137,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs index 51fcc124ea8..286039951f3 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,15 +39,15 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -84,15 +82,15 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -131,7 +129,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -142,15 +144,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -205,31 +202,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index f9428a5e29f..5c1a82842ca 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,19 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -50,21 +50,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -98,19 +97,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index f28547a573a..8da2cc428e0 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,19 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -50,21 +50,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -98,19 +97,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index b480bc785fe..ff833fc049a 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,27 +44,26 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option); return command; @@ -80,19 +79,19 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -106,20 +105,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -133,19 +131,19 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -153,14 +151,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -232,42 +229,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs index e932b68bacb..f6587f3be94 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,15 +41,15 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -58,21 +57,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -86,15 +84,15 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -133,7 +131,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -144,15 +146,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -207,31 +204,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index b05aeb53762..b7b88bfa884 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -44,11 +43,11 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -84,11 +82,11 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -127,7 +125,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -138,15 +140,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -201,31 +198,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index b513ec4bb93..6f54ebed29a 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index c4d1b9da906..f5917fb2414 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index 9e86ef0bccc..c5e2c687190 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,23 +44,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option); return command; @@ -76,15 +75,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -125,15 +123,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs index bb3da3777e7..cded1185b29 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,11 +41,11 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -82,11 +80,11 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -125,7 +123,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 9f7a1eecab7..8daa53adb31 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 9e8718065fc..29673624aeb 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs index 6e75acf597c..e3ee9cfb4a9 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,19 +44,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -72,11 +71,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -117,11 +115,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index a3960b5ae41..0eccb55ab0d 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,26 +30,25 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenotePageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/PagesRequestBuilder.cs index 3c9414a2bf3..c177b4d76fc 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,7 +44,7 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -81,7 +79,7 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -194,31 +191,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 8245420bf12..2b114d6d87f 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 994b46fc0b3..50903b3b6cc 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,15 +39,14 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,7 +102,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -127,6 +124,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Groups.Item.Onenote.Sections.Item.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,6 +134,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Groups.Item.Onenote.Sections.Item.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -205,42 +208,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 531a7fa0bdc..f580d69826b 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 51dacfe0e49..8f098d9b2d0 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,19 +37,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -65,11 +64,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,11 +108,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index ea60b02620b..ce4df620273 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index c1cbcb611da..d6658b49b27 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -62,11 +61,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -80,20 +79,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -124,11 +122,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -136,14 +134,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -151,6 +148,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Groups.Item.Onenote.Sections.Item.ParentNotebook.SectionGroups.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -158,6 +158,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Groups.Item.Onenote.Sections.Item.ParentNotebook.SectionGroups.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -229,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index 1d9a9927095..1157650247c 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs index b910cd701b8..0b2670c4203 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,11 +39,11 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -80,11 +78,11 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 2fe14220edc..e3ce38a276d 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 7e724b4663a..5041ae903d4 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index 852f039ec70..556f6dc7e42 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,23 +44,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option); return command; @@ -76,15 +75,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -125,15 +123,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs index e7a9f9742de..f6d36928548 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,11 +41,11 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -82,11 +80,11 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -125,7 +123,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index 17473e8f3f3..8754753997a 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -44,7 +43,7 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -80,7 +78,7 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -130,15 +132,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -193,31 +190,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index b90508327a2..7c99454b2b3 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index fb1a08fce43..8d22dbbb5a4 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index 51a730b2e44..41c8f0b5614 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,19 +44,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, onenoteSectionId1Option); return command; @@ -72,11 +71,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -117,11 +115,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs index 16ec7444eb3..37b8b2c534b 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,7 +41,7 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -78,7 +76,7 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -117,7 +115,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 1f170cb1217..2f110b481a6 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs index 6f39cf732a8..cf709deb9ef 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,15 +39,14 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,7 +102,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -127,6 +124,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Groups.Item.Onenote.Sections.Item.ParentSectionGroup.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,6 +134,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Groups.Item.Onenote.Sections.Item.ParentSectionGroup.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -205,42 +208,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index 586020f271d..2ded21de51c 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index bcc7585dd3b..e99c94f215a 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 9d752dba47d..2f2f17583da 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 2dfcce3c34e..5aadae7fef2 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index d843f9e20a4..a2ab87ad936 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,19 +44,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, onenoteSectionId1Option); return command; @@ -72,11 +71,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -117,11 +115,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs index cb6e4bbfb1a..324f7e5bc90 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,7 +41,7 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -78,7 +76,7 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -117,7 +115,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs deleted file mode 100644 index 6603af09f53..00000000000 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ /dev/null @@ -1,229 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Groups.Item.Onenote.Sections.Item.ParentSectionGroup.ParentSectionGroup { - /// Builds and executes requests for operations under \groups\{group-id}\onenote\sections\{onenoteSection-id}\parentSectionGroup\parentSectionGroup - public class ParentSectionGroupRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string onenoteSectionId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, groupIdOption, onenoteSectionIdOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, selectOption, expandOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildPatchCommand() { - var command = new Command("patch"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePatchRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, groupIdOption, onenoteSectionIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new ParentSectionGroupRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public ParentSectionGroupRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/groups/{group_id}/onenote/sections/{onenoteSection_id}/parentSectionGroup/parentSectionGroup{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePatchRequestInformation(SectionGroup body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PATCH, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// The section group that contains the section group. Read-only. - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 4d66f68a7fa..bc562417489 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,15 +33,14 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string groupId, string onenoteSectionId) => { + command.SetHandler(async (string groupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption); return command; @@ -57,7 +56,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -71,20 +70,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -98,18 +96,6 @@ public Command BuildParentNotebookCommand() { command.AddCommand(builder.BuildSectionsCommand()); return command; } - public Command BuildParentSectionGroupCommand() { - var command = new Command("parent-section-group"); - var builder = new ApiSdk.Groups.Item.Onenote.Sections.Item.ParentSectionGroup.ParentSectionGroupRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildDeleteCommand()); - command.AddCommand(builder.BuildGetCommand()); - command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); - command.AddCommand(builder.BuildPatchCommand()); - command.AddCommand(builder.BuildSectionGroupsCommand()); - command.AddCommand(builder.BuildSectionsCommand()); - return command; - } /// /// The section group that contains the section. Read-only. /// @@ -121,7 +107,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -129,14 +115,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -144,6 +129,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Groups.Item.Onenote.Sections.Item.ParentSectionGroup.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -151,6 +139,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Groups.Item.Onenote.Sections.Item.ParentSectionGroup.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -222,42 +213,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs index 38aa6877fe1..6d268d25161 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs index b4d1e37df45..7383383e1b8 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index d5a356cb65d..cb8302442c7 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index be038cb846d..5c06deebbb7 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs index 6bb41d42d91..a7744b3c8f9 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,19 +44,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, onenoteSectionId1Option); return command; @@ -72,11 +71,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -117,11 +115,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string groupId, string onenoteSectionId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs index f6e4ea0d14b..d7656ccb6ab 100644 --- a/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,7 +41,7 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -78,7 +76,7 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -117,7 +115,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Onenote/Sections/SectionsRequestBuilder.cs b/src/generated/Groups/Item/Onenote/Sections/SectionsRequestBuilder.cs index 79bc760d26c..6db770fe858 100644 --- a/src/generated/Groups/Item/Onenote/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Onenote/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -112,7 +110,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -186,31 +183,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Owners/@Ref/@Ref.cs b/src/generated/Groups/Item/Owners/@Ref/@Ref.cs deleted file mode 100644 index 31afc0ce646..00000000000 --- a/src/generated/Groups/Item/Owners/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.Owners.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Groups/Item/Owners/@Ref/RefRequestBuilder.cs b/src/generated/Groups/Item/Owners/@Ref/RefRequestBuilder.cs deleted file mode 100644 index a7242608052..00000000000 --- a/src/generated/Groups/Item/Owners/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Groups.Item.Owners.@Ref { - /// Builds and executes requests for operations under \groups\{group-id}\owners\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The owners of the group. The owners are a set of non-admin users who are allowed to modify this object. Nullable. If this property is not specified when creating a Microsoft 365 group, the calling user is automatically assigned as the group owner. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The owners of the group. The owners are a set of non-admin users who are allowed to modify this object. Nullable. If this property is not specified when creating a Microsoft 365 group, the calling user is automatically assigned as the group owner. Supports $expand."; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The owners of the group. The owners are a set of non-admin users who are allowed to modify this object. Nullable. If this property is not specified when creating a Microsoft 365 group, the calling user is automatically assigned as the group owner. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The owners of the group. The owners are a set of non-admin users who are allowed to modify this object. Nullable. If this property is not specified when creating a Microsoft 365 group, the calling user is automatically assigned as the group owner. Supports $expand."; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/groups/{group_id}/owners/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The owners of the group. The owners are a set of non-admin users who are allowed to modify this object. Nullable. If this property is not specified when creating a Microsoft 365 group, the calling user is automatically assigned as the group owner. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The owners of the group. The owners are a set of non-admin users who are allowed to modify this object. Nullable. If this property is not specified when creating a Microsoft 365 group, the calling user is automatically assigned as the group owner. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Groups.Item.Owners.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The owners of the group. The owners are a set of non-admin users who are allowed to modify this object. Nullable. If this property is not specified when creating a Microsoft 365 group, the calling user is automatically assigned as the group owner. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The owners of the group. The owners are a set of non-admin users who are allowed to modify this object. Nullable. If this property is not specified when creating a Microsoft 365 group, the calling user is automatically assigned as the group owner. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Groups.Item.Owners.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The owners of the group. The owners are a set of non-admin users who are allowed to modify this object. Nullable. If this property is not specified when creating a Microsoft 365 group, the calling user is automatically assigned as the group owner. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Groups/Item/Owners/@Ref/RefResponse.cs b/src/generated/Groups/Item/Owners/@Ref/RefResponse.cs deleted file mode 100644 index bdd79f860c3..00000000000 --- a/src/generated/Groups/Item/Owners/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.Owners.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Groups/Item/Owners/OwnersRequestBuilder.cs b/src/generated/Groups/Item/Owners/OwnersRequestBuilder.cs index 10e9fc614de..f34fc50243b 100644 --- a/src/generated/Groups/Item/Owners/OwnersRequestBuilder.cs +++ b/src/generated/Groups/Item/Owners/OwnersRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Groups.Item.Owners.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -20,11 +20,11 @@ public class OwnersRequestBuilder { /// Url template to use to build the URL for the current request builder private string UrlTemplate { get; set; } /// - /// The owners of the group. The owners are a set of non-admin users who are allowed to modify this object. Nullable. If this property is not specified when creating a Microsoft 365 group, the calling user is automatically assigned as the group owner. Supports $expand. + /// The owners of the group who can be users or service principals. Nullable. If this property is not specified when creating a Microsoft 365 group, the calling user is automatically assigned as the group owner. Supports $expand including nested $select. For example, /groups?$filter=startsWith(displayName,'Role')&$select=id,displayName&$expand=owners($select=id,userPrincipalName,displayName). /// public Command BuildGetCommand() { var command = new Command("get"); - command.Description = "The owners of the group. The owners are a set of non-admin users who are allowed to modify this object. Nullable. If this property is not specified when creating a Microsoft 365 group, the calling user is automatically assigned as the group owner. Supports $expand."; + command.Description = "The owners of the group who can be users or service principals. Nullable. If this property is not specified when creating a Microsoft 365 group, the calling user is automatically assigned as the group owner. Supports $expand including nested $select. For example, /groups?$filter=startsWith(displayName,'Role')&$select=id,displayName&$expand=owners($select=id,userPrincipalName,displayName)."; // Create options for all the parameters var groupIdOption = new Option("--group-id", description: "key: id of group") { }; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Groups.Item.Owners.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Groups.Item.Owners.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -108,7 +107,7 @@ public OwnersRequestBuilder(Dictionary pathParameters, IRequestA RequestAdapter = requestAdapter; } /// - /// The owners of the group. The owners are a set of non-admin users who are allowed to modify this object. Nullable. If this property is not specified when creating a Microsoft 365 group, the calling user is automatically assigned as the group owner. Supports $expand. + /// The owners of the group who can be users or service principals. Nullable. If this property is not specified when creating a Microsoft 365 group, the calling user is automatically assigned as the group owner. Supports $expand including nested $select. For example, /groups?$filter=startsWith(displayName,'Role')&$select=id,displayName&$expand=owners($select=id,userPrincipalName,displayName). /// Request headers /// Request options /// Request query parameters @@ -128,19 +127,7 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The owners of the group. The owners are a set of non-admin users who are allowed to modify this object. Nullable. If this property is not specified when creating a Microsoft 365 group, the calling user is automatically assigned as the group owner. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The owners of the group. The owners are a set of non-admin users who are allowed to modify this object. Nullable. If this property is not specified when creating a Microsoft 365 group, the calling user is automatically assigned as the group owner. Supports $expand. + /// The owners of the group who can be users or service principals. Nullable. If this property is not specified when creating a Microsoft 365 group, the calling user is automatically assigned as the group owner. Supports $expand including nested $select. For example, /groups?$filter=startsWith(displayName,'Role')&$select=id,displayName&$expand=owners($select=id,userPrincipalName,displayName). public class GetQueryParameters : QueryParametersBase { /// Include count of items public bool? Count { get; set; } diff --git a/src/generated/Groups/Item/Owners/Ref/Ref.cs b/src/generated/Groups/Item/Owners/Ref/Ref.cs new file mode 100644 index 00000000000..3c8c1643c5b --- /dev/null +++ b/src/generated/Groups/Item/Owners/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Groups.Item.Owners.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Groups/Item/Owners/Ref/RefRequestBuilder.cs b/src/generated/Groups/Item/Owners/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..e5422bcd5a0 --- /dev/null +++ b/src/generated/Groups/Item/Owners/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Groups.Item.Owners.Ref { + /// Builds and executes requests for operations under \groups\{group-id}\owners\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The owners of the group who can be users or service principals. Nullable. If this property is not specified when creating a Microsoft 365 group, the calling user is automatically assigned as the group owner. Supports $expand including nested $select. For example, /groups?$filter=startsWith(displayName,'Role')&$select=id,displayName&$expand=owners($select=id,userPrincipalName,displayName). + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The owners of the group who can be users or service principals. Nullable. If this property is not specified when creating a Microsoft 365 group, the calling user is automatically assigned as the group owner. Supports $expand including nested $select. For example, /groups?$filter=startsWith(displayName,'Role')&$select=id,displayName&$expand=owners($select=id,userPrincipalName,displayName)."; + // Create options for all the parameters + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The owners of the group who can be users or service principals. Nullable. If this property is not specified when creating a Microsoft 365 group, the calling user is automatically assigned as the group owner. Supports $expand including nested $select. For example, /groups?$filter=startsWith(displayName,'Role')&$select=id,displayName&$expand=owners($select=id,userPrincipalName,displayName). + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The owners of the group who can be users or service principals. Nullable. If this property is not specified when creating a Microsoft 365 group, the calling user is automatically assigned as the group owner. Supports $expand including nested $select. For example, /groups?$filter=startsWith(displayName,'Role')&$select=id,displayName&$expand=owners($select=id,userPrincipalName,displayName)."; + // Create options for all the parameters + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/groups/{group_id}/owners/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The owners of the group who can be users or service principals. Nullable. If this property is not specified when creating a Microsoft 365 group, the calling user is automatically assigned as the group owner. Supports $expand including nested $select. For example, /groups?$filter=startsWith(displayName,'Role')&$select=id,displayName&$expand=owners($select=id,userPrincipalName,displayName). + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The owners of the group who can be users or service principals. Nullable. If this property is not specified when creating a Microsoft 365 group, the calling user is automatically assigned as the group owner. Supports $expand including nested $select. For example, /groups?$filter=startsWith(displayName,'Role')&$select=id,displayName&$expand=owners($select=id,userPrincipalName,displayName). + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Groups.Item.Owners.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The owners of the group who can be users or service principals. Nullable. If this property is not specified when creating a Microsoft 365 group, the calling user is automatically assigned as the group owner. Supports $expand including nested $select. For example, /groups?$filter=startsWith(displayName,'Role')&$select=id,displayName&$expand=owners($select=id,userPrincipalName,displayName). + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Groups/Item/Owners/Ref/RefResponse.cs b/src/generated/Groups/Item/Owners/Ref/RefResponse.cs new file mode 100644 index 00000000000..0afef48bf50 --- /dev/null +++ b/src/generated/Groups/Item/Owners/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Groups.Item.Owners.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Groups/Item/PermissionGrants/Item/ResourceSpecificPermissionGrantRequestBuilder.cs b/src/generated/Groups/Item/PermissionGrants/Item/ResourceSpecificPermissionGrantRequestBuilder.cs index 93d10609fcd..f7deb8a8b27 100644 --- a/src/generated/Groups/Item/PermissionGrants/Item/ResourceSpecificPermissionGrantRequestBuilder.cs +++ b/src/generated/Groups/Item/PermissionGrants/Item/ResourceSpecificPermissionGrantRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var resourceSpecificPermissionGrantIdOption = new Option("--resourcespecificpermissiongrant-id", description: "key: id of resourceSpecificPermissionGrant") { + var resourceSpecificPermissionGrantIdOption = new Option("--resource-specific-permission-grant-id", description: "key: id of resourceSpecificPermissionGrant") { }; resourceSpecificPermissionGrantIdOption.IsRequired = true; command.AddOption(resourceSpecificPermissionGrantIdOption); - command.SetHandler(async (string groupId, string resourceSpecificPermissionGrantId) => { + command.SetHandler(async (string groupId, string resourceSpecificPermissionGrantId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, resourceSpecificPermissionGrantIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var resourceSpecificPermissionGrantIdOption = new Option("--resourcespecificpermissiongrant-id", description: "key: id of resourceSpecificPermissionGrant") { + var resourceSpecificPermissionGrantIdOption = new Option("--resource-specific-permission-grant-id", description: "key: id of resourceSpecificPermissionGrant") { }; resourceSpecificPermissionGrantIdOption.IsRequired = true; command.AddOption(resourceSpecificPermissionGrantIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string resourceSpecificPermissionGrantId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string resourceSpecificPermissionGrantId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, resourceSpecificPermissionGrantIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, resourceSpecificPermissionGrantIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var resourceSpecificPermissionGrantIdOption = new Option("--resourcespecificpermissiongrant-id", description: "key: id of resourceSpecificPermissionGrant") { + var resourceSpecificPermissionGrantIdOption = new Option("--resource-specific-permission-grant-id", description: "key: id of resourceSpecificPermissionGrant") { }; resourceSpecificPermissionGrantIdOption.IsRequired = true; command.AddOption(resourceSpecificPermissionGrantIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string resourceSpecificPermissionGrantId, string body) => { + command.SetHandler(async (string groupId, string resourceSpecificPermissionGrantId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, resourceSpecificPermissionGrantIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ResourceSpecificPermissi requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions that have been granted for a group to a specific application. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions that have been granted for a group to a specific application. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions that have been granted for a group to a specific application. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ResourceSpecificPermissionGrant model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions that have been granted for a group to a specific application. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/PermissionGrants/PermissionGrantsRequestBuilder.cs b/src/generated/Groups/Item/PermissionGrants/PermissionGrantsRequestBuilder.cs index 77a90e85487..ec91f51b812 100644 --- a/src/generated/Groups/Item/PermissionGrants/PermissionGrantsRequestBuilder.cs +++ b/src/generated/Groups/Item/PermissionGrants/PermissionGrantsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class PermissionGrantsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ResourceSpecificPermissionGrantRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ResourceSpecificPermissio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions that have been granted for a group to a specific application. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions that have been granted for a group to a specific application. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ResourceSpecificPermissionGrant model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions that have been granted for a group to a specific application. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Photo/PhotoRequestBuilder.cs b/src/generated/Groups/Item/Photo/PhotoRequestBuilder.cs index 93f95bbb9f2..bda932c6790 100644 --- a/src/generated/Groups/Item/Photo/PhotoRequestBuilder.cs +++ b/src/generated/Groups/Item/Photo/PhotoRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - command.SetHandler(async (string groupId) => { + command.SetHandler(async (string groupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption); return command; @@ -63,19 +62,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, selectOption, outputOption); return command; } /// @@ -93,14 +91,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + command.SetHandler(async (string groupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, bodyOption); return command; @@ -172,42 +169,6 @@ public RequestInformation CreatePatchRequestInformation(ProfilePhoto body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The group's profile photo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The group's profile photo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The group's profile photo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ProfilePhoto model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The group's profile photo. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Groups/Item/Photo/Value/ContentRequestBuilder.cs b/src/generated/Groups/Item/Photo/Value/ContentRequestBuilder.cs index 842cec585bd..95519b27d90 100644 --- a/src/generated/Groups/Item/Photo/Value/ContentRequestBuilder.cs +++ b/src/generated/Groups/Item/Photo/Value/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string groupId, FileInfo output) => { + command.SetHandler(async (string groupId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, groupIdOption, outputOption); + }, groupIdOption, fileOption, outputOption); return command; } /// @@ -64,12 +66,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, FileInfo file) => { + command.SetHandler(async (string groupId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, bodyOption); return command; @@ -120,29 +121,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// The group's profile photo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The group's profile photo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Photos/Item/ProfilePhotoRequestBuilder.cs b/src/generated/Groups/Item/Photos/Item/ProfilePhotoRequestBuilder.cs index 69f13b51241..c05d6ce5916 100644 --- a/src/generated/Groups/Item/Photos/Item/ProfilePhotoRequestBuilder.cs +++ b/src/generated/Groups/Item/Photos/Item/ProfilePhotoRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var profilePhotoIdOption = new Option("--profilephoto-id", description: "key: id of profilePhoto") { + var profilePhotoIdOption = new Option("--profile-photo-id", description: "key: id of profilePhoto") { }; profilePhotoIdOption.IsRequired = true; command.AddOption(profilePhotoIdOption); - command.SetHandler(async (string groupId, string profilePhotoId) => { + command.SetHandler(async (string groupId, string profilePhotoId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, profilePhotoIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var profilePhotoIdOption = new Option("--profilephoto-id", description: "key: id of profilePhoto") { + var profilePhotoIdOption = new Option("--profile-photo-id", description: "key: id of profilePhoto") { }; profilePhotoIdOption.IsRequired = true; command.AddOption(profilePhotoIdOption); @@ -71,19 +70,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string profilePhotoId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string profilePhotoId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, profilePhotoIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, profilePhotoIdOption, selectOption, outputOption); return command; } /// @@ -97,7 +95,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var profilePhotoIdOption = new Option("--profilephoto-id", description: "key: id of profilePhoto") { + var profilePhotoIdOption = new Option("--profile-photo-id", description: "key: id of profilePhoto") { }; profilePhotoIdOption.IsRequired = true; command.AddOption(profilePhotoIdOption); @@ -105,14 +103,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string profilePhotoId, string body) => { + command.SetHandler(async (string groupId, string profilePhotoId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, profilePhotoIdOption, bodyOption); return command; @@ -184,42 +181,6 @@ public RequestInformation CreatePatchRequestInformation(ProfilePhoto body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The profile photos owned by the group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The profile photos owned by the group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The profile photos owned by the group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ProfilePhoto model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The profile photos owned by the group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Groups/Item/Photos/Item/Value/ContentRequestBuilder.cs b/src/generated/Groups/Item/Photos/Item/Value/ContentRequestBuilder.cs index 44960e133ae..861f8b62d1d 100644 --- a/src/generated/Groups/Item/Photos/Item/Value/ContentRequestBuilder.cs +++ b/src/generated/Groups/Item/Photos/Item/Value/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,28 +29,30 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var profilePhotoIdOption = new Option("--profilephoto-id", description: "key: id of profilePhoto") { + var profilePhotoIdOption = new Option("--profile-photo-id", description: "key: id of profilePhoto") { }; profilePhotoIdOption.IsRequired = true; command.AddOption(profilePhotoIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string groupId, string profilePhotoId, FileInfo output) => { + command.SetHandler(async (string groupId, string profilePhotoId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, groupIdOption, profilePhotoIdOption, outputOption); + }, groupIdOption, profilePhotoIdOption, fileOption, outputOption); return command; } /// @@ -64,7 +66,7 @@ public Command BuildPutCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var profilePhotoIdOption = new Option("--profilephoto-id", description: "key: id of profilePhoto") { + var profilePhotoIdOption = new Option("--profile-photo-id", description: "key: id of profilePhoto") { }; profilePhotoIdOption.IsRequired = true; command.AddOption(profilePhotoIdOption); @@ -72,12 +74,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string profilePhotoId, FileInfo file) => { + command.SetHandler(async (string groupId, string profilePhotoId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, profilePhotoIdOption, bodyOption); return command; @@ -128,29 +129,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property photos from groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property photos in groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Photos/PhotosRequestBuilder.cs b/src/generated/Groups/Item/Photos/PhotosRequestBuilder.cs index da0af259c63..1426794700f 100644 --- a/src/generated/Groups/Item/Photos/PhotosRequestBuilder.cs +++ b/src/generated/Groups/Item/Photos/PhotosRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class PhotosRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ProfilePhotoRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -108,15 +110,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -171,31 +168,6 @@ public RequestInformation CreatePostRequestInformation(ProfilePhoto body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The profile photos owned by the group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The profile photos owned by the group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ProfilePhoto model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The profile photos owned by the group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Planner/PlannerRequestBuilder.cs b/src/generated/Groups/Item/Planner/PlannerRequestBuilder.cs index 86bf36876a1..4b732e45bc1 100644 --- a/src/generated/Groups/Item/Planner/PlannerRequestBuilder.cs +++ b/src/generated/Groups/Item/Planner/PlannerRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,11 +31,10 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - command.SetHandler(async (string groupId) => { + command.SetHandler(async (string groupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption); return command; @@ -61,20 +60,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -92,14 +90,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + command.SetHandler(async (string groupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, bodyOption); return command; @@ -107,6 +104,9 @@ public Command BuildPatchCommand() { public Command BuildPlansCommand() { var command = new Command("plans"); var builder = new ApiSdk.Groups.Item.Planner.Plans.PlansRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -178,42 +178,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Selective Planner services available to the group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Selective Planner services available to the group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Selective Planner services available to the group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Selective Planner services available to the group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Planner/Plans/Item/Buckets/BucketsRequestBuilder.cs b/src/generated/Groups/Item/Planner/Plans/Item/Buckets/BucketsRequestBuilder.cs index f5d3a9b0d8e..ae45bfaeb66 100644 --- a/src/generated/Groups/Item/Planner/Plans/Item/Buckets/BucketsRequestBuilder.cs +++ b/src/generated/Groups/Item/Planner/Plans/Item/Buckets/BucketsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class BucketsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PlannerBucketRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildTasksCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildTasksCommand()); return commands; } /// @@ -41,7 +40,7 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string plannerPlanId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string plannerPlanId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, plannerPlanIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, plannerPlanIdOption, bodyOption, outputOption); return command; } /// @@ -77,7 +75,7 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -116,7 +114,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string plannerPlanId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string plannerPlanId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -127,15 +129,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, plannerPlanIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, plannerPlanIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -190,31 +187,6 @@ public RequestInformation CreatePostRequestInformation(PlannerBucket body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of buckets in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of buckets in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PlannerBucket model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of buckets in the plan. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/PlannerBucketRequestBuilder.cs b/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/PlannerBucketRequestBuilder.cs index 90924369ce2..adffc634525 100644 --- a/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/PlannerBucketRequestBuilder.cs +++ b/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/PlannerBucketRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,19 +31,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId) => { + command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption); return command; @@ -59,11 +58,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,11 +102,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); @@ -116,14 +114,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string body) => { + command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption, bodyOption); return command; @@ -131,6 +128,9 @@ public Command BuildPatchCommand() { public Command BuildTasksCommand() { var command = new Command("tasks"); var builder = new ApiSdk.Groups.Item.Planner.Plans.Item.Buckets.Item.Tasks.TasksRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -202,42 +202,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerBucket body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of buckets in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of buckets in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of buckets in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerBucket model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of buckets in the plan. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs b/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs index e5ecc093b44..44d44bab015 100644 --- a/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId) => { + command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string body) => { + command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerAssignedToTaskBoa requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerAssignedToTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs b/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs index 63779fd3ddc..640bbff8d45 100644 --- a/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId) => { + command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string body) => { + command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerBucketTaskBoardTa requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerBucketTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/Details/DetailsRequestBuilder.cs b/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/Details/DetailsRequestBuilder.cs index eb010fd57f7..3661366906e 100644 --- a/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/Details/DetailsRequestBuilder.cs +++ b/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/Details/DetailsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId) => { + command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string body) => { + command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerTaskDetails body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerTaskDetails model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Additional details about the task. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/PlannerTaskRequestBuilder.cs b/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/PlannerTaskRequestBuilder.cs index 259792a62ba..3a9d6a5ba9e 100644 --- a/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/PlannerTaskRequestBuilder.cs +++ b/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/PlannerTaskRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -50,23 +50,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId) => { + command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption); return command; @@ -90,15 +89,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -112,20 +111,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -139,15 +137,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -155,14 +153,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string body) => { + command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, bodyOption); return command; @@ -242,42 +239,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerTask body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. The collection of tasks in the bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. The collection of tasks in the bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. The collection of tasks in the bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. The collection of tasks in the bucket. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs b/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs index dfff11c067d..7d392fa22da 100644 --- a/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId) => { + command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string body) => { + command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerProgressTaskBoard requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerProgressTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/Tasks/TasksRequestBuilder.cs b/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/Tasks/TasksRequestBuilder.cs index 550c7cb5ee6..a6b4ce94e0c 100644 --- a/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/Tasks/TasksRequestBuilder.cs +++ b/src/generated/Groups/Item/Planner/Plans/Item/Buckets/Item/Tasks/TasksRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class TasksRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PlannerTaskRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAssignedToTaskBoardFormatCommand(), - builder.BuildBucketTaskBoardFormatCommand(), - builder.BuildDeleteCommand(), - builder.BuildDetailsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildProgressTaskBoardFormatCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAssignedToTaskBoardFormatCommand()); + commands.Add(builder.BuildBucketTaskBoardFormatCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDetailsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildProgressTaskBoardFormatCommand()); return commands; } /// @@ -44,11 +43,11 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption, bodyOption, outputOption); return command; } /// @@ -84,11 +82,11 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); @@ -127,7 +125,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string plannerPlanId, string plannerBucketId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -138,15 +140,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, plannerPlanIdOption, plannerBucketIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -201,31 +198,6 @@ public RequestInformation CreatePostRequestInformation(PlannerTask body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. The collection of tasks in the bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. The collection of tasks in the bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PlannerTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. The collection of tasks in the bucket. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Planner/Plans/Item/Details/DetailsRequestBuilder.cs b/src/generated/Groups/Item/Planner/Plans/Item/Details/DetailsRequestBuilder.cs index 9ac5d069032..9799cf9b536 100644 --- a/src/generated/Groups/Item/Planner/Plans/Item/Details/DetailsRequestBuilder.cs +++ b/src/generated/Groups/Item/Planner/Plans/Item/Details/DetailsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - command.SetHandler(async (string groupId, string plannerPlanId) => { + command.SetHandler(async (string groupId, string plannerPlanId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, plannerPlanIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string plannerPlanId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string plannerPlanId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, plannerPlanIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, plannerPlanIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string plannerPlanId, string body) => { + command.SetHandler(async (string groupId, string plannerPlanId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, plannerPlanIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerPlanDetails body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Additional details about the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Additional details about the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Additional details about the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerPlanDetails model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Additional details about the plan. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Planner/Plans/Item/PlannerPlanRequestBuilder.cs b/src/generated/Groups/Item/Planner/Plans/Item/PlannerPlanRequestBuilder.cs index b0472d31202..145300a839e 100644 --- a/src/generated/Groups/Item/Planner/Plans/Item/PlannerPlanRequestBuilder.cs +++ b/src/generated/Groups/Item/Planner/Plans/Item/PlannerPlanRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,6 +25,9 @@ public class PlannerPlanRequestBuilder { public Command BuildBucketsCommand() { var command = new Command("buckets"); var builder = new ApiSdk.Groups.Item.Planner.Plans.Item.Buckets.BucketsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -40,15 +43,14 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - command.SetHandler(async (string groupId, string plannerPlanId) => { + command.SetHandler(async (string groupId, string plannerPlanId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, plannerPlanIdOption); return command; @@ -72,7 +74,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -86,20 +88,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string plannerPlanId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string plannerPlanId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, plannerPlanIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, plannerPlanIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -113,7 +114,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -121,14 +122,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string plannerPlanId, string body) => { + command.SetHandler(async (string groupId, string plannerPlanId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, plannerPlanIdOption, bodyOption); return command; @@ -136,6 +136,9 @@ public Command BuildPatchCommand() { public Command BuildTasksCommand() { var command = new Command("tasks"); var builder = new ApiSdk.Groups.Item.Planner.Plans.Item.Tasks.TasksRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -207,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerPlan body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Returns the plannerPlans owned by the group. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns the plannerPlans owned by the group. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns the plannerPlans owned by the group. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerPlan model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Returns the plannerPlans owned by the group. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Planner/Plans/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs b/src/generated/Groups/Item/Planner/Plans/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs index 1f95c239a4e..021b6593f02 100644 --- a/src/generated/Groups/Item/Planner/Plans/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Groups/Item/Planner/Plans/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId) => { + command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, plannerPlanIdOption, plannerTaskIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId, string body) => { + command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, plannerPlanIdOption, plannerTaskIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerAssignedToTaskBoa requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerAssignedToTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Planner/Plans/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs b/src/generated/Groups/Item/Planner/Plans/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs index bc5aa9d4d61..98e08397408 100644 --- a/src/generated/Groups/Item/Planner/Plans/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Groups/Item/Planner/Plans/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId) => { + command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, plannerPlanIdOption, plannerTaskIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId, string body) => { + command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, plannerPlanIdOption, plannerTaskIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerBucketTaskBoardTa requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerBucketTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Planner/Plans/Item/Tasks/Item/Details/DetailsRequestBuilder.cs b/src/generated/Groups/Item/Planner/Plans/Item/Tasks/Item/Details/DetailsRequestBuilder.cs index c27db49dc6c..1809925c7fe 100644 --- a/src/generated/Groups/Item/Planner/Plans/Item/Tasks/Item/Details/DetailsRequestBuilder.cs +++ b/src/generated/Groups/Item/Planner/Plans/Item/Tasks/Item/Details/DetailsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId) => { + command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, plannerPlanIdOption, plannerTaskIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId, string body) => { + command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, plannerPlanIdOption, plannerTaskIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerTaskDetails body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerTaskDetails model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Additional details about the task. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Planner/Plans/Item/Tasks/Item/PlannerTaskRequestBuilder.cs b/src/generated/Groups/Item/Planner/Plans/Item/Tasks/Item/PlannerTaskRequestBuilder.cs index 72bf2717f55..4e7d8438ac7 100644 --- a/src/generated/Groups/Item/Planner/Plans/Item/Tasks/Item/PlannerTaskRequestBuilder.cs +++ b/src/generated/Groups/Item/Planner/Plans/Item/Tasks/Item/PlannerTaskRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -50,19 +50,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId) => { + command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, plannerPlanIdOption, plannerTaskIdOption); return command; @@ -86,11 +85,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -104,20 +103,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -131,11 +129,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -143,14 +141,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId, string body) => { + command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, plannerPlanIdOption, plannerTaskIdOption, bodyOption); return command; @@ -230,42 +227,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerTask body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of tasks in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of tasks in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of tasks in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of tasks in the plan. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Planner/Plans/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs b/src/generated/Groups/Item/Planner/Plans/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs index 8c8758eb449..ecfe3233035 100644 --- a/src/generated/Groups/Item/Planner/Plans/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Groups/Item/Planner/Plans/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId) => { + command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, plannerPlanIdOption, plannerTaskIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId, string body) => { + command.SetHandler(async (string groupId, string plannerPlanId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, plannerPlanIdOption, plannerTaskIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerProgressTaskBoard requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerProgressTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Planner/Plans/Item/Tasks/TasksRequestBuilder.cs b/src/generated/Groups/Item/Planner/Plans/Item/Tasks/TasksRequestBuilder.cs index 738fcc97682..2afe6f4c459 100644 --- a/src/generated/Groups/Item/Planner/Plans/Item/Tasks/TasksRequestBuilder.cs +++ b/src/generated/Groups/Item/Planner/Plans/Item/Tasks/TasksRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class TasksRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PlannerTaskRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAssignedToTaskBoardFormatCommand(), - builder.BuildBucketTaskBoardFormatCommand(), - builder.BuildDeleteCommand(), - builder.BuildDetailsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildProgressTaskBoardFormatCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAssignedToTaskBoardFormatCommand()); + commands.Add(builder.BuildBucketTaskBoardFormatCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDetailsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildProgressTaskBoardFormatCommand()); return commands; } /// @@ -44,7 +43,7 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string plannerPlanId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string plannerPlanId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, plannerPlanIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, plannerPlanIdOption, bodyOption, outputOption); return command; } /// @@ -80,7 +78,7 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string plannerPlanId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string plannerPlanId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -130,15 +132,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, plannerPlanIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, plannerPlanIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -193,31 +190,6 @@ public RequestInformation CreatePostRequestInformation(PlannerTask body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of tasks in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of tasks in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PlannerTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of tasks in the plan. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Planner/Plans/PlansRequestBuilder.cs b/src/generated/Groups/Item/Planner/Plans/PlansRequestBuilder.cs index c0f57306f8d..7eab1f5e274 100644 --- a/src/generated/Groups/Item/Planner/Plans/PlansRequestBuilder.cs +++ b/src/generated/Groups/Item/Planner/Plans/PlansRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class PlansRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PlannerPlanRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildBucketsCommand(), - builder.BuildDeleteCommand(), - builder.BuildDetailsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildTasksCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildBucketsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDetailsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildTasksCommand()); return commands; } /// @@ -47,21 +46,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -110,7 +108,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(PlannerPlan body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Returns the plannerPlans owned by the group. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns the plannerPlans owned by the group. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PlannerPlan model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Returns the plannerPlans owned by the group. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/RejectedSenders/@Ref/@Ref.cs b/src/generated/Groups/Item/RejectedSenders/@Ref/@Ref.cs deleted file mode 100644 index f692c39b1e7..00000000000 --- a/src/generated/Groups/Item/RejectedSenders/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.RejectedSenders.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Groups/Item/RejectedSenders/@Ref/RefRequestBuilder.cs b/src/generated/Groups/Item/RejectedSenders/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 15f6093d0d0..00000000000 --- a/src/generated/Groups/Item/RejectedSenders/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,195 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Groups.Item.RejectedSenders.@Ref { - /// Builds and executes requests for operations under \groups\{group-id}\rejectedSenders\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The list of users or groups that are not allowed to create posts or calendar events in this group. Nullable - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The list of users or groups that are not allowed to create posts or calendar events in this group. Nullable"; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string groupId, int? top, int? skip, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The list of users or groups that are not allowed to create posts or calendar events in this group. Nullable - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The list of users or groups that are not allowed to create posts or calendar events in this group. Nullable"; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/groups/{group_id}/rejectedSenders/$ref{?top,skip,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The list of users or groups that are not allowed to create posts or calendar events in this group. Nullable - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The list of users or groups that are not allowed to create posts or calendar events in this group. Nullable - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Groups.Item.RejectedSenders.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The list of users or groups that are not allowed to create posts or calendar events in this group. Nullable - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of users or groups that are not allowed to create posts or calendar events in this group. Nullable - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Groups.Item.RejectedSenders.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The list of users or groups that are not allowed to create posts or calendar events in this group. Nullable - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Groups/Item/RejectedSenders/@Ref/RefResponse.cs b/src/generated/Groups/Item/RejectedSenders/@Ref/RefResponse.cs deleted file mode 100644 index 665fbe28b7e..00000000000 --- a/src/generated/Groups/Item/RejectedSenders/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.RejectedSenders.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Groups/Item/RejectedSenders/Ref/Ref.cs b/src/generated/Groups/Item/RejectedSenders/Ref/Ref.cs new file mode 100644 index 00000000000..59d488be88d --- /dev/null +++ b/src/generated/Groups/Item/RejectedSenders/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Groups.Item.RejectedSenders.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Groups/Item/RejectedSenders/Ref/RefRequestBuilder.cs b/src/generated/Groups/Item/RejectedSenders/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..6f9bf69eee6 --- /dev/null +++ b/src/generated/Groups/Item/RejectedSenders/Ref/RefRequestBuilder.cs @@ -0,0 +1,168 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Groups.Item.RejectedSenders.Ref { + /// Builds and executes requests for operations under \groups\{group-id}\rejectedSenders\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The list of users or groups that are not allowed to create posts or calendar events in this group. Nullable + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The list of users or groups that are not allowed to create posts or calendar events in this group. Nullable"; + // Create options for all the parameters + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The list of users or groups that are not allowed to create posts or calendar events in this group. Nullable + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The list of users or groups that are not allowed to create posts or calendar events in this group. Nullable"; + // Create options for all the parameters + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/groups/{group_id}/rejectedSenders/$ref{?top,skip,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The list of users or groups that are not allowed to create posts or calendar events in this group. Nullable + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The list of users or groups that are not allowed to create posts or calendar events in this group. Nullable + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Groups.Item.RejectedSenders.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The list of users or groups that are not allowed to create posts or calendar events in this group. Nullable + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Groups/Item/RejectedSenders/Ref/RefResponse.cs b/src/generated/Groups/Item/RejectedSenders/Ref/RefResponse.cs new file mode 100644 index 00000000000..ee5cf7069fa --- /dev/null +++ b/src/generated/Groups/Item/RejectedSenders/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Groups.Item.RejectedSenders.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Groups/Item/RejectedSenders/RejectedSendersRequestBuilder.cs b/src/generated/Groups/Item/RejectedSenders/RejectedSendersRequestBuilder.cs index 87ca274015f..a2a799540be 100644 --- a/src/generated/Groups/Item/RejectedSenders/RejectedSendersRequestBuilder.cs +++ b/src/generated/Groups/Item/RejectedSenders/RejectedSendersRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Groups.Item.RejectedSenders.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -56,7 +56,11 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -65,20 +69,15 @@ public Command BuildGetCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Groups.Item.RejectedSenders.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Groups.Item.RejectedSenders.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -117,18 +116,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of users or groups that are not allowed to create posts or calendar events in this group. Nullable - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of users or groups that are not allowed to create posts or calendar events in this group. Nullable public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/RemoveFavorite/RemoveFavoriteRequestBuilder.cs b/src/generated/Groups/Item/RemoveFavorite/RemoveFavoriteRequestBuilder.cs index fcb1b24ab56..d6ee75f5bf2 100644 --- a/src/generated/Groups/Item/RemoveFavorite/RemoveFavoriteRequestBuilder.cs +++ b/src/generated/Groups/Item/RemoveFavorite/RemoveFavoriteRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,10 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - command.SetHandler(async (string groupId) => { + command.SetHandler(async (string groupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action removeFavorite - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Renew/RenewRequestBuilder.cs b/src/generated/Groups/Item/Renew/RenewRequestBuilder.cs index 15744421692..6a460829894 100644 --- a/src/generated/Groups/Item/Renew/RenewRequestBuilder.cs +++ b/src/generated/Groups/Item/Renew/RenewRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,10 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - command.SetHandler(async (string groupId) => { + command.SetHandler(async (string groupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action renew - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/ResetUnseenCount/ResetUnseenCountRequestBuilder.cs b/src/generated/Groups/Item/ResetUnseenCount/ResetUnseenCountRequestBuilder.cs index 4f0bd39cbda..b18dafddc1f 100644 --- a/src/generated/Groups/Item/ResetUnseenCount/ResetUnseenCountRequestBuilder.cs +++ b/src/generated/Groups/Item/ResetUnseenCount/ResetUnseenCountRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,10 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - command.SetHandler(async (string groupId) => { + command.SetHandler(async (string groupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action resetUnseenCount - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Restore/RestoreRequestBuilder.cs b/src/generated/Groups/Item/Restore/RestoreRequestBuilder.cs index 0d7e1d8456f..10547d7d8dd 100644 --- a/src/generated/Groups/Item/Restore/RestoreRequestBuilder.cs +++ b/src/generated/Groups/Item/Restore/RestoreRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - command.SetHandler(async (string groupId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action restore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes directoryObject public class RestoreResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Settings/Item/GroupSettingRequestBuilder.cs b/src/generated/Groups/Item/Settings/Item/GroupSettingRequestBuilder.cs index 3e0c1bec69b..58a5893dc06 100644 --- a/src/generated/Groups/Item/Settings/Item/GroupSettingRequestBuilder.cs +++ b/src/generated/Groups/Item/Settings/Item/GroupSettingRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var groupSettingIdOption = new Option("--groupsetting-id", description: "key: id of groupSetting") { + var groupSettingIdOption = new Option("--group-setting-id", description: "key: id of groupSetting") { }; groupSettingIdOption.IsRequired = true; command.AddOption(groupSettingIdOption); - command.SetHandler(async (string groupId, string groupSettingId) => { + command.SetHandler(async (string groupId, string groupSettingId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, groupSettingIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var groupSettingIdOption = new Option("--groupsetting-id", description: "key: id of groupSetting") { + var groupSettingIdOption = new Option("--group-setting-id", description: "key: id of groupSetting") { }; groupSettingIdOption.IsRequired = true; command.AddOption(groupSettingIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string groupSettingId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string groupSettingId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, groupSettingIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, groupSettingIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var groupSettingIdOption = new Option("--groupsetting-id", description: "key: id of groupSetting") { + var groupSettingIdOption = new Option("--group-setting-id", description: "key: id of groupSetting") { }; groupSettingIdOption.IsRequired = true; command.AddOption(groupSettingIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string groupSettingId, string body) => { + command.SetHandler(async (string groupId, string groupSettingId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, groupSettingIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(GroupSetting body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Settings that can govern this group's behavior, like whether members can invite guest users to the group. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Settings that can govern this group's behavior, like whether members can invite guest users to the group. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Settings that can govern this group's behavior, like whether members can invite guest users to the group. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(GroupSetting model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Settings that can govern this group's behavior, like whether members can invite guest users to the group. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Settings/SettingsRequestBuilder.cs b/src/generated/Groups/Item/Settings/SettingsRequestBuilder.cs index 190a7aa0c3c..3e63831053f 100644 --- a/src/generated/Groups/Item/Settings/SettingsRequestBuilder.cs +++ b/src/generated/Groups/Item/Settings/SettingsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SettingsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new GroupSettingRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(GroupSetting body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Settings that can govern this group's behavior, like whether members can invite guest users to the group. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Settings that can govern this group's behavior, like whether members can invite guest users to the group. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GroupSetting model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Settings that can govern this group's behavior, like whether members can invite guest users to the group. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Sites/Item/SiteRequestBuilder.cs b/src/generated/Groups/Item/Sites/Item/SiteRequestBuilder.cs index 29763cff923..59da91d88df 100644 --- a/src/generated/Groups/Item/Sites/Item/SiteRequestBuilder.cs +++ b/src/generated/Groups/Item/Sites/Item/SiteRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - command.SetHandler(async (string groupId, string siteId) => { + command.SetHandler(async (string groupId, string siteId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, siteIdOption); return command; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string siteId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string siteId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, siteIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, siteIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string siteId, string body) => { + command.SetHandler(async (string groupId, string siteId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, siteIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of SharePoint sites in this group. Access the default site with /sites/root. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of SharePoint sites in this group. Access the default site with /sites/root. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of SharePoint sites in this group. Access the default site with /sites/root. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Site model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of SharePoint sites in this group. Access the default site with /sites/root. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Sites/SitesRequestBuilder.cs b/src/generated/Groups/Item/Sites/SitesRequestBuilder.cs index fbeb4e99316..eed81d03d7e 100644 --- a/src/generated/Groups/Item/Sites/SitesRequestBuilder.cs +++ b/src/generated/Groups/Item/Sites/SitesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SitesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SiteRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of SharePoint sites in this group. Access the default site with /sites/root. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of SharePoint sites in this group. Access the default site with /sites/root. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Site model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of SharePoint sites in this group. Access the default site with /sites/root. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/SubscribeByMail/SubscribeByMailRequestBuilder.cs b/src/generated/Groups/Item/SubscribeByMail/SubscribeByMailRequestBuilder.cs index 633217268bd..370ab117143 100644 --- a/src/generated/Groups/Item/SubscribeByMail/SubscribeByMailRequestBuilder.cs +++ b/src/generated/Groups/Item/SubscribeByMail/SubscribeByMailRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,10 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - command.SetHandler(async (string groupId) => { + command.SetHandler(async (string groupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action subscribeByMail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Team/TeamRequestBuilder.cs b/src/generated/Groups/Item/Team/TeamRequestBuilder.cs index 68b2e13c7de..5d8956a16a1 100644 --- a/src/generated/Groups/Item/Team/TeamRequestBuilder.cs +++ b/src/generated/Groups/Item/Team/TeamRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,10 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - command.SetHandler(async (string groupId) => { + command.SetHandler(async (string groupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption); return command; @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + command.SetHandler(async (string groupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property team for groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get team from groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property team in groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Team model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get team from groups public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Threads/Item/ConversationThreadRequestBuilder.cs b/src/generated/Groups/Item/Threads/Item/ConversationThreadRequestBuilder.cs index c819f7d80e8..57eadd971ef 100644 --- a/src/generated/Groups/Item/Threads/Item/ConversationThreadRequestBuilder.cs +++ b/src/generated/Groups/Item/Threads/Item/ConversationThreadRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -32,15 +32,14 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); - command.SetHandler(async (string groupId, string conversationThreadId) => { + command.SetHandler(async (string groupId, string conversationThreadId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationThreadIdOption); return command; @@ -56,7 +55,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -65,19 +64,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, string conversationThreadId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationThreadId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationThreadIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationThreadIdOption, selectOption, outputOption); return command; } /// @@ -91,7 +89,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -99,14 +97,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationThreadId, string body) => { + command.SetHandler(async (string groupId, string conversationThreadId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationThreadIdOption, bodyOption); return command; @@ -114,6 +111,9 @@ public Command BuildPatchCommand() { public Command BuildPostsCommand() { var command = new Command("posts"); var builder = new ApiSdk.Groups.Item.Threads.Item.Posts.PostsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -191,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(ConversationThread body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The group's conversation threads. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The group's conversation threads. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The group's conversation threads. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ConversationThread model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The group's conversation threads. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Groups/Item/Threads/Item/Posts/Item/Attachments/AttachmentsRequestBuilder.cs b/src/generated/Groups/Item/Threads/Item/Posts/Item/Attachments/AttachmentsRequestBuilder.cs index 7d92ef84d22..aec14eda3c2 100644 --- a/src/generated/Groups/Item/Threads/Item/Posts/Item/Attachments/AttachmentsRequestBuilder.cs +++ b/src/generated/Groups/Item/Threads/Item/Posts/Item/Attachments/AttachmentsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class AttachmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttachmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,7 +40,7 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationThreadId, string postId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationThreadIdOption, postIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationThreadIdOption, postIdOption, bodyOption, outputOption); return command; } public Command BuildCreateUploadSessionCommand() { @@ -87,7 +85,7 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -126,7 +124,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationThreadId, string postId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationThreadIdOption, postIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationThreadIdOption, postIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(Attachment body, Action - /// The collection of fileAttachment, itemAttachment, and referenceAttachment attachments for the post. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of fileAttachment, itemAttachment, and referenceAttachment attachments for the post. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of fileAttachment, itemAttachment, and referenceAttachment attachments for the post. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Threads/Item/Posts/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Groups/Item/Threads/Item/Posts/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index cd93de6f350..464d31edd24 100644 --- a/src/generated/Groups/Item/Threads/Item/Posts/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Groups/Item/Threads/Item/Posts/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationThreadId, string postId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationThreadIdOption, postIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationThreadIdOption, postIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Groups/Item/Threads/Item/Posts/Item/Attachments/Item/AttachmentRequestBuilder.cs b/src/generated/Groups/Item/Threads/Item/Posts/Item/Attachments/Item/AttachmentRequestBuilder.cs index 4c09aef5d76..6ce6108a540 100644 --- a/src/generated/Groups/Item/Threads/Item/Posts/Item/Attachments/Item/AttachmentRequestBuilder.cs +++ b/src/generated/Groups/Item/Threads/Item/Posts/Item/Attachments/Item/AttachmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -42,11 +42,10 @@ public Command BuildDeleteCommand() { }; attachmentIdOption.IsRequired = true; command.AddOption(attachmentIdOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, string attachmentId) => { + command.SetHandler(async (string groupId, string conversationThreadId, string postId, string attachmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationThreadIdOption, postIdOption, attachmentIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, string attachmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationThreadId, string postId, string attachmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationThreadIdOption, postIdOption, attachmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationThreadIdOption, postIdOption, attachmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,7 +109,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, string attachmentId, string body) => { + command.SetHandler(async (string groupId, string conversationThreadId, string postId, string attachmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationThreadIdOption, postIdOption, attachmentIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(Attachment body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of fileAttachment, itemAttachment, and referenceAttachment attachments for the post. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of fileAttachment, itemAttachment, and referenceAttachment attachments for the post. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of fileAttachment, itemAttachment, and referenceAttachment attachments for the post. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of fileAttachment, itemAttachment, and referenceAttachment attachments for the post. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Threads/Item/Posts/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Groups/Item/Threads/Item/Posts/Item/Extensions/ExtensionsRequestBuilder.cs index db19727f694..71d572ac4c6 100644 --- a/src/generated/Groups/Item/Threads/Item/Posts/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Groups/Item/Threads/Item/Posts/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationThreadId, string postId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationThreadIdOption, postIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationThreadIdOption, postIdOption, bodyOption, outputOption); return command; } /// @@ -80,7 +78,7 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationThreadId, string postId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -129,15 +131,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationThreadIdOption, postIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationThreadIdOption, postIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the post. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the post. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the post. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Threads/Item/Posts/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Groups/Item/Threads/Item/Posts/Item/Extensions/Item/ExtensionRequestBuilder.cs index 56097cbaead..82bd1b23b00 100644 --- a/src/generated/Groups/Item/Threads/Item/Posts/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Groups/Item/Threads/Item/Posts/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -42,11 +42,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, string extensionId) => { + command.SetHandler(async (string groupId, string conversationThreadId, string postId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationThreadIdOption, postIdOption, extensionIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationThreadId, string postId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationThreadIdOption, postIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationThreadIdOption, postIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,7 +109,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, string extensionId, string body) => { + command.SetHandler(async (string groupId, string conversationThreadId, string postId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationThreadIdOption, postIdOption, extensionIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the post. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the post. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the post. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the post. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Threads/Item/Posts/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Groups/Item/Threads/Item/Posts/Item/Forward/ForwardRequestBuilder.cs index 4ca9ef02686..511ee143b59 100644 --- a/src/generated/Groups/Item/Threads/Item/Posts/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Groups/Item/Threads/Item/Posts/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, string body) => { + command.SetHandler(async (string groupId, string conversationThreadId, string postId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationThreadIdOption, postIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Threads/Item/Posts/Item/InReplyTo/Forward/ForwardRequestBuilder.cs b/src/generated/Groups/Item/Threads/Item/Posts/Item/InReplyTo/Forward/ForwardRequestBuilder.cs index 3abe52e71fa..17387ed67f9 100644 --- a/src/generated/Groups/Item/Threads/Item/Posts/Item/InReplyTo/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Groups/Item/Threads/Item/Posts/Item/InReplyTo/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, string body) => { + command.SetHandler(async (string groupId, string conversationThreadId, string postId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationThreadIdOption, postIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Threads/Item/Posts/Item/InReplyTo/InReplyToRequestBuilder.cs b/src/generated/Groups/Item/Threads/Item/Posts/Item/InReplyTo/InReplyToRequestBuilder.cs index ca17e0e6d2d..5647a653891 100644 --- a/src/generated/Groups/Item/Threads/Item/Posts/Item/InReplyTo/InReplyToRequestBuilder.cs +++ b/src/generated/Groups/Item/Threads/Item/Posts/Item/InReplyTo/InReplyToRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -32,7 +32,7 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -40,11 +40,10 @@ public Command BuildDeleteCommand() { }; postIdOption.IsRequired = true; command.AddOption(postIdOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId) => { + command.SetHandler(async (string groupId, string conversationThreadId, string postId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationThreadIdOption, postIdOption); return command; @@ -66,7 +65,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationThreadId, string postId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationThreadIdOption, postIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationThreadIdOption, postIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,7 +109,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -123,14 +121,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, string body) => { + command.SetHandler(async (string groupId, string conversationThreadId, string postId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationThreadIdOption, postIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(Post body, Action - /// The earlier post that this post is replying to in the conversationThread. Read-only. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The earlier post that this post is replying to in the conversationThread. Read-only. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The earlier post that this post is replying to in the conversationThread. Read-only. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Post model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The earlier post that this post is replying to in the conversationThread. Read-only. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Threads/Item/Posts/Item/InReplyTo/Reply/ReplyRequestBuilder.cs b/src/generated/Groups/Item/Threads/Item/Posts/Item/InReplyTo/Reply/ReplyRequestBuilder.cs index 69be4a0b7f7..835a2036f0c 100644 --- a/src/generated/Groups/Item/Threads/Item/Posts/Item/InReplyTo/Reply/ReplyRequestBuilder.cs +++ b/src/generated/Groups/Item/Threads/Item/Posts/Item/InReplyTo/Reply/ReplyRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, string body) => { + command.SetHandler(async (string groupId, string conversationThreadId, string postId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationThreadIdOption, postIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ReplyRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action reply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ReplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Threads/Item/Posts/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Groups/Item/Threads/Item/Posts/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index f3d46e52861..1d6ca40a376 100644 --- a/src/generated/Groups/Item/Threads/Item/Posts/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Groups/Item/Threads/Item/Posts/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; postIdOption.IsRequired = true; command.AddOption(postIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string groupId, string conversationThreadId, string postId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationThreadIdOption, postIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -70,7 +69,7 @@ public Command BuildGetCommand() { }; postIdOption.IsRequired = true; command.AddOption(postIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationThreadId, string postId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationThreadIdOption, postIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationThreadIdOption, postIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,7 +109,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -119,7 +117,7 @@ public Command BuildPatchCommand() { }; postIdOption.IsRequired = true; command.AddOption(postIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string groupId, string conversationThreadId, string postId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationThreadIdOption, postIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the post. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the post. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the post. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the post. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Threads/Item/Posts/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Groups/Item/Threads/Item/Posts/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 92c661090fb..6a2ff4812b4 100644 --- a/src/generated/Groups/Item/Threads/Item/Posts/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Groups/Item/Threads/Item/Posts/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationThreadId, string postId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationThreadIdOption, postIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationThreadIdOption, postIdOption, bodyOption, outputOption); return command; } /// @@ -80,7 +78,7 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationThreadId, string postId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationThreadIdOption, postIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationThreadIdOption, postIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the post. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the post. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the post. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Threads/Item/Posts/Item/PostRequestBuilder.cs b/src/generated/Groups/Item/Threads/Item/Posts/Item/PostRequestBuilder.cs index 35d88eaf49f..d936d28f7de 100644 --- a/src/generated/Groups/Item/Threads/Item/Posts/Item/PostRequestBuilder.cs +++ b/src/generated/Groups/Item/Threads/Item/Posts/Item/PostRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,6 +29,9 @@ public class PostRequestBuilder { public Command BuildAttachmentsCommand() { var command = new Command("attachments"); var builder = new ApiSdk.Groups.Item.Threads.Item.Posts.Item.Attachments.AttachmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateUploadSessionCommand()); command.AddCommand(builder.BuildListCommand()); @@ -45,7 +48,7 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -53,11 +56,10 @@ public Command BuildDeleteCommand() { }; postIdOption.IsRequired = true; command.AddOption(postIdOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId) => { + command.SetHandler(async (string groupId, string conversationThreadId, string postId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationThreadIdOption, postIdOption); return command; @@ -65,6 +67,9 @@ public Command BuildDeleteCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Groups.Item.Threads.Item.Posts.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -86,7 +91,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -104,20 +109,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationThreadId, string postId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationThreadIdOption, postIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationThreadIdOption, postIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildInReplyToCommand() { @@ -133,6 +137,9 @@ public Command BuildInReplyToCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Groups.Item.Threads.Item.Posts.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -148,7 +155,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -160,14 +167,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, string body) => { + command.SetHandler(async (string groupId, string conversationThreadId, string postId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationThreadIdOption, postIdOption, bodyOption); return command; @@ -181,6 +187,9 @@ public Command BuildReplyCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Groups.Item.Threads.Item.Posts.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -252,42 +261,6 @@ public RequestInformation CreatePatchRequestInformation(Post body, Action - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Post model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Threads/Item/Posts/Item/Reply/ReplyRequestBuilder.cs b/src/generated/Groups/Item/Threads/Item/Posts/Item/Reply/ReplyRequestBuilder.cs index 48fe415d9af..2e29c8fb15c 100644 --- a/src/generated/Groups/Item/Threads/Item/Posts/Item/Reply/ReplyRequestBuilder.cs +++ b/src/generated/Groups/Item/Threads/Item/Posts/Item/Reply/ReplyRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, string body) => { + command.SetHandler(async (string groupId, string conversationThreadId, string postId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationThreadIdOption, postIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ReplyRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action reply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ReplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Threads/Item/Posts/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Groups/Item/Threads/Item/Posts/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index bcdc759929b..e2e2d24392b 100644 --- a/src/generated/Groups/Item/Threads/Item/Posts/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Groups/Item/Threads/Item/Posts/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; postIdOption.IsRequired = true; command.AddOption(postIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string groupId, string conversationThreadId, string postId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationThreadIdOption, postIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -70,7 +69,7 @@ public Command BuildGetCommand() { }; postIdOption.IsRequired = true; command.AddOption(postIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationThreadId, string postId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationThreadIdOption, postIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationThreadIdOption, postIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,7 +109,7 @@ public Command BuildPatchCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -119,7 +117,7 @@ public Command BuildPatchCommand() { }; postIdOption.IsRequired = true; command.AddOption(postIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string groupId, string conversationThreadId, string postId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationThreadIdOption, postIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the post. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the post. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the post. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the post. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Groups/Item/Threads/Item/Posts/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Groups/Item/Threads/Item/Posts/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 5aa0f0563e2..5f690f631a5 100644 --- a/src/generated/Groups/Item/Threads/Item/Posts/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Groups/Item/Threads/Item/Posts/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationThreadId, string postId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationThreadIdOption, postIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationThreadIdOption, postIdOption, bodyOption, outputOption); return command; } /// @@ -80,7 +78,7 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string conversationThreadId, string postId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationThreadId, string postId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationThreadIdOption, postIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationThreadIdOption, postIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the post. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the post. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the post. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Threads/Item/Posts/PostsRequestBuilder.cs b/src/generated/Groups/Item/Threads/Item/Posts/PostsRequestBuilder.cs index c9abddd6f6a..107bc788992 100644 --- a/src/generated/Groups/Item/Threads/Item/Posts/PostsRequestBuilder.cs +++ b/src/generated/Groups/Item/Threads/Item/Posts/PostsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,18 +22,17 @@ public class PostsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PostRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAttachmentsCommand(), - builder.BuildDeleteCommand(), - builder.BuildExtensionsCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildInReplyToCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildReplyCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAttachmentsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInReplyToCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildReplyCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); return commands; } /// @@ -47,7 +46,7 @@ public Command BuildCreateCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -55,21 +54,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationThreadId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationThreadId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationThreadIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationThreadIdOption, bodyOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildListCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, string conversationThreadId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string conversationThreadId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, conversationThreadIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, conversationThreadIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(Post body, Action - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Post model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/Threads/Item/Reply/ReplyRequestBuilder.cs b/src/generated/Groups/Item/Threads/Item/Reply/ReplyRequestBuilder.cs index e52507e65a5..145ef401460 100644 --- a/src/generated/Groups/Item/Threads/Item/Reply/ReplyRequestBuilder.cs +++ b/src/generated/Groups/Item/Threads/Item/Reply/ReplyRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var conversationThreadIdOption = new Option("--conversationthread-id", description: "key: id of conversationThread") { + var conversationThreadIdOption = new Option("--conversation-thread-id", description: "key: id of conversationThread") { }; conversationThreadIdOption.IsRequired = true; command.AddOption(conversationThreadIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string conversationThreadId, string body) => { + command.SetHandler(async (string groupId, string conversationThreadId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, conversationThreadIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ReplyRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action reply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ReplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/Threads/ThreadsRequestBuilder.cs b/src/generated/Groups/Item/Threads/ThreadsRequestBuilder.cs index 34fe05390b3..65834cfb9db 100644 --- a/src/generated/Groups/Item/Threads/ThreadsRequestBuilder.cs +++ b/src/generated/Groups/Item/Threads/ThreadsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class ThreadsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ConversationThreadRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildPostsCommand(), - builder.BuildReplyCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPostsCommand()); + commands.Add(builder.BuildReplyCommand()); return commands; } /// @@ -46,21 +45,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string groupId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -109,15 +111,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -172,31 +169,6 @@ public RequestInformation CreatePostRequestInformation(ConversationThread body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The group's conversation threads. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The group's conversation threads. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ConversationThread model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The group's conversation threads. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/TransitiveMemberOf/@Ref/@Ref.cs b/src/generated/Groups/Item/TransitiveMemberOf/@Ref/@Ref.cs deleted file mode 100644 index 0899b3de218..00000000000 --- a/src/generated/Groups/Item/TransitiveMemberOf/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.TransitiveMemberOf.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Groups/Item/TransitiveMemberOf/@Ref/RefRequestBuilder.cs b/src/generated/Groups/Item/TransitiveMemberOf/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 0d6569bbc4c..00000000000 --- a/src/generated/Groups/Item/TransitiveMemberOf/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Groups.Item.TransitiveMemberOf.@Ref { - /// Builds and executes requests for operations under \groups\{group-id}\transitiveMemberOf\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Get ref of transitiveMemberOf from groups - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Get ref of transitiveMemberOf from groups"; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Create new navigation property ref to transitiveMemberOf for groups - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Create new navigation property ref to transitiveMemberOf for groups"; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/groups/{group_id}/transitiveMemberOf/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Get ref of transitiveMemberOf from groups - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Create new navigation property ref to transitiveMemberOf for groups - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Groups.Item.TransitiveMemberOf.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Get ref of transitiveMemberOf from groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property ref to transitiveMemberOf for groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Groups.Item.TransitiveMemberOf.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Get ref of transitiveMemberOf from groups - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Groups/Item/TransitiveMemberOf/@Ref/RefResponse.cs b/src/generated/Groups/Item/TransitiveMemberOf/@Ref/RefResponse.cs deleted file mode 100644 index 6d44e0a16c4..00000000000 --- a/src/generated/Groups/Item/TransitiveMemberOf/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.TransitiveMemberOf.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Groups/Item/TransitiveMemberOf/Ref/Ref.cs b/src/generated/Groups/Item/TransitiveMemberOf/Ref/Ref.cs new file mode 100644 index 00000000000..3db885f07df --- /dev/null +++ b/src/generated/Groups/Item/TransitiveMemberOf/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Groups.Item.TransitiveMemberOf.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Groups/Item/TransitiveMemberOf/Ref/RefRequestBuilder.cs b/src/generated/Groups/Item/TransitiveMemberOf/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..8a66b99da03 --- /dev/null +++ b/src/generated/Groups/Item/TransitiveMemberOf/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Groups.Item.TransitiveMemberOf.Ref { + /// Builds and executes requests for operations under \groups\{group-id}\transitiveMemberOf\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Get ref of transitiveMemberOf from groups + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Get ref of transitiveMemberOf from groups"; + // Create options for all the parameters + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Create new navigation property ref to transitiveMemberOf for groups + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Create new navigation property ref to transitiveMemberOf for groups"; + // Create options for all the parameters + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/groups/{group_id}/transitiveMemberOf/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Get ref of transitiveMemberOf from groups + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Create new navigation property ref to transitiveMemberOf for groups + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Groups.Item.TransitiveMemberOf.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Get ref of transitiveMemberOf from groups + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Groups/Item/TransitiveMemberOf/Ref/RefResponse.cs b/src/generated/Groups/Item/TransitiveMemberOf/Ref/RefResponse.cs new file mode 100644 index 00000000000..83e5f0e6dce --- /dev/null +++ b/src/generated/Groups/Item/TransitiveMemberOf/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Groups.Item.TransitiveMemberOf.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Groups/Item/TransitiveMemberOf/TransitiveMemberOfRequestBuilder.cs b/src/generated/Groups/Item/TransitiveMemberOf/TransitiveMemberOfRequestBuilder.cs index 8939e6ad35d..5428d0ceea5 100644 --- a/src/generated/Groups/Item/TransitiveMemberOf/TransitiveMemberOfRequestBuilder.cs +++ b/src/generated/Groups/Item/TransitiveMemberOf/TransitiveMemberOfRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Groups.Item.TransitiveMemberOf.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Groups.Item.TransitiveMemberOf.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Groups.Item.TransitiveMemberOf.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get transitiveMemberOf from groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get transitiveMemberOf from groups public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/TransitiveMembers/@Ref/@Ref.cs b/src/generated/Groups/Item/TransitiveMembers/@Ref/@Ref.cs deleted file mode 100644 index 5c0f726685b..00000000000 --- a/src/generated/Groups/Item/TransitiveMembers/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.TransitiveMembers.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Groups/Item/TransitiveMembers/@Ref/RefRequestBuilder.cs b/src/generated/Groups/Item/TransitiveMembers/@Ref/RefRequestBuilder.cs deleted file mode 100644 index ac02056dca7..00000000000 --- a/src/generated/Groups/Item/TransitiveMembers/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Groups.Item.TransitiveMembers.@Ref { - /// Builds and executes requests for operations under \groups\{group-id}\transitiveMembers\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Get ref of transitiveMembers from groups - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Get ref of transitiveMembers from groups"; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Create new navigation property ref to transitiveMembers for groups - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Create new navigation property ref to transitiveMembers for groups"; - // Create options for all the parameters - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/groups/{group_id}/transitiveMembers/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Get ref of transitiveMembers from groups - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Create new navigation property ref to transitiveMembers for groups - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Groups.Item.TransitiveMembers.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Get ref of transitiveMembers from groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property ref to transitiveMembers for groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Groups.Item.TransitiveMembers.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Get ref of transitiveMembers from groups - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Groups/Item/TransitiveMembers/@Ref/RefResponse.cs b/src/generated/Groups/Item/TransitiveMembers/@Ref/RefResponse.cs deleted file mode 100644 index 5fac5a3f665..00000000000 --- a/src/generated/Groups/Item/TransitiveMembers/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Groups.Item.TransitiveMembers.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Groups/Item/TransitiveMembers/Ref/Ref.cs b/src/generated/Groups/Item/TransitiveMembers/Ref/Ref.cs new file mode 100644 index 00000000000..880c47f4ec5 --- /dev/null +++ b/src/generated/Groups/Item/TransitiveMembers/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Groups.Item.TransitiveMembers.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Groups/Item/TransitiveMembers/Ref/RefRequestBuilder.cs b/src/generated/Groups/Item/TransitiveMembers/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..68c98b4dce6 --- /dev/null +++ b/src/generated/Groups/Item/TransitiveMembers/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Groups.Item.TransitiveMembers.Ref { + /// Builds and executes requests for operations under \groups\{group-id}\transitiveMembers\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Get ref of transitiveMembers from groups + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Get ref of transitiveMembers from groups"; + // Create options for all the parameters + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Create new navigation property ref to transitiveMembers for groups + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Create new navigation property ref to transitiveMembers for groups"; + // Create options for all the parameters + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/groups/{group_id}/transitiveMembers/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Get ref of transitiveMembers from groups + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Create new navigation property ref to transitiveMembers for groups + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Groups.Item.TransitiveMembers.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Get ref of transitiveMembers from groups + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Groups/Item/TransitiveMembers/Ref/RefResponse.cs b/src/generated/Groups/Item/TransitiveMembers/Ref/RefResponse.cs new file mode 100644 index 00000000000..5f584c81c65 --- /dev/null +++ b/src/generated/Groups/Item/TransitiveMembers/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Groups.Item.TransitiveMembers.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Groups/Item/TransitiveMembers/TransitiveMembersRequestBuilder.cs b/src/generated/Groups/Item/TransitiveMembers/TransitiveMembersRequestBuilder.cs index e6d9d6b8966..9ddf791262a 100644 --- a/src/generated/Groups/Item/TransitiveMembers/TransitiveMembersRequestBuilder.cs +++ b/src/generated/Groups/Item/TransitiveMembers/TransitiveMembersRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Groups.Item.TransitiveMembers.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Groups.Item.TransitiveMembers.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Groups.Item.TransitiveMembers.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get transitiveMembers from groups - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get transitiveMembers from groups public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Groups/Item/UnsubscribeByMail/UnsubscribeByMailRequestBuilder.cs b/src/generated/Groups/Item/UnsubscribeByMail/UnsubscribeByMailRequestBuilder.cs index 969d1260c8f..2c6081554ff 100644 --- a/src/generated/Groups/Item/UnsubscribeByMail/UnsubscribeByMailRequestBuilder.cs +++ b/src/generated/Groups/Item/UnsubscribeByMail/UnsubscribeByMailRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,10 @@ public Command BuildPostCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - command.SetHandler(async (string groupId) => { + command.SetHandler(async (string groupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action unsubscribeByMail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/Item/ValidateProperties/ValidatePropertiesRequestBuilder.cs b/src/generated/Groups/Item/ValidateProperties/ValidatePropertiesRequestBuilder.cs index ef8bbab7dfd..ac1b1ba7b05 100644 --- a/src/generated/Groups/Item/ValidateProperties/ValidatePropertiesRequestBuilder.cs +++ b/src/generated/Groups/Item/ValidateProperties/ValidatePropertiesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string groupId, string body) => { + command.SetHandler(async (string groupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, groupIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ValidatePropertiesRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action validateProperties - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ValidatePropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Groups/ValidateProperties/ValidatePropertiesRequestBuilder.cs b/src/generated/Groups/ValidateProperties/ValidatePropertiesRequestBuilder.cs index 6e3c6e465e7..f11b21c6484 100644 --- a/src/generated/Groups/ValidateProperties/ValidatePropertiesRequestBuilder.cs +++ b/src/generated/Groups/ValidateProperties/ValidatePropertiesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,14 +29,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -72,18 +71,5 @@ public RequestInformation CreatePostRequestInformation(ValidatePropertiesRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action validateProperties - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ValidatePropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Identity/ApiConnectors/ApiConnectorsRequestBuilder.cs b/src/generated/Identity/ApiConnectors/ApiConnectorsRequestBuilder.cs index 75f9d311689..dbd916bb6ba 100644 --- a/src/generated/Identity/ApiConnectors/ApiConnectorsRequestBuilder.cs +++ b/src/generated/Identity/ApiConnectors/ApiConnectorsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class ApiConnectorsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new IdentityApiConnectorRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildUploadClientCertificateCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildUploadClientCertificateCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(IdentityApiConnector body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents entry point for API connectors. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents entry point for API connectors. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(IdentityApiConnector model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents entry point for API connectors. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Identity/ApiConnectors/Item/IdentityApiConnectorRequestBuilder.cs b/src/generated/Identity/ApiConnectors/Item/IdentityApiConnectorRequestBuilder.cs index 7af87aa0704..17a81a56d92 100644 --- a/src/generated/Identity/ApiConnectors/Item/IdentityApiConnectorRequestBuilder.cs +++ b/src/generated/Identity/ApiConnectors/Item/IdentityApiConnectorRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,15 +27,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents entry point for API connectors."; // Create options for all the parameters - var identityApiConnectorIdOption = new Option("--identityapiconnector-id", description: "key: id of identityApiConnector") { + var identityApiConnectorIdOption = new Option("--identity-api-connector-id", description: "key: id of identityApiConnector") { }; identityApiConnectorIdOption.IsRequired = true; command.AddOption(identityApiConnectorIdOption); - command.SetHandler(async (string identityApiConnectorId) => { + command.SetHandler(async (string identityApiConnectorId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, identityApiConnectorIdOption); return command; @@ -47,7 +46,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents entry point for API connectors."; // Create options for all the parameters - var identityApiConnectorIdOption = new Option("--identityapiconnector-id", description: "key: id of identityApiConnector") { + var identityApiConnectorIdOption = new Option("--identity-api-connector-id", description: "key: id of identityApiConnector") { }; identityApiConnectorIdOption.IsRequired = true; command.AddOption(identityApiConnectorIdOption); @@ -61,20 +60,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string identityApiConnectorId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string identityApiConnectorId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, identityApiConnectorIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, identityApiConnectorIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents entry point for API connectors."; // Create options for all the parameters - var identityApiConnectorIdOption = new Option("--identityapiconnector-id", description: "key: id of identityApiConnector") { + var identityApiConnectorIdOption = new Option("--identity-api-connector-id", description: "key: id of identityApiConnector") { }; identityApiConnectorIdOption.IsRequired = true; command.AddOption(identityApiConnectorIdOption); @@ -92,14 +90,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string identityApiConnectorId, string body) => { + command.SetHandler(async (string identityApiConnectorId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, identityApiConnectorIdOption, bodyOption); return command; @@ -177,42 +174,6 @@ public RequestInformation CreatePatchRequestInformation(IdentityApiConnector bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents entry point for API connectors. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents entry point for API connectors. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents entry point for API connectors. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(IdentityApiConnector model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents entry point for API connectors. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Identity/ApiConnectors/Item/UploadClientCertificate/UploadClientCertificateRequestBuilder.cs b/src/generated/Identity/ApiConnectors/Item/UploadClientCertificate/UploadClientCertificateRequestBuilder.cs index a325f572fb6..a0429fb6d86 100644 --- a/src/generated/Identity/ApiConnectors/Item/UploadClientCertificate/UploadClientCertificateRequestBuilder.cs +++ b/src/generated/Identity/ApiConnectors/Item/UploadClientCertificate/UploadClientCertificateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action uploadClientCertificate"; // Create options for all the parameters - var identityApiConnectorIdOption = new Option("--identityapiconnector-id", description: "key: id of identityApiConnector") { + var identityApiConnectorIdOption = new Option("--identity-api-connector-id", description: "key: id of identityApiConnector") { }; identityApiConnectorIdOption.IsRequired = true; command.AddOption(identityApiConnectorIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string identityApiConnectorId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string identityApiConnectorId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, identityApiConnectorIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, identityApiConnectorIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(UploadClientCertificateRe requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action uploadClientCertificate - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UploadClientCertificateRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes identityApiConnector public class UploadClientCertificateResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Identity/B2xUserFlows/B2xUserFlowsRequestBuilder.cs b/src/generated/Identity/B2xUserFlows/B2xUserFlowsRequestBuilder.cs index 5dc8c787b22..11f8364ad6a 100644 --- a/src/generated/Identity/B2xUserFlows/B2xUserFlowsRequestBuilder.cs +++ b/src/generated/Identity/B2xUserFlows/B2xUserFlowsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class B2xUserFlowsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new B2xIdentityUserFlowRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildIdentityProvidersCommand(), - builder.BuildLanguagesCommand(), - builder.BuildPatchCommand(), - builder.BuildUserAttributeAssignmentsCommand(), - builder.BuildUserFlowIdentityProvidersCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildIdentityProvidersCommand()); + commands.Add(builder.BuildLanguagesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildUserAttributeAssignmentsCommand()); + commands.Add(builder.BuildUserFlowIdentityProvidersCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -103,7 +101,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -114,15 +116,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -177,31 +174,6 @@ public RequestInformation CreatePostRequestInformation(B2xIdentityUserFlow body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents entry point for B2X and self-service sign-up identity userflows. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents entry point for B2X and self-service sign-up identity userflows. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(B2xIdentityUserFlow model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents entry point for B2X and self-service sign-up identity userflows. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Identity/B2xUserFlows/Item/B2xIdentityUserFlowRequestBuilder.cs b/src/generated/Identity/B2xUserFlows/Item/B2xIdentityUserFlowRequestBuilder.cs index 489fe9ea680..9bb2ace8bda 100644 --- a/src/generated/Identity/B2xUserFlows/Item/B2xIdentityUserFlowRequestBuilder.cs +++ b/src/generated/Identity/B2xUserFlows/Item/B2xIdentityUserFlowRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents entry point for B2X and self-service sign-up identity userflows."; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); - command.SetHandler(async (string b2xIdentityUserFlowId) => { + command.SetHandler(async (string b2xIdentityUserFlowId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, b2xIdentityUserFlowIdOption); return command; @@ -50,7 +49,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents entry point for B2X and self-service sign-up identity userflows."; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); @@ -64,20 +63,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string b2xIdentityUserFlowId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, b2xIdentityUserFlowIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, b2xIdentityUserFlowIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildIdentityProvidersCommand() { @@ -90,6 +88,9 @@ public Command BuildIdentityProvidersCommand() { public Command BuildLanguagesCommand() { var command = new Command("languages"); var builder = new ApiSdk.Identity.B2xUserFlows.Item.Languages.LanguagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -101,7 +102,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents entry point for B2X and self-service sign-up identity userflows."; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); @@ -109,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string body) => { + command.SetHandler(async (string b2xIdentityUserFlowId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, b2xIdentityUserFlowIdOption, bodyOption); return command; @@ -124,6 +124,9 @@ public Command BuildPatchCommand() { public Command BuildUserAttributeAssignmentsCommand() { var command = new Command("user-attribute-assignments"); var builder = new ApiSdk.Identity.B2xUserFlows.Item.UserAttributeAssignments.UserAttributeAssignmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); command.AddCommand(builder.BuildSetOrderCommand()); @@ -203,42 +206,6 @@ public RequestInformation CreatePatchRequestInformation(B2xIdentityUserFlow body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents entry point for B2X and self-service sign-up identity userflows. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents entry point for B2X and self-service sign-up identity userflows. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents entry point for B2X and self-service sign-up identity userflows. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(B2xIdentityUserFlow model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents entry point for B2X and self-service sign-up identity userflows. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Identity/B2xUserFlows/Item/IdentityProviders/@Ref/@Ref.cs b/src/generated/Identity/B2xUserFlows/Item/IdentityProviders/@Ref/@Ref.cs deleted file mode 100644 index 325b5ffbac4..00000000000 --- a/src/generated/Identity/B2xUserFlows/Item/IdentityProviders/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Identity.B2xUserFlows.Item.IdentityProviders.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Identity/B2xUserFlows/Item/IdentityProviders/@Ref/RefRequestBuilder.cs b/src/generated/Identity/B2xUserFlows/Item/IdentityProviders/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 3d63e38a953..00000000000 --- a/src/generated/Identity/B2xUserFlows/Item/IdentityProviders/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Identity.B2xUserFlows.Item.IdentityProviders.@Ref { - /// Builds and executes requests for operations under \identity\b2xUserFlows\{b2xIdentityUserFlow-id}\identityProviders\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The identity providers included in the user flow. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The identity providers included in the user flow."; - // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { - }; - b2xIdentityUserFlowIdOption.IsRequired = true; - command.AddOption(b2xIdentityUserFlowIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string b2xIdentityUserFlowId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, b2xIdentityUserFlowIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The identity providers included in the user flow. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The identity providers included in the user flow."; - // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { - }; - b2xIdentityUserFlowIdOption.IsRequired = true; - command.AddOption(b2xIdentityUserFlowIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, b2xIdentityUserFlowIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/identity/b2xUserFlows/{b2xIdentityUserFlow_id}/identityProviders/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The identity providers included in the user flow. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The identity providers included in the user flow. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Identity.B2xUserFlows.Item.IdentityProviders.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The identity providers included in the user flow. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The identity providers included in the user flow. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Identity.B2xUserFlows.Item.IdentityProviders.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The identity providers included in the user flow. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Identity/B2xUserFlows/Item/IdentityProviders/@Ref/RefResponse.cs b/src/generated/Identity/B2xUserFlows/Item/IdentityProviders/@Ref/RefResponse.cs deleted file mode 100644 index 245ba71f7de..00000000000 --- a/src/generated/Identity/B2xUserFlows/Item/IdentityProviders/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Identity.B2xUserFlows.Item.IdentityProviders.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Identity/B2xUserFlows/Item/IdentityProviders/IdentityProvidersRequestBuilder.cs b/src/generated/Identity/B2xUserFlows/Item/IdentityProviders/IdentityProvidersRequestBuilder.cs index 05f43fc4d7b..ea5d82093fd 100644 --- a/src/generated/Identity/B2xUserFlows/Item/IdentityProviders/IdentityProvidersRequestBuilder.cs +++ b/src/generated/Identity/B2xUserFlows/Item/IdentityProviders/IdentityProvidersRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Identity.B2xUserFlows.Item.IdentityProviders.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The identity providers included in the user flow."; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string b2xIdentityUserFlowId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string b2xIdentityUserFlowId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, b2xIdentityUserFlowIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, b2xIdentityUserFlowIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Identity.B2xUserFlows.Item.IdentityProviders.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Identity.B2xUserFlows.Item.IdentityProviders.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The identity providers included in the user flow. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The identity providers included in the user flow. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Identity/B2xUserFlows/Item/IdentityProviders/Ref/Ref.cs b/src/generated/Identity/B2xUserFlows/Item/IdentityProviders/Ref/Ref.cs new file mode 100644 index 00000000000..a92d0ae3ec8 --- /dev/null +++ b/src/generated/Identity/B2xUserFlows/Item/IdentityProviders/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Identity.B2xUserFlows.Item.IdentityProviders.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Identity/B2xUserFlows/Item/IdentityProviders/Ref/RefRequestBuilder.cs b/src/generated/Identity/B2xUserFlows/Item/IdentityProviders/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..115656e398d --- /dev/null +++ b/src/generated/Identity/B2xUserFlows/Item/IdentityProviders/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Identity.B2xUserFlows.Item.IdentityProviders.Ref { + /// Builds and executes requests for operations under \identity\b2xUserFlows\{b2xIdentityUserFlow-id}\identityProviders\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The identity providers included in the user flow. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The identity providers included in the user flow."; + // Create options for all the parameters + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { + }; + b2xIdentityUserFlowIdOption.IsRequired = true; + command.AddOption(b2xIdentityUserFlowIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string b2xIdentityUserFlowId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, b2xIdentityUserFlowIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The identity providers included in the user flow. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The identity providers included in the user flow."; + // Create options for all the parameters + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { + }; + b2xIdentityUserFlowIdOption.IsRequired = true; + command.AddOption(b2xIdentityUserFlowIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string b2xIdentityUserFlowId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, b2xIdentityUserFlowIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/identity/b2xUserFlows/{b2xIdentityUserFlow_id}/identityProviders/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The identity providers included in the user flow. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The identity providers included in the user flow. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Identity.B2xUserFlows.Item.IdentityProviders.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The identity providers included in the user flow. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Identity/B2xUserFlows/Item/IdentityProviders/Ref/RefResponse.cs b/src/generated/Identity/B2xUserFlows/Item/IdentityProviders/Ref/RefResponse.cs new file mode 100644 index 00000000000..6730b97268f --- /dev/null +++ b/src/generated/Identity/B2xUserFlows/Item/IdentityProviders/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Identity.B2xUserFlows.Item.IdentityProviders.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Identity/B2xUserFlows/Item/Languages/Item/DefaultPages/DefaultPagesRequestBuilder.cs b/src/generated/Identity/B2xUserFlows/Item/Languages/Item/DefaultPages/DefaultPagesRequestBuilder.cs index 08e1ce1acb6..0907f885774 100644 --- a/src/generated/Identity/B2xUserFlows/Item/Languages/Item/DefaultPages/DefaultPagesRequestBuilder.cs +++ b/src/generated/Identity/B2xUserFlows/Item/Languages/Item/DefaultPages/DefaultPagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class DefaultPagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new UserFlowLanguagePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -37,11 +36,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Collection of pages with the default content to display in a user flow for a specified language. This collection does not allow any kind of modification."; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); - var userFlowLanguageConfigurationIdOption = new Option("--userflowlanguageconfiguration-id", description: "key: id of userFlowLanguageConfiguration") { + var userFlowLanguageConfigurationIdOption = new Option("--user-flow-language-configuration-id", description: "key: id of userFlowLanguageConfiguration") { }; userFlowLanguageConfigurationIdOption.IsRequired = true; command.AddOption(userFlowLanguageConfigurationIdOption); @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, b2xIdentityUserFlowIdOption, userFlowLanguageConfigurationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, b2xIdentityUserFlowIdOption, userFlowLanguageConfigurationIdOption, bodyOption, outputOption); return command; } /// @@ -73,11 +71,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Collection of pages with the default content to display in a user flow for a specified language. This collection does not allow any kind of modification."; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); - var userFlowLanguageConfigurationIdOption = new Option("--userflowlanguageconfiguration-id", description: "key: id of userFlowLanguageConfiguration") { + var userFlowLanguageConfigurationIdOption = new Option("--user-flow-language-configuration-id", description: "key: id of userFlowLanguageConfiguration") { }; userFlowLanguageConfigurationIdOption.IsRequired = true; command.AddOption(userFlowLanguageConfigurationIdOption); @@ -116,7 +114,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -127,15 +129,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, b2xIdentityUserFlowIdOption, userFlowLanguageConfigurationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, b2xIdentityUserFlowIdOption, userFlowLanguageConfigurationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -190,31 +187,6 @@ public RequestInformation CreatePostRequestInformation(UserFlowLanguagePage body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of pages with the default content to display in a user flow for a specified language. This collection does not allow any kind of modification. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of pages with the default content to display in a user flow for a specified language. This collection does not allow any kind of modification. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UserFlowLanguagePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of pages with the default content to display in a user flow for a specified language. This collection does not allow any kind of modification. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Identity/B2xUserFlows/Item/Languages/Item/DefaultPages/Item/UserFlowLanguagePageRequestBuilder.cs b/src/generated/Identity/B2xUserFlows/Item/Languages/Item/DefaultPages/Item/UserFlowLanguagePageRequestBuilder.cs index 47285916814..7c6027f344c 100644 --- a/src/generated/Identity/B2xUserFlows/Item/Languages/Item/DefaultPages/Item/UserFlowLanguagePageRequestBuilder.cs +++ b/src/generated/Identity/B2xUserFlows/Item/Languages/Item/DefaultPages/Item/UserFlowLanguagePageRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,23 +34,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Collection of pages with the default content to display in a user flow for a specified language. This collection does not allow any kind of modification."; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); - var userFlowLanguageConfigurationIdOption = new Option("--userflowlanguageconfiguration-id", description: "key: id of userFlowLanguageConfiguration") { + var userFlowLanguageConfigurationIdOption = new Option("--user-flow-language-configuration-id", description: "key: id of userFlowLanguageConfiguration") { }; userFlowLanguageConfigurationIdOption.IsRequired = true; command.AddOption(userFlowLanguageConfigurationIdOption); - var userFlowLanguagePageIdOption = new Option("--userflowlanguagepage-id", description: "key: id of userFlowLanguagePage") { + var userFlowLanguagePageIdOption = new Option("--user-flow-language-page-id", description: "key: id of userFlowLanguagePage") { }; userFlowLanguagePageIdOption.IsRequired = true; command.AddOption(userFlowLanguagePageIdOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string userFlowLanguagePageId) => { + command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string userFlowLanguagePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, b2xIdentityUserFlowIdOption, userFlowLanguageConfigurationIdOption, userFlowLanguagePageIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Collection of pages with the default content to display in a user flow for a specified language. This collection does not allow any kind of modification."; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); - var userFlowLanguageConfigurationIdOption = new Option("--userflowlanguageconfiguration-id", description: "key: id of userFlowLanguageConfiguration") { + var userFlowLanguageConfigurationIdOption = new Option("--user-flow-language-configuration-id", description: "key: id of userFlowLanguageConfiguration") { }; userFlowLanguageConfigurationIdOption.IsRequired = true; command.AddOption(userFlowLanguageConfigurationIdOption); - var userFlowLanguagePageIdOption = new Option("--userflowlanguagepage-id", description: "key: id of userFlowLanguagePage") { + var userFlowLanguagePageIdOption = new Option("--user-flow-language-page-id", description: "key: id of userFlowLanguagePage") { }; userFlowLanguagePageIdOption.IsRequired = true; command.AddOption(userFlowLanguagePageIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string userFlowLanguagePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string userFlowLanguagePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, b2xIdentityUserFlowIdOption, userFlowLanguageConfigurationIdOption, userFlowLanguagePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, b2xIdentityUserFlowIdOption, userFlowLanguageConfigurationIdOption, userFlowLanguagePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,15 +105,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Collection of pages with the default content to display in a user flow for a specified language. This collection does not allow any kind of modification."; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); - var userFlowLanguageConfigurationIdOption = new Option("--userflowlanguageconfiguration-id", description: "key: id of userFlowLanguageConfiguration") { + var userFlowLanguageConfigurationIdOption = new Option("--user-flow-language-configuration-id", description: "key: id of userFlowLanguageConfiguration") { }; userFlowLanguageConfigurationIdOption.IsRequired = true; command.AddOption(userFlowLanguageConfigurationIdOption); - var userFlowLanguagePageIdOption = new Option("--userflowlanguagepage-id", description: "key: id of userFlowLanguagePage") { + var userFlowLanguagePageIdOption = new Option("--user-flow-language-page-id", description: "key: id of userFlowLanguagePage") { }; userFlowLanguagePageIdOption.IsRequired = true; command.AddOption(userFlowLanguagePageIdOption); @@ -123,14 +121,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string userFlowLanguagePageId, string body) => { + command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string userFlowLanguagePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, b2xIdentityUserFlowIdOption, userFlowLanguageConfigurationIdOption, userFlowLanguagePageIdOption, bodyOption); return command; @@ -202,42 +199,6 @@ public RequestInformation CreatePatchRequestInformation(UserFlowLanguagePage bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of pages with the default content to display in a user flow for a specified language. This collection does not allow any kind of modification. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of pages with the default content to display in a user flow for a specified language. This collection does not allow any kind of modification. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of pages with the default content to display in a user flow for a specified language. This collection does not allow any kind of modification. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(UserFlowLanguagePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of pages with the default content to display in a user flow for a specified language. This collection does not allow any kind of modification. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Identity/B2xUserFlows/Item/Languages/Item/DefaultPages/Item/Value/ContentRequestBuilder.cs b/src/generated/Identity/B2xUserFlows/Item/Languages/Item/DefaultPages/Item/Value/ContentRequestBuilder.cs index 35aa3563165..95add95096a 100644 --- a/src/generated/Identity/B2xUserFlows/Item/Languages/Item/DefaultPages/Item/Value/ContentRequestBuilder.cs +++ b/src/generated/Identity/B2xUserFlows/Item/Languages/Item/DefaultPages/Item/Value/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,36 +25,38 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get media content for the navigation property defaultPages from identity"; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); - var userFlowLanguageConfigurationIdOption = new Option("--userflowlanguageconfiguration-id", description: "key: id of userFlowLanguageConfiguration") { + var userFlowLanguageConfigurationIdOption = new Option("--user-flow-language-configuration-id", description: "key: id of userFlowLanguageConfiguration") { }; userFlowLanguageConfigurationIdOption.IsRequired = true; command.AddOption(userFlowLanguageConfigurationIdOption); - var userFlowLanguagePageIdOption = new Option("--userflowlanguagepage-id", description: "key: id of userFlowLanguagePage") { + var userFlowLanguagePageIdOption = new Option("--user-flow-language-page-id", description: "key: id of userFlowLanguagePage") { }; userFlowLanguagePageIdOption.IsRequired = true; command.AddOption(userFlowLanguagePageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string userFlowLanguagePageId, FileInfo output) => { + command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string userFlowLanguagePageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, b2xIdentityUserFlowIdOption, userFlowLanguageConfigurationIdOption, userFlowLanguagePageIdOption, outputOption); + }, b2xIdentityUserFlowIdOption, userFlowLanguageConfigurationIdOption, userFlowLanguagePageIdOption, fileOption, outputOption); return command; } /// @@ -64,15 +66,15 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "Update media content for the navigation property defaultPages in identity"; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); - var userFlowLanguageConfigurationIdOption = new Option("--userflowlanguageconfiguration-id", description: "key: id of userFlowLanguageConfiguration") { + var userFlowLanguageConfigurationIdOption = new Option("--user-flow-language-configuration-id", description: "key: id of userFlowLanguageConfiguration") { }; userFlowLanguageConfigurationIdOption.IsRequired = true; command.AddOption(userFlowLanguageConfigurationIdOption); - var userFlowLanguagePageIdOption = new Option("--userflowlanguagepage-id", description: "key: id of userFlowLanguagePage") { + var userFlowLanguagePageIdOption = new Option("--user-flow-language-page-id", description: "key: id of userFlowLanguagePage") { }; userFlowLanguagePageIdOption.IsRequired = true; command.AddOption(userFlowLanguagePageIdOption); @@ -80,12 +82,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string userFlowLanguagePageId, FileInfo file) => { + command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string userFlowLanguagePageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, b2xIdentityUserFlowIdOption, userFlowLanguageConfigurationIdOption, userFlowLanguagePageIdOption, bodyOption); return command; @@ -136,29 +137,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property defaultPages from identity - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property defaultPages in identity - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Identity/B2xUserFlows/Item/Languages/Item/OverridesPages/Item/UserFlowLanguagePageRequestBuilder.cs b/src/generated/Identity/B2xUserFlows/Item/Languages/Item/OverridesPages/Item/UserFlowLanguagePageRequestBuilder.cs index 395efb78a46..a2170e27b3d 100644 --- a/src/generated/Identity/B2xUserFlows/Item/Languages/Item/OverridesPages/Item/UserFlowLanguagePageRequestBuilder.cs +++ b/src/generated/Identity/B2xUserFlows/Item/Languages/Item/OverridesPages/Item/UserFlowLanguagePageRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,23 +34,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Collection of pages with the overrides messages to display in a user flow for a specified language. This collection only allows to modify the content of the page, any other modification is not allowed (creation or deletion of pages)."; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); - var userFlowLanguageConfigurationIdOption = new Option("--userflowlanguageconfiguration-id", description: "key: id of userFlowLanguageConfiguration") { + var userFlowLanguageConfigurationIdOption = new Option("--user-flow-language-configuration-id", description: "key: id of userFlowLanguageConfiguration") { }; userFlowLanguageConfigurationIdOption.IsRequired = true; command.AddOption(userFlowLanguageConfigurationIdOption); - var userFlowLanguagePageIdOption = new Option("--userflowlanguagepage-id", description: "key: id of userFlowLanguagePage") { + var userFlowLanguagePageIdOption = new Option("--user-flow-language-page-id", description: "key: id of userFlowLanguagePage") { }; userFlowLanguagePageIdOption.IsRequired = true; command.AddOption(userFlowLanguagePageIdOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string userFlowLanguagePageId) => { + command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string userFlowLanguagePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, b2xIdentityUserFlowIdOption, userFlowLanguageConfigurationIdOption, userFlowLanguagePageIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Collection of pages with the overrides messages to display in a user flow for a specified language. This collection only allows to modify the content of the page, any other modification is not allowed (creation or deletion of pages)."; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); - var userFlowLanguageConfigurationIdOption = new Option("--userflowlanguageconfiguration-id", description: "key: id of userFlowLanguageConfiguration") { + var userFlowLanguageConfigurationIdOption = new Option("--user-flow-language-configuration-id", description: "key: id of userFlowLanguageConfiguration") { }; userFlowLanguageConfigurationIdOption.IsRequired = true; command.AddOption(userFlowLanguageConfigurationIdOption); - var userFlowLanguagePageIdOption = new Option("--userflowlanguagepage-id", description: "key: id of userFlowLanguagePage") { + var userFlowLanguagePageIdOption = new Option("--user-flow-language-page-id", description: "key: id of userFlowLanguagePage") { }; userFlowLanguagePageIdOption.IsRequired = true; command.AddOption(userFlowLanguagePageIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string userFlowLanguagePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string userFlowLanguagePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, b2xIdentityUserFlowIdOption, userFlowLanguageConfigurationIdOption, userFlowLanguagePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, b2xIdentityUserFlowIdOption, userFlowLanguageConfigurationIdOption, userFlowLanguagePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,15 +105,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Collection of pages with the overrides messages to display in a user flow for a specified language. This collection only allows to modify the content of the page, any other modification is not allowed (creation or deletion of pages)."; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); - var userFlowLanguageConfigurationIdOption = new Option("--userflowlanguageconfiguration-id", description: "key: id of userFlowLanguageConfiguration") { + var userFlowLanguageConfigurationIdOption = new Option("--user-flow-language-configuration-id", description: "key: id of userFlowLanguageConfiguration") { }; userFlowLanguageConfigurationIdOption.IsRequired = true; command.AddOption(userFlowLanguageConfigurationIdOption); - var userFlowLanguagePageIdOption = new Option("--userflowlanguagepage-id", description: "key: id of userFlowLanguagePage") { + var userFlowLanguagePageIdOption = new Option("--user-flow-language-page-id", description: "key: id of userFlowLanguagePage") { }; userFlowLanguagePageIdOption.IsRequired = true; command.AddOption(userFlowLanguagePageIdOption); @@ -123,14 +121,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string userFlowLanguagePageId, string body) => { + command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string userFlowLanguagePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, b2xIdentityUserFlowIdOption, userFlowLanguageConfigurationIdOption, userFlowLanguagePageIdOption, bodyOption); return command; @@ -202,42 +199,6 @@ public RequestInformation CreatePatchRequestInformation(UserFlowLanguagePage bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of pages with the overrides messages to display in a user flow for a specified language. This collection only allows to modify the content of the page, any other modification is not allowed (creation or deletion of pages). - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of pages with the overrides messages to display in a user flow for a specified language. This collection only allows to modify the content of the page, any other modification is not allowed (creation or deletion of pages). - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of pages with the overrides messages to display in a user flow for a specified language. This collection only allows to modify the content of the page, any other modification is not allowed (creation or deletion of pages). - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(UserFlowLanguagePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of pages with the overrides messages to display in a user flow for a specified language. This collection only allows to modify the content of the page, any other modification is not allowed (creation or deletion of pages). public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Identity/B2xUserFlows/Item/Languages/Item/OverridesPages/Item/Value/ContentRequestBuilder.cs b/src/generated/Identity/B2xUserFlows/Item/Languages/Item/OverridesPages/Item/Value/ContentRequestBuilder.cs index 11c158d019c..07eb29d217b 100644 --- a/src/generated/Identity/B2xUserFlows/Item/Languages/Item/OverridesPages/Item/Value/ContentRequestBuilder.cs +++ b/src/generated/Identity/B2xUserFlows/Item/Languages/Item/OverridesPages/Item/Value/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,36 +25,38 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get media content for the navigation property overridesPages from identity"; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); - var userFlowLanguageConfigurationIdOption = new Option("--userflowlanguageconfiguration-id", description: "key: id of userFlowLanguageConfiguration") { + var userFlowLanguageConfigurationIdOption = new Option("--user-flow-language-configuration-id", description: "key: id of userFlowLanguageConfiguration") { }; userFlowLanguageConfigurationIdOption.IsRequired = true; command.AddOption(userFlowLanguageConfigurationIdOption); - var userFlowLanguagePageIdOption = new Option("--userflowlanguagepage-id", description: "key: id of userFlowLanguagePage") { + var userFlowLanguagePageIdOption = new Option("--user-flow-language-page-id", description: "key: id of userFlowLanguagePage") { }; userFlowLanguagePageIdOption.IsRequired = true; command.AddOption(userFlowLanguagePageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string userFlowLanguagePageId, FileInfo output) => { + command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string userFlowLanguagePageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, b2xIdentityUserFlowIdOption, userFlowLanguageConfigurationIdOption, userFlowLanguagePageIdOption, outputOption); + }, b2xIdentityUserFlowIdOption, userFlowLanguageConfigurationIdOption, userFlowLanguagePageIdOption, fileOption, outputOption); return command; } /// @@ -64,15 +66,15 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "Update media content for the navigation property overridesPages in identity"; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); - var userFlowLanguageConfigurationIdOption = new Option("--userflowlanguageconfiguration-id", description: "key: id of userFlowLanguageConfiguration") { + var userFlowLanguageConfigurationIdOption = new Option("--user-flow-language-configuration-id", description: "key: id of userFlowLanguageConfiguration") { }; userFlowLanguageConfigurationIdOption.IsRequired = true; command.AddOption(userFlowLanguageConfigurationIdOption); - var userFlowLanguagePageIdOption = new Option("--userflowlanguagepage-id", description: "key: id of userFlowLanguagePage") { + var userFlowLanguagePageIdOption = new Option("--user-flow-language-page-id", description: "key: id of userFlowLanguagePage") { }; userFlowLanguagePageIdOption.IsRequired = true; command.AddOption(userFlowLanguagePageIdOption); @@ -80,12 +82,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string userFlowLanguagePageId, FileInfo file) => { + command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string userFlowLanguagePageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, b2xIdentityUserFlowIdOption, userFlowLanguageConfigurationIdOption, userFlowLanguagePageIdOption, bodyOption); return command; @@ -136,29 +137,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property overridesPages from identity - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property overridesPages in identity - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Identity/B2xUserFlows/Item/Languages/Item/OverridesPages/OverridesPagesRequestBuilder.cs b/src/generated/Identity/B2xUserFlows/Item/Languages/Item/OverridesPages/OverridesPagesRequestBuilder.cs index a01b3bf58ed..f1348d16d59 100644 --- a/src/generated/Identity/B2xUserFlows/Item/Languages/Item/OverridesPages/OverridesPagesRequestBuilder.cs +++ b/src/generated/Identity/B2xUserFlows/Item/Languages/Item/OverridesPages/OverridesPagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class OverridesPagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new UserFlowLanguagePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -37,11 +36,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Collection of pages with the overrides messages to display in a user flow for a specified language. This collection only allows to modify the content of the page, any other modification is not allowed (creation or deletion of pages)."; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); - var userFlowLanguageConfigurationIdOption = new Option("--userflowlanguageconfiguration-id", description: "key: id of userFlowLanguageConfiguration") { + var userFlowLanguageConfigurationIdOption = new Option("--user-flow-language-configuration-id", description: "key: id of userFlowLanguageConfiguration") { }; userFlowLanguageConfigurationIdOption.IsRequired = true; command.AddOption(userFlowLanguageConfigurationIdOption); @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, b2xIdentityUserFlowIdOption, userFlowLanguageConfigurationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, b2xIdentityUserFlowIdOption, userFlowLanguageConfigurationIdOption, bodyOption, outputOption); return command; } /// @@ -73,11 +71,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Collection of pages with the overrides messages to display in a user flow for a specified language. This collection only allows to modify the content of the page, any other modification is not allowed (creation or deletion of pages)."; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); - var userFlowLanguageConfigurationIdOption = new Option("--userflowlanguageconfiguration-id", description: "key: id of userFlowLanguageConfiguration") { + var userFlowLanguageConfigurationIdOption = new Option("--user-flow-language-configuration-id", description: "key: id of userFlowLanguageConfiguration") { }; userFlowLanguageConfigurationIdOption.IsRequired = true; command.AddOption(userFlowLanguageConfigurationIdOption); @@ -116,7 +114,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -127,15 +129,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, b2xIdentityUserFlowIdOption, userFlowLanguageConfigurationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, b2xIdentityUserFlowIdOption, userFlowLanguageConfigurationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -190,31 +187,6 @@ public RequestInformation CreatePostRequestInformation(UserFlowLanguagePage body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of pages with the overrides messages to display in a user flow for a specified language. This collection only allows to modify the content of the page, any other modification is not allowed (creation or deletion of pages). - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of pages with the overrides messages to display in a user flow for a specified language. This collection only allows to modify the content of the page, any other modification is not allowed (creation or deletion of pages). - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UserFlowLanguagePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of pages with the overrides messages to display in a user flow for a specified language. This collection only allows to modify the content of the page, any other modification is not allowed (creation or deletion of pages). public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Identity/B2xUserFlows/Item/Languages/Item/UserFlowLanguageConfigurationRequestBuilder.cs b/src/generated/Identity/B2xUserFlows/Item/Languages/Item/UserFlowLanguageConfigurationRequestBuilder.cs index 4514f42bfbd..53415e54a30 100644 --- a/src/generated/Identity/B2xUserFlows/Item/Languages/Item/UserFlowLanguageConfigurationRequestBuilder.cs +++ b/src/generated/Identity/B2xUserFlows/Item/Languages/Item/UserFlowLanguageConfigurationRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -24,6 +24,9 @@ public class UserFlowLanguageConfigurationRequestBuilder { public Command BuildDefaultPagesCommand() { var command = new Command("default-pages"); var builder = new ApiSdk.Identity.B2xUserFlows.Item.Languages.Item.DefaultPages.DefaultPagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -35,19 +38,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The languages supported for customization within the user flow. Language customization is enabled by default in self-service sign up user flow. You cannot create custom languages in self-service sign up user flows."; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); - var userFlowLanguageConfigurationIdOption = new Option("--userflowlanguageconfiguration-id", description: "key: id of userFlowLanguageConfiguration") { + var userFlowLanguageConfigurationIdOption = new Option("--user-flow-language-configuration-id", description: "key: id of userFlowLanguageConfiguration") { }; userFlowLanguageConfigurationIdOption.IsRequired = true; command.AddOption(userFlowLanguageConfigurationIdOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId) => { + command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, b2xIdentityUserFlowIdOption, userFlowLanguageConfigurationIdOption); return command; @@ -59,11 +61,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The languages supported for customization within the user flow. Language customization is enabled by default in self-service sign up user flow. You cannot create custom languages in self-service sign up user flows."; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); - var userFlowLanguageConfigurationIdOption = new Option("--userflowlanguageconfiguration-id", description: "key: id of userFlowLanguageConfiguration") { + var userFlowLanguageConfigurationIdOption = new Option("--user-flow-language-configuration-id", description: "key: id of userFlowLanguageConfiguration") { }; userFlowLanguageConfigurationIdOption.IsRequired = true; command.AddOption(userFlowLanguageConfigurationIdOption); @@ -77,25 +79,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, b2xIdentityUserFlowIdOption, userFlowLanguageConfigurationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, b2xIdentityUserFlowIdOption, userFlowLanguageConfigurationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOverridesPagesCommand() { var command = new Command("overrides-pages"); var builder = new ApiSdk.Identity.B2xUserFlows.Item.Languages.Item.OverridesPages.OverridesPagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -107,11 +111,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The languages supported for customization within the user flow. Language customization is enabled by default in self-service sign up user flow. You cannot create custom languages in self-service sign up user flows."; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); - var userFlowLanguageConfigurationIdOption = new Option("--userflowlanguageconfiguration-id", description: "key: id of userFlowLanguageConfiguration") { + var userFlowLanguageConfigurationIdOption = new Option("--user-flow-language-configuration-id", description: "key: id of userFlowLanguageConfiguration") { }; userFlowLanguageConfigurationIdOption.IsRequired = true; command.AddOption(userFlowLanguageConfigurationIdOption); @@ -119,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string body) => { + command.SetHandler(async (string b2xIdentityUserFlowId, string userFlowLanguageConfigurationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, b2xIdentityUserFlowIdOption, userFlowLanguageConfigurationIdOption, bodyOption); return command; @@ -198,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(UserFlowLanguageConfigur requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The languages supported for customization within the user flow. Language customization is enabled by default in self-service sign up user flow. You cannot create custom languages in self-service sign up user flows. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The languages supported for customization within the user flow. Language customization is enabled by default in self-service sign up user flow. You cannot create custom languages in self-service sign up user flows. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The languages supported for customization within the user flow. Language customization is enabled by default in self-service sign up user flow. You cannot create custom languages in self-service sign up user flows. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(UserFlowLanguageConfiguration model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The languages supported for customization within the user flow. Language customization is enabled by default in self-service sign up user flow. You cannot create custom languages in self-service sign up user flows. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Identity/B2xUserFlows/Item/Languages/LanguagesRequestBuilder.cs b/src/generated/Identity/B2xUserFlows/Item/Languages/LanguagesRequestBuilder.cs index b2092807ab5..cea96d9b3e5 100644 --- a/src/generated/Identity/B2xUserFlows/Item/Languages/LanguagesRequestBuilder.cs +++ b/src/generated/Identity/B2xUserFlows/Item/Languages/LanguagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class LanguagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new UserFlowLanguageConfigurationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDefaultPagesCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOverridesPagesCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDefaultPagesCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOverridesPagesCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -38,7 +37,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The languages supported for customization within the user flow. Language customization is enabled by default in self-service sign up user flow. You cannot create custom languages in self-service sign up user flows."; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); @@ -46,21 +45,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string b2xIdentityUserFlowId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, b2xIdentityUserFlowIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, b2xIdentityUserFlowIdOption, bodyOption, outputOption); return command; } /// @@ -70,7 +68,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The languages supported for customization within the user flow. Language customization is enabled by default in self-service sign up user flow. You cannot create custom languages in self-service sign up user flows."; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); @@ -109,7 +107,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string b2xIdentityUserFlowId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string b2xIdentityUserFlowId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -120,15 +122,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, b2xIdentityUserFlowIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, b2xIdentityUserFlowIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -183,31 +180,6 @@ public RequestInformation CreatePostRequestInformation(UserFlowLanguageConfigura requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The languages supported for customization within the user flow. Language customization is enabled by default in self-service sign up user flow. You cannot create custom languages in self-service sign up user flows. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The languages supported for customization within the user flow. Language customization is enabled by default in self-service sign up user flow. You cannot create custom languages in self-service sign up user flows. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UserFlowLanguageConfiguration model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The languages supported for customization within the user flow. Language customization is enabled by default in self-service sign up user flow. You cannot create custom languages in self-service sign up user flows. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/GetOrder/GetOrderRequestBuilder.cs b/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/GetOrder/GetOrderRequestBuilder.cs index 4045e56ee3f..54e5c95caca 100644 --- a/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/GetOrder/GetOrderRequestBuilder.cs +++ b/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/GetOrder/GetOrderRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function getOrder"; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); - command.SetHandler(async (string b2xIdentityUserFlowId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string b2xIdentityUserFlowId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, b2xIdentityUserFlowIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, b2xIdentityUserFlowIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getOrder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes assignmentOrder public class GetOrderResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/Item/IdentityUserFlowAttributeAssignmentRequestBuilder.cs b/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/Item/IdentityUserFlowAttributeAssignmentRequestBuilder.cs index 975242d1174..ebe6db42649 100644 --- a/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/Item/IdentityUserFlowAttributeAssignmentRequestBuilder.cs +++ b/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/Item/IdentityUserFlowAttributeAssignmentRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,19 +27,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The user attribute assignments included in the user flow."; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); - var identityUserFlowAttributeAssignmentIdOption = new Option("--identityuserflowattributeassignment-id", description: "key: id of identityUserFlowAttributeAssignment") { + var identityUserFlowAttributeAssignmentIdOption = new Option("--identity-user-flow-attribute-assignment-id", description: "key: id of identityUserFlowAttributeAssignment") { }; identityUserFlowAttributeAssignmentIdOption.IsRequired = true; command.AddOption(identityUserFlowAttributeAssignmentIdOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string identityUserFlowAttributeAssignmentId) => { + command.SetHandler(async (string b2xIdentityUserFlowId, string identityUserFlowAttributeAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, b2xIdentityUserFlowIdOption, identityUserFlowAttributeAssignmentIdOption); return command; @@ -51,11 +50,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The user attribute assignments included in the user flow."; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); - var identityUserFlowAttributeAssignmentIdOption = new Option("--identityuserflowattributeassignment-id", description: "key: id of identityUserFlowAttributeAssignment") { + var identityUserFlowAttributeAssignmentIdOption = new Option("--identity-user-flow-attribute-assignment-id", description: "key: id of identityUserFlowAttributeAssignment") { }; identityUserFlowAttributeAssignmentIdOption.IsRequired = true; command.AddOption(identityUserFlowAttributeAssignmentIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string identityUserFlowAttributeAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string b2xIdentityUserFlowId, string identityUserFlowAttributeAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, b2xIdentityUserFlowIdOption, identityUserFlowAttributeAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, b2xIdentityUserFlowIdOption, identityUserFlowAttributeAssignmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -92,11 +90,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The user attribute assignments included in the user flow."; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); - var identityUserFlowAttributeAssignmentIdOption = new Option("--identityuserflowattributeassignment-id", description: "key: id of identityUserFlowAttributeAssignment") { + var identityUserFlowAttributeAssignmentIdOption = new Option("--identity-user-flow-attribute-assignment-id", description: "key: id of identityUserFlowAttributeAssignment") { }; identityUserFlowAttributeAssignmentIdOption.IsRequired = true; command.AddOption(identityUserFlowAttributeAssignmentIdOption); @@ -104,14 +102,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string identityUserFlowAttributeAssignmentId, string body) => { + command.SetHandler(async (string b2xIdentityUserFlowId, string identityUserFlowAttributeAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, b2xIdentityUserFlowIdOption, identityUserFlowAttributeAssignmentIdOption, bodyOption); return command; @@ -190,42 +187,6 @@ public RequestInformation CreatePatchRequestInformation(IdentityUserFlowAttribut requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user attribute assignments included in the user flow. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user attribute assignments included in the user flow. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user attribute assignments included in the user flow. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(IdentityUserFlowAttributeAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The user attribute assignments included in the user flow. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/Item/UserAttribute/@Ref/@Ref.cs b/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/Item/UserAttribute/@Ref/@Ref.cs deleted file mode 100644 index 07d97fda753..00000000000 --- a/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/Item/UserAttribute/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Identity.B2xUserFlows.Item.UserAttributeAssignments.Item.UserAttribute.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/Item/UserAttribute/@Ref/RefRequestBuilder.cs b/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/Item/UserAttribute/@Ref/RefRequestBuilder.cs deleted file mode 100644 index a20414c4014..00000000000 --- a/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/Item/UserAttribute/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Identity.B2xUserFlows.Item.UserAttributeAssignments.Item.UserAttribute.@Ref { - /// Builds and executes requests for operations under \identity\b2xUserFlows\{b2xIdentityUserFlow-id}\userAttributeAssignments\{identityUserFlowAttributeAssignment-id}\userAttribute\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The user attribute that you want to add to your user flow. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The user attribute that you want to add to your user flow."; - // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { - }; - b2xIdentityUserFlowIdOption.IsRequired = true; - command.AddOption(b2xIdentityUserFlowIdOption); - var identityUserFlowAttributeAssignmentIdOption = new Option("--identityuserflowattributeassignment-id", description: "key: id of identityUserFlowAttributeAssignment") { - }; - identityUserFlowAttributeAssignmentIdOption.IsRequired = true; - command.AddOption(identityUserFlowAttributeAssignmentIdOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string identityUserFlowAttributeAssignmentId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, b2xIdentityUserFlowIdOption, identityUserFlowAttributeAssignmentIdOption); - return command; - } - /// - /// The user attribute that you want to add to your user flow. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The user attribute that you want to add to your user flow."; - // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { - }; - b2xIdentityUserFlowIdOption.IsRequired = true; - command.AddOption(b2xIdentityUserFlowIdOption); - var identityUserFlowAttributeAssignmentIdOption = new Option("--identityuserflowattributeassignment-id", description: "key: id of identityUserFlowAttributeAssignment") { - }; - identityUserFlowAttributeAssignmentIdOption.IsRequired = true; - command.AddOption(identityUserFlowAttributeAssignmentIdOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string identityUserFlowAttributeAssignmentId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, b2xIdentityUserFlowIdOption, identityUserFlowAttributeAssignmentIdOption); - return command; - } - /// - /// The user attribute that you want to add to your user flow. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The user attribute that you want to add to your user flow."; - // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { - }; - b2xIdentityUserFlowIdOption.IsRequired = true; - command.AddOption(b2xIdentityUserFlowIdOption); - var identityUserFlowAttributeAssignmentIdOption = new Option("--identityuserflowattributeassignment-id", description: "key: id of identityUserFlowAttributeAssignment") { - }; - identityUserFlowAttributeAssignmentIdOption.IsRequired = true; - command.AddOption(identityUserFlowAttributeAssignmentIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string identityUserFlowAttributeAssignmentId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, b2xIdentityUserFlowIdOption, identityUserFlowAttributeAssignmentIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/identity/b2xUserFlows/{b2xIdentityUserFlow_id}/userAttributeAssignments/{identityUserFlowAttributeAssignment_id}/userAttribute/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The user attribute that you want to add to your user flow. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The user attribute that you want to add to your user flow. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The user attribute that you want to add to your user flow. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Identity.B2xUserFlows.Item.UserAttributeAssignments.Item.UserAttribute.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The user attribute that you want to add to your user flow. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user attribute that you want to add to your user flow. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user attribute that you want to add to your user flow. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Identity.B2xUserFlows.Item.UserAttributeAssignments.Item.UserAttribute.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/Item/UserAttribute/Ref/Ref.cs b/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/Item/UserAttribute/Ref/Ref.cs new file mode 100644 index 00000000000..6d4c800a544 --- /dev/null +++ b/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/Item/UserAttribute/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Identity.B2xUserFlows.Item.UserAttributeAssignments.Item.UserAttribute.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/Item/UserAttribute/Ref/RefRequestBuilder.cs b/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/Item/UserAttribute/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..b43b74bcd4e --- /dev/null +++ b/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/Item/UserAttribute/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Identity.B2xUserFlows.Item.UserAttributeAssignments.Item.UserAttribute.Ref { + /// Builds and executes requests for operations under \identity\b2xUserFlows\{b2xIdentityUserFlow-id}\userAttributeAssignments\{identityUserFlowAttributeAssignment-id}\userAttribute\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The user attribute that you want to add to your user flow. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The user attribute that you want to add to your user flow."; + // Create options for all the parameters + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { + }; + b2xIdentityUserFlowIdOption.IsRequired = true; + command.AddOption(b2xIdentityUserFlowIdOption); + var identityUserFlowAttributeAssignmentIdOption = new Option("--identity-user-flow-attribute-assignment-id", description: "key: id of identityUserFlowAttributeAssignment") { + }; + identityUserFlowAttributeAssignmentIdOption.IsRequired = true; + command.AddOption(identityUserFlowAttributeAssignmentIdOption); + command.SetHandler(async (string b2xIdentityUserFlowId, string identityUserFlowAttributeAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, b2xIdentityUserFlowIdOption, identityUserFlowAttributeAssignmentIdOption); + return command; + } + /// + /// The user attribute that you want to add to your user flow. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The user attribute that you want to add to your user flow."; + // Create options for all the parameters + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { + }; + b2xIdentityUserFlowIdOption.IsRequired = true; + command.AddOption(b2xIdentityUserFlowIdOption); + var identityUserFlowAttributeAssignmentIdOption = new Option("--identity-user-flow-attribute-assignment-id", description: "key: id of identityUserFlowAttributeAssignment") { + }; + identityUserFlowAttributeAssignmentIdOption.IsRequired = true; + command.AddOption(identityUserFlowAttributeAssignmentIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string b2xIdentityUserFlowId, string identityUserFlowAttributeAssignmentId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, b2xIdentityUserFlowIdOption, identityUserFlowAttributeAssignmentIdOption, outputOption); + return command; + } + /// + /// The user attribute that you want to add to your user flow. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The user attribute that you want to add to your user flow."; + // Create options for all the parameters + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { + }; + b2xIdentityUserFlowIdOption.IsRequired = true; + command.AddOption(b2xIdentityUserFlowIdOption); + var identityUserFlowAttributeAssignmentIdOption = new Option("--identity-user-flow-attribute-assignment-id", description: "key: id of identityUserFlowAttributeAssignment") { + }; + identityUserFlowAttributeAssignmentIdOption.IsRequired = true; + command.AddOption(identityUserFlowAttributeAssignmentIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string b2xIdentityUserFlowId, string identityUserFlowAttributeAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, b2xIdentityUserFlowIdOption, identityUserFlowAttributeAssignmentIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/identity/b2xUserFlows/{b2xIdentityUserFlow_id}/userAttributeAssignments/{identityUserFlowAttributeAssignment_id}/userAttribute/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The user attribute that you want to add to your user flow. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The user attribute that you want to add to your user flow. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The user attribute that you want to add to your user flow. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Identity.B2xUserFlows.Item.UserAttributeAssignments.Item.UserAttribute.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/Item/UserAttribute/UserAttributeRequestBuilder.cs b/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/Item/UserAttribute/UserAttributeRequestBuilder.cs index 83b48c4b7fb..c35af6c43da 100644 --- a/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/Item/UserAttribute/UserAttributeRequestBuilder.cs +++ b/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/Item/UserAttribute/UserAttributeRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,11 +27,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The user attribute that you want to add to your user flow."; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); - var identityUserFlowAttributeAssignmentIdOption = new Option("--identityuserflowattributeassignment-id", description: "key: id of identityUserFlowAttributeAssignment") { + var identityUserFlowAttributeAssignmentIdOption = new Option("--identity-user-flow-attribute-assignment-id", description: "key: id of identityUserFlowAttributeAssignment") { }; identityUserFlowAttributeAssignmentIdOption.IsRequired = true; command.AddOption(identityUserFlowAttributeAssignmentIdOption); @@ -45,25 +45,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string identityUserFlowAttributeAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string b2xIdentityUserFlowId, string identityUserFlowAttributeAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, b2xIdentityUserFlowIdOption, identityUserFlowAttributeAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, b2xIdentityUserFlowIdOption, identityUserFlowAttributeAssignmentIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Identity.B2xUserFlows.Item.UserAttributeAssignments.Item.UserAttribute.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Identity.B2xUserFlows.Item.UserAttributeAssignments.Item.UserAttribute.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -103,18 +102,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user attribute that you want to add to your user flow. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The user attribute that you want to add to your user flow. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/SetOrder/SetOrderRequestBuilder.cs b/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/SetOrder/SetOrderRequestBuilder.cs index 46b22eae416..e5b774fd4ad 100644 --- a/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/SetOrder/SetOrderRequestBuilder.cs +++ b/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/SetOrder/SetOrderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setOrder"; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string body) => { + command.SetHandler(async (string b2xIdentityUserFlowId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, b2xIdentityUserFlowIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(SetOrderRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setOrder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetOrderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/UserAttributeAssignmentsRequestBuilder.cs b/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/UserAttributeAssignmentsRequestBuilder.cs index 7695aa72a37..318c8e45054 100644 --- a/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/UserAttributeAssignmentsRequestBuilder.cs +++ b/src/generated/Identity/B2xUserFlows/Item/UserAttributeAssignments/UserAttributeAssignmentsRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -24,12 +24,11 @@ public class UserAttributeAssignmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new IdentityUserFlowAttributeAssignmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildUserAttributeCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildUserAttributeCommand()); return commands; } /// @@ -39,7 +38,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The user attribute assignments included in the user flow."; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); @@ -47,21 +46,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string b2xIdentityUserFlowId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, b2xIdentityUserFlowIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, b2xIdentityUserFlowIdOption, bodyOption, outputOption); return command; } /// @@ -71,7 +69,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The user attribute assignments included in the user flow."; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); @@ -110,7 +108,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string b2xIdentityUserFlowId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string b2xIdentityUserFlowId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, b2xIdentityUserFlowIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, b2xIdentityUserFlowIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildSetOrderCommand() { @@ -191,36 +188,11 @@ public RequestInformation CreatePostRequestInformation(IdentityUserFlowAttribute return requestInfo; } /// - /// The user attribute assignments included in the user flow. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \identity\b2xUserFlows\{b2xIdentityUserFlow-id}\userAttributeAssignments\microsoft.graph.getOrder() /// public GetOrderRequestBuilder GetOrder() { return new GetOrderRequestBuilder(PathParameters, RequestAdapter); } - /// - /// The user attribute assignments included in the user flow. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(IdentityUserFlowAttributeAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The user attribute assignments included in the user flow. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Identity/B2xUserFlows/Item/UserFlowIdentityProviders/@Ref/@Ref.cs b/src/generated/Identity/B2xUserFlows/Item/UserFlowIdentityProviders/@Ref/@Ref.cs deleted file mode 100644 index 4731a2c7b5b..00000000000 --- a/src/generated/Identity/B2xUserFlows/Item/UserFlowIdentityProviders/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Identity.B2xUserFlows.Item.UserFlowIdentityProviders.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Identity/B2xUserFlows/Item/UserFlowIdentityProviders/@Ref/RefRequestBuilder.cs b/src/generated/Identity/B2xUserFlows/Item/UserFlowIdentityProviders/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 0539dd04489..00000000000 --- a/src/generated/Identity/B2xUserFlows/Item/UserFlowIdentityProviders/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Identity.B2xUserFlows.Item.UserFlowIdentityProviders.@Ref { - /// Builds and executes requests for operations under \identity\b2xUserFlows\{b2xIdentityUserFlow-id}\userFlowIdentityProviders\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Get ref of userFlowIdentityProviders from identity - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Get ref of userFlowIdentityProviders from identity"; - // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { - }; - b2xIdentityUserFlowIdOption.IsRequired = true; - command.AddOption(b2xIdentityUserFlowIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string b2xIdentityUserFlowId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, b2xIdentityUserFlowIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Create new navigation property ref to userFlowIdentityProviders for identity - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Create new navigation property ref to userFlowIdentityProviders for identity"; - // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { - }; - b2xIdentityUserFlowIdOption.IsRequired = true; - command.AddOption(b2xIdentityUserFlowIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string b2xIdentityUserFlowId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, b2xIdentityUserFlowIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/identity/b2xUserFlows/{b2xIdentityUserFlow_id}/userFlowIdentityProviders/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Get ref of userFlowIdentityProviders from identity - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Create new navigation property ref to userFlowIdentityProviders for identity - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Identity.B2xUserFlows.Item.UserFlowIdentityProviders.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Get ref of userFlowIdentityProviders from identity - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property ref to userFlowIdentityProviders for identity - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Identity.B2xUserFlows.Item.UserFlowIdentityProviders.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Get ref of userFlowIdentityProviders from identity - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Identity/B2xUserFlows/Item/UserFlowIdentityProviders/@Ref/RefResponse.cs b/src/generated/Identity/B2xUserFlows/Item/UserFlowIdentityProviders/@Ref/RefResponse.cs deleted file mode 100644 index bf953c830c3..00000000000 --- a/src/generated/Identity/B2xUserFlows/Item/UserFlowIdentityProviders/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Identity.B2xUserFlows.Item.UserFlowIdentityProviders.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Identity/B2xUserFlows/Item/UserFlowIdentityProviders/AvailableProviderTypes/AvailableProviderTypesRequestBuilder.cs b/src/generated/Identity/B2xUserFlows/Item/UserFlowIdentityProviders/AvailableProviderTypes/AvailableProviderTypesRequestBuilder.cs index 17b90f64584..1ae56ff709a 100644 --- a/src/generated/Identity/B2xUserFlows/Item/UserFlowIdentityProviders/AvailableProviderTypes/AvailableProviderTypesRequestBuilder.cs +++ b/src/generated/Identity/B2xUserFlows/Item/UserFlowIdentityProviders/AvailableProviderTypes/AvailableProviderTypesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,22 +25,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function availableProviderTypes"; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); - command.SetHandler(async (string b2xIdentityUserFlowId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string b2xIdentityUserFlowId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, b2xIdentityUserFlowIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, b2xIdentityUserFlowIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function availableProviderTypes - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Identity/B2xUserFlows/Item/UserFlowIdentityProviders/Ref/Ref.cs b/src/generated/Identity/B2xUserFlows/Item/UserFlowIdentityProviders/Ref/Ref.cs new file mode 100644 index 00000000000..c18b5e7293f --- /dev/null +++ b/src/generated/Identity/B2xUserFlows/Item/UserFlowIdentityProviders/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Identity.B2xUserFlows.Item.UserFlowIdentityProviders.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Identity/B2xUserFlows/Item/UserFlowIdentityProviders/Ref/RefRequestBuilder.cs b/src/generated/Identity/B2xUserFlows/Item/UserFlowIdentityProviders/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..d7c30fdd611 --- /dev/null +++ b/src/generated/Identity/B2xUserFlows/Item/UserFlowIdentityProviders/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Identity.B2xUserFlows.Item.UserFlowIdentityProviders.Ref { + /// Builds and executes requests for operations under \identity\b2xUserFlows\{b2xIdentityUserFlow-id}\userFlowIdentityProviders\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Get ref of userFlowIdentityProviders from identity + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Get ref of userFlowIdentityProviders from identity"; + // Create options for all the parameters + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { + }; + b2xIdentityUserFlowIdOption.IsRequired = true; + command.AddOption(b2xIdentityUserFlowIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string b2xIdentityUserFlowId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, b2xIdentityUserFlowIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Create new navigation property ref to userFlowIdentityProviders for identity + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Create new navigation property ref to userFlowIdentityProviders for identity"; + // Create options for all the parameters + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { + }; + b2xIdentityUserFlowIdOption.IsRequired = true; + command.AddOption(b2xIdentityUserFlowIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string b2xIdentityUserFlowId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, b2xIdentityUserFlowIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/identity/b2xUserFlows/{b2xIdentityUserFlow_id}/userFlowIdentityProviders/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Get ref of userFlowIdentityProviders from identity + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Create new navigation property ref to userFlowIdentityProviders for identity + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Identity.B2xUserFlows.Item.UserFlowIdentityProviders.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Get ref of userFlowIdentityProviders from identity + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Identity/B2xUserFlows/Item/UserFlowIdentityProviders/Ref/RefResponse.cs b/src/generated/Identity/B2xUserFlows/Item/UserFlowIdentityProviders/Ref/RefResponse.cs new file mode 100644 index 00000000000..be9e8e3f4ca --- /dev/null +++ b/src/generated/Identity/B2xUserFlows/Item/UserFlowIdentityProviders/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Identity.B2xUserFlows.Item.UserFlowIdentityProviders.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Identity/B2xUserFlows/Item/UserFlowIdentityProviders/UserFlowIdentityProvidersRequestBuilder.cs b/src/generated/Identity/B2xUserFlows/Item/UserFlowIdentityProviders/UserFlowIdentityProvidersRequestBuilder.cs index 968928deece..d74fb4a7e45 100644 --- a/src/generated/Identity/B2xUserFlows/Item/UserFlowIdentityProviders/UserFlowIdentityProvidersRequestBuilder.cs +++ b/src/generated/Identity/B2xUserFlows/Item/UserFlowIdentityProviders/UserFlowIdentityProvidersRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Identity.B2xUserFlows.Item.UserFlowIdentityProviders.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,7 +33,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get userFlowIdentityProviders from identity"; // Create options for all the parameters - var b2xIdentityUserFlowIdOption = new Option("--b2xidentityuserflow-id", description: "key: id of b2xIdentityUserFlow") { + var b2xIdentityUserFlowIdOption = new Option("--b2x-identity-user-flow-id", description: "key: id of b2xIdentityUserFlow") { }; b2xIdentityUserFlowIdOption.IsRequired = true; command.AddOption(b2xIdentityUserFlowIdOption); @@ -72,7 +72,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string b2xIdentityUserFlowId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string b2xIdentityUserFlowId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -83,20 +87,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, b2xIdentityUserFlowIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, b2xIdentityUserFlowIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Identity.B2xUserFlows.Item.UserFlowIdentityProviders.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Identity.B2xUserFlows.Item.UserFlowIdentityProviders.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -135,18 +134,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get userFlowIdentityProviders from identity - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get userFlowIdentityProviders from identity public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Identity/ConditionalAccess/ConditionalAccessRequestBuilder.cs b/src/generated/Identity/ConditionalAccess/ConditionalAccessRequestBuilder.cs index bbe73b3ab78..64e646feb27 100644 --- a/src/generated/Identity/ConditionalAccess/ConditionalAccessRequestBuilder.cs +++ b/src/generated/Identity/ConditionalAccess/ConditionalAccessRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,11 +28,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "the entry point for the Conditional Access (CA) object model."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -54,25 +53,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } public Command BuildNamedLocationsCommand() { var command = new Command("named-locations"); var builder = new ApiSdk.Identity.ConditionalAccess.NamedLocations.NamedLocationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -88,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -103,6 +103,9 @@ public Command BuildPatchCommand() { public Command BuildPoliciesCommand() { var command = new Command("policies"); var builder = new ApiSdk.Identity.ConditionalAccess.Policies.PoliciesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -174,42 +177,6 @@ public RequestInformation CreatePatchRequestInformation(ConditionalAccessRoot bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// the entry point for the Conditional Access (CA) object model. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// the entry point for the Conditional Access (CA) object model. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// the entry point for the Conditional Access (CA) object model. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ConditionalAccessRoot model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// the entry point for the Conditional Access (CA) object model. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Identity/ConditionalAccess/NamedLocations/Item/NamedLocationRequestBuilder.cs b/src/generated/Identity/ConditionalAccess/NamedLocations/Item/NamedLocationRequestBuilder.cs index 438044e094a..de727f549d9 100644 --- a/src/generated/Identity/ConditionalAccess/NamedLocations/Item/NamedLocationRequestBuilder.cs +++ b/src/generated/Identity/ConditionalAccess/NamedLocations/Item/NamedLocationRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Returns a collection of the specified named locations."; // Create options for all the parameters - var namedLocationIdOption = new Option("--namedlocation-id", description: "key: id of namedLocation") { + var namedLocationIdOption = new Option("--named-location-id", description: "key: id of namedLocation") { }; namedLocationIdOption.IsRequired = true; command.AddOption(namedLocationIdOption); - command.SetHandler(async (string namedLocationId) => { + command.SetHandler(async (string namedLocationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, namedLocationIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Returns a collection of the specified named locations."; // Create options for all the parameters - var namedLocationIdOption = new Option("--namedlocation-id", description: "key: id of namedLocation") { + var namedLocationIdOption = new Option("--named-location-id", description: "key: id of namedLocation") { }; namedLocationIdOption.IsRequired = true; command.AddOption(namedLocationIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string namedLocationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string namedLocationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, namedLocationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, namedLocationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Returns a collection of the specified named locations."; // Create options for all the parameters - var namedLocationIdOption = new Option("--namedlocation-id", description: "key: id of namedLocation") { + var namedLocationIdOption = new Option("--named-location-id", description: "key: id of namedLocation") { }; namedLocationIdOption.IsRequired = true; command.AddOption(namedLocationIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string namedLocationId, string body) => { + command.SetHandler(async (string namedLocationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, namedLocationIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(NamedLocation body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Returns a collection of the specified named locations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns a collection of the specified named locations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns a collection of the specified named locations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(NamedLocation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Returns a collection of the specified named locations. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Identity/ConditionalAccess/NamedLocations/NamedLocationsRequestBuilder.cs b/src/generated/Identity/ConditionalAccess/NamedLocations/NamedLocationsRequestBuilder.cs index e7e424add14..24b9981a872 100644 --- a/src/generated/Identity/ConditionalAccess/NamedLocations/NamedLocationsRequestBuilder.cs +++ b/src/generated/Identity/ConditionalAccess/NamedLocations/NamedLocationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class NamedLocationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new NamedLocationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(NamedLocation body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Returns a collection of the specified named locations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns a collection of the specified named locations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(NamedLocation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Returns a collection of the specified named locations. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Identity/ConditionalAccess/Policies/Item/ConditionalAccessPolicyRequestBuilder.cs b/src/generated/Identity/ConditionalAccess/Policies/Item/ConditionalAccessPolicyRequestBuilder.cs index 07cc96776b2..41fc84c4c37 100644 --- a/src/generated/Identity/ConditionalAccess/Policies/Item/ConditionalAccessPolicyRequestBuilder.cs +++ b/src/generated/Identity/ConditionalAccess/Policies/Item/ConditionalAccessPolicyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Returns a collection of the specified Conditional Access policies."; // Create options for all the parameters - var conditionalAccessPolicyIdOption = new Option("--conditionalaccesspolicy-id", description: "key: id of conditionalAccessPolicy") { + var conditionalAccessPolicyIdOption = new Option("--conditional-access-policy-id", description: "key: id of conditionalAccessPolicy") { }; conditionalAccessPolicyIdOption.IsRequired = true; command.AddOption(conditionalAccessPolicyIdOption); - command.SetHandler(async (string conditionalAccessPolicyId) => { + command.SetHandler(async (string conditionalAccessPolicyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, conditionalAccessPolicyIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Returns a collection of the specified Conditional Access policies."; // Create options for all the parameters - var conditionalAccessPolicyIdOption = new Option("--conditionalaccesspolicy-id", description: "key: id of conditionalAccessPolicy") { + var conditionalAccessPolicyIdOption = new Option("--conditional-access-policy-id", description: "key: id of conditionalAccessPolicy") { }; conditionalAccessPolicyIdOption.IsRequired = true; command.AddOption(conditionalAccessPolicyIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string conditionalAccessPolicyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string conditionalAccessPolicyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, conditionalAccessPolicyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, conditionalAccessPolicyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Returns a collection of the specified Conditional Access policies."; // Create options for all the parameters - var conditionalAccessPolicyIdOption = new Option("--conditionalaccesspolicy-id", description: "key: id of conditionalAccessPolicy") { + var conditionalAccessPolicyIdOption = new Option("--conditional-access-policy-id", description: "key: id of conditionalAccessPolicy") { }; conditionalAccessPolicyIdOption.IsRequired = true; command.AddOption(conditionalAccessPolicyIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string conditionalAccessPolicyId, string body) => { + command.SetHandler(async (string conditionalAccessPolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, conditionalAccessPolicyIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ConditionalAccessPolicy requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Returns a collection of the specified Conditional Access policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns a collection of the specified Conditional Access policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns a collection of the specified Conditional Access policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ConditionalAccessPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Returns a collection of the specified Conditional Access policies. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Identity/ConditionalAccess/Policies/PoliciesRequestBuilder.cs b/src/generated/Identity/ConditionalAccess/Policies/PoliciesRequestBuilder.cs index 16edfdfe72d..d55437926a0 100644 --- a/src/generated/Identity/ConditionalAccess/Policies/PoliciesRequestBuilder.cs +++ b/src/generated/Identity/ConditionalAccess/Policies/PoliciesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class PoliciesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ConditionalAccessPolicyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(ConditionalAccessPolicy b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Returns a collection of the specified Conditional Access policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns a collection of the specified Conditional Access policies. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ConditionalAccessPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Returns a collection of the specified Conditional Access policies. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Identity/IdentityProviders/AvailableProviderTypes/AvailableProviderTypesRequestBuilder.cs b/src/generated/Identity/IdentityProviders/AvailableProviderTypes/AvailableProviderTypesRequestBuilder.cs index e8e14f39e0b..322c1087d80 100644 --- a/src/generated/Identity/IdentityProviders/AvailableProviderTypes/AvailableProviderTypesRequestBuilder.cs +++ b/src/generated/Identity/IdentityProviders/AvailableProviderTypes/AvailableProviderTypesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function availableProviderTypes"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function availableProviderTypes - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Identity/IdentityProviders/IdentityProvidersRequestBuilder.cs b/src/generated/Identity/IdentityProviders/IdentityProvidersRequestBuilder.cs index 79419c16971..4876283f618 100644 --- a/src/generated/Identity/IdentityProviders/IdentityProvidersRequestBuilder.cs +++ b/src/generated/Identity/IdentityProviders/IdentityProvidersRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,10 @@ public AvailableProviderTypesRequestBuilder AvailableProviderTypes() { } public List BuildCommand() { var builder = new IdentityProviderBaseRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -47,21 +46,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -106,7 +104,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -117,15 +119,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -180,31 +177,6 @@ public RequestInformation CreatePostRequestInformation(IdentityProviderBase body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents entry point for identity provider base. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents entry point for identity provider base. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(IdentityProviderBase model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents entry point for identity provider base. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Identity/IdentityProviders/Item/IdentityProviderBaseRequestBuilder.cs b/src/generated/Identity/IdentityProviders/Item/IdentityProviderBaseRequestBuilder.cs index 0014d9c02eb..b29d480f00c 100644 --- a/src/generated/Identity/IdentityProviders/Item/IdentityProviderBaseRequestBuilder.cs +++ b/src/generated/Identity/IdentityProviders/Item/IdentityProviderBaseRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents entry point for identity provider base."; // Create options for all the parameters - var identityProviderBaseIdOption = new Option("--identityproviderbase-id", description: "key: id of identityProviderBase") { + var identityProviderBaseIdOption = new Option("--identity-provider-base-id", description: "key: id of identityProviderBase") { }; identityProviderBaseIdOption.IsRequired = true; command.AddOption(identityProviderBaseIdOption); - command.SetHandler(async (string identityProviderBaseId) => { + command.SetHandler(async (string identityProviderBaseId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, identityProviderBaseIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents entry point for identity provider base."; // Create options for all the parameters - var identityProviderBaseIdOption = new Option("--identityproviderbase-id", description: "key: id of identityProviderBase") { + var identityProviderBaseIdOption = new Option("--identity-provider-base-id", description: "key: id of identityProviderBase") { }; identityProviderBaseIdOption.IsRequired = true; command.AddOption(identityProviderBaseIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string identityProviderBaseId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string identityProviderBaseId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, identityProviderBaseIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, identityProviderBaseIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents entry point for identity provider base."; // Create options for all the parameters - var identityProviderBaseIdOption = new Option("--identityproviderbase-id", description: "key: id of identityProviderBase") { + var identityProviderBaseIdOption = new Option("--identity-provider-base-id", description: "key: id of identityProviderBase") { }; identityProviderBaseIdOption.IsRequired = true; command.AddOption(identityProviderBaseIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string identityProviderBaseId, string body) => { + command.SetHandler(async (string identityProviderBaseId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, identityProviderBaseIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(IdentityProviderBase bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents entry point for identity provider base. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents entry point for identity provider base. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents entry point for identity provider base. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(IdentityProviderBase model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents entry point for identity provider base. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Identity/IdentityRequestBuilder.cs b/src/generated/Identity/IdentityRequestBuilder.cs index 7b436cf78bf..7ba892e5d9c 100644 --- a/src/generated/Identity/IdentityRequestBuilder.cs +++ b/src/generated/Identity/IdentityRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,6 +27,9 @@ public class IdentityRequestBuilder { public Command BuildApiConnectorsCommand() { var command = new Command("api-connectors"); var builder = new ApiSdk.Identity.ApiConnectors.ApiConnectorsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -34,6 +37,9 @@ public Command BuildApiConnectorsCommand() { public Command BuildB2xUserFlowsCommand() { var command = new Command("b2x-user-flows"); var builder = new ApiSdk.Identity.B2xUserFlows.B2xUserFlowsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -65,25 +71,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } public Command BuildIdentityProvidersCommand() { var command = new Command("identity-providers"); var builder = new ApiSdk.Identity.IdentityProviders.IdentityProvidersRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -99,14 +107,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -114,6 +121,9 @@ public Command BuildPatchCommand() { public Command BuildUserFlowAttributesCommand() { var command = new Command("user-flow-attributes"); var builder = new ApiSdk.Identity.UserFlowAttributes.UserFlowAttributesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -170,31 +180,6 @@ public RequestInformation CreatePatchRequestInformation(IdentityContainer body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get identity - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update identity - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(IdentityContainer model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get identity public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Identity/UserFlowAttributes/Item/IdentityUserFlowAttributeRequestBuilder.cs b/src/generated/Identity/UserFlowAttributes/Item/IdentityUserFlowAttributeRequestBuilder.cs index 88e56e82abe..f5da6bb16e2 100644 --- a/src/generated/Identity/UserFlowAttributes/Item/IdentityUserFlowAttributeRequestBuilder.cs +++ b/src/generated/Identity/UserFlowAttributes/Item/IdentityUserFlowAttributeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents entry point for identity userflow attributes."; // Create options for all the parameters - var identityUserFlowAttributeIdOption = new Option("--identityuserflowattribute-id", description: "key: id of identityUserFlowAttribute") { + var identityUserFlowAttributeIdOption = new Option("--identity-user-flow-attribute-id", description: "key: id of identityUserFlowAttribute") { }; identityUserFlowAttributeIdOption.IsRequired = true; command.AddOption(identityUserFlowAttributeIdOption); - command.SetHandler(async (string identityUserFlowAttributeId) => { + command.SetHandler(async (string identityUserFlowAttributeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, identityUserFlowAttributeIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents entry point for identity userflow attributes."; // Create options for all the parameters - var identityUserFlowAttributeIdOption = new Option("--identityuserflowattribute-id", description: "key: id of identityUserFlowAttribute") { + var identityUserFlowAttributeIdOption = new Option("--identity-user-flow-attribute-id", description: "key: id of identityUserFlowAttribute") { }; identityUserFlowAttributeIdOption.IsRequired = true; command.AddOption(identityUserFlowAttributeIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string identityUserFlowAttributeId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string identityUserFlowAttributeId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, identityUserFlowAttributeIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, identityUserFlowAttributeIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents entry point for identity userflow attributes."; // Create options for all the parameters - var identityUserFlowAttributeIdOption = new Option("--identityuserflowattribute-id", description: "key: id of identityUserFlowAttribute") { + var identityUserFlowAttributeIdOption = new Option("--identity-user-flow-attribute-id", description: "key: id of identityUserFlowAttribute") { }; identityUserFlowAttributeIdOption.IsRequired = true; command.AddOption(identityUserFlowAttributeIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string identityUserFlowAttributeId, string body) => { + command.SetHandler(async (string identityUserFlowAttributeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, identityUserFlowAttributeIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(IdentityUserFlowAttribut requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents entry point for identity userflow attributes. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents entry point for identity userflow attributes. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents entry point for identity userflow attributes. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(IdentityUserFlowAttribute model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents entry point for identity userflow attributes. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Identity/UserFlowAttributes/UserFlowAttributesRequestBuilder.cs b/src/generated/Identity/UserFlowAttributes/UserFlowAttributesRequestBuilder.cs index 85500e51868..fcb5b06b9a1 100644 --- a/src/generated/Identity/UserFlowAttributes/UserFlowAttributesRequestBuilder.cs +++ b/src/generated/Identity/UserFlowAttributes/UserFlowAttributesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class UserFlowAttributesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new IdentityUserFlowAttributeRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(IdentityUserFlowAttribute requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents entry point for identity userflow attributes. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents entry point for identity userflow attributes. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(IdentityUserFlowAttribute model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents entry point for identity userflow attributes. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/IdentityGovernance/AccessReviews/AccessReviewsRequestBuilder.cs b/src/generated/IdentityGovernance/AccessReviews/AccessReviewsRequestBuilder.cs index e15c0a8bcc2..48074a33fc3 100644 --- a/src/generated/IdentityGovernance/AccessReviews/AccessReviewsRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AccessReviews/AccessReviewsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,6 +23,9 @@ public class AccessReviewsRequestBuilder { public Command BuildDefinitionsCommand() { var command = new Command("definitions"); var builder = new ApiSdk.IdentityGovernance.AccessReviews.Definitions.DefinitionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -34,11 +37,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property accessReviews for identityGovernance"; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -60,20 +62,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -87,14 +88,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -166,42 +166,6 @@ public RequestInformation CreatePatchRequestInformation(AccessReviewSet body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property accessReviews for identityGovernance - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get accessReviews from identityGovernance - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property accessReviews in identityGovernance - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AccessReviewSet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get accessReviews from identityGovernance public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/AccessReviews/Definitions/DefinitionsRequestBuilder.cs b/src/generated/IdentityGovernance/AccessReviews/Definitions/DefinitionsRequestBuilder.cs index 9fbafd82ff6..e2ed6302629 100644 --- a/src/generated/IdentityGovernance/AccessReviews/Definitions/DefinitionsRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AccessReviews/Definitions/DefinitionsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,13 +23,12 @@ public class DefinitionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AccessReviewScheduleDefinitionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildInstancesCommand(), - builder.BuildPatchCommand(), - builder.BuildStopCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInstancesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildStopCommand()); return commands; } /// @@ -43,21 +42,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -102,7 +100,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -113,15 +115,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -184,31 +181,6 @@ public FilterByCurrentUserWithOnRequestBuilder FilterByCurrentUserWithOn(string if(string.IsNullOrEmpty(on)) throw new ArgumentNullException(nameof(on)); return new FilterByCurrentUserWithOnRequestBuilder(PathParameters, RequestAdapter, on); } - /// - /// Represents the template and scheduling for an access review. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the template and scheduling for an access review. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AccessReviewScheduleDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the template and scheduling for an access review. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/IdentityGovernance/AccessReviews/Definitions/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs b/src/generated/IdentityGovernance/AccessReviews/Definitions/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs index 6de38421c92..5561e75b2e7 100644 --- a/src/generated/IdentityGovernance/AccessReviews/Definitions/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AccessReviews/Definitions/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +29,17 @@ public Command BuildGetCommand() { }; onOption.IsRequired = true; command.AddOption(onOption); - command.SetHandler(async (object on) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (object on, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onOption, outputOption); return command; } /// @@ -73,16 +72,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function filterByCurrentUser - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/AccessReviewScheduleDefinitionRequestBuilder.cs b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/AccessReviewScheduleDefinitionRequestBuilder.cs index 1831a22cc47..756079934f4 100644 --- a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/AccessReviewScheduleDefinitionRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/AccessReviewScheduleDefinitionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,15 +28,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the template and scheduling for an access review."; // Create options for all the parameters - var accessReviewScheduleDefinitionIdOption = new Option("--accessreviewscheduledefinition-id", description: "key: id of accessReviewScheduleDefinition") { + var accessReviewScheduleDefinitionIdOption = new Option("--access-review-schedule-definition-id", description: "key: id of accessReviewScheduleDefinition") { }; accessReviewScheduleDefinitionIdOption.IsRequired = true; command.AddOption(accessReviewScheduleDefinitionIdOption); - command.SetHandler(async (string accessReviewScheduleDefinitionId) => { + command.SetHandler(async (string accessReviewScheduleDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, accessReviewScheduleDefinitionIdOption); return command; @@ -48,7 +47,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the template and scheduling for an access review."; // Create options for all the parameters - var accessReviewScheduleDefinitionIdOption = new Option("--accessreviewscheduledefinition-id", description: "key: id of accessReviewScheduleDefinition") { + var accessReviewScheduleDefinitionIdOption = new Option("--access-review-schedule-definition-id", description: "key: id of accessReviewScheduleDefinition") { }; accessReviewScheduleDefinitionIdOption.IsRequired = true; command.AddOption(accessReviewScheduleDefinitionIdOption); @@ -62,25 +61,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string accessReviewScheduleDefinitionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessReviewScheduleDefinitionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessReviewScheduleDefinitionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessReviewScheduleDefinitionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildInstancesCommand() { var command = new Command("instances"); var builder = new ApiSdk.IdentityGovernance.AccessReviews.Definitions.Item.Instances.InstancesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -92,7 +93,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the template and scheduling for an access review."; // Create options for all the parameters - var accessReviewScheduleDefinitionIdOption = new Option("--accessreviewscheduledefinition-id", description: "key: id of accessReviewScheduleDefinition") { + var accessReviewScheduleDefinitionIdOption = new Option("--access-review-schedule-definition-id", description: "key: id of accessReviewScheduleDefinition") { }; accessReviewScheduleDefinitionIdOption.IsRequired = true; command.AddOption(accessReviewScheduleDefinitionIdOption); @@ -100,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string accessReviewScheduleDefinitionId, string body) => { + command.SetHandler(async (string accessReviewScheduleDefinitionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, accessReviewScheduleDefinitionIdOption, bodyOption); return command; @@ -185,42 +185,6 @@ public RequestInformation CreatePatchRequestInformation(AccessReviewScheduleDefi requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the template and scheduling for an access review. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the template and scheduling for an access review. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the template and scheduling for an access review. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AccessReviewScheduleDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the template and scheduling for an access review. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs index e804337932b..ccaa5b7e619 100644 --- a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function filterByCurrentUser"; // Create options for all the parameters - var accessReviewScheduleDefinitionIdOption = new Option("--accessreviewscheduledefinition-id", description: "key: id of accessReviewScheduleDefinition") { + var accessReviewScheduleDefinitionIdOption = new Option("--access-review-schedule-definition-id", description: "key: id of accessReviewScheduleDefinition") { }; accessReviewScheduleDefinitionIdOption.IsRequired = true; command.AddOption(accessReviewScheduleDefinitionIdOption); @@ -33,18 +33,17 @@ public Command BuildGetCommand() { }; onOption.IsRequired = true; command.AddOption(onOption); - command.SetHandler(async (string accessReviewScheduleDefinitionId, object on) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessReviewScheduleDefinitionId, object on, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessReviewScheduleDefinitionIdOption, onOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessReviewScheduleDefinitionIdOption, onOption, outputOption); return command; } /// @@ -77,16 +76,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function filterByCurrentUser - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/InstancesRequestBuilder.cs b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/InstancesRequestBuilder.cs index fdb1a235512..f7a86bf6c2d 100644 --- a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/InstancesRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/InstancesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,19 +23,18 @@ public class InstancesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AccessReviewInstanceRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptRecommendationsCommand(), - builder.BuildApplyDecisionsCommand(), - builder.BuildBatchRecordDecisionsCommand(), - builder.BuildContactedReviewersCommand(), - builder.BuildDecisionsCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildResetDecisionsCommand(), - builder.BuildSendReminderCommand(), - builder.BuildStopCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptRecommendationsCommand()); + commands.Add(builder.BuildApplyDecisionsCommand()); + commands.Add(builder.BuildBatchRecordDecisionsCommand()); + commands.Add(builder.BuildContactedReviewersCommand()); + commands.Add(builder.BuildDecisionsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildResetDecisionsCommand()); + commands.Add(builder.BuildSendReminderCommand()); + commands.Add(builder.BuildStopCommand()); return commands; } /// @@ -45,7 +44,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Set of access reviews instances for this access review series. Access reviews that do not recur will only have one instance; otherwise, there is an instance for each recurrence."; // Create options for all the parameters - var accessReviewScheduleDefinitionIdOption = new Option("--accessreviewscheduledefinition-id", description: "key: id of accessReviewScheduleDefinition") { + var accessReviewScheduleDefinitionIdOption = new Option("--access-review-schedule-definition-id", description: "key: id of accessReviewScheduleDefinition") { }; accessReviewScheduleDefinitionIdOption.IsRequired = true; command.AddOption(accessReviewScheduleDefinitionIdOption); @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string accessReviewScheduleDefinitionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessReviewScheduleDefinitionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessReviewScheduleDefinitionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessReviewScheduleDefinitionIdOption, bodyOption, outputOption); return command; } /// @@ -77,7 +75,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Set of access reviews instances for this access review series. Access reviews that do not recur will only have one instance; otherwise, there is an instance for each recurrence."; // Create options for all the parameters - var accessReviewScheduleDefinitionIdOption = new Option("--accessreviewscheduledefinition-id", description: "key: id of accessReviewScheduleDefinition") { + var accessReviewScheduleDefinitionIdOption = new Option("--access-review-schedule-definition-id", description: "key: id of accessReviewScheduleDefinition") { }; accessReviewScheduleDefinitionIdOption.IsRequired = true; command.AddOption(accessReviewScheduleDefinitionIdOption); @@ -116,7 +114,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string accessReviewScheduleDefinitionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessReviewScheduleDefinitionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -127,15 +129,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessReviewScheduleDefinitionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessReviewScheduleDefinitionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -198,31 +195,6 @@ public FilterByCurrentUserWithOnRequestBuilder FilterByCurrentUserWithOn(string if(string.IsNullOrEmpty(on)) throw new ArgumentNullException(nameof(on)); return new FilterByCurrentUserWithOnRequestBuilder(PathParameters, RequestAdapter, on); } - /// - /// Set of access reviews instances for this access review series. Access reviews that do not recur will only have one instance; otherwise, there is an instance for each recurrence. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Set of access reviews instances for this access review series. Access reviews that do not recur will only have one instance; otherwise, there is an instance for each recurrence. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AccessReviewInstance model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Set of access reviews instances for this access review series. Access reviews that do not recur will only have one instance; otherwise, there is an instance for each recurrence. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/AcceptRecommendations/AcceptRecommendationsRequestBuilder.cs b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/AcceptRecommendations/AcceptRecommendationsRequestBuilder.cs index 9033335bee0..df64193fc43 100644 --- a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/AcceptRecommendations/AcceptRecommendationsRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/AcceptRecommendations/AcceptRecommendationsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,18 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action acceptRecommendations"; // Create options for all the parameters - var accessReviewScheduleDefinitionIdOption = new Option("--accessreviewscheduledefinition-id", description: "key: id of accessReviewScheduleDefinition") { + var accessReviewScheduleDefinitionIdOption = new Option("--access-review-schedule-definition-id", description: "key: id of accessReviewScheduleDefinition") { }; accessReviewScheduleDefinitionIdOption.IsRequired = true; command.AddOption(accessReviewScheduleDefinitionIdOption); - var accessReviewInstanceIdOption = new Option("--accessreviewinstance-id", description: "key: id of accessReviewInstance") { + var accessReviewInstanceIdOption = new Option("--access-review-instance-id", description: "key: id of accessReviewInstance") { }; accessReviewInstanceIdOption.IsRequired = true; command.AddOption(accessReviewInstanceIdOption); - command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId) => { + command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action acceptRecommendations - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/AccessReviewInstanceRequestBuilder.cs b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/AccessReviewInstanceRequestBuilder.cs index 71430afcbbf..c90e84cba78 100644 --- a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/AccessReviewInstanceRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/AccessReviewInstanceRequestBuilder.cs @@ -9,10 +9,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -48,6 +48,9 @@ public Command BuildBatchRecordDecisionsCommand() { public Command BuildContactedReviewersCommand() { var command = new Command("contacted-reviewers"); var builder = new ApiSdk.IdentityGovernance.AccessReviews.Definitions.Item.Instances.Item.ContactedReviewers.ContactedReviewersRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -55,6 +58,9 @@ public Command BuildContactedReviewersCommand() { public Command BuildDecisionsCommand() { var command = new Command("decisions"); var builder = new ApiSdk.IdentityGovernance.AccessReviews.Definitions.Item.Instances.Item.Decisions.DecisionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -66,19 +72,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Set of access reviews instances for this access review series. Access reviews that do not recur will only have one instance; otherwise, there is an instance for each recurrence."; // Create options for all the parameters - var accessReviewScheduleDefinitionIdOption = new Option("--accessreviewscheduledefinition-id", description: "key: id of accessReviewScheduleDefinition") { + var accessReviewScheduleDefinitionIdOption = new Option("--access-review-schedule-definition-id", description: "key: id of accessReviewScheduleDefinition") { }; accessReviewScheduleDefinitionIdOption.IsRequired = true; command.AddOption(accessReviewScheduleDefinitionIdOption); - var accessReviewInstanceIdOption = new Option("--accessreviewinstance-id", description: "key: id of accessReviewInstance") { + var accessReviewInstanceIdOption = new Option("--access-review-instance-id", description: "key: id of accessReviewInstance") { }; accessReviewInstanceIdOption.IsRequired = true; command.AddOption(accessReviewInstanceIdOption); - command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId) => { + command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption); return command; @@ -90,11 +95,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Set of access reviews instances for this access review series. Access reviews that do not recur will only have one instance; otherwise, there is an instance for each recurrence."; // Create options for all the parameters - var accessReviewScheduleDefinitionIdOption = new Option("--accessreviewscheduledefinition-id", description: "key: id of accessReviewScheduleDefinition") { + var accessReviewScheduleDefinitionIdOption = new Option("--access-review-schedule-definition-id", description: "key: id of accessReviewScheduleDefinition") { }; accessReviewScheduleDefinitionIdOption.IsRequired = true; command.AddOption(accessReviewScheduleDefinitionIdOption); - var accessReviewInstanceIdOption = new Option("--accessreviewinstance-id", description: "key: id of accessReviewInstance") { + var accessReviewInstanceIdOption = new Option("--access-review-instance-id", description: "key: id of accessReviewInstance") { }; accessReviewInstanceIdOption.IsRequired = true; command.AddOption(accessReviewInstanceIdOption); @@ -108,20 +113,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -131,11 +135,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Set of access reviews instances for this access review series. Access reviews that do not recur will only have one instance; otherwise, there is an instance for each recurrence."; // Create options for all the parameters - var accessReviewScheduleDefinitionIdOption = new Option("--accessreviewscheduledefinition-id", description: "key: id of accessReviewScheduleDefinition") { + var accessReviewScheduleDefinitionIdOption = new Option("--access-review-schedule-definition-id", description: "key: id of accessReviewScheduleDefinition") { }; accessReviewScheduleDefinitionIdOption.IsRequired = true; command.AddOption(accessReviewScheduleDefinitionIdOption); - var accessReviewInstanceIdOption = new Option("--accessreviewinstance-id", description: "key: id of accessReviewInstance") { + var accessReviewInstanceIdOption = new Option("--access-review-instance-id", description: "key: id of accessReviewInstance") { }; accessReviewInstanceIdOption.IsRequired = true; command.AddOption(accessReviewInstanceIdOption); @@ -143,14 +147,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, string body) => { + command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption, bodyOption); return command; @@ -240,42 +243,6 @@ public RequestInformation CreatePatchRequestInformation(AccessReviewInstance bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Set of access reviews instances for this access review series. Access reviews that do not recur will only have one instance; otherwise, there is an instance for each recurrence. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Set of access reviews instances for this access review series. Access reviews that do not recur will only have one instance; otherwise, there is an instance for each recurrence. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Set of access reviews instances for this access review series. Access reviews that do not recur will only have one instance; otherwise, there is an instance for each recurrence. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AccessReviewInstance model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Set of access reviews instances for this access review series. Access reviews that do not recur will only have one instance; otherwise, there is an instance for each recurrence. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/ApplyDecisions/ApplyDecisionsRequestBuilder.cs b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/ApplyDecisions/ApplyDecisionsRequestBuilder.cs index 027dc3c3f0a..2eaa6a9b9ff 100644 --- a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/ApplyDecisions/ApplyDecisionsRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/ApplyDecisions/ApplyDecisionsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,18 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyDecisions"; // Create options for all the parameters - var accessReviewScheduleDefinitionIdOption = new Option("--accessreviewscheduledefinition-id", description: "key: id of accessReviewScheduleDefinition") { + var accessReviewScheduleDefinitionIdOption = new Option("--access-review-schedule-definition-id", description: "key: id of accessReviewScheduleDefinition") { }; accessReviewScheduleDefinitionIdOption.IsRequired = true; command.AddOption(accessReviewScheduleDefinitionIdOption); - var accessReviewInstanceIdOption = new Option("--accessreviewinstance-id", description: "key: id of accessReviewInstance") { + var accessReviewInstanceIdOption = new Option("--access-review-instance-id", description: "key: id of accessReviewInstance") { }; accessReviewInstanceIdOption.IsRequired = true; command.AddOption(accessReviewInstanceIdOption); - command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId) => { + command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action applyDecisions - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/BatchRecordDecisions/BatchRecordDecisionsRequestBuilder.cs b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/BatchRecordDecisions/BatchRecordDecisionsRequestBuilder.cs index eff7ece2645..74dddc58160 100644 --- a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/BatchRecordDecisions/BatchRecordDecisionsRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/BatchRecordDecisions/BatchRecordDecisionsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,11 +25,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action batchRecordDecisions"; // Create options for all the parameters - var accessReviewScheduleDefinitionIdOption = new Option("--accessreviewscheduledefinition-id", description: "key: id of accessReviewScheduleDefinition") { + var accessReviewScheduleDefinitionIdOption = new Option("--access-review-schedule-definition-id", description: "key: id of accessReviewScheduleDefinition") { }; accessReviewScheduleDefinitionIdOption.IsRequired = true; command.AddOption(accessReviewScheduleDefinitionIdOption); - var accessReviewInstanceIdOption = new Option("--accessreviewinstance-id", description: "key: id of accessReviewInstance") { + var accessReviewInstanceIdOption = new Option("--access-review-instance-id", description: "key: id of accessReviewInstance") { }; accessReviewInstanceIdOption.IsRequired = true; command.AddOption(accessReviewInstanceIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, string body) => { + command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(BatchRecordDecisionsReque requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action batchRecordDecisions - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(BatchRecordDecisionsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/ContactedReviewers/ContactedReviewersRequestBuilder.cs b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/ContactedReviewers/ContactedReviewersRequestBuilder.cs index 7f7fabc2f14..12fe335067f 100644 --- a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/ContactedReviewers/ContactedReviewersRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/ContactedReviewers/ContactedReviewersRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ContactedReviewersRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AccessReviewReviewerRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,11 +35,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Returns the collection of reviewers who were contacted to complete this review. While the reviewers and fallbackReviewers properties of the accessReviewScheduleDefinition might specify group owners or managers as reviewers, contactedReviewers returns their individual identities. Supports $select. Read-only."; // Create options for all the parameters - var accessReviewScheduleDefinitionIdOption = new Option("--accessreviewscheduledefinition-id", description: "key: id of accessReviewScheduleDefinition") { + var accessReviewScheduleDefinitionIdOption = new Option("--access-review-schedule-definition-id", description: "key: id of accessReviewScheduleDefinition") { }; accessReviewScheduleDefinitionIdOption.IsRequired = true; command.AddOption(accessReviewScheduleDefinitionIdOption); - var accessReviewInstanceIdOption = new Option("--accessreviewinstance-id", description: "key: id of accessReviewInstance") { + var accessReviewInstanceIdOption = new Option("--access-review-instance-id", description: "key: id of accessReviewInstance") { }; accessReviewInstanceIdOption.IsRequired = true; command.AddOption(accessReviewInstanceIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption, bodyOption, outputOption); return command; } /// @@ -72,11 +70,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Returns the collection of reviewers who were contacted to complete this review. While the reviewers and fallbackReviewers properties of the accessReviewScheduleDefinition might specify group owners or managers as reviewers, contactedReviewers returns their individual identities. Supports $select. Read-only."; // Create options for all the parameters - var accessReviewScheduleDefinitionIdOption = new Option("--accessreviewscheduledefinition-id", description: "key: id of accessReviewScheduleDefinition") { + var accessReviewScheduleDefinitionIdOption = new Option("--access-review-schedule-definition-id", description: "key: id of accessReviewScheduleDefinition") { }; accessReviewScheduleDefinitionIdOption.IsRequired = true; command.AddOption(accessReviewScheduleDefinitionIdOption); - var accessReviewInstanceIdOption = new Option("--accessreviewinstance-id", description: "key: id of accessReviewInstance") { + var accessReviewInstanceIdOption = new Option("--access-review-instance-id", description: "key: id of accessReviewInstance") { }; accessReviewInstanceIdOption.IsRequired = true; command.AddOption(accessReviewInstanceIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(AccessReviewReviewer body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Returns the collection of reviewers who were contacted to complete this review. While the reviewers and fallbackReviewers properties of the accessReviewScheduleDefinition might specify group owners or managers as reviewers, contactedReviewers returns their individual identities. Supports $select. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns the collection of reviewers who were contacted to complete this review. While the reviewers and fallbackReviewers properties of the accessReviewScheduleDefinition might specify group owners or managers as reviewers, contactedReviewers returns their individual identities. Supports $select. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AccessReviewReviewer model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns the collection of reviewers who were contacted to complete this review. While the reviewers and fallbackReviewers properties of the accessReviewScheduleDefinition might specify group owners or managers as reviewers, contactedReviewers returns their individual identities. Supports $select. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/ContactedReviewers/Item/AccessReviewReviewerRequestBuilder.cs b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/ContactedReviewers/Item/AccessReviewReviewerRequestBuilder.cs index c8935d1f926..971f3d6148a 100644 --- a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/ContactedReviewers/Item/AccessReviewReviewerRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/ContactedReviewers/Item/AccessReviewReviewerRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns the collection of reviewers who were contacted to complete this review. While the reviewers and fallbackReviewers properties of the accessReviewScheduleDefinition might specify group owners or managers as reviewers, contactedReviewers returns their individual identities. Supports $select. Read-only."; // Create options for all the parameters - var accessReviewScheduleDefinitionIdOption = new Option("--accessreviewscheduledefinition-id", description: "key: id of accessReviewScheduleDefinition") { + var accessReviewScheduleDefinitionIdOption = new Option("--access-review-schedule-definition-id", description: "key: id of accessReviewScheduleDefinition") { }; accessReviewScheduleDefinitionIdOption.IsRequired = true; command.AddOption(accessReviewScheduleDefinitionIdOption); - var accessReviewInstanceIdOption = new Option("--accessreviewinstance-id", description: "key: id of accessReviewInstance") { + var accessReviewInstanceIdOption = new Option("--access-review-instance-id", description: "key: id of accessReviewInstance") { }; accessReviewInstanceIdOption.IsRequired = true; command.AddOption(accessReviewInstanceIdOption); - var accessReviewReviewerIdOption = new Option("--accessreviewreviewer-id", description: "key: id of accessReviewReviewer") { + var accessReviewReviewerIdOption = new Option("--access-review-reviewer-id", description: "key: id of accessReviewReviewer") { }; accessReviewReviewerIdOption.IsRequired = true; command.AddOption(accessReviewReviewerIdOption); - command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, string accessReviewReviewerId) => { + command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, string accessReviewReviewerId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption, accessReviewReviewerIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns the collection of reviewers who were contacted to complete this review. While the reviewers and fallbackReviewers properties of the accessReviewScheduleDefinition might specify group owners or managers as reviewers, contactedReviewers returns their individual identities. Supports $select. Read-only."; // Create options for all the parameters - var accessReviewScheduleDefinitionIdOption = new Option("--accessreviewscheduledefinition-id", description: "key: id of accessReviewScheduleDefinition") { + var accessReviewScheduleDefinitionIdOption = new Option("--access-review-schedule-definition-id", description: "key: id of accessReviewScheduleDefinition") { }; accessReviewScheduleDefinitionIdOption.IsRequired = true; command.AddOption(accessReviewScheduleDefinitionIdOption); - var accessReviewInstanceIdOption = new Option("--accessreviewinstance-id", description: "key: id of accessReviewInstance") { + var accessReviewInstanceIdOption = new Option("--access-review-instance-id", description: "key: id of accessReviewInstance") { }; accessReviewInstanceIdOption.IsRequired = true; command.AddOption(accessReviewInstanceIdOption); - var accessReviewReviewerIdOption = new Option("--accessreviewreviewer-id", description: "key: id of accessReviewReviewer") { + var accessReviewReviewerIdOption = new Option("--access-review-reviewer-id", description: "key: id of accessReviewReviewer") { }; accessReviewReviewerIdOption.IsRequired = true; command.AddOption(accessReviewReviewerIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, string accessReviewReviewerId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, string accessReviewReviewerId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption, accessReviewReviewerIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption, accessReviewReviewerIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns the collection of reviewers who were contacted to complete this review. While the reviewers and fallbackReviewers properties of the accessReviewScheduleDefinition might specify group owners or managers as reviewers, contactedReviewers returns their individual identities. Supports $select. Read-only."; // Create options for all the parameters - var accessReviewScheduleDefinitionIdOption = new Option("--accessreviewscheduledefinition-id", description: "key: id of accessReviewScheduleDefinition") { + var accessReviewScheduleDefinitionIdOption = new Option("--access-review-schedule-definition-id", description: "key: id of accessReviewScheduleDefinition") { }; accessReviewScheduleDefinitionIdOption.IsRequired = true; command.AddOption(accessReviewScheduleDefinitionIdOption); - var accessReviewInstanceIdOption = new Option("--accessreviewinstance-id", description: "key: id of accessReviewInstance") { + var accessReviewInstanceIdOption = new Option("--access-review-instance-id", description: "key: id of accessReviewInstance") { }; accessReviewInstanceIdOption.IsRequired = true; command.AddOption(accessReviewInstanceIdOption); - var accessReviewReviewerIdOption = new Option("--accessreviewreviewer-id", description: "key: id of accessReviewReviewer") { + var accessReviewReviewerIdOption = new Option("--access-review-reviewer-id", description: "key: id of accessReviewReviewer") { }; accessReviewReviewerIdOption.IsRequired = true; command.AddOption(accessReviewReviewerIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, string accessReviewReviewerId, string body) => { + command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, string accessReviewReviewerId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption, accessReviewReviewerIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(AccessReviewReviewer bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Returns the collection of reviewers who were contacted to complete this review. While the reviewers and fallbackReviewers properties of the accessReviewScheduleDefinition might specify group owners or managers as reviewers, contactedReviewers returns their individual identities. Supports $select. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns the collection of reviewers who were contacted to complete this review. While the reviewers and fallbackReviewers properties of the accessReviewScheduleDefinition might specify group owners or managers as reviewers, contactedReviewers returns their individual identities. Supports $select. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns the collection of reviewers who were contacted to complete this review. While the reviewers and fallbackReviewers properties of the accessReviewScheduleDefinition might specify group owners or managers as reviewers, contactedReviewers returns their individual identities. Supports $select. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AccessReviewReviewer model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns the collection of reviewers who were contacted to complete this review. While the reviewers and fallbackReviewers properties of the accessReviewScheduleDefinition might specify group owners or managers as reviewers, contactedReviewers returns their individual identities. Supports $select. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/Decisions/DecisionsRequestBuilder.cs b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/Decisions/DecisionsRequestBuilder.cs index e110c034626..c3548fca695 100644 --- a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/Decisions/DecisionsRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/Decisions/DecisionsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class DecisionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AccessReviewInstanceDecisionItemRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -37,11 +36,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Each user reviewed in an accessReviewInstance has a decision item representing if they were approved, denied, or not yet reviewed."; // Create options for all the parameters - var accessReviewScheduleDefinitionIdOption = new Option("--accessreviewscheduledefinition-id", description: "key: id of accessReviewScheduleDefinition") { + var accessReviewScheduleDefinitionIdOption = new Option("--access-review-schedule-definition-id", description: "key: id of accessReviewScheduleDefinition") { }; accessReviewScheduleDefinitionIdOption.IsRequired = true; command.AddOption(accessReviewScheduleDefinitionIdOption); - var accessReviewInstanceIdOption = new Option("--accessreviewinstance-id", description: "key: id of accessReviewInstance") { + var accessReviewInstanceIdOption = new Option("--access-review-instance-id", description: "key: id of accessReviewInstance") { }; accessReviewInstanceIdOption.IsRequired = true; command.AddOption(accessReviewInstanceIdOption); @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption, bodyOption, outputOption); return command; } /// @@ -73,11 +71,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Each user reviewed in an accessReviewInstance has a decision item representing if they were approved, denied, or not yet reviewed."; // Create options for all the parameters - var accessReviewScheduleDefinitionIdOption = new Option("--accessreviewscheduledefinition-id", description: "key: id of accessReviewScheduleDefinition") { + var accessReviewScheduleDefinitionIdOption = new Option("--access-review-schedule-definition-id", description: "key: id of accessReviewScheduleDefinition") { }; accessReviewScheduleDefinitionIdOption.IsRequired = true; command.AddOption(accessReviewScheduleDefinitionIdOption); - var accessReviewInstanceIdOption = new Option("--accessreviewinstance-id", description: "key: id of accessReviewInstance") { + var accessReviewInstanceIdOption = new Option("--access-review-instance-id", description: "key: id of accessReviewInstance") { }; accessReviewInstanceIdOption.IsRequired = true; command.AddOption(accessReviewInstanceIdOption); @@ -116,7 +114,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -127,15 +129,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -198,31 +195,6 @@ public FilterByCurrentUserWithOnRequestBuilder FilterByCurrentUserWithOn(string if(string.IsNullOrEmpty(on)) throw new ArgumentNullException(nameof(on)); return new FilterByCurrentUserWithOnRequestBuilder(PathParameters, RequestAdapter, on); } - /// - /// Each user reviewed in an accessReviewInstance has a decision item representing if they were approved, denied, or not yet reviewed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Each user reviewed in an accessReviewInstance has a decision item representing if they were approved, denied, or not yet reviewed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AccessReviewInstanceDecisionItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Each user reviewed in an accessReviewInstance has a decision item representing if they were approved, denied, or not yet reviewed. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/Decisions/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/Decisions/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs index 64277290420..ca9b1943b81 100644 --- a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/Decisions/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/Decisions/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,11 +25,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function filterByCurrentUser"; // Create options for all the parameters - var accessReviewScheduleDefinitionIdOption = new Option("--accessreviewscheduledefinition-id", description: "key: id of accessReviewScheduleDefinition") { + var accessReviewScheduleDefinitionIdOption = new Option("--access-review-schedule-definition-id", description: "key: id of accessReviewScheduleDefinition") { }; accessReviewScheduleDefinitionIdOption.IsRequired = true; command.AddOption(accessReviewScheduleDefinitionIdOption); - var accessReviewInstanceIdOption = new Option("--accessreviewinstance-id", description: "key: id of accessReviewInstance") { + var accessReviewInstanceIdOption = new Option("--access-review-instance-id", description: "key: id of accessReviewInstance") { }; accessReviewInstanceIdOption.IsRequired = true; command.AddOption(accessReviewInstanceIdOption); @@ -37,18 +37,17 @@ public Command BuildGetCommand() { }; onOption.IsRequired = true; command.AddOption(onOption); - command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, object on) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, object on, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption, onOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption, onOption, outputOption); return command; } /// @@ -81,16 +80,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function filterByCurrentUser - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/Decisions/Item/AccessReviewInstanceDecisionItemRequestBuilder.cs b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/Decisions/Item/AccessReviewInstanceDecisionItemRequestBuilder.cs index 4cf7694c94b..f8d70752251 100644 --- a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/Decisions/Item/AccessReviewInstanceDecisionItemRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/Decisions/Item/AccessReviewInstanceDecisionItemRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Each user reviewed in an accessReviewInstance has a decision item representing if they were approved, denied, or not yet reviewed."; // Create options for all the parameters - var accessReviewScheduleDefinitionIdOption = new Option("--accessreviewscheduledefinition-id", description: "key: id of accessReviewScheduleDefinition") { + var accessReviewScheduleDefinitionIdOption = new Option("--access-review-schedule-definition-id", description: "key: id of accessReviewScheduleDefinition") { }; accessReviewScheduleDefinitionIdOption.IsRequired = true; command.AddOption(accessReviewScheduleDefinitionIdOption); - var accessReviewInstanceIdOption = new Option("--accessreviewinstance-id", description: "key: id of accessReviewInstance") { + var accessReviewInstanceIdOption = new Option("--access-review-instance-id", description: "key: id of accessReviewInstance") { }; accessReviewInstanceIdOption.IsRequired = true; command.AddOption(accessReviewInstanceIdOption); - var accessReviewInstanceDecisionItemIdOption = new Option("--accessreviewinstancedecisionitem-id", description: "key: id of accessReviewInstanceDecisionItem") { + var accessReviewInstanceDecisionItemIdOption = new Option("--access-review-instance-decision-item-id", description: "key: id of accessReviewInstanceDecisionItem") { }; accessReviewInstanceDecisionItemIdOption.IsRequired = true; command.AddOption(accessReviewInstanceDecisionItemIdOption); - command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, string accessReviewInstanceDecisionItemId) => { + command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, string accessReviewInstanceDecisionItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption, accessReviewInstanceDecisionItemIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Each user reviewed in an accessReviewInstance has a decision item representing if they were approved, denied, or not yet reviewed."; // Create options for all the parameters - var accessReviewScheduleDefinitionIdOption = new Option("--accessreviewscheduledefinition-id", description: "key: id of accessReviewScheduleDefinition") { + var accessReviewScheduleDefinitionIdOption = new Option("--access-review-schedule-definition-id", description: "key: id of accessReviewScheduleDefinition") { }; accessReviewScheduleDefinitionIdOption.IsRequired = true; command.AddOption(accessReviewScheduleDefinitionIdOption); - var accessReviewInstanceIdOption = new Option("--accessreviewinstance-id", description: "key: id of accessReviewInstance") { + var accessReviewInstanceIdOption = new Option("--access-review-instance-id", description: "key: id of accessReviewInstance") { }; accessReviewInstanceIdOption.IsRequired = true; command.AddOption(accessReviewInstanceIdOption); - var accessReviewInstanceDecisionItemIdOption = new Option("--accessreviewinstancedecisionitem-id", description: "key: id of accessReviewInstanceDecisionItem") { + var accessReviewInstanceDecisionItemIdOption = new Option("--access-review-instance-decision-item-id", description: "key: id of accessReviewInstanceDecisionItem") { }; accessReviewInstanceDecisionItemIdOption.IsRequired = true; command.AddOption(accessReviewInstanceDecisionItemIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, string accessReviewInstanceDecisionItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, string accessReviewInstanceDecisionItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption, accessReviewInstanceDecisionItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption, accessReviewInstanceDecisionItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Each user reviewed in an accessReviewInstance has a decision item representing if they were approved, denied, or not yet reviewed."; // Create options for all the parameters - var accessReviewScheduleDefinitionIdOption = new Option("--accessreviewscheduledefinition-id", description: "key: id of accessReviewScheduleDefinition") { + var accessReviewScheduleDefinitionIdOption = new Option("--access-review-schedule-definition-id", description: "key: id of accessReviewScheduleDefinition") { }; accessReviewScheduleDefinitionIdOption.IsRequired = true; command.AddOption(accessReviewScheduleDefinitionIdOption); - var accessReviewInstanceIdOption = new Option("--accessreviewinstance-id", description: "key: id of accessReviewInstance") { + var accessReviewInstanceIdOption = new Option("--access-review-instance-id", description: "key: id of accessReviewInstance") { }; accessReviewInstanceIdOption.IsRequired = true; command.AddOption(accessReviewInstanceIdOption); - var accessReviewInstanceDecisionItemIdOption = new Option("--accessreviewinstancedecisionitem-id", description: "key: id of accessReviewInstanceDecisionItem") { + var accessReviewInstanceDecisionItemIdOption = new Option("--access-review-instance-decision-item-id", description: "key: id of accessReviewInstanceDecisionItem") { }; accessReviewInstanceDecisionItemIdOption.IsRequired = true; command.AddOption(accessReviewInstanceDecisionItemIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, string accessReviewInstanceDecisionItemId, string body) => { + command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, string accessReviewInstanceDecisionItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption, accessReviewInstanceDecisionItemIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(AccessReviewInstanceDeci requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Each user reviewed in an accessReviewInstance has a decision item representing if they were approved, denied, or not yet reviewed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Each user reviewed in an accessReviewInstance has a decision item representing if they were approved, denied, or not yet reviewed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Each user reviewed in an accessReviewInstance has a decision item representing if they were approved, denied, or not yet reviewed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AccessReviewInstanceDecisionItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Each user reviewed in an accessReviewInstance has a decision item representing if they were approved, denied, or not yet reviewed. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/ResetDecisions/ResetDecisionsRequestBuilder.cs b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/ResetDecisions/ResetDecisionsRequestBuilder.cs index f181fed3a99..8d1b74a16ad 100644 --- a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/ResetDecisions/ResetDecisionsRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/ResetDecisions/ResetDecisionsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,18 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action resetDecisions"; // Create options for all the parameters - var accessReviewScheduleDefinitionIdOption = new Option("--accessreviewscheduledefinition-id", description: "key: id of accessReviewScheduleDefinition") { + var accessReviewScheduleDefinitionIdOption = new Option("--access-review-schedule-definition-id", description: "key: id of accessReviewScheduleDefinition") { }; accessReviewScheduleDefinitionIdOption.IsRequired = true; command.AddOption(accessReviewScheduleDefinitionIdOption); - var accessReviewInstanceIdOption = new Option("--accessreviewinstance-id", description: "key: id of accessReviewInstance") { + var accessReviewInstanceIdOption = new Option("--access-review-instance-id", description: "key: id of accessReviewInstance") { }; accessReviewInstanceIdOption.IsRequired = true; command.AddOption(accessReviewInstanceIdOption); - command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId) => { + command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action resetDecisions - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/SendReminder/SendReminderRequestBuilder.cs b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/SendReminder/SendReminderRequestBuilder.cs index 135d986b54b..daf8f919bd3 100644 --- a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/SendReminder/SendReminderRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/SendReminder/SendReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,18 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action sendReminder"; // Create options for all the parameters - var accessReviewScheduleDefinitionIdOption = new Option("--accessreviewscheduledefinition-id", description: "key: id of accessReviewScheduleDefinition") { + var accessReviewScheduleDefinitionIdOption = new Option("--access-review-schedule-definition-id", description: "key: id of accessReviewScheduleDefinition") { }; accessReviewScheduleDefinitionIdOption.IsRequired = true; command.AddOption(accessReviewScheduleDefinitionIdOption); - var accessReviewInstanceIdOption = new Option("--accessreviewinstance-id", description: "key: id of accessReviewInstance") { + var accessReviewInstanceIdOption = new Option("--access-review-instance-id", description: "key: id of accessReviewInstance") { }; accessReviewInstanceIdOption.IsRequired = true; command.AddOption(accessReviewInstanceIdOption); - command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId) => { + command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action sendReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/Stop/StopRequestBuilder.cs b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/Stop/StopRequestBuilder.cs index bcb42f105be..c99d5150a02 100644 --- a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/Stop/StopRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Instances/Item/Stop/StopRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,18 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action stop"; // Create options for all the parameters - var accessReviewScheduleDefinitionIdOption = new Option("--accessreviewscheduledefinition-id", description: "key: id of accessReviewScheduleDefinition") { + var accessReviewScheduleDefinitionIdOption = new Option("--access-review-schedule-definition-id", description: "key: id of accessReviewScheduleDefinition") { }; accessReviewScheduleDefinitionIdOption.IsRequired = true; command.AddOption(accessReviewScheduleDefinitionIdOption); - var accessReviewInstanceIdOption = new Option("--accessreviewinstance-id", description: "key: id of accessReviewInstance") { + var accessReviewInstanceIdOption = new Option("--access-review-instance-id", description: "key: id of accessReviewInstance") { }; accessReviewInstanceIdOption.IsRequired = true; command.AddOption(accessReviewInstanceIdOption); - command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId) => { + command.SetHandler(async (string accessReviewScheduleDefinitionId, string accessReviewInstanceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, accessReviewScheduleDefinitionIdOption, accessReviewInstanceIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action stop - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Stop/StopRequestBuilder.cs b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Stop/StopRequestBuilder.cs index 523a7c8a004..3b6c71ee270 100644 --- a/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Stop/StopRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AccessReviews/Definitions/Item/Stop/StopRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action stop"; // Create options for all the parameters - var accessReviewScheduleDefinitionIdOption = new Option("--accessreviewscheduledefinition-id", description: "key: id of accessReviewScheduleDefinition") { + var accessReviewScheduleDefinitionIdOption = new Option("--access-review-schedule-definition-id", description: "key: id of accessReviewScheduleDefinition") { }; accessReviewScheduleDefinitionIdOption.IsRequired = true; command.AddOption(accessReviewScheduleDefinitionIdOption); - command.SetHandler(async (string accessReviewScheduleDefinitionId) => { + command.SetHandler(async (string accessReviewScheduleDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, accessReviewScheduleDefinitionIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action stop - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/IdentityGovernance/AppConsent/AppConsentRequestBuilder.cs b/src/generated/IdentityGovernance/AppConsent/AppConsentRequestBuilder.cs index d5877eb9284..d2e463e22f2 100644 --- a/src/generated/IdentityGovernance/AppConsent/AppConsentRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AppConsent/AppConsentRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,6 +23,9 @@ public class AppConsentRequestBuilder { public Command BuildAppConsentRequestsCommand() { var command = new Command("app-consent-requests"); var builder = new ApiSdk.IdentityGovernance.AppConsent.AppConsentRequests.AppConsentRequestsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -34,11 +37,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property appConsent for identityGovernance"; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -60,20 +62,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -87,14 +88,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -166,42 +166,6 @@ public RequestInformation CreatePatchRequestInformation(AppConsentApprovalRoute requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property appConsent for identityGovernance - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get appConsent from identityGovernance - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property appConsent in identityGovernance - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AppConsentApprovalRoute model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get appConsent from identityGovernance public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/AppConsentRequestsRequestBuilder.cs b/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/AppConsentRequestsRequestBuilder.cs index 74afcd17d33..7e1f1c1cda3 100644 --- a/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/AppConsentRequestsRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/AppConsentRequestsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,12 +23,11 @@ public class AppConsentRequestsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AppConsentRequestRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildUserConsentRequestsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildUserConsentRequestsCommand()); return commands; } /// @@ -42,21 +41,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -101,7 +99,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -112,15 +114,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -183,31 +180,6 @@ public FilterByCurrentUserWithOnRequestBuilder FilterByCurrentUserWithOn(string if(string.IsNullOrEmpty(on)) throw new ArgumentNullException(nameof(on)); return new FilterByCurrentUserWithOnRequestBuilder(PathParameters, RequestAdapter, on); } - /// - /// A collection of userConsentRequest objects for a specific application. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of userConsentRequest objects for a specific application. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AppConsentRequest model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of userConsentRequest objects for a specific application. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs b/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs index 071c89ad9dd..80be565df26 100644 --- a/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +29,17 @@ public Command BuildGetCommand() { }; onOption.IsRequired = true; command.AddOption(onOption); - command.SetHandler(async (object on) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (object on, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onOption, outputOption); return command; } /// @@ -73,16 +72,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function filterByCurrentUser - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/AppConsentRequestRequestBuilder.cs b/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/AppConsentRequestRequestBuilder.cs index 798caff8213..8d51283ef5f 100644 --- a/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/AppConsentRequestRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/AppConsentRequestRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,15 +27,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "A collection of userConsentRequest objects for a specific application."; // Create options for all the parameters - var appConsentRequestIdOption = new Option("--appconsentrequest-id", description: "key: id of appConsentRequest") { + var appConsentRequestIdOption = new Option("--app-consent-request-id", description: "key: id of appConsentRequest") { }; appConsentRequestIdOption.IsRequired = true; command.AddOption(appConsentRequestIdOption); - command.SetHandler(async (string appConsentRequestId) => { + command.SetHandler(async (string appConsentRequestId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, appConsentRequestIdOption); return command; @@ -47,7 +46,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "A collection of userConsentRequest objects for a specific application."; // Create options for all the parameters - var appConsentRequestIdOption = new Option("--appconsentrequest-id", description: "key: id of appConsentRequest") { + var appConsentRequestIdOption = new Option("--app-consent-request-id", description: "key: id of appConsentRequest") { }; appConsentRequestIdOption.IsRequired = true; command.AddOption(appConsentRequestIdOption); @@ -61,20 +60,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string appConsentRequestId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string appConsentRequestId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, appConsentRequestIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, appConsentRequestIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "A collection of userConsentRequest objects for a specific application."; // Create options for all the parameters - var appConsentRequestIdOption = new Option("--appconsentrequest-id", description: "key: id of appConsentRequest") { + var appConsentRequestIdOption = new Option("--app-consent-request-id", description: "key: id of appConsentRequest") { }; appConsentRequestIdOption.IsRequired = true; command.AddOption(appConsentRequestIdOption); @@ -92,14 +90,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string appConsentRequestId, string body) => { + command.SetHandler(async (string appConsentRequestId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, appConsentRequestIdOption, bodyOption); return command; @@ -107,6 +104,9 @@ public Command BuildPatchCommand() { public Command BuildUserConsentRequestsCommand() { var command = new Command("user-consent-requests"); var builder = new ApiSdk.IdentityGovernance.AppConsent.AppConsentRequests.Item.UserConsentRequests.UserConsentRequestsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -178,42 +178,6 @@ public RequestInformation CreatePatchRequestInformation(AppConsentRequest body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of userConsentRequest objects for a specific application. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of userConsentRequest objects for a specific application. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of userConsentRequest objects for a specific application. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AppConsentRequest model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of userConsentRequest objects for a specific application. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/UserConsentRequests/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs b/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/UserConsentRequests/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs index 5b93786f9d7..4cbbef8504a 100644 --- a/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/UserConsentRequests/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/UserConsentRequests/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function filterByCurrentUser"; // Create options for all the parameters - var appConsentRequestIdOption = new Option("--appconsentrequest-id", description: "key: id of appConsentRequest") { + var appConsentRequestIdOption = new Option("--app-consent-request-id", description: "key: id of appConsentRequest") { }; appConsentRequestIdOption.IsRequired = true; command.AddOption(appConsentRequestIdOption); @@ -33,18 +33,17 @@ public Command BuildGetCommand() { }; onOption.IsRequired = true; command.AddOption(onOption); - command.SetHandler(async (string appConsentRequestId, object on) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string appConsentRequestId, object on, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, appConsentRequestIdOption, onOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, appConsentRequestIdOption, onOption, outputOption); return command; } /// @@ -77,16 +76,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function filterByCurrentUser - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/UserConsentRequests/Item/Approval/ApprovalRequestBuilder.cs b/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/UserConsentRequests/Item/Approval/ApprovalRequestBuilder.cs index 8024ef88012..3b5fcc739fd 100644 --- a/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/UserConsentRequests/Item/Approval/ApprovalRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/UserConsentRequests/Item/Approval/ApprovalRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,19 +27,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Approval decisions associated with a request."; // Create options for all the parameters - var appConsentRequestIdOption = new Option("--appconsentrequest-id", description: "key: id of appConsentRequest") { + var appConsentRequestIdOption = new Option("--app-consent-request-id", description: "key: id of appConsentRequest") { }; appConsentRequestIdOption.IsRequired = true; command.AddOption(appConsentRequestIdOption); - var userConsentRequestIdOption = new Option("--userconsentrequest-id", description: "key: id of userConsentRequest") { + var userConsentRequestIdOption = new Option("--user-consent-request-id", description: "key: id of userConsentRequest") { }; userConsentRequestIdOption.IsRequired = true; command.AddOption(userConsentRequestIdOption); - command.SetHandler(async (string appConsentRequestId, string userConsentRequestId) => { + command.SetHandler(async (string appConsentRequestId, string userConsentRequestId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, appConsentRequestIdOption, userConsentRequestIdOption); return command; @@ -51,11 +50,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Approval decisions associated with a request."; // Create options for all the parameters - var appConsentRequestIdOption = new Option("--appconsentrequest-id", description: "key: id of appConsentRequest") { + var appConsentRequestIdOption = new Option("--app-consent-request-id", description: "key: id of appConsentRequest") { }; appConsentRequestIdOption.IsRequired = true; command.AddOption(appConsentRequestIdOption); - var userConsentRequestIdOption = new Option("--userconsentrequest-id", description: "key: id of userConsentRequest") { + var userConsentRequestIdOption = new Option("--user-consent-request-id", description: "key: id of userConsentRequest") { }; userConsentRequestIdOption.IsRequired = true; command.AddOption(userConsentRequestIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string appConsentRequestId, string userConsentRequestId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string appConsentRequestId, string userConsentRequestId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, appConsentRequestIdOption, userConsentRequestIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, appConsentRequestIdOption, userConsentRequestIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -92,11 +90,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Approval decisions associated with a request."; // Create options for all the parameters - var appConsentRequestIdOption = new Option("--appconsentrequest-id", description: "key: id of appConsentRequest") { + var appConsentRequestIdOption = new Option("--app-consent-request-id", description: "key: id of appConsentRequest") { }; appConsentRequestIdOption.IsRequired = true; command.AddOption(appConsentRequestIdOption); - var userConsentRequestIdOption = new Option("--userconsentrequest-id", description: "key: id of userConsentRequest") { + var userConsentRequestIdOption = new Option("--user-consent-request-id", description: "key: id of userConsentRequest") { }; userConsentRequestIdOption.IsRequired = true; command.AddOption(userConsentRequestIdOption); @@ -104,14 +102,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string appConsentRequestId, string userConsentRequestId, string body) => { + command.SetHandler(async (string appConsentRequestId, string userConsentRequestId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, appConsentRequestIdOption, userConsentRequestIdOption, bodyOption); return command; @@ -119,6 +116,9 @@ public Command BuildPatchCommand() { public Command BuildStagesCommand() { var command = new Command("stages"); var builder = new ApiSdk.IdentityGovernance.AppConsent.AppConsentRequests.Item.UserConsentRequests.Item.Approval.Stages.StagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -190,42 +190,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Approval decisions associated with a request. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Approval decisions associated with a request. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Approval decisions associated with a request. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Approval model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Approval decisions associated with a request. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/UserConsentRequests/Item/Approval/Stages/Item/ApprovalStageRequestBuilder.cs b/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/UserConsentRequests/Item/Approval/Stages/Item/ApprovalStageRequestBuilder.cs index cc2f359cf57..1a81742fe91 100644 --- a/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/UserConsentRequests/Item/Approval/Stages/Item/ApprovalStageRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/UserConsentRequests/Item/Approval/Stages/Item/ApprovalStageRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Used for the approvalStages property of approval settings in the requestApprovalSettings property of an access package assignment policy. Specifies the primary, fallback, and escalation approvers of each stage."; // Create options for all the parameters - var appConsentRequestIdOption = new Option("--appconsentrequest-id", description: "key: id of appConsentRequest") { + var appConsentRequestIdOption = new Option("--app-consent-request-id", description: "key: id of appConsentRequest") { }; appConsentRequestIdOption.IsRequired = true; command.AddOption(appConsentRequestIdOption); - var userConsentRequestIdOption = new Option("--userconsentrequest-id", description: "key: id of userConsentRequest") { + var userConsentRequestIdOption = new Option("--user-consent-request-id", description: "key: id of userConsentRequest") { }; userConsentRequestIdOption.IsRequired = true; command.AddOption(userConsentRequestIdOption); - var approvalStageIdOption = new Option("--approvalstage-id", description: "key: id of approvalStage") { + var approvalStageIdOption = new Option("--approval-stage-id", description: "key: id of approvalStage") { }; approvalStageIdOption.IsRequired = true; command.AddOption(approvalStageIdOption); - command.SetHandler(async (string appConsentRequestId, string userConsentRequestId, string approvalStageId) => { + command.SetHandler(async (string appConsentRequestId, string userConsentRequestId, string approvalStageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, appConsentRequestIdOption, userConsentRequestIdOption, approvalStageIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Used for the approvalStages property of approval settings in the requestApprovalSettings property of an access package assignment policy. Specifies the primary, fallback, and escalation approvers of each stage."; // Create options for all the parameters - var appConsentRequestIdOption = new Option("--appconsentrequest-id", description: "key: id of appConsentRequest") { + var appConsentRequestIdOption = new Option("--app-consent-request-id", description: "key: id of appConsentRequest") { }; appConsentRequestIdOption.IsRequired = true; command.AddOption(appConsentRequestIdOption); - var userConsentRequestIdOption = new Option("--userconsentrequest-id", description: "key: id of userConsentRequest") { + var userConsentRequestIdOption = new Option("--user-consent-request-id", description: "key: id of userConsentRequest") { }; userConsentRequestIdOption.IsRequired = true; command.AddOption(userConsentRequestIdOption); - var approvalStageIdOption = new Option("--approvalstage-id", description: "key: id of approvalStage") { + var approvalStageIdOption = new Option("--approval-stage-id", description: "key: id of approvalStage") { }; approvalStageIdOption.IsRequired = true; command.AddOption(approvalStageIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string appConsentRequestId, string userConsentRequestId, string approvalStageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string appConsentRequestId, string userConsentRequestId, string approvalStageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, appConsentRequestIdOption, userConsentRequestIdOption, approvalStageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, appConsentRequestIdOption, userConsentRequestIdOption, approvalStageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Used for the approvalStages property of approval settings in the requestApprovalSettings property of an access package assignment policy. Specifies the primary, fallback, and escalation approvers of each stage."; // Create options for all the parameters - var appConsentRequestIdOption = new Option("--appconsentrequest-id", description: "key: id of appConsentRequest") { + var appConsentRequestIdOption = new Option("--app-consent-request-id", description: "key: id of appConsentRequest") { }; appConsentRequestIdOption.IsRequired = true; command.AddOption(appConsentRequestIdOption); - var userConsentRequestIdOption = new Option("--userconsentrequest-id", description: "key: id of userConsentRequest") { + var userConsentRequestIdOption = new Option("--user-consent-request-id", description: "key: id of userConsentRequest") { }; userConsentRequestIdOption.IsRequired = true; command.AddOption(userConsentRequestIdOption); - var approvalStageIdOption = new Option("--approvalstage-id", description: "key: id of approvalStage") { + var approvalStageIdOption = new Option("--approval-stage-id", description: "key: id of approvalStage") { }; approvalStageIdOption.IsRequired = true; command.AddOption(approvalStageIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string appConsentRequestId, string userConsentRequestId, string approvalStageId, string body) => { + command.SetHandler(async (string appConsentRequestId, string userConsentRequestId, string approvalStageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, appConsentRequestIdOption, userConsentRequestIdOption, approvalStageIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(ApprovalStage body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Used for the approvalStages property of approval settings in the requestApprovalSettings property of an access package assignment policy. Specifies the primary, fallback, and escalation approvers of each stage. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used for the approvalStages property of approval settings in the requestApprovalSettings property of an access package assignment policy. Specifies the primary, fallback, and escalation approvers of each stage. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used for the approvalStages property of approval settings in the requestApprovalSettings property of an access package assignment policy. Specifies the primary, fallback, and escalation approvers of each stage. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApprovalStage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Used for the approvalStages property of approval settings in the requestApprovalSettings property of an access package assignment policy. Specifies the primary, fallback, and escalation approvers of each stage. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/UserConsentRequests/Item/Approval/Stages/StagesRequestBuilder.cs b/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/UserConsentRequests/Item/Approval/Stages/StagesRequestBuilder.cs index 3bd870c81e0..2139e1a6c82 100644 --- a/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/UserConsentRequests/Item/Approval/Stages/StagesRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/UserConsentRequests/Item/Approval/Stages/StagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class StagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ApprovalStageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,11 +35,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Used for the approvalStages property of approval settings in the requestApprovalSettings property of an access package assignment policy. Specifies the primary, fallback, and escalation approvers of each stage."; // Create options for all the parameters - var appConsentRequestIdOption = new Option("--appconsentrequest-id", description: "key: id of appConsentRequest") { + var appConsentRequestIdOption = new Option("--app-consent-request-id", description: "key: id of appConsentRequest") { }; appConsentRequestIdOption.IsRequired = true; command.AddOption(appConsentRequestIdOption); - var userConsentRequestIdOption = new Option("--userconsentrequest-id", description: "key: id of userConsentRequest") { + var userConsentRequestIdOption = new Option("--user-consent-request-id", description: "key: id of userConsentRequest") { }; userConsentRequestIdOption.IsRequired = true; command.AddOption(userConsentRequestIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string appConsentRequestId, string userConsentRequestId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string appConsentRequestId, string userConsentRequestId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, appConsentRequestIdOption, userConsentRequestIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, appConsentRequestIdOption, userConsentRequestIdOption, bodyOption, outputOption); return command; } /// @@ -72,11 +70,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Used for the approvalStages property of approval settings in the requestApprovalSettings property of an access package assignment policy. Specifies the primary, fallback, and escalation approvers of each stage."; // Create options for all the parameters - var appConsentRequestIdOption = new Option("--appconsentrequest-id", description: "key: id of appConsentRequest") { + var appConsentRequestIdOption = new Option("--app-consent-request-id", description: "key: id of appConsentRequest") { }; appConsentRequestIdOption.IsRequired = true; command.AddOption(appConsentRequestIdOption); - var userConsentRequestIdOption = new Option("--userconsentrequest-id", description: "key: id of userConsentRequest") { + var userConsentRequestIdOption = new Option("--user-consent-request-id", description: "key: id of userConsentRequest") { }; userConsentRequestIdOption.IsRequired = true; command.AddOption(userConsentRequestIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string appConsentRequestId, string userConsentRequestId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string appConsentRequestId, string userConsentRequestId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, appConsentRequestIdOption, userConsentRequestIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, appConsentRequestIdOption, userConsentRequestIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(ApprovalStage body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Used for the approvalStages property of approval settings in the requestApprovalSettings property of an access package assignment policy. Specifies the primary, fallback, and escalation approvers of each stage. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used for the approvalStages property of approval settings in the requestApprovalSettings property of an access package assignment policy. Specifies the primary, fallback, and escalation approvers of each stage. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApprovalStage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Used for the approvalStages property of approval settings in the requestApprovalSettings property of an access package assignment policy. Specifies the primary, fallback, and escalation approvers of each stage. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/UserConsentRequests/Item/UserConsentRequestRequestBuilder.cs b/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/UserConsentRequests/Item/UserConsentRequestRequestBuilder.cs index 0bc227ebf10..8239c8f7687 100644 --- a/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/UserConsentRequests/Item/UserConsentRequestRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/UserConsentRequests/Item/UserConsentRequestRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -36,19 +36,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "A list of pending user consent requests."; // Create options for all the parameters - var appConsentRequestIdOption = new Option("--appconsentrequest-id", description: "key: id of appConsentRequest") { + var appConsentRequestIdOption = new Option("--app-consent-request-id", description: "key: id of appConsentRequest") { }; appConsentRequestIdOption.IsRequired = true; command.AddOption(appConsentRequestIdOption); - var userConsentRequestIdOption = new Option("--userconsentrequest-id", description: "key: id of userConsentRequest") { + var userConsentRequestIdOption = new Option("--user-consent-request-id", description: "key: id of userConsentRequest") { }; userConsentRequestIdOption.IsRequired = true; command.AddOption(userConsentRequestIdOption); - command.SetHandler(async (string appConsentRequestId, string userConsentRequestId) => { + command.SetHandler(async (string appConsentRequestId, string userConsentRequestId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, appConsentRequestIdOption, userConsentRequestIdOption); return command; @@ -60,11 +59,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "A list of pending user consent requests."; // Create options for all the parameters - var appConsentRequestIdOption = new Option("--appconsentrequest-id", description: "key: id of appConsentRequest") { + var appConsentRequestIdOption = new Option("--app-consent-request-id", description: "key: id of appConsentRequest") { }; appConsentRequestIdOption.IsRequired = true; command.AddOption(appConsentRequestIdOption); - var userConsentRequestIdOption = new Option("--userconsentrequest-id", description: "key: id of userConsentRequest") { + var userConsentRequestIdOption = new Option("--user-consent-request-id", description: "key: id of userConsentRequest") { }; userConsentRequestIdOption.IsRequired = true; command.AddOption(userConsentRequestIdOption); @@ -78,20 +77,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string appConsentRequestId, string userConsentRequestId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string appConsentRequestId, string userConsentRequestId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, appConsentRequestIdOption, userConsentRequestIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, appConsentRequestIdOption, userConsentRequestIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -101,11 +99,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "A list of pending user consent requests."; // Create options for all the parameters - var appConsentRequestIdOption = new Option("--appconsentrequest-id", description: "key: id of appConsentRequest") { + var appConsentRequestIdOption = new Option("--app-consent-request-id", description: "key: id of appConsentRequest") { }; appConsentRequestIdOption.IsRequired = true; command.AddOption(appConsentRequestIdOption); - var userConsentRequestIdOption = new Option("--userconsentrequest-id", description: "key: id of userConsentRequest") { + var userConsentRequestIdOption = new Option("--user-consent-request-id", description: "key: id of userConsentRequest") { }; userConsentRequestIdOption.IsRequired = true; command.AddOption(userConsentRequestIdOption); @@ -113,14 +111,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string appConsentRequestId, string userConsentRequestId, string body) => { + command.SetHandler(async (string appConsentRequestId, string userConsentRequestId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, appConsentRequestIdOption, userConsentRequestIdOption, bodyOption); return command; @@ -192,42 +189,6 @@ public RequestInformation CreatePatchRequestInformation(UserConsentRequest body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A list of pending user consent requests. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A list of pending user consent requests. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A list of pending user consent requests. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(UserConsentRequest model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A list of pending user consent requests. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/UserConsentRequests/UserConsentRequestsRequestBuilder.cs b/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/UserConsentRequests/UserConsentRequestsRequestBuilder.cs index c40ff0d58fa..64a1ce6e92e 100644 --- a/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/UserConsentRequests/UserConsentRequestsRequestBuilder.cs +++ b/src/generated/IdentityGovernance/AppConsent/AppConsentRequests/Item/UserConsentRequests/UserConsentRequestsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,12 +23,11 @@ public class UserConsentRequestsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new UserConsentRequestRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildApprovalCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildApprovalCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -38,7 +37,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "A list of pending user consent requests."; // Create options for all the parameters - var appConsentRequestIdOption = new Option("--appconsentrequest-id", description: "key: id of appConsentRequest") { + var appConsentRequestIdOption = new Option("--app-consent-request-id", description: "key: id of appConsentRequest") { }; appConsentRequestIdOption.IsRequired = true; command.AddOption(appConsentRequestIdOption); @@ -46,21 +45,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string appConsentRequestId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string appConsentRequestId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, appConsentRequestIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, appConsentRequestIdOption, bodyOption, outputOption); return command; } /// @@ -70,7 +68,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "A list of pending user consent requests."; // Create options for all the parameters - var appConsentRequestIdOption = new Option("--appconsentrequest-id", description: "key: id of appConsentRequest") { + var appConsentRequestIdOption = new Option("--app-consent-request-id", description: "key: id of appConsentRequest") { }; appConsentRequestIdOption.IsRequired = true; command.AddOption(appConsentRequestIdOption); @@ -109,7 +107,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string appConsentRequestId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string appConsentRequestId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -120,15 +122,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, appConsentRequestIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, appConsentRequestIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public FilterByCurrentUserWithOnRequestBuilder FilterByCurrentUserWithOn(string if(string.IsNullOrEmpty(on)) throw new ArgumentNullException(nameof(on)); return new FilterByCurrentUserWithOnRequestBuilder(PathParameters, RequestAdapter, on); } - /// - /// A list of pending user consent requests. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A list of pending user consent requests. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UserConsentRequest model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A list of pending user consent requests. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AccessPackageAssignmentApprovals/AccessPackageAssignmentApprovalsRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/AccessPackageAssignmentApprovals/AccessPackageAssignmentApprovalsRequestBuilder.cs index c51dbd7b75f..9f58e0993a5 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/AccessPackageAssignmentApprovals/AccessPackageAssignmentApprovalsRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/AccessPackageAssignmentApprovals/AccessPackageAssignmentApprovalsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,12 +23,11 @@ public class AccessPackageAssignmentApprovalsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ApprovalRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildStagesCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildStagesCommand()); return commands; } /// @@ -42,21 +41,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -101,7 +99,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -112,15 +114,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -183,31 +180,6 @@ public FilterByCurrentUserWithOnRequestBuilder FilterByCurrentUserWithOn(string if(string.IsNullOrEmpty(on)) throw new ArgumentNullException(nameof(on)); return new FilterByCurrentUserWithOnRequestBuilder(PathParameters, RequestAdapter, on); } - /// - /// Get accessPackageAssignmentApprovals from identityGovernance - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to accessPackageAssignmentApprovals for identityGovernance - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Approval model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get accessPackageAssignmentApprovals from identityGovernance public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AccessPackageAssignmentApprovals/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/AccessPackageAssignmentApprovals/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs index f1e68567551..b07e2568ca4 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/AccessPackageAssignmentApprovals/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/AccessPackageAssignmentApprovals/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +29,17 @@ public Command BuildGetCommand() { }; onOption.IsRequired = true; command.AddOption(onOption); - command.SetHandler(async (object on) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (object on, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onOption, outputOption); return command; } /// @@ -73,16 +72,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function filterByCurrentUser - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AccessPackageAssignmentApprovals/Item/ApprovalRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/AccessPackageAssignmentApprovals/Item/ApprovalRequestBuilder.cs index 03d50f7ffd9..ad2ebbd4932 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/AccessPackageAssignmentApprovals/Item/ApprovalRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/AccessPackageAssignmentApprovals/Item/ApprovalRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,11 +31,10 @@ public Command BuildDeleteCommand() { }; approvalIdOption.IsRequired = true; command.AddOption(approvalIdOption); - command.SetHandler(async (string approvalId) => { + command.SetHandler(async (string approvalId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, approvalIdOption); return command; @@ -61,20 +60,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string approvalId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string approvalId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, approvalIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, approvalIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -92,14 +90,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string approvalId, string body) => { + command.SetHandler(async (string approvalId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, approvalIdOption, bodyOption); return command; @@ -107,6 +104,9 @@ public Command BuildPatchCommand() { public Command BuildStagesCommand() { var command = new Command("stages"); var builder = new ApiSdk.IdentityGovernance.EntitlementManagement.AccessPackageAssignmentApprovals.Item.Stages.StagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -178,42 +178,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property accessPackageAssignmentApprovals for identityGovernance - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get accessPackageAssignmentApprovals from identityGovernance - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property accessPackageAssignmentApprovals in identityGovernance - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Approval model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get accessPackageAssignmentApprovals from identityGovernance public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AccessPackageAssignmentApprovals/Item/Stages/Item/ApprovalStageRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/AccessPackageAssignmentApprovals/Item/Stages/Item/ApprovalStageRequestBuilder.cs index a0aef59f15a..21f4f654689 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/AccessPackageAssignmentApprovals/Item/Stages/Item/ApprovalStageRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/AccessPackageAssignmentApprovals/Item/Stages/Item/ApprovalStageRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; approvalIdOption.IsRequired = true; command.AddOption(approvalIdOption); - var approvalStageIdOption = new Option("--approvalstage-id", description: "key: id of approvalStage") { + var approvalStageIdOption = new Option("--approval-stage-id", description: "key: id of approvalStage") { }; approvalStageIdOption.IsRequired = true; command.AddOption(approvalStageIdOption); - command.SetHandler(async (string approvalId, string approvalStageId) => { + command.SetHandler(async (string approvalId, string approvalStageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, approvalIdOption, approvalStageIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; approvalIdOption.IsRequired = true; command.AddOption(approvalIdOption); - var approvalStageIdOption = new Option("--approvalstage-id", description: "key: id of approvalStage") { + var approvalStageIdOption = new Option("--approval-stage-id", description: "key: id of approvalStage") { }; approvalStageIdOption.IsRequired = true; command.AddOption(approvalStageIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string approvalId, string approvalStageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string approvalId, string approvalStageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, approvalIdOption, approvalStageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, approvalIdOption, approvalStageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; approvalIdOption.IsRequired = true; command.AddOption(approvalIdOption); - var approvalStageIdOption = new Option("--approvalstage-id", description: "key: id of approvalStage") { + var approvalStageIdOption = new Option("--approval-stage-id", description: "key: id of approvalStage") { }; approvalStageIdOption.IsRequired = true; command.AddOption(approvalStageIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string approvalId, string approvalStageId, string body) => { + command.SetHandler(async (string approvalId, string approvalStageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, approvalIdOption, approvalStageIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ApprovalStage body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Used for the approvalStages property of approval settings in the requestApprovalSettings property of an access package assignment policy. Specifies the primary, fallback, and escalation approvers of each stage. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used for the approvalStages property of approval settings in the requestApprovalSettings property of an access package assignment policy. Specifies the primary, fallback, and escalation approvers of each stage. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used for the approvalStages property of approval settings in the requestApprovalSettings property of an access package assignment policy. Specifies the primary, fallback, and escalation approvers of each stage. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApprovalStage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Used for the approvalStages property of approval settings in the requestApprovalSettings property of an access package assignment policy. Specifies the primary, fallback, and escalation approvers of each stage. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AccessPackageAssignmentApprovals/Item/Stages/StagesRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/AccessPackageAssignmentApprovals/Item/Stages/StagesRequestBuilder.cs index 573760bbefa..0cfa3e2362c 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/AccessPackageAssignmentApprovals/Item/Stages/StagesRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/AccessPackageAssignmentApprovals/Item/Stages/StagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class StagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ApprovalStageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string approvalId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string approvalId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, approvalIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, approvalIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string approvalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string approvalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, approvalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, approvalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ApprovalStage body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Used for the approvalStages property of approval settings in the requestApprovalSettings property of an access package assignment policy. Specifies the primary, fallback, and escalation approvers of each stage. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used for the approvalStages property of approval settings in the requestApprovalSettings property of an access package assignment policy. Specifies the primary, fallback, and escalation approvers of each stage. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApprovalStage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Used for the approvalStages property of approval settings in the requestApprovalSettings property of an access package assignment policy. Specifies the primary, fallback, and escalation approvers of each stage. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/AccessPackagesRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/AccessPackagesRequestBuilder.cs index b544219dbdf..1c8c0ccb08f 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/AccessPackagesRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/AccessPackagesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,13 +23,12 @@ public class AccessPackagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AccessPackageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCatalogCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetApplicablePolicyRequirementsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCatalogCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetApplicablePolicyRequirementsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -43,21 +42,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -102,7 +100,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -113,15 +115,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -184,31 +181,6 @@ public FilterByCurrentUserWithOnRequestBuilder FilterByCurrentUserWithOn(string if(string.IsNullOrEmpty(on)) throw new ArgumentNullException(nameof(on)); return new FilterByCurrentUserWithOnRequestBuilder(PathParameters, RequestAdapter, on); } - /// - /// Represents access package objects. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents access package objects. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.AccessPackage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents access package objects. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs index ecf3adbbbb1..344dcd52883 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +29,17 @@ public Command BuildGetCommand() { }; onOption.IsRequired = true; command.AddOption(onOption); - command.SetHandler(async (object on) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (object on, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onOption, outputOption); return command; } /// @@ -73,16 +72,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function filterByCurrentUser - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/Item/AccessPackageRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/Item/AccessPackageRequestBuilder.cs index 894e7ca4ef6..26a2db24084 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/Item/AccessPackageRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/Item/AccessPackageRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,15 +35,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents access package objects."; // Create options for all the parameters - var accessPackageIdOption = new Option("--accesspackage-id", description: "key: id of accessPackage") { + var accessPackageIdOption = new Option("--access-package-id", description: "key: id of accessPackage") { }; accessPackageIdOption.IsRequired = true; command.AddOption(accessPackageIdOption); - command.SetHandler(async (string accessPackageId) => { + command.SetHandler(async (string accessPackageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, accessPackageIdOption); return command; @@ -61,7 +60,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents access package objects."; // Create options for all the parameters - var accessPackageIdOption = new Option("--accesspackage-id", description: "key: id of accessPackage") { + var accessPackageIdOption = new Option("--access-package-id", description: "key: id of accessPackage") { }; accessPackageIdOption.IsRequired = true; command.AddOption(accessPackageIdOption); @@ -75,20 +74,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string accessPackageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessPackageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessPackageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessPackageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -98,7 +96,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents access package objects."; // Create options for all the parameters - var accessPackageIdOption = new Option("--accesspackage-id", description: "key: id of accessPackage") { + var accessPackageIdOption = new Option("--access-package-id", description: "key: id of accessPackage") { }; accessPackageIdOption.IsRequired = true; command.AddOption(accessPackageIdOption); @@ -106,14 +104,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string accessPackageId, string body) => { + command.SetHandler(async (string accessPackageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, accessPackageIdOption, bodyOption); return command; @@ -185,42 +182,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents access package objects. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents access package objects. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents access package objects. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.AccessPackage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents access package objects. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/Item/Catalog/@Ref/@Ref.cs b/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/Item/Catalog/@Ref/@Ref.cs deleted file mode 100644 index c068d63103e..00000000000 --- a/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/Item/Catalog/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.IdentityGovernance.EntitlementManagement.AccessPackages.Item.Catalog.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/Item/Catalog/@Ref/RefRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/Item/Catalog/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 716f5e83062..00000000000 --- a/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/Item/Catalog/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.IdentityGovernance.EntitlementManagement.AccessPackages.Item.Catalog.@Ref { - /// Builds and executes requests for operations under \identityGovernance\entitlementManagement\accessPackages\{accessPackage-id}\catalog\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Read-only. Nullable. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Read-only. Nullable."; - // Create options for all the parameters - var accessPackageIdOption = new Option("--accesspackage-id", description: "key: id of accessPackage") { - }; - accessPackageIdOption.IsRequired = true; - command.AddOption(accessPackageIdOption); - command.SetHandler(async (string accessPackageId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, accessPackageIdOption); - return command; - } - /// - /// Read-only. Nullable. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Read-only. Nullable."; - // Create options for all the parameters - var accessPackageIdOption = new Option("--accesspackage-id", description: "key: id of accessPackage") { - }; - accessPackageIdOption.IsRequired = true; - command.AddOption(accessPackageIdOption); - command.SetHandler(async (string accessPackageId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessPackageIdOption); - return command; - } - /// - /// Read-only. Nullable. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Read-only. Nullable."; - // Create options for all the parameters - var accessPackageIdOption = new Option("--accesspackage-id", description: "key: id of accessPackage") { - }; - accessPackageIdOption.IsRequired = true; - command.AddOption(accessPackageIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string accessPackageId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, accessPackageIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/identityGovernance/entitlementManagement/accessPackages/{accessPackage_id}/catalog/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Read-only. Nullable. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Read-only. Nullable. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Read-only. Nullable. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.IdentityGovernance.EntitlementManagement.AccessPackages.Item.Catalog.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.IdentityGovernance.EntitlementManagement.AccessPackages.Item.Catalog.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/Item/Catalog/CatalogRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/Item/Catalog/CatalogRequestBuilder.cs index 96819ac77a0..1a9a28578cf 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/Item/Catalog/CatalogRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/Item/Catalog/CatalogRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var accessPackageIdOption = new Option("--accesspackage-id", description: "key: id of accessPackage") { + var accessPackageIdOption = new Option("--access-package-id", description: "key: id of accessPackage") { }; accessPackageIdOption.IsRequired = true; command.AddOption(accessPackageIdOption); @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string accessPackageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessPackageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessPackageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessPackageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.IdentityGovernance.EntitlementManagement.AccessPackages.Item.Catalog.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.IdentityGovernance.EntitlementManagement.AccessPackages.Item.Catalog.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/Item/Catalog/Ref/Ref.cs b/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/Item/Catalog/Ref/Ref.cs new file mode 100644 index 00000000000..38483d33861 --- /dev/null +++ b/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/Item/Catalog/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.IdentityGovernance.EntitlementManagement.AccessPackages.Item.Catalog.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/Item/Catalog/Ref/RefRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/Item/Catalog/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..ed07e896202 --- /dev/null +++ b/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/Item/Catalog/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.IdentityGovernance.EntitlementManagement.AccessPackages.Item.Catalog.Ref { + /// Builds and executes requests for operations under \identityGovernance\entitlementManagement\accessPackages\{accessPackage-id}\catalog\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Read-only. Nullable. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Read-only. Nullable."; + // Create options for all the parameters + var accessPackageIdOption = new Option("--access-package-id", description: "key: id of accessPackage") { + }; + accessPackageIdOption.IsRequired = true; + command.AddOption(accessPackageIdOption); + command.SetHandler(async (string accessPackageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, accessPackageIdOption); + return command; + } + /// + /// Read-only. Nullable. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Read-only. Nullable."; + // Create options for all the parameters + var accessPackageIdOption = new Option("--access-package-id", description: "key: id of accessPackage") { + }; + accessPackageIdOption.IsRequired = true; + command.AddOption(accessPackageIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessPackageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessPackageIdOption, outputOption); + return command; + } + /// + /// Read-only. Nullable. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Read-only. Nullable."; + // Create options for all the parameters + var accessPackageIdOption = new Option("--access-package-id", description: "key: id of accessPackage") { + }; + accessPackageIdOption.IsRequired = true; + command.AddOption(accessPackageIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string accessPackageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, accessPackageIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/identityGovernance/entitlementManagement/accessPackages/{accessPackage_id}/catalog/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Read-only. Nullable. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Read-only. Nullable. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Read-only. Nullable. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.IdentityGovernance.EntitlementManagement.AccessPackages.Item.Catalog.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/Item/GetApplicablePolicyRequirements/GetApplicablePolicyRequirementsRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/Item/GetApplicablePolicyRequirements/GetApplicablePolicyRequirementsRequestBuilder.cs index d06818b61ed..1c22100660d 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/Item/GetApplicablePolicyRequirements/GetApplicablePolicyRequirementsRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/AccessPackages/Item/GetApplicablePolicyRequirements/GetApplicablePolicyRequirementsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,22 +25,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action getApplicablePolicyRequirements"; // Create options for all the parameters - var accessPackageIdOption = new Option("--accesspackage-id", description: "key: id of accessPackage") { + var accessPackageIdOption = new Option("--access-package-id", description: "key: id of accessPackage") { }; accessPackageIdOption.IsRequired = true; command.AddOption(accessPackageIdOption); - command.SetHandler(async (string accessPackageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessPackageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessPackageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessPackageIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action getApplicablePolicyRequirements - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/AssignmentRequestsRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/AssignmentRequestsRequestBuilder.cs index 46bf0a1317f..21d20538168 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/AssignmentRequestsRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/AssignmentRequestsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,15 +23,14 @@ public class AssignmentRequestsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AccessPackageAssignmentRequestRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAccessPackageCommand(), - builder.BuildAssignmentCommand(), - builder.BuildCancelCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildRequestorCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAccessPackageCommand()); + commands.Add(builder.BuildAssignmentCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRequestorCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -104,7 +102,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -115,15 +117,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -186,31 +183,6 @@ public FilterByCurrentUserWithOnRequestBuilder FilterByCurrentUserWithOn(string if(string.IsNullOrEmpty(on)) throw new ArgumentNullException(nameof(on)); return new FilterByCurrentUserWithOnRequestBuilder(PathParameters, RequestAdapter, on); } - /// - /// Represents access package assignment requests created by or on behalf of a user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents access package assignment requests created by or on behalf of a user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AccessPackageAssignmentRequest model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents access package assignment requests created by or on behalf of a user. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs index c079cc984d6..8882e0be249 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +29,17 @@ public Command BuildGetCommand() { }; onOption.IsRequired = true; command.AddOption(onOption); - command.SetHandler(async (object on) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (object on, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onOption, outputOption); return command; } /// @@ -73,16 +72,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function filterByCurrentUser - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/AccessPackage/@Ref/@Ref.cs b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/AccessPackage/@Ref/@Ref.cs deleted file mode 100644 index 0bbe86176a2..00000000000 --- a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/AccessPackage/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.Item.AccessPackage.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/AccessPackage/@Ref/RefRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/AccessPackage/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 007a9879715..00000000000 --- a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/AccessPackage/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.Item.AccessPackage.@Ref { - /// Builds and executes requests for operations under \identityGovernance\entitlementManagement\assignmentRequests\{accessPackageAssignmentRequest-id}\accessPackage\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The access package associated with the accessPackageAssignmentRequest. An access package defines the collections of resource roles and the policies for how one or more users can get access to those resources. Read-only. Nullable. Supports $expand. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The access package associated with the accessPackageAssignmentRequest. An access package defines the collections of resource roles and the policies for how one or more users can get access to those resources. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var accessPackageAssignmentRequestIdOption = new Option("--accesspackageassignmentrequest-id", description: "key: id of accessPackageAssignmentRequest") { - }; - accessPackageAssignmentRequestIdOption.IsRequired = true; - command.AddOption(accessPackageAssignmentRequestIdOption); - command.SetHandler(async (string accessPackageAssignmentRequestId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, accessPackageAssignmentRequestIdOption); - return command; - } - /// - /// The access package associated with the accessPackageAssignmentRequest. An access package defines the collections of resource roles and the policies for how one or more users can get access to those resources. Read-only. Nullable. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The access package associated with the accessPackageAssignmentRequest. An access package defines the collections of resource roles and the policies for how one or more users can get access to those resources. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var accessPackageAssignmentRequestIdOption = new Option("--accesspackageassignmentrequest-id", description: "key: id of accessPackageAssignmentRequest") { - }; - accessPackageAssignmentRequestIdOption.IsRequired = true; - command.AddOption(accessPackageAssignmentRequestIdOption); - command.SetHandler(async (string accessPackageAssignmentRequestId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessPackageAssignmentRequestIdOption); - return command; - } - /// - /// The access package associated with the accessPackageAssignmentRequest. An access package defines the collections of resource roles and the policies for how one or more users can get access to those resources. Read-only. Nullable. Supports $expand. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The access package associated with the accessPackageAssignmentRequest. An access package defines the collections of resource roles and the policies for how one or more users can get access to those resources. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var accessPackageAssignmentRequestIdOption = new Option("--accesspackageassignmentrequest-id", description: "key: id of accessPackageAssignmentRequest") { - }; - accessPackageAssignmentRequestIdOption.IsRequired = true; - command.AddOption(accessPackageAssignmentRequestIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string accessPackageAssignmentRequestId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, accessPackageAssignmentRequestIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/identityGovernance/entitlementManagement/assignmentRequests/{accessPackageAssignmentRequest_id}/accessPackage/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The access package associated with the accessPackageAssignmentRequest. An access package defines the collections of resource roles and the policies for how one or more users can get access to those resources. Read-only. Nullable. Supports $expand. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The access package associated with the accessPackageAssignmentRequest. An access package defines the collections of resource roles and the policies for how one or more users can get access to those resources. Read-only. Nullable. Supports $expand. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The access package associated with the accessPackageAssignmentRequest. An access package defines the collections of resource roles and the policies for how one or more users can get access to those resources. Read-only. Nullable. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.Item.AccessPackage.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The access package associated with the accessPackageAssignmentRequest. An access package defines the collections of resource roles and the policies for how one or more users can get access to those resources. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The access package associated with the accessPackageAssignmentRequest. An access package defines the collections of resource roles and the policies for how one or more users can get access to those resources. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The access package associated with the accessPackageAssignmentRequest. An access package defines the collections of resource roles and the policies for how one or more users can get access to those resources. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.Item.AccessPackage.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/AccessPackage/AccessPackageRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/AccessPackage/AccessPackageRequestBuilder.cs index 3bd0cdcf4ec..3a096590cbe 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/AccessPackage/AccessPackageRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/AccessPackage/AccessPackageRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,7 +34,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The access package associated with the accessPackageAssignmentRequest. An access package defines the collections of resource roles and the policies for how one or more users can get access to those resources. Read-only. Nullable. Supports $expand."; // Create options for all the parameters - var accessPackageAssignmentRequestIdOption = new Option("--accesspackageassignmentrequest-id", description: "key: id of accessPackageAssignmentRequest") { + var accessPackageAssignmentRequestIdOption = new Option("--access-package-assignment-request-id", description: "key: id of accessPackageAssignmentRequest") { }; accessPackageAssignmentRequestIdOption.IsRequired = true; command.AddOption(accessPackageAssignmentRequestIdOption); @@ -48,25 +48,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string accessPackageAssignmentRequestId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessPackageAssignmentRequestId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessPackageAssignmentRequestIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessPackageAssignmentRequestIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.Item.AccessPackage.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.Item.AccessPackage.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -106,18 +105,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The access package associated with the accessPackageAssignmentRequest. An access package defines the collections of resource roles and the policies for how one or more users can get access to those resources. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The access package associated with the accessPackageAssignmentRequest. An access package defines the collections of resource roles and the policies for how one or more users can get access to those resources. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/AccessPackage/GetApplicablePolicyRequirements/GetApplicablePolicyRequirementsRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/AccessPackage/GetApplicablePolicyRequirements/GetApplicablePolicyRequirementsRequestBuilder.cs index 4fc5a37cea2..eafcdaa9dd9 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/AccessPackage/GetApplicablePolicyRequirements/GetApplicablePolicyRequirementsRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/AccessPackage/GetApplicablePolicyRequirements/GetApplicablePolicyRequirementsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,22 +25,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action getApplicablePolicyRequirements"; // Create options for all the parameters - var accessPackageAssignmentRequestIdOption = new Option("--accesspackageassignmentrequest-id", description: "key: id of accessPackageAssignmentRequest") { + var accessPackageAssignmentRequestIdOption = new Option("--access-package-assignment-request-id", description: "key: id of accessPackageAssignmentRequest") { }; accessPackageAssignmentRequestIdOption.IsRequired = true; command.AddOption(accessPackageAssignmentRequestIdOption); - command.SetHandler(async (string accessPackageAssignmentRequestId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessPackageAssignmentRequestId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessPackageAssignmentRequestIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessPackageAssignmentRequestIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action getApplicablePolicyRequirements - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/AccessPackage/Ref/Ref.cs b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/AccessPackage/Ref/Ref.cs new file mode 100644 index 00000000000..631e54bb416 --- /dev/null +++ b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/AccessPackage/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.Item.AccessPackage.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/AccessPackage/Ref/RefRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/AccessPackage/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..b42a0509a75 --- /dev/null +++ b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/AccessPackage/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.Item.AccessPackage.Ref { + /// Builds and executes requests for operations under \identityGovernance\entitlementManagement\assignmentRequests\{accessPackageAssignmentRequest-id}\accessPackage\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The access package associated with the accessPackageAssignmentRequest. An access package defines the collections of resource roles and the policies for how one or more users can get access to those resources. Read-only. Nullable. Supports $expand. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The access package associated with the accessPackageAssignmentRequest. An access package defines the collections of resource roles and the policies for how one or more users can get access to those resources. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var accessPackageAssignmentRequestIdOption = new Option("--access-package-assignment-request-id", description: "key: id of accessPackageAssignmentRequest") { + }; + accessPackageAssignmentRequestIdOption.IsRequired = true; + command.AddOption(accessPackageAssignmentRequestIdOption); + command.SetHandler(async (string accessPackageAssignmentRequestId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, accessPackageAssignmentRequestIdOption); + return command; + } + /// + /// The access package associated with the accessPackageAssignmentRequest. An access package defines the collections of resource roles and the policies for how one or more users can get access to those resources. Read-only. Nullable. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The access package associated with the accessPackageAssignmentRequest. An access package defines the collections of resource roles and the policies for how one or more users can get access to those resources. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var accessPackageAssignmentRequestIdOption = new Option("--access-package-assignment-request-id", description: "key: id of accessPackageAssignmentRequest") { + }; + accessPackageAssignmentRequestIdOption.IsRequired = true; + command.AddOption(accessPackageAssignmentRequestIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessPackageAssignmentRequestId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessPackageAssignmentRequestIdOption, outputOption); + return command; + } + /// + /// The access package associated with the accessPackageAssignmentRequest. An access package defines the collections of resource roles and the policies for how one or more users can get access to those resources. Read-only. Nullable. Supports $expand. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The access package associated with the accessPackageAssignmentRequest. An access package defines the collections of resource roles and the policies for how one or more users can get access to those resources. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var accessPackageAssignmentRequestIdOption = new Option("--access-package-assignment-request-id", description: "key: id of accessPackageAssignmentRequest") { + }; + accessPackageAssignmentRequestIdOption.IsRequired = true; + command.AddOption(accessPackageAssignmentRequestIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string accessPackageAssignmentRequestId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, accessPackageAssignmentRequestIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/identityGovernance/entitlementManagement/assignmentRequests/{accessPackageAssignmentRequest_id}/accessPackage/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The access package associated with the accessPackageAssignmentRequest. An access package defines the collections of resource roles and the policies for how one or more users can get access to those resources. Read-only. Nullable. Supports $expand. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The access package associated with the accessPackageAssignmentRequest. An access package defines the collections of resource roles and the policies for how one or more users can get access to those resources. Read-only. Nullable. Supports $expand. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The access package associated with the accessPackageAssignmentRequest. An access package defines the collections of resource roles and the policies for how one or more users can get access to those resources. Read-only. Nullable. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.Item.AccessPackage.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/AccessPackageAssignmentRequestRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/AccessPackageAssignmentRequestRequestBuilder.cs index 253f70cd5ea..919b109fce2 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/AccessPackageAssignmentRequestRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/AccessPackageAssignmentRequestRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -51,15 +51,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents access package assignment requests created by or on behalf of a user."; // Create options for all the parameters - var accessPackageAssignmentRequestIdOption = new Option("--accesspackageassignmentrequest-id", description: "key: id of accessPackageAssignmentRequest") { + var accessPackageAssignmentRequestIdOption = new Option("--access-package-assignment-request-id", description: "key: id of accessPackageAssignmentRequest") { }; accessPackageAssignmentRequestIdOption.IsRequired = true; command.AddOption(accessPackageAssignmentRequestIdOption); - command.SetHandler(async (string accessPackageAssignmentRequestId) => { + command.SetHandler(async (string accessPackageAssignmentRequestId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, accessPackageAssignmentRequestIdOption); return command; @@ -71,7 +70,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents access package assignment requests created by or on behalf of a user."; // Create options for all the parameters - var accessPackageAssignmentRequestIdOption = new Option("--accesspackageassignmentrequest-id", description: "key: id of accessPackageAssignmentRequest") { + var accessPackageAssignmentRequestIdOption = new Option("--access-package-assignment-request-id", description: "key: id of accessPackageAssignmentRequest") { }; accessPackageAssignmentRequestIdOption.IsRequired = true; command.AddOption(accessPackageAssignmentRequestIdOption); @@ -85,20 +84,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string accessPackageAssignmentRequestId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessPackageAssignmentRequestId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessPackageAssignmentRequestIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessPackageAssignmentRequestIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -108,7 +106,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents access package assignment requests created by or on behalf of a user."; // Create options for all the parameters - var accessPackageAssignmentRequestIdOption = new Option("--accesspackageassignmentrequest-id", description: "key: id of accessPackageAssignmentRequest") { + var accessPackageAssignmentRequestIdOption = new Option("--access-package-assignment-request-id", description: "key: id of accessPackageAssignmentRequest") { }; accessPackageAssignmentRequestIdOption.IsRequired = true; command.AddOption(accessPackageAssignmentRequestIdOption); @@ -116,14 +114,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string accessPackageAssignmentRequestId, string body) => { + command.SetHandler(async (string accessPackageAssignmentRequestId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, accessPackageAssignmentRequestIdOption, bodyOption); return command; @@ -202,42 +199,6 @@ public RequestInformation CreatePatchRequestInformation(AccessPackageAssignmentR requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents access package assignment requests created by or on behalf of a user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents access package assignment requests created by or on behalf of a user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents access package assignment requests created by or on behalf of a user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AccessPackageAssignmentRequest model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents access package assignment requests created by or on behalf of a user. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Assignment/@Ref/@Ref.cs b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Assignment/@Ref/@Ref.cs deleted file mode 100644 index 91d1ae3ddfe..00000000000 --- a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Assignment/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.Item.Assignment.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Assignment/@Ref/RefRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Assignment/@Ref/RefRequestBuilder.cs deleted file mode 100644 index ca0843b9572..00000000000 --- a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Assignment/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.Item.Assignment.@Ref { - /// Builds and executes requests for operations under \identityGovernance\entitlementManagement\assignmentRequests\{accessPackageAssignmentRequest-id}\assignment\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// For a requestType of UserAdd or AdminAdd, this is an access package assignment requested to be created. For a requestType of UserRemove, AdminRemove or SystemRemove, this has the id property of an existing assignment to be removed. Supports $expand. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "For a requestType of UserAdd or AdminAdd, this is an access package assignment requested to be created. For a requestType of UserRemove, AdminRemove or SystemRemove, this has the id property of an existing assignment to be removed. Supports $expand."; - // Create options for all the parameters - var accessPackageAssignmentRequestIdOption = new Option("--accesspackageassignmentrequest-id", description: "key: id of accessPackageAssignmentRequest") { - }; - accessPackageAssignmentRequestIdOption.IsRequired = true; - command.AddOption(accessPackageAssignmentRequestIdOption); - command.SetHandler(async (string accessPackageAssignmentRequestId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, accessPackageAssignmentRequestIdOption); - return command; - } - /// - /// For a requestType of UserAdd or AdminAdd, this is an access package assignment requested to be created. For a requestType of UserRemove, AdminRemove or SystemRemove, this has the id property of an existing assignment to be removed. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "For a requestType of UserAdd or AdminAdd, this is an access package assignment requested to be created. For a requestType of UserRemove, AdminRemove or SystemRemove, this has the id property of an existing assignment to be removed. Supports $expand."; - // Create options for all the parameters - var accessPackageAssignmentRequestIdOption = new Option("--accesspackageassignmentrequest-id", description: "key: id of accessPackageAssignmentRequest") { - }; - accessPackageAssignmentRequestIdOption.IsRequired = true; - command.AddOption(accessPackageAssignmentRequestIdOption); - command.SetHandler(async (string accessPackageAssignmentRequestId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessPackageAssignmentRequestIdOption); - return command; - } - /// - /// For a requestType of UserAdd or AdminAdd, this is an access package assignment requested to be created. For a requestType of UserRemove, AdminRemove or SystemRemove, this has the id property of an existing assignment to be removed. Supports $expand. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "For a requestType of UserAdd or AdminAdd, this is an access package assignment requested to be created. For a requestType of UserRemove, AdminRemove or SystemRemove, this has the id property of an existing assignment to be removed. Supports $expand."; - // Create options for all the parameters - var accessPackageAssignmentRequestIdOption = new Option("--accesspackageassignmentrequest-id", description: "key: id of accessPackageAssignmentRequest") { - }; - accessPackageAssignmentRequestIdOption.IsRequired = true; - command.AddOption(accessPackageAssignmentRequestIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string accessPackageAssignmentRequestId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, accessPackageAssignmentRequestIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/identityGovernance/entitlementManagement/assignmentRequests/{accessPackageAssignmentRequest_id}/assignment/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// For a requestType of UserAdd or AdminAdd, this is an access package assignment requested to be created. For a requestType of UserRemove, AdminRemove or SystemRemove, this has the id property of an existing assignment to be removed. Supports $expand. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// For a requestType of UserAdd or AdminAdd, this is an access package assignment requested to be created. For a requestType of UserRemove, AdminRemove or SystemRemove, this has the id property of an existing assignment to be removed. Supports $expand. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// For a requestType of UserAdd or AdminAdd, this is an access package assignment requested to be created. For a requestType of UserRemove, AdminRemove or SystemRemove, this has the id property of an existing assignment to be removed. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.Item.Assignment.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// For a requestType of UserAdd or AdminAdd, this is an access package assignment requested to be created. For a requestType of UserRemove, AdminRemove or SystemRemove, this has the id property of an existing assignment to be removed. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// For a requestType of UserAdd or AdminAdd, this is an access package assignment requested to be created. For a requestType of UserRemove, AdminRemove or SystemRemove, this has the id property of an existing assignment to be removed. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// For a requestType of UserAdd or AdminAdd, this is an access package assignment requested to be created. For a requestType of UserRemove, AdminRemove or SystemRemove, this has the id property of an existing assignment to be removed. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.Item.Assignment.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Assignment/AssignmentRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Assignment/AssignmentRequestBuilder.cs index 95a0057a04b..34f28144ce1 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Assignment/AssignmentRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Assignment/AssignmentRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "For a requestType of UserAdd or AdminAdd, this is an access package assignment requested to be created. For a requestType of UserRemove, AdminRemove or SystemRemove, this has the id property of an existing assignment to be removed. Supports $expand."; // Create options for all the parameters - var accessPackageAssignmentRequestIdOption = new Option("--accesspackageassignmentrequest-id", description: "key: id of accessPackageAssignmentRequest") { + var accessPackageAssignmentRequestIdOption = new Option("--access-package-assignment-request-id", description: "key: id of accessPackageAssignmentRequest") { }; accessPackageAssignmentRequestIdOption.IsRequired = true; command.AddOption(accessPackageAssignmentRequestIdOption); @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string accessPackageAssignmentRequestId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessPackageAssignmentRequestId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessPackageAssignmentRequestIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessPackageAssignmentRequestIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.Item.Assignment.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.Item.Assignment.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// For a requestType of UserAdd or AdminAdd, this is an access package assignment requested to be created. For a requestType of UserRemove, AdminRemove or SystemRemove, this has the id property of an existing assignment to be removed. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// For a requestType of UserAdd or AdminAdd, this is an access package assignment requested to be created. For a requestType of UserRemove, AdminRemove or SystemRemove, this has the id property of an existing assignment to be removed. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Assignment/Ref/Ref.cs b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Assignment/Ref/Ref.cs new file mode 100644 index 00000000000..a36181bd669 --- /dev/null +++ b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Assignment/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.Item.Assignment.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Assignment/Ref/RefRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Assignment/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..bef7017d45f --- /dev/null +++ b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Assignment/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.Item.Assignment.Ref { + /// Builds and executes requests for operations under \identityGovernance\entitlementManagement\assignmentRequests\{accessPackageAssignmentRequest-id}\assignment\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// For a requestType of UserAdd or AdminAdd, this is an access package assignment requested to be created. For a requestType of UserRemove, AdminRemove or SystemRemove, this has the id property of an existing assignment to be removed. Supports $expand. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "For a requestType of UserAdd or AdminAdd, this is an access package assignment requested to be created. For a requestType of UserRemove, AdminRemove or SystemRemove, this has the id property of an existing assignment to be removed. Supports $expand."; + // Create options for all the parameters + var accessPackageAssignmentRequestIdOption = new Option("--access-package-assignment-request-id", description: "key: id of accessPackageAssignmentRequest") { + }; + accessPackageAssignmentRequestIdOption.IsRequired = true; + command.AddOption(accessPackageAssignmentRequestIdOption); + command.SetHandler(async (string accessPackageAssignmentRequestId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, accessPackageAssignmentRequestIdOption); + return command; + } + /// + /// For a requestType of UserAdd or AdminAdd, this is an access package assignment requested to be created. For a requestType of UserRemove, AdminRemove or SystemRemove, this has the id property of an existing assignment to be removed. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "For a requestType of UserAdd or AdminAdd, this is an access package assignment requested to be created. For a requestType of UserRemove, AdminRemove or SystemRemove, this has the id property of an existing assignment to be removed. Supports $expand."; + // Create options for all the parameters + var accessPackageAssignmentRequestIdOption = new Option("--access-package-assignment-request-id", description: "key: id of accessPackageAssignmentRequest") { + }; + accessPackageAssignmentRequestIdOption.IsRequired = true; + command.AddOption(accessPackageAssignmentRequestIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessPackageAssignmentRequestId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessPackageAssignmentRequestIdOption, outputOption); + return command; + } + /// + /// For a requestType of UserAdd or AdminAdd, this is an access package assignment requested to be created. For a requestType of UserRemove, AdminRemove or SystemRemove, this has the id property of an existing assignment to be removed. Supports $expand. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "For a requestType of UserAdd or AdminAdd, this is an access package assignment requested to be created. For a requestType of UserRemove, AdminRemove or SystemRemove, this has the id property of an existing assignment to be removed. Supports $expand."; + // Create options for all the parameters + var accessPackageAssignmentRequestIdOption = new Option("--access-package-assignment-request-id", description: "key: id of accessPackageAssignmentRequest") { + }; + accessPackageAssignmentRequestIdOption.IsRequired = true; + command.AddOption(accessPackageAssignmentRequestIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string accessPackageAssignmentRequestId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, accessPackageAssignmentRequestIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/identityGovernance/entitlementManagement/assignmentRequests/{accessPackageAssignmentRequest_id}/assignment/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// For a requestType of UserAdd or AdminAdd, this is an access package assignment requested to be created. For a requestType of UserRemove, AdminRemove or SystemRemove, this has the id property of an existing assignment to be removed. Supports $expand. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// For a requestType of UserAdd or AdminAdd, this is an access package assignment requested to be created. For a requestType of UserRemove, AdminRemove or SystemRemove, this has the id property of an existing assignment to be removed. Supports $expand. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// For a requestType of UserAdd or AdminAdd, this is an access package assignment requested to be created. For a requestType of UserRemove, AdminRemove or SystemRemove, this has the id property of an existing assignment to be removed. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.Item.Assignment.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Cancel/CancelRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Cancel/CancelRequestBuilder.cs index ab03921c3f8..cf9fd1e5a3a 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action cancel"; // Create options for all the parameters - var accessPackageAssignmentRequestIdOption = new Option("--accesspackageassignmentrequest-id", description: "key: id of accessPackageAssignmentRequest") { + var accessPackageAssignmentRequestIdOption = new Option("--access-package-assignment-request-id", description: "key: id of accessPackageAssignmentRequest") { }; accessPackageAssignmentRequestIdOption.IsRequired = true; command.AddOption(accessPackageAssignmentRequestIdOption); - command.SetHandler(async (string accessPackageAssignmentRequestId) => { + command.SetHandler(async (string accessPackageAssignmentRequestId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, accessPackageAssignmentRequestIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Requestor/@Ref/@Ref.cs b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Requestor/@Ref/@Ref.cs deleted file mode 100644 index 75717d92ce3..00000000000 --- a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Requestor/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.Item.Requestor.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Requestor/@Ref/RefRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Requestor/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 504089b0bd9..00000000000 --- a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Requestor/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.Item.Requestor.@Ref { - /// Builds and executes requests for operations under \identityGovernance\entitlementManagement\assignmentRequests\{accessPackageAssignmentRequest-id}\requestor\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The subject who requested or, if a direct assignment, was assigned. Read-only. Nullable. Supports $expand. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The subject who requested or, if a direct assignment, was assigned. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var accessPackageAssignmentRequestIdOption = new Option("--accesspackageassignmentrequest-id", description: "key: id of accessPackageAssignmentRequest") { - }; - accessPackageAssignmentRequestIdOption.IsRequired = true; - command.AddOption(accessPackageAssignmentRequestIdOption); - command.SetHandler(async (string accessPackageAssignmentRequestId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, accessPackageAssignmentRequestIdOption); - return command; - } - /// - /// The subject who requested or, if a direct assignment, was assigned. Read-only. Nullable. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The subject who requested or, if a direct assignment, was assigned. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var accessPackageAssignmentRequestIdOption = new Option("--accesspackageassignmentrequest-id", description: "key: id of accessPackageAssignmentRequest") { - }; - accessPackageAssignmentRequestIdOption.IsRequired = true; - command.AddOption(accessPackageAssignmentRequestIdOption); - command.SetHandler(async (string accessPackageAssignmentRequestId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessPackageAssignmentRequestIdOption); - return command; - } - /// - /// The subject who requested or, if a direct assignment, was assigned. Read-only. Nullable. Supports $expand. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The subject who requested or, if a direct assignment, was assigned. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var accessPackageAssignmentRequestIdOption = new Option("--accesspackageassignmentrequest-id", description: "key: id of accessPackageAssignmentRequest") { - }; - accessPackageAssignmentRequestIdOption.IsRequired = true; - command.AddOption(accessPackageAssignmentRequestIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string accessPackageAssignmentRequestId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, accessPackageAssignmentRequestIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/identityGovernance/entitlementManagement/assignmentRequests/{accessPackageAssignmentRequest_id}/requestor/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The subject who requested or, if a direct assignment, was assigned. Read-only. Nullable. Supports $expand. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The subject who requested or, if a direct assignment, was assigned. Read-only. Nullable. Supports $expand. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The subject who requested or, if a direct assignment, was assigned. Read-only. Nullable. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.Item.Requestor.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The subject who requested or, if a direct assignment, was assigned. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The subject who requested or, if a direct assignment, was assigned. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The subject who requested or, if a direct assignment, was assigned. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.Item.Requestor.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Requestor/Ref/Ref.cs b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Requestor/Ref/Ref.cs new file mode 100644 index 00000000000..0623db667dc --- /dev/null +++ b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Requestor/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.Item.Requestor.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Requestor/Ref/RefRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Requestor/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..2b2474a7d24 --- /dev/null +++ b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Requestor/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.Item.Requestor.Ref { + /// Builds and executes requests for operations under \identityGovernance\entitlementManagement\assignmentRequests\{accessPackageAssignmentRequest-id}\requestor\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The subject who requested or, if a direct assignment, was assigned. Read-only. Nullable. Supports $expand. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The subject who requested or, if a direct assignment, was assigned. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var accessPackageAssignmentRequestIdOption = new Option("--access-package-assignment-request-id", description: "key: id of accessPackageAssignmentRequest") { + }; + accessPackageAssignmentRequestIdOption.IsRequired = true; + command.AddOption(accessPackageAssignmentRequestIdOption); + command.SetHandler(async (string accessPackageAssignmentRequestId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, accessPackageAssignmentRequestIdOption); + return command; + } + /// + /// The subject who requested or, if a direct assignment, was assigned. Read-only. Nullable. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The subject who requested or, if a direct assignment, was assigned. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var accessPackageAssignmentRequestIdOption = new Option("--access-package-assignment-request-id", description: "key: id of accessPackageAssignmentRequest") { + }; + accessPackageAssignmentRequestIdOption.IsRequired = true; + command.AddOption(accessPackageAssignmentRequestIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessPackageAssignmentRequestId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessPackageAssignmentRequestIdOption, outputOption); + return command; + } + /// + /// The subject who requested or, if a direct assignment, was assigned. Read-only. Nullable. Supports $expand. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The subject who requested or, if a direct assignment, was assigned. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var accessPackageAssignmentRequestIdOption = new Option("--access-package-assignment-request-id", description: "key: id of accessPackageAssignmentRequest") { + }; + accessPackageAssignmentRequestIdOption.IsRequired = true; + command.AddOption(accessPackageAssignmentRequestIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string accessPackageAssignmentRequestId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, accessPackageAssignmentRequestIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/identityGovernance/entitlementManagement/assignmentRequests/{accessPackageAssignmentRequest_id}/requestor/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The subject who requested or, if a direct assignment, was assigned. Read-only. Nullable. Supports $expand. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The subject who requested or, if a direct assignment, was assigned. Read-only. Nullable. Supports $expand. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The subject who requested or, if a direct assignment, was assigned. Read-only. Nullable. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.Item.Requestor.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Requestor/RequestorRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Requestor/RequestorRequestBuilder.cs index 90341e0bba0..4487767571a 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Requestor/RequestorRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/AssignmentRequests/Item/Requestor/RequestorRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The subject who requested or, if a direct assignment, was assigned. Read-only. Nullable. Supports $expand."; // Create options for all the parameters - var accessPackageAssignmentRequestIdOption = new Option("--accesspackageassignmentrequest-id", description: "key: id of accessPackageAssignmentRequest") { + var accessPackageAssignmentRequestIdOption = new Option("--access-package-assignment-request-id", description: "key: id of accessPackageAssignmentRequest") { }; accessPackageAssignmentRequestIdOption.IsRequired = true; command.AddOption(accessPackageAssignmentRequestIdOption); @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string accessPackageAssignmentRequestId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessPackageAssignmentRequestId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessPackageAssignmentRequestIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessPackageAssignmentRequestIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.Item.Requestor.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.Item.Requestor.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The subject who requested or, if a direct assignment, was assigned. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The subject who requested or, if a direct assignment, was assigned. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/EntitlementManagement/Assignments/AssignmentsRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/Assignments/AssignmentsRequestBuilder.cs index dc4b2238255..b486286e6e9 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/Assignments/AssignmentsRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/Assignments/AssignmentsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,13 +23,12 @@ public class AssignmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AccessPackageAssignmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAccessPackageCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildTargetCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAccessPackageCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildTargetCommand()); return commands; } /// @@ -43,21 +42,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -102,7 +100,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -113,15 +115,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -184,31 +181,6 @@ public FilterByCurrentUserWithOnRequestBuilder FilterByCurrentUserWithOn(string if(string.IsNullOrEmpty(on)) throw new ArgumentNullException(nameof(on)); return new FilterByCurrentUserWithOnRequestBuilder(PathParameters, RequestAdapter, on); } - /// - /// Represents the grant of an access package to a subject (user or group). - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the grant of an access package to a subject (user or group). - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AccessPackageAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the grant of an access package to a subject (user or group). public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/IdentityGovernance/EntitlementManagement/Assignments/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/Assignments/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs index b917234d057..80ff91357a6 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/Assignments/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/Assignments/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +29,17 @@ public Command BuildGetCommand() { }; onOption.IsRequired = true; command.AddOption(onOption); - command.SetHandler(async (object on) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (object on, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onOption, outputOption); return command; } /// @@ -73,16 +72,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function filterByCurrentUser - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/AccessPackage/@Ref/@Ref.cs b/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/AccessPackage/@Ref/@Ref.cs deleted file mode 100644 index 9c5c2c3b2cf..00000000000 --- a/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/AccessPackage/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.IdentityGovernance.EntitlementManagement.Assignments.Item.AccessPackage.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/AccessPackage/@Ref/RefRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/AccessPackage/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 516e1119357..00000000000 --- a/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/AccessPackage/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.IdentityGovernance.EntitlementManagement.Assignments.Item.AccessPackage.@Ref { - /// Builds and executes requests for operations under \identityGovernance\entitlementManagement\assignments\{accessPackageAssignment-id}\accessPackage\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Read-only. Nullable. Supports $filter (eq) on the id property and $expand query parameters. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Read-only. Nullable. Supports $filter (eq) on the id property and $expand query parameters."; - // Create options for all the parameters - var accessPackageAssignmentIdOption = new Option("--accesspackageassignment-id", description: "key: id of accessPackageAssignment") { - }; - accessPackageAssignmentIdOption.IsRequired = true; - command.AddOption(accessPackageAssignmentIdOption); - command.SetHandler(async (string accessPackageAssignmentId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, accessPackageAssignmentIdOption); - return command; - } - /// - /// Read-only. Nullable. Supports $filter (eq) on the id property and $expand query parameters. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Read-only. Nullable. Supports $filter (eq) on the id property and $expand query parameters."; - // Create options for all the parameters - var accessPackageAssignmentIdOption = new Option("--accesspackageassignment-id", description: "key: id of accessPackageAssignment") { - }; - accessPackageAssignmentIdOption.IsRequired = true; - command.AddOption(accessPackageAssignmentIdOption); - command.SetHandler(async (string accessPackageAssignmentId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessPackageAssignmentIdOption); - return command; - } - /// - /// Read-only. Nullable. Supports $filter (eq) on the id property and $expand query parameters. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Read-only. Nullable. Supports $filter (eq) on the id property and $expand query parameters."; - // Create options for all the parameters - var accessPackageAssignmentIdOption = new Option("--accesspackageassignment-id", description: "key: id of accessPackageAssignment") { - }; - accessPackageAssignmentIdOption.IsRequired = true; - command.AddOption(accessPackageAssignmentIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string accessPackageAssignmentId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, accessPackageAssignmentIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/identityGovernance/entitlementManagement/assignments/{accessPackageAssignment_id}/accessPackage/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Read-only. Nullable. Supports $filter (eq) on the id property and $expand query parameters. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Read-only. Nullable. Supports $filter (eq) on the id property and $expand query parameters. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Read-only. Nullable. Supports $filter (eq) on the id property and $expand query parameters. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.IdentityGovernance.EntitlementManagement.Assignments.Item.AccessPackage.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Read-only. Nullable. Supports $filter (eq) on the id property and $expand query parameters. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Supports $filter (eq) on the id property and $expand query parameters. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Supports $filter (eq) on the id property and $expand query parameters. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.IdentityGovernance.EntitlementManagement.Assignments.Item.AccessPackage.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/AccessPackage/AccessPackageRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/AccessPackage/AccessPackageRequestBuilder.cs index b4862f85192..9ae4c4d71e0 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/AccessPackage/AccessPackageRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/AccessPackage/AccessPackageRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,7 +34,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Supports $filter (eq) on the id property and $expand query parameters."; // Create options for all the parameters - var accessPackageAssignmentIdOption = new Option("--accesspackageassignment-id", description: "key: id of accessPackageAssignment") { + var accessPackageAssignmentIdOption = new Option("--access-package-assignment-id", description: "key: id of accessPackageAssignment") { }; accessPackageAssignmentIdOption.IsRequired = true; command.AddOption(accessPackageAssignmentIdOption); @@ -48,25 +48,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string accessPackageAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessPackageAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessPackageAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessPackageAssignmentIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.IdentityGovernance.EntitlementManagement.Assignments.Item.AccessPackage.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.IdentityGovernance.EntitlementManagement.Assignments.Item.AccessPackage.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -106,18 +105,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Supports $filter (eq) on the id property and $expand query parameters. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Supports $filter (eq) on the id property and $expand query parameters. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/AccessPackage/GetApplicablePolicyRequirements/GetApplicablePolicyRequirementsRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/AccessPackage/GetApplicablePolicyRequirements/GetApplicablePolicyRequirementsRequestBuilder.cs index a79827facd1..d5122b69a57 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/AccessPackage/GetApplicablePolicyRequirements/GetApplicablePolicyRequirementsRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/AccessPackage/GetApplicablePolicyRequirements/GetApplicablePolicyRequirementsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,22 +25,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action getApplicablePolicyRequirements"; // Create options for all the parameters - var accessPackageAssignmentIdOption = new Option("--accesspackageassignment-id", description: "key: id of accessPackageAssignment") { + var accessPackageAssignmentIdOption = new Option("--access-package-assignment-id", description: "key: id of accessPackageAssignment") { }; accessPackageAssignmentIdOption.IsRequired = true; command.AddOption(accessPackageAssignmentIdOption); - command.SetHandler(async (string accessPackageAssignmentId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessPackageAssignmentId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessPackageAssignmentIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessPackageAssignmentIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action getApplicablePolicyRequirements - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/AccessPackage/Ref/Ref.cs b/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/AccessPackage/Ref/Ref.cs new file mode 100644 index 00000000000..543ea36b86c --- /dev/null +++ b/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/AccessPackage/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.IdentityGovernance.EntitlementManagement.Assignments.Item.AccessPackage.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/AccessPackage/Ref/RefRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/AccessPackage/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..ba5987a3767 --- /dev/null +++ b/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/AccessPackage/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.IdentityGovernance.EntitlementManagement.Assignments.Item.AccessPackage.Ref { + /// Builds and executes requests for operations under \identityGovernance\entitlementManagement\assignments\{accessPackageAssignment-id}\accessPackage\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Read-only. Nullable. Supports $filter (eq) on the id property and $expand query parameters. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Read-only. Nullable. Supports $filter (eq) on the id property and $expand query parameters."; + // Create options for all the parameters + var accessPackageAssignmentIdOption = new Option("--access-package-assignment-id", description: "key: id of accessPackageAssignment") { + }; + accessPackageAssignmentIdOption.IsRequired = true; + command.AddOption(accessPackageAssignmentIdOption); + command.SetHandler(async (string accessPackageAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, accessPackageAssignmentIdOption); + return command; + } + /// + /// Read-only. Nullable. Supports $filter (eq) on the id property and $expand query parameters. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Read-only. Nullable. Supports $filter (eq) on the id property and $expand query parameters."; + // Create options for all the parameters + var accessPackageAssignmentIdOption = new Option("--access-package-assignment-id", description: "key: id of accessPackageAssignment") { + }; + accessPackageAssignmentIdOption.IsRequired = true; + command.AddOption(accessPackageAssignmentIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessPackageAssignmentId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessPackageAssignmentIdOption, outputOption); + return command; + } + /// + /// Read-only. Nullable. Supports $filter (eq) on the id property and $expand query parameters. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Read-only. Nullable. Supports $filter (eq) on the id property and $expand query parameters."; + // Create options for all the parameters + var accessPackageAssignmentIdOption = new Option("--access-package-assignment-id", description: "key: id of accessPackageAssignment") { + }; + accessPackageAssignmentIdOption.IsRequired = true; + command.AddOption(accessPackageAssignmentIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string accessPackageAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, accessPackageAssignmentIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/identityGovernance/entitlementManagement/assignments/{accessPackageAssignment_id}/accessPackage/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Read-only. Nullable. Supports $filter (eq) on the id property and $expand query parameters. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Read-only. Nullable. Supports $filter (eq) on the id property and $expand query parameters. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Read-only. Nullable. Supports $filter (eq) on the id property and $expand query parameters. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.IdentityGovernance.EntitlementManagement.Assignments.Item.AccessPackage.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/AccessPackageAssignmentRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/AccessPackageAssignmentRequestBuilder.cs index 29c1b78f9bc..c4420e7e14a 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/AccessPackageAssignmentRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/AccessPackageAssignmentRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -36,15 +36,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the grant of an access package to a subject (user or group)."; // Create options for all the parameters - var accessPackageAssignmentIdOption = new Option("--accesspackageassignment-id", description: "key: id of accessPackageAssignment") { + var accessPackageAssignmentIdOption = new Option("--access-package-assignment-id", description: "key: id of accessPackageAssignment") { }; accessPackageAssignmentIdOption.IsRequired = true; command.AddOption(accessPackageAssignmentIdOption); - command.SetHandler(async (string accessPackageAssignmentId) => { + command.SetHandler(async (string accessPackageAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, accessPackageAssignmentIdOption); return command; @@ -56,7 +55,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the grant of an access package to a subject (user or group)."; // Create options for all the parameters - var accessPackageAssignmentIdOption = new Option("--accesspackageassignment-id", description: "key: id of accessPackageAssignment") { + var accessPackageAssignmentIdOption = new Option("--access-package-assignment-id", description: "key: id of accessPackageAssignment") { }; accessPackageAssignmentIdOption.IsRequired = true; command.AddOption(accessPackageAssignmentIdOption); @@ -70,20 +69,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string accessPackageAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessPackageAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessPackageAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessPackageAssignmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -93,7 +91,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the grant of an access package to a subject (user or group)."; // Create options for all the parameters - var accessPackageAssignmentIdOption = new Option("--accesspackageassignment-id", description: "key: id of accessPackageAssignment") { + var accessPackageAssignmentIdOption = new Option("--access-package-assignment-id", description: "key: id of accessPackageAssignment") { }; accessPackageAssignmentIdOption.IsRequired = true; command.AddOption(accessPackageAssignmentIdOption); @@ -101,14 +99,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string accessPackageAssignmentId, string body) => { + command.SetHandler(async (string accessPackageAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, accessPackageAssignmentIdOption, bodyOption); return command; @@ -187,42 +184,6 @@ public RequestInformation CreatePatchRequestInformation(AccessPackageAssignment requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the grant of an access package to a subject (user or group). - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the grant of an access package to a subject (user or group). - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the grant of an access package to a subject (user or group). - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AccessPackageAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the grant of an access package to a subject (user or group). public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/Target/@Ref/@Ref.cs b/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/Target/@Ref/@Ref.cs deleted file mode 100644 index c27361558ad..00000000000 --- a/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/Target/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.IdentityGovernance.EntitlementManagement.Assignments.Item.Target.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/Target/@Ref/RefRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/Target/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 41ce71c5368..00000000000 --- a/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/Target/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.IdentityGovernance.EntitlementManagement.Assignments.Item.Target.@Ref { - /// Builds and executes requests for operations under \identityGovernance\entitlementManagement\assignments\{accessPackageAssignment-id}\target\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The subject of the access package assignment. Read-only. Nullable. Supports $expand. Supports $filter (eq) on objectId. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The subject of the access package assignment. Read-only. Nullable. Supports $expand. Supports $filter (eq) on objectId."; - // Create options for all the parameters - var accessPackageAssignmentIdOption = new Option("--accesspackageassignment-id", description: "key: id of accessPackageAssignment") { - }; - accessPackageAssignmentIdOption.IsRequired = true; - command.AddOption(accessPackageAssignmentIdOption); - command.SetHandler(async (string accessPackageAssignmentId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, accessPackageAssignmentIdOption); - return command; - } - /// - /// The subject of the access package assignment. Read-only. Nullable. Supports $expand. Supports $filter (eq) on objectId. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The subject of the access package assignment. Read-only. Nullable. Supports $expand. Supports $filter (eq) on objectId."; - // Create options for all the parameters - var accessPackageAssignmentIdOption = new Option("--accesspackageassignment-id", description: "key: id of accessPackageAssignment") { - }; - accessPackageAssignmentIdOption.IsRequired = true; - command.AddOption(accessPackageAssignmentIdOption); - command.SetHandler(async (string accessPackageAssignmentId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessPackageAssignmentIdOption); - return command; - } - /// - /// The subject of the access package assignment. Read-only. Nullable. Supports $expand. Supports $filter (eq) on objectId. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The subject of the access package assignment. Read-only. Nullable. Supports $expand. Supports $filter (eq) on objectId."; - // Create options for all the parameters - var accessPackageAssignmentIdOption = new Option("--accesspackageassignment-id", description: "key: id of accessPackageAssignment") { - }; - accessPackageAssignmentIdOption.IsRequired = true; - command.AddOption(accessPackageAssignmentIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string accessPackageAssignmentId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, accessPackageAssignmentIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/identityGovernance/entitlementManagement/assignments/{accessPackageAssignment_id}/target/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The subject of the access package assignment. Read-only. Nullable. Supports $expand. Supports $filter (eq) on objectId. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The subject of the access package assignment. Read-only. Nullable. Supports $expand. Supports $filter (eq) on objectId. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The subject of the access package assignment. Read-only. Nullable. Supports $expand. Supports $filter (eq) on objectId. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.IdentityGovernance.EntitlementManagement.Assignments.Item.Target.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The subject of the access package assignment. Read-only. Nullable. Supports $expand. Supports $filter (eq) on objectId. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The subject of the access package assignment. Read-only. Nullable. Supports $expand. Supports $filter (eq) on objectId. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The subject of the access package assignment. Read-only. Nullable. Supports $expand. Supports $filter (eq) on objectId. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.IdentityGovernance.EntitlementManagement.Assignments.Item.Target.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/Target/Ref/Ref.cs b/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/Target/Ref/Ref.cs new file mode 100644 index 00000000000..8c329a21c1f --- /dev/null +++ b/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/Target/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.IdentityGovernance.EntitlementManagement.Assignments.Item.Target.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/Target/Ref/RefRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/Target/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..7ec0a5d3263 --- /dev/null +++ b/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/Target/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.IdentityGovernance.EntitlementManagement.Assignments.Item.Target.Ref { + /// Builds and executes requests for operations under \identityGovernance\entitlementManagement\assignments\{accessPackageAssignment-id}\target\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The subject of the access package assignment. Read-only. Nullable. Supports $expand. Supports $filter (eq) on objectId. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The subject of the access package assignment. Read-only. Nullable. Supports $expand. Supports $filter (eq) on objectId."; + // Create options for all the parameters + var accessPackageAssignmentIdOption = new Option("--access-package-assignment-id", description: "key: id of accessPackageAssignment") { + }; + accessPackageAssignmentIdOption.IsRequired = true; + command.AddOption(accessPackageAssignmentIdOption); + command.SetHandler(async (string accessPackageAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, accessPackageAssignmentIdOption); + return command; + } + /// + /// The subject of the access package assignment. Read-only. Nullable. Supports $expand. Supports $filter (eq) on objectId. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The subject of the access package assignment. Read-only. Nullable. Supports $expand. Supports $filter (eq) on objectId."; + // Create options for all the parameters + var accessPackageAssignmentIdOption = new Option("--access-package-assignment-id", description: "key: id of accessPackageAssignment") { + }; + accessPackageAssignmentIdOption.IsRequired = true; + command.AddOption(accessPackageAssignmentIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessPackageAssignmentId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessPackageAssignmentIdOption, outputOption); + return command; + } + /// + /// The subject of the access package assignment. Read-only. Nullable. Supports $expand. Supports $filter (eq) on objectId. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The subject of the access package assignment. Read-only. Nullable. Supports $expand. Supports $filter (eq) on objectId."; + // Create options for all the parameters + var accessPackageAssignmentIdOption = new Option("--access-package-assignment-id", description: "key: id of accessPackageAssignment") { + }; + accessPackageAssignmentIdOption.IsRequired = true; + command.AddOption(accessPackageAssignmentIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string accessPackageAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, accessPackageAssignmentIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/identityGovernance/entitlementManagement/assignments/{accessPackageAssignment_id}/target/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The subject of the access package assignment. Read-only. Nullable. Supports $expand. Supports $filter (eq) on objectId. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The subject of the access package assignment. Read-only. Nullable. Supports $expand. Supports $filter (eq) on objectId. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The subject of the access package assignment. Read-only. Nullable. Supports $expand. Supports $filter (eq) on objectId. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.IdentityGovernance.EntitlementManagement.Assignments.Item.Target.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/Target/TargetRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/Target/TargetRequestBuilder.cs index bf9c0f99777..c7c23a9fece 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/Target/TargetRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/Assignments/Item/Target/TargetRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The subject of the access package assignment. Read-only. Nullable. Supports $expand. Supports $filter (eq) on objectId."; // Create options for all the parameters - var accessPackageAssignmentIdOption = new Option("--accesspackageassignment-id", description: "key: id of accessPackageAssignment") { + var accessPackageAssignmentIdOption = new Option("--access-package-assignment-id", description: "key: id of accessPackageAssignment") { }; accessPackageAssignmentIdOption.IsRequired = true; command.AddOption(accessPackageAssignmentIdOption); @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string accessPackageAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessPackageAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessPackageAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessPackageAssignmentIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.IdentityGovernance.EntitlementManagement.Assignments.Item.Target.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.IdentityGovernance.EntitlementManagement.Assignments.Item.Target.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The subject of the access package assignment. Read-only. Nullable. Supports $expand. Supports $filter (eq) on objectId. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The subject of the access package assignment. Read-only. Nullable. Supports $expand. Supports $filter (eq) on objectId. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/CatalogsRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/CatalogsRequestBuilder.cs index e74f20d2286..49ed947b8f6 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/CatalogsRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/CatalogsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class CatalogsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AccessPackageCatalogRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAccessPackagesCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAccessPackagesCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(AccessPackageCatalog body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents a group of access packages. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a group of access packages. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AccessPackageCatalog model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents a group of access packages. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackageCatalogRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackageCatalogRequestBuilder.cs index 588498e4e57..408ccf7c910 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackageCatalogRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackageCatalogRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,6 +23,9 @@ public class AccessPackageCatalogRequestBuilder { public Command BuildAccessPackagesCommand() { var command = new Command("access-packages"); var builder = new ApiSdk.IdentityGovernance.EntitlementManagement.Catalogs.Item.AccessPackages.AccessPackagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -34,15 +37,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents a group of access packages."; // Create options for all the parameters - var accessPackageCatalogIdOption = new Option("--accesspackagecatalog-id", description: "key: id of accessPackageCatalog") { + var accessPackageCatalogIdOption = new Option("--access-package-catalog-id", description: "key: id of accessPackageCatalog") { }; accessPackageCatalogIdOption.IsRequired = true; command.AddOption(accessPackageCatalogIdOption); - command.SetHandler(async (string accessPackageCatalogId) => { + command.SetHandler(async (string accessPackageCatalogId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, accessPackageCatalogIdOption); return command; @@ -54,7 +56,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents a group of access packages."; // Create options for all the parameters - var accessPackageCatalogIdOption = new Option("--accesspackagecatalog-id", description: "key: id of accessPackageCatalog") { + var accessPackageCatalogIdOption = new Option("--access-package-catalog-id", description: "key: id of accessPackageCatalog") { }; accessPackageCatalogIdOption.IsRequired = true; command.AddOption(accessPackageCatalogIdOption); @@ -68,20 +70,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string accessPackageCatalogId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessPackageCatalogId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessPackageCatalogIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessPackageCatalogIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,7 +92,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents a group of access packages."; // Create options for all the parameters - var accessPackageCatalogIdOption = new Option("--accesspackagecatalog-id", description: "key: id of accessPackageCatalog") { + var accessPackageCatalogIdOption = new Option("--access-package-catalog-id", description: "key: id of accessPackageCatalog") { }; accessPackageCatalogIdOption.IsRequired = true; command.AddOption(accessPackageCatalogIdOption); @@ -99,14 +100,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string accessPackageCatalogId, string body) => { + command.SetHandler(async (string accessPackageCatalogId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, accessPackageCatalogIdOption, bodyOption); return command; @@ -178,42 +178,6 @@ public RequestInformation CreatePatchRequestInformation(AccessPackageCatalog bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents a group of access packages. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a group of access packages. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a group of access packages. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AccessPackageCatalog model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents a group of access packages. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/AccessPackagesRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/AccessPackagesRequestBuilder.cs index 374dd50179d..5e8d7580e45 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/AccessPackagesRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/AccessPackagesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,13 +23,12 @@ public class AccessPackagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AccessPackageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCatalogCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetApplicablePolicyRequirementsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCatalogCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetApplicablePolicyRequirementsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -39,7 +38,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The access packages in this catalog. Read-only. Nullable. Supports $expand."; // Create options for all the parameters - var accessPackageCatalogIdOption = new Option("--accesspackagecatalog-id", description: "key: id of accessPackageCatalog") { + var accessPackageCatalogIdOption = new Option("--access-package-catalog-id", description: "key: id of accessPackageCatalog") { }; accessPackageCatalogIdOption.IsRequired = true; command.AddOption(accessPackageCatalogIdOption); @@ -47,21 +46,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string accessPackageCatalogId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessPackageCatalogId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessPackageCatalogIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessPackageCatalogIdOption, bodyOption, outputOption); return command; } /// @@ -71,7 +69,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The access packages in this catalog. Read-only. Nullable. Supports $expand."; // Create options for all the parameters - var accessPackageCatalogIdOption = new Option("--accesspackagecatalog-id", description: "key: id of accessPackageCatalog") { + var accessPackageCatalogIdOption = new Option("--access-package-catalog-id", description: "key: id of accessPackageCatalog") { }; accessPackageCatalogIdOption.IsRequired = true; command.AddOption(accessPackageCatalogIdOption); @@ -110,7 +108,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string accessPackageCatalogId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessPackageCatalogId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessPackageCatalogIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessPackageCatalogIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -192,31 +189,6 @@ public FilterByCurrentUserWithOnRequestBuilder FilterByCurrentUserWithOn(string if(string.IsNullOrEmpty(on)) throw new ArgumentNullException(nameof(on)); return new FilterByCurrentUserWithOnRequestBuilder(PathParameters, RequestAdapter, on); } - /// - /// The access packages in this catalog. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The access packages in this catalog. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.AccessPackage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The access packages in this catalog. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs index 3984baf0a27..f50c9de5616 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/FilterByCurrentUserWithOn/FilterByCurrentUserWithOnRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function filterByCurrentUser"; // Create options for all the parameters - var accessPackageCatalogIdOption = new Option("--accesspackagecatalog-id", description: "key: id of accessPackageCatalog") { + var accessPackageCatalogIdOption = new Option("--access-package-catalog-id", description: "key: id of accessPackageCatalog") { }; accessPackageCatalogIdOption.IsRequired = true; command.AddOption(accessPackageCatalogIdOption); @@ -33,18 +33,17 @@ public Command BuildGetCommand() { }; onOption.IsRequired = true; command.AddOption(onOption); - command.SetHandler(async (string accessPackageCatalogId, object on) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessPackageCatalogId, object on, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessPackageCatalogIdOption, onOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessPackageCatalogIdOption, onOption, outputOption); return command; } /// @@ -77,16 +76,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function filterByCurrentUser - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/Item/AccessPackageRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/Item/AccessPackageRequestBuilder.cs index ed7ea010144..430f17227ef 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/Item/AccessPackageRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/Item/AccessPackageRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,19 +35,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The access packages in this catalog. Read-only. Nullable. Supports $expand."; // Create options for all the parameters - var accessPackageCatalogIdOption = new Option("--accesspackagecatalog-id", description: "key: id of accessPackageCatalog") { + var accessPackageCatalogIdOption = new Option("--access-package-catalog-id", description: "key: id of accessPackageCatalog") { }; accessPackageCatalogIdOption.IsRequired = true; command.AddOption(accessPackageCatalogIdOption); - var accessPackageIdOption = new Option("--accesspackage-id", description: "key: id of accessPackage") { + var accessPackageIdOption = new Option("--access-package-id", description: "key: id of accessPackage") { }; accessPackageIdOption.IsRequired = true; command.AddOption(accessPackageIdOption); - command.SetHandler(async (string accessPackageCatalogId, string accessPackageId) => { + command.SetHandler(async (string accessPackageCatalogId, string accessPackageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, accessPackageCatalogIdOption, accessPackageIdOption); return command; @@ -65,11 +64,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The access packages in this catalog. Read-only. Nullable. Supports $expand."; // Create options for all the parameters - var accessPackageCatalogIdOption = new Option("--accesspackagecatalog-id", description: "key: id of accessPackageCatalog") { + var accessPackageCatalogIdOption = new Option("--access-package-catalog-id", description: "key: id of accessPackageCatalog") { }; accessPackageCatalogIdOption.IsRequired = true; command.AddOption(accessPackageCatalogIdOption); - var accessPackageIdOption = new Option("--accesspackage-id", description: "key: id of accessPackage") { + var accessPackageIdOption = new Option("--access-package-id", description: "key: id of accessPackage") { }; accessPackageIdOption.IsRequired = true; command.AddOption(accessPackageIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string accessPackageCatalogId, string accessPackageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessPackageCatalogId, string accessPackageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessPackageCatalogIdOption, accessPackageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessPackageCatalogIdOption, accessPackageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,11 +104,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The access packages in this catalog. Read-only. Nullable. Supports $expand."; // Create options for all the parameters - var accessPackageCatalogIdOption = new Option("--accesspackagecatalog-id", description: "key: id of accessPackageCatalog") { + var accessPackageCatalogIdOption = new Option("--access-package-catalog-id", description: "key: id of accessPackageCatalog") { }; accessPackageCatalogIdOption.IsRequired = true; command.AddOption(accessPackageCatalogIdOption); - var accessPackageIdOption = new Option("--accesspackage-id", description: "key: id of accessPackage") { + var accessPackageIdOption = new Option("--access-package-id", description: "key: id of accessPackage") { }; accessPackageIdOption.IsRequired = true; command.AddOption(accessPackageIdOption); @@ -118,14 +116,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string accessPackageCatalogId, string accessPackageId, string body) => { + command.SetHandler(async (string accessPackageCatalogId, string accessPackageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, accessPackageCatalogIdOption, accessPackageIdOption, bodyOption); return command; @@ -197,42 +194,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The access packages in this catalog. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The access packages in this catalog. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The access packages in this catalog. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.AccessPackage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The access packages in this catalog. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/Item/Catalog/@Ref/@Ref.cs b/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/Item/Catalog/@Ref/@Ref.cs deleted file mode 100644 index 12e7b2b5e95..00000000000 --- a/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/Item/Catalog/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.IdentityGovernance.EntitlementManagement.Catalogs.Item.AccessPackages.Item.Catalog.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/Item/Catalog/@Ref/RefRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/Item/Catalog/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 9e99a68f13c..00000000000 --- a/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/Item/Catalog/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.IdentityGovernance.EntitlementManagement.Catalogs.Item.AccessPackages.Item.Catalog.@Ref { - /// Builds and executes requests for operations under \identityGovernance\entitlementManagement\catalogs\{accessPackageCatalog-id}\accessPackages\{accessPackage-id}\catalog\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Read-only. Nullable. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Read-only. Nullable."; - // Create options for all the parameters - var accessPackageCatalogIdOption = new Option("--accesspackagecatalog-id", description: "key: id of accessPackageCatalog") { - }; - accessPackageCatalogIdOption.IsRequired = true; - command.AddOption(accessPackageCatalogIdOption); - var accessPackageIdOption = new Option("--accesspackage-id", description: "key: id of accessPackage") { - }; - accessPackageIdOption.IsRequired = true; - command.AddOption(accessPackageIdOption); - command.SetHandler(async (string accessPackageCatalogId, string accessPackageId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, accessPackageCatalogIdOption, accessPackageIdOption); - return command; - } - /// - /// Read-only. Nullable. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Read-only. Nullable."; - // Create options for all the parameters - var accessPackageCatalogIdOption = new Option("--accesspackagecatalog-id", description: "key: id of accessPackageCatalog") { - }; - accessPackageCatalogIdOption.IsRequired = true; - command.AddOption(accessPackageCatalogIdOption); - var accessPackageIdOption = new Option("--accesspackage-id", description: "key: id of accessPackage") { - }; - accessPackageIdOption.IsRequired = true; - command.AddOption(accessPackageIdOption); - command.SetHandler(async (string accessPackageCatalogId, string accessPackageId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessPackageCatalogIdOption, accessPackageIdOption); - return command; - } - /// - /// Read-only. Nullable. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Read-only. Nullable."; - // Create options for all the parameters - var accessPackageCatalogIdOption = new Option("--accesspackagecatalog-id", description: "key: id of accessPackageCatalog") { - }; - accessPackageCatalogIdOption.IsRequired = true; - command.AddOption(accessPackageCatalogIdOption); - var accessPackageIdOption = new Option("--accesspackage-id", description: "key: id of accessPackage") { - }; - accessPackageIdOption.IsRequired = true; - command.AddOption(accessPackageIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string accessPackageCatalogId, string accessPackageId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, accessPackageCatalogIdOption, accessPackageIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/identityGovernance/entitlementManagement/catalogs/{accessPackageCatalog_id}/accessPackages/{accessPackage_id}/catalog/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Read-only. Nullable. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Read-only. Nullable. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Read-only. Nullable. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.IdentityGovernance.EntitlementManagement.Catalogs.Item.AccessPackages.Item.Catalog.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.IdentityGovernance.EntitlementManagement.Catalogs.Item.AccessPackages.Item.Catalog.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/Item/Catalog/CatalogRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/Item/Catalog/CatalogRequestBuilder.cs index 866b97136f0..017d2e9c68b 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/Item/Catalog/CatalogRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/Item/Catalog/CatalogRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,11 +27,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var accessPackageCatalogIdOption = new Option("--accesspackagecatalog-id", description: "key: id of accessPackageCatalog") { + var accessPackageCatalogIdOption = new Option("--access-package-catalog-id", description: "key: id of accessPackageCatalog") { }; accessPackageCatalogIdOption.IsRequired = true; command.AddOption(accessPackageCatalogIdOption); - var accessPackageIdOption = new Option("--accesspackage-id", description: "key: id of accessPackage") { + var accessPackageIdOption = new Option("--access-package-id", description: "key: id of accessPackage") { }; accessPackageIdOption.IsRequired = true; command.AddOption(accessPackageIdOption); @@ -45,25 +45,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string accessPackageCatalogId, string accessPackageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessPackageCatalogId, string accessPackageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessPackageCatalogIdOption, accessPackageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessPackageCatalogIdOption, accessPackageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.IdentityGovernance.EntitlementManagement.Catalogs.Item.AccessPackages.Item.Catalog.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.IdentityGovernance.EntitlementManagement.Catalogs.Item.AccessPackages.Item.Catalog.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -103,18 +102,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/Item/Catalog/Ref/Ref.cs b/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/Item/Catalog/Ref/Ref.cs new file mode 100644 index 00000000000..7789a9fc422 --- /dev/null +++ b/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/Item/Catalog/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.IdentityGovernance.EntitlementManagement.Catalogs.Item.AccessPackages.Item.Catalog.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/Item/Catalog/Ref/RefRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/Item/Catalog/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..c0c38106582 --- /dev/null +++ b/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/Item/Catalog/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.IdentityGovernance.EntitlementManagement.Catalogs.Item.AccessPackages.Item.Catalog.Ref { + /// Builds and executes requests for operations under \identityGovernance\entitlementManagement\catalogs\{accessPackageCatalog-id}\accessPackages\{accessPackage-id}\catalog\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Read-only. Nullable. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Read-only. Nullable."; + // Create options for all the parameters + var accessPackageCatalogIdOption = new Option("--access-package-catalog-id", description: "key: id of accessPackageCatalog") { + }; + accessPackageCatalogIdOption.IsRequired = true; + command.AddOption(accessPackageCatalogIdOption); + var accessPackageIdOption = new Option("--access-package-id", description: "key: id of accessPackage") { + }; + accessPackageIdOption.IsRequired = true; + command.AddOption(accessPackageIdOption); + command.SetHandler(async (string accessPackageCatalogId, string accessPackageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, accessPackageCatalogIdOption, accessPackageIdOption); + return command; + } + /// + /// Read-only. Nullable. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Read-only. Nullable."; + // Create options for all the parameters + var accessPackageCatalogIdOption = new Option("--access-package-catalog-id", description: "key: id of accessPackageCatalog") { + }; + accessPackageCatalogIdOption.IsRequired = true; + command.AddOption(accessPackageCatalogIdOption); + var accessPackageIdOption = new Option("--access-package-id", description: "key: id of accessPackage") { + }; + accessPackageIdOption.IsRequired = true; + command.AddOption(accessPackageIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessPackageCatalogId, string accessPackageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessPackageCatalogIdOption, accessPackageIdOption, outputOption); + return command; + } + /// + /// Read-only. Nullable. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Read-only. Nullable."; + // Create options for all the parameters + var accessPackageCatalogIdOption = new Option("--access-package-catalog-id", description: "key: id of accessPackageCatalog") { + }; + accessPackageCatalogIdOption.IsRequired = true; + command.AddOption(accessPackageCatalogIdOption); + var accessPackageIdOption = new Option("--access-package-id", description: "key: id of accessPackage") { + }; + accessPackageIdOption.IsRequired = true; + command.AddOption(accessPackageIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string accessPackageCatalogId, string accessPackageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, accessPackageCatalogIdOption, accessPackageIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/identityGovernance/entitlementManagement/catalogs/{accessPackageCatalog_id}/accessPackages/{accessPackage_id}/catalog/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Read-only. Nullable. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Read-only. Nullable. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Read-only. Nullable. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.IdentityGovernance.EntitlementManagement.Catalogs.Item.AccessPackages.Item.Catalog.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/Item/GetApplicablePolicyRequirements/GetApplicablePolicyRequirementsRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/Item/GetApplicablePolicyRequirements/GetApplicablePolicyRequirementsRequestBuilder.cs index 1ba2a9efb14..2aaf9d81dde 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/Item/GetApplicablePolicyRequirements/GetApplicablePolicyRequirementsRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/Catalogs/Item/AccessPackages/Item/GetApplicablePolicyRequirements/GetApplicablePolicyRequirementsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,26 +25,25 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action getApplicablePolicyRequirements"; // Create options for all the parameters - var accessPackageCatalogIdOption = new Option("--accesspackagecatalog-id", description: "key: id of accessPackageCatalog") { + var accessPackageCatalogIdOption = new Option("--access-package-catalog-id", description: "key: id of accessPackageCatalog") { }; accessPackageCatalogIdOption.IsRequired = true; command.AddOption(accessPackageCatalogIdOption); - var accessPackageIdOption = new Option("--accesspackage-id", description: "key: id of accessPackage") { + var accessPackageIdOption = new Option("--access-package-id", description: "key: id of accessPackage") { }; accessPackageIdOption.IsRequired = true; command.AddOption(accessPackageIdOption); - command.SetHandler(async (string accessPackageCatalogId, string accessPackageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string accessPackageCatalogId, string accessPackageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, accessPackageCatalogIdOption, accessPackageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, accessPackageCatalogIdOption, accessPackageIdOption, outputOption); return command; } /// @@ -75,16 +74,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action getApplicablePolicyRequirements - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/IdentityGovernance/EntitlementManagement/ConnectedOrganizations/ConnectedOrganizationsRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/ConnectedOrganizations/ConnectedOrganizationsRequestBuilder.cs index 89746086518..204ea59a4af 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/ConnectedOrganizations/ConnectedOrganizationsRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/ConnectedOrganizations/ConnectedOrganizationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class ConnectedOrganizationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ConnectedOrganizationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildExternalSponsorsCommand(), - builder.BuildGetCommand(), - builder.BuildInternalSponsorsCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildExternalSponsorsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInternalSponsorsCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,21 +41,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -101,7 +99,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -112,15 +114,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -175,31 +172,6 @@ public RequestInformation CreatePostRequestInformation(ConnectedOrganization bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents references to a directory or domain of another organization whose users can request access. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents references to a directory or domain of another organization whose users can request access. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ConnectedOrganization model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents references to a directory or domain of another organization whose users can request access. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/IdentityGovernance/EntitlementManagement/ConnectedOrganizations/Item/ConnectedOrganizationRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/ConnectedOrganizations/Item/ConnectedOrganizationRequestBuilder.cs index ea7763b01f7..ff1ca6ad04b 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/ConnectedOrganizations/Item/ConnectedOrganizationRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/ConnectedOrganizations/Item/ConnectedOrganizationRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,15 +28,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents references to a directory or domain of another organization whose users can request access."; // Create options for all the parameters - var connectedOrganizationIdOption = new Option("--connectedorganization-id", description: "key: id of connectedOrganization") { + var connectedOrganizationIdOption = new Option("--connected-organization-id", description: "key: id of connectedOrganization") { }; connectedOrganizationIdOption.IsRequired = true; command.AddOption(connectedOrganizationIdOption); - command.SetHandler(async (string connectedOrganizationId) => { + command.SetHandler(async (string connectedOrganizationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, connectedOrganizationIdOption); return command; @@ -44,6 +43,9 @@ public Command BuildDeleteCommand() { public Command BuildExternalSponsorsCommand() { var command = new Command("external-sponsors"); var builder = new ApiSdk.IdentityGovernance.EntitlementManagement.ConnectedOrganizations.Item.ExternalSponsors.ExternalSponsorsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -55,7 +57,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents references to a directory or domain of another organization whose users can request access."; // Create options for all the parameters - var connectedOrganizationIdOption = new Option("--connectedorganization-id", description: "key: id of connectedOrganization") { + var connectedOrganizationIdOption = new Option("--connected-organization-id", description: "key: id of connectedOrganization") { }; connectedOrganizationIdOption.IsRequired = true; command.AddOption(connectedOrganizationIdOption); @@ -69,25 +71,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string connectedOrganizationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string connectedOrganizationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, connectedOrganizationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, connectedOrganizationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildInternalSponsorsCommand() { var command = new Command("internal-sponsors"); var builder = new ApiSdk.IdentityGovernance.EntitlementManagement.ConnectedOrganizations.Item.InternalSponsors.InternalSponsorsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -99,7 +103,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents references to a directory or domain of another organization whose users can request access."; // Create options for all the parameters - var connectedOrganizationIdOption = new Option("--connectedorganization-id", description: "key: id of connectedOrganization") { + var connectedOrganizationIdOption = new Option("--connected-organization-id", description: "key: id of connectedOrganization") { }; connectedOrganizationIdOption.IsRequired = true; command.AddOption(connectedOrganizationIdOption); @@ -107,14 +111,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string connectedOrganizationId, string body) => { + command.SetHandler(async (string connectedOrganizationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, connectedOrganizationIdOption, bodyOption); return command; @@ -186,42 +189,6 @@ public RequestInformation CreatePatchRequestInformation(ConnectedOrganization bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents references to a directory or domain of another organization whose users can request access. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents references to a directory or domain of another organization whose users can request access. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents references to a directory or domain of another organization whose users can request access. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ConnectedOrganization model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents references to a directory or domain of another organization whose users can request access. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/EntitlementManagement/ConnectedOrganizations/Item/ExternalSponsors/ExternalSponsorsRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/ConnectedOrganizations/Item/ExternalSponsors/ExternalSponsorsRequestBuilder.cs index 51750cc2f94..70ed14a1249 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/ConnectedOrganizations/Item/ExternalSponsors/ExternalSponsorsRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/ConnectedOrganizations/Item/ExternalSponsors/ExternalSponsorsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExternalSponsorsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DirectoryObjectRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Nullable."; // Create options for all the parameters - var connectedOrganizationIdOption = new Option("--connectedorganization-id", description: "key: id of connectedOrganization") { + var connectedOrganizationIdOption = new Option("--connected-organization-id", description: "key: id of connectedOrganization") { }; connectedOrganizationIdOption.IsRequired = true; command.AddOption(connectedOrganizationIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string connectedOrganizationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string connectedOrganizationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, connectedOrganizationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, connectedOrganizationIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Nullable."; // Create options for all the parameters - var connectedOrganizationIdOption = new Option("--connectedorganization-id", description: "key: id of connectedOrganization") { + var connectedOrganizationIdOption = new Option("--connected-organization-id", description: "key: id of connectedOrganization") { }; connectedOrganizationIdOption.IsRequired = true; command.AddOption(connectedOrganizationIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string connectedOrganizationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string connectedOrganizationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, connectedOrganizationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, connectedOrganizationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(DirectoryObject body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DirectoryObject model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/IdentityGovernance/EntitlementManagement/ConnectedOrganizations/Item/ExternalSponsors/Item/DirectoryObjectRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/ConnectedOrganizations/Item/ExternalSponsors/Item/DirectoryObjectRequestBuilder.cs index 992721da3fa..1bec6bc0609 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/ConnectedOrganizations/Item/ExternalSponsors/Item/DirectoryObjectRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/ConnectedOrganizations/Item/ExternalSponsors/Item/DirectoryObjectRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Nullable."; // Create options for all the parameters - var connectedOrganizationIdOption = new Option("--connectedorganization-id", description: "key: id of connectedOrganization") { + var connectedOrganizationIdOption = new Option("--connected-organization-id", description: "key: id of connectedOrganization") { }; connectedOrganizationIdOption.IsRequired = true; command.AddOption(connectedOrganizationIdOption); - var directoryObjectIdOption = new Option("--directoryobject-id", description: "key: id of directoryObject") { + var directoryObjectIdOption = new Option("--directory-object-id", description: "key: id of directoryObject") { }; directoryObjectIdOption.IsRequired = true; command.AddOption(directoryObjectIdOption); - command.SetHandler(async (string connectedOrganizationId, string directoryObjectId) => { + command.SetHandler(async (string connectedOrganizationId, string directoryObjectId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, connectedOrganizationIdOption, directoryObjectIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Nullable."; // Create options for all the parameters - var connectedOrganizationIdOption = new Option("--connectedorganization-id", description: "key: id of connectedOrganization") { + var connectedOrganizationIdOption = new Option("--connected-organization-id", description: "key: id of connectedOrganization") { }; connectedOrganizationIdOption.IsRequired = true; command.AddOption(connectedOrganizationIdOption); - var directoryObjectIdOption = new Option("--directoryobject-id", description: "key: id of directoryObject") { + var directoryObjectIdOption = new Option("--directory-object-id", description: "key: id of directoryObject") { }; directoryObjectIdOption.IsRequired = true; command.AddOption(directoryObjectIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string connectedOrganizationId, string directoryObjectId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string connectedOrganizationId, string directoryObjectId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, connectedOrganizationIdOption, directoryObjectIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, connectedOrganizationIdOption, directoryObjectIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Nullable."; // Create options for all the parameters - var connectedOrganizationIdOption = new Option("--connectedorganization-id", description: "key: id of connectedOrganization") { + var connectedOrganizationIdOption = new Option("--connected-organization-id", description: "key: id of connectedOrganization") { }; connectedOrganizationIdOption.IsRequired = true; command.AddOption(connectedOrganizationIdOption); - var directoryObjectIdOption = new Option("--directoryobject-id", description: "key: id of directoryObject") { + var directoryObjectIdOption = new Option("--directory-object-id", description: "key: id of directoryObject") { }; directoryObjectIdOption.IsRequired = true; command.AddOption(directoryObjectIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string connectedOrganizationId, string directoryObjectId, string body) => { + command.SetHandler(async (string connectedOrganizationId, string directoryObjectId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, connectedOrganizationIdOption, directoryObjectIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(DirectoryObject body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DirectoryObject model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/EntitlementManagement/ConnectedOrganizations/Item/InternalSponsors/InternalSponsorsRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/ConnectedOrganizations/Item/InternalSponsors/InternalSponsorsRequestBuilder.cs index 3f1b8c4bf86..b5663573261 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/ConnectedOrganizations/Item/InternalSponsors/InternalSponsorsRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/ConnectedOrganizations/Item/InternalSponsors/InternalSponsorsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class InternalSponsorsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DirectoryObjectRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Nullable."; // Create options for all the parameters - var connectedOrganizationIdOption = new Option("--connectedorganization-id", description: "key: id of connectedOrganization") { + var connectedOrganizationIdOption = new Option("--connected-organization-id", description: "key: id of connectedOrganization") { }; connectedOrganizationIdOption.IsRequired = true; command.AddOption(connectedOrganizationIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string connectedOrganizationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string connectedOrganizationId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, connectedOrganizationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, connectedOrganizationIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Nullable."; // Create options for all the parameters - var connectedOrganizationIdOption = new Option("--connectedorganization-id", description: "key: id of connectedOrganization") { + var connectedOrganizationIdOption = new Option("--connected-organization-id", description: "key: id of connectedOrganization") { }; connectedOrganizationIdOption.IsRequired = true; command.AddOption(connectedOrganizationIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string connectedOrganizationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string connectedOrganizationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, connectedOrganizationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, connectedOrganizationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(DirectoryObject body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DirectoryObject model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/IdentityGovernance/EntitlementManagement/ConnectedOrganizations/Item/InternalSponsors/Item/DirectoryObjectRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/ConnectedOrganizations/Item/InternalSponsors/Item/DirectoryObjectRequestBuilder.cs index 93338c64744..92847f98e84 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/ConnectedOrganizations/Item/InternalSponsors/Item/DirectoryObjectRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/ConnectedOrganizations/Item/InternalSponsors/Item/DirectoryObjectRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Nullable."; // Create options for all the parameters - var connectedOrganizationIdOption = new Option("--connectedorganization-id", description: "key: id of connectedOrganization") { + var connectedOrganizationIdOption = new Option("--connected-organization-id", description: "key: id of connectedOrganization") { }; connectedOrganizationIdOption.IsRequired = true; command.AddOption(connectedOrganizationIdOption); - var directoryObjectIdOption = new Option("--directoryobject-id", description: "key: id of directoryObject") { + var directoryObjectIdOption = new Option("--directory-object-id", description: "key: id of directoryObject") { }; directoryObjectIdOption.IsRequired = true; command.AddOption(directoryObjectIdOption); - command.SetHandler(async (string connectedOrganizationId, string directoryObjectId) => { + command.SetHandler(async (string connectedOrganizationId, string directoryObjectId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, connectedOrganizationIdOption, directoryObjectIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Nullable."; // Create options for all the parameters - var connectedOrganizationIdOption = new Option("--connectedorganization-id", description: "key: id of connectedOrganization") { + var connectedOrganizationIdOption = new Option("--connected-organization-id", description: "key: id of connectedOrganization") { }; connectedOrganizationIdOption.IsRequired = true; command.AddOption(connectedOrganizationIdOption); - var directoryObjectIdOption = new Option("--directoryobject-id", description: "key: id of directoryObject") { + var directoryObjectIdOption = new Option("--directory-object-id", description: "key: id of directoryObject") { }; directoryObjectIdOption.IsRequired = true; command.AddOption(directoryObjectIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string connectedOrganizationId, string directoryObjectId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string connectedOrganizationId, string directoryObjectId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, connectedOrganizationIdOption, directoryObjectIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, connectedOrganizationIdOption, directoryObjectIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Nullable."; // Create options for all the parameters - var connectedOrganizationIdOption = new Option("--connectedorganization-id", description: "key: id of connectedOrganization") { + var connectedOrganizationIdOption = new Option("--connected-organization-id", description: "key: id of connectedOrganization") { }; connectedOrganizationIdOption.IsRequired = true; command.AddOption(connectedOrganizationIdOption); - var directoryObjectIdOption = new Option("--directoryobject-id", description: "key: id of directoryObject") { + var directoryObjectIdOption = new Option("--directory-object-id", description: "key: id of directoryObject") { }; directoryObjectIdOption.IsRequired = true; command.AddOption(directoryObjectIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string connectedOrganizationId, string directoryObjectId, string body) => { + command.SetHandler(async (string connectedOrganizationId, string directoryObjectId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, connectedOrganizationIdOption, directoryObjectIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(DirectoryObject body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DirectoryObject model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/EntitlementManagement/EntitlementManagementRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/EntitlementManagementRequestBuilder.cs index 0e248d51406..adc3a0159e1 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/EntitlementManagementRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/EntitlementManagementRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,6 +29,9 @@ public class EntitlementManagementRequestBuilder { public Command BuildAccessPackageAssignmentApprovalsCommand() { var command = new Command("access-package-assignment-approvals"); var builder = new ApiSdk.IdentityGovernance.EntitlementManagement.AccessPackageAssignmentApprovals.AccessPackageAssignmentApprovalsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -36,6 +39,9 @@ public Command BuildAccessPackageAssignmentApprovalsCommand() { public Command BuildAccessPackagesCommand() { var command = new Command("access-packages"); var builder = new ApiSdk.IdentityGovernance.EntitlementManagement.AccessPackages.AccessPackagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -43,6 +49,9 @@ public Command BuildAccessPackagesCommand() { public Command BuildAssignmentRequestsCommand() { var command = new Command("assignment-requests"); var builder = new ApiSdk.IdentityGovernance.EntitlementManagement.AssignmentRequests.AssignmentRequestsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -50,6 +59,9 @@ public Command BuildAssignmentRequestsCommand() { public Command BuildAssignmentsCommand() { var command = new Command("assignments"); var builder = new ApiSdk.IdentityGovernance.EntitlementManagement.Assignments.AssignmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -57,6 +69,9 @@ public Command BuildAssignmentsCommand() { public Command BuildCatalogsCommand() { var command = new Command("catalogs"); var builder = new ApiSdk.IdentityGovernance.EntitlementManagement.Catalogs.CatalogsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -64,6 +79,9 @@ public Command BuildCatalogsCommand() { public Command BuildConnectedOrganizationsCommand() { var command = new Command("connected-organizations"); var builder = new ApiSdk.IdentityGovernance.EntitlementManagement.ConnectedOrganizations.ConnectedOrganizationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -75,11 +93,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property entitlementManagement for identityGovernance"; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -101,20 +118,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -128,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -215,42 +230,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property entitlementManagement for identityGovernance - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entitlementManagement from identityGovernance - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property entitlementManagement in identityGovernance - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.EntitlementManagement model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entitlementManagement from identityGovernance public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/EntitlementManagement/Settings/SettingsRequestBuilder.cs b/src/generated/IdentityGovernance/EntitlementManagement/Settings/SettingsRequestBuilder.cs index 520ab5d27fe..3b1f126a583 100644 --- a/src/generated/IdentityGovernance/EntitlementManagement/Settings/SettingsRequestBuilder.cs +++ b/src/generated/IdentityGovernance/EntitlementManagement/Settings/SettingsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the settings that control the behavior of Azure AD entitlement management."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -52,20 +51,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -79,14 +77,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -158,42 +155,6 @@ public RequestInformation CreatePatchRequestInformation(EntitlementManagementSet requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the settings that control the behavior of Azure AD entitlement management. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the settings that control the behavior of Azure AD entitlement management. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the settings that control the behavior of Azure AD entitlement management. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(EntitlementManagementSettings model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the settings that control the behavior of Azure AD entitlement management. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/IdentityGovernanceRequestBuilder.cs b/src/generated/IdentityGovernance/IdentityGovernanceRequestBuilder.cs index 21c7320a5bc..0e3937c7d7c 100644 --- a/src/generated/IdentityGovernance/IdentityGovernanceRequestBuilder.cs +++ b/src/generated/IdentityGovernance/IdentityGovernanceRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -73,20 +73,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -100,14 +99,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -174,31 +172,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get identityGovernance - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update identityGovernance - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.IdentityGovernance model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get identityGovernance public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/TermsOfUse/AgreementAcceptances/AgreementAcceptancesRequestBuilder.cs b/src/generated/IdentityGovernance/TermsOfUse/AgreementAcceptances/AgreementAcceptancesRequestBuilder.cs index e9259139437..ae48400e25d 100644 --- a/src/generated/IdentityGovernance/TermsOfUse/AgreementAcceptances/AgreementAcceptancesRequestBuilder.cs +++ b/src/generated/IdentityGovernance/TermsOfUse/AgreementAcceptances/AgreementAcceptancesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AgreementAcceptancesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AgreementAcceptanceRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(AgreementAcceptance body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the current status of a user's response to a company's customizable terms of use agreement. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the current status of a user's response to a company's customizable terms of use agreement. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AgreementAcceptance model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the current status of a user's response to a company's customizable terms of use agreement. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/IdentityGovernance/TermsOfUse/AgreementAcceptances/Item/AgreementAcceptanceRequestBuilder.cs b/src/generated/IdentityGovernance/TermsOfUse/AgreementAcceptances/Item/AgreementAcceptanceRequestBuilder.cs index 2b5106275a2..004799e3bc5 100644 --- a/src/generated/IdentityGovernance/TermsOfUse/AgreementAcceptances/Item/AgreementAcceptanceRequestBuilder.cs +++ b/src/generated/IdentityGovernance/TermsOfUse/AgreementAcceptances/Item/AgreementAcceptanceRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the current status of a user's response to a company's customizable terms of use agreement."; // Create options for all the parameters - var agreementAcceptanceIdOption = new Option("--agreementacceptance-id", description: "key: id of agreementAcceptance") { + var agreementAcceptanceIdOption = new Option("--agreement-acceptance-id", description: "key: id of agreementAcceptance") { }; agreementAcceptanceIdOption.IsRequired = true; command.AddOption(agreementAcceptanceIdOption); - command.SetHandler(async (string agreementAcceptanceId) => { + command.SetHandler(async (string agreementAcceptanceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, agreementAcceptanceIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the current status of a user's response to a company's customizable terms of use agreement."; // Create options for all the parameters - var agreementAcceptanceIdOption = new Option("--agreementacceptance-id", description: "key: id of agreementAcceptance") { + var agreementAcceptanceIdOption = new Option("--agreement-acceptance-id", description: "key: id of agreementAcceptance") { }; agreementAcceptanceIdOption.IsRequired = true; command.AddOption(agreementAcceptanceIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string agreementAcceptanceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string agreementAcceptanceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, agreementAcceptanceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, agreementAcceptanceIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the current status of a user's response to a company's customizable terms of use agreement."; // Create options for all the parameters - var agreementAcceptanceIdOption = new Option("--agreementacceptance-id", description: "key: id of agreementAcceptance") { + var agreementAcceptanceIdOption = new Option("--agreement-acceptance-id", description: "key: id of agreementAcceptance") { }; agreementAcceptanceIdOption.IsRequired = true; command.AddOption(agreementAcceptanceIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string agreementAcceptanceId, string body) => { + command.SetHandler(async (string agreementAcceptanceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, agreementAcceptanceIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(AgreementAcceptance body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the current status of a user's response to a company's customizable terms of use agreement. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the current status of a user's response to a company's customizable terms of use agreement. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the current status of a user's response to a company's customizable terms of use agreement. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AgreementAcceptance model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the current status of a user's response to a company's customizable terms of use agreement. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/TermsOfUse/Agreements/AgreementsRequestBuilder.cs b/src/generated/IdentityGovernance/TermsOfUse/Agreements/AgreementsRequestBuilder.cs index 8aac1b96ea8..29970f13c44 100644 --- a/src/generated/IdentityGovernance/TermsOfUse/Agreements/AgreementsRequestBuilder.cs +++ b/src/generated/IdentityGovernance/TermsOfUse/Agreements/AgreementsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AgreementsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AgreementRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(Agreement body, Action - /// Represents a tenant's customizable terms of use agreement that's created and managed with Azure Active Directory (Azure AD). - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a tenant's customizable terms of use agreement that's created and managed with Azure Active Directory (Azure AD). - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Agreement model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents a tenant's customizable terms of use agreement that's created and managed with Azure Active Directory (Azure AD). public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/IdentityGovernance/TermsOfUse/Agreements/Item/AgreementRequestBuilder.cs b/src/generated/IdentityGovernance/TermsOfUse/Agreements/Item/AgreementRequestBuilder.cs index e7754c908d8..495910d510a 100644 --- a/src/generated/IdentityGovernance/TermsOfUse/Agreements/Item/AgreementRequestBuilder.cs +++ b/src/generated/IdentityGovernance/TermsOfUse/Agreements/Item/AgreementRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,10 @@ public Command BuildDeleteCommand() { }; agreementIdOption.IsRequired = true; command.AddOption(agreementIdOption); - command.SetHandler(async (string agreementId) => { + command.SetHandler(async (string agreementId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, agreementIdOption); return command; @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string agreementId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string agreementId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, agreementIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, agreementIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string agreementId, string body) => { + command.SetHandler(async (string agreementId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, agreementIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(Agreement body, Action - /// Represents a tenant's customizable terms of use agreement that's created and managed with Azure Active Directory (Azure AD). - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a tenant's customizable terms of use agreement that's created and managed with Azure Active Directory (Azure AD). - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a tenant's customizable terms of use agreement that's created and managed with Azure Active Directory (Azure AD). - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Agreement model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents a tenant's customizable terms of use agreement that's created and managed with Azure Active Directory (Azure AD). public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityGovernance/TermsOfUse/TermsOfUseRequestBuilder.cs b/src/generated/IdentityGovernance/TermsOfUse/TermsOfUseRequestBuilder.cs index 38c23fd4bef..920891ba04e 100644 --- a/src/generated/IdentityGovernance/TermsOfUse/TermsOfUseRequestBuilder.cs +++ b/src/generated/IdentityGovernance/TermsOfUse/TermsOfUseRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -24,6 +24,9 @@ public class TermsOfUseRequestBuilder { public Command BuildAgreementAcceptancesCommand() { var command = new Command("agreement-acceptances"); var builder = new ApiSdk.IdentityGovernance.TermsOfUse.AgreementAcceptances.AgreementAcceptancesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -31,6 +34,9 @@ public Command BuildAgreementAcceptancesCommand() { public Command BuildAgreementsCommand() { var command = new Command("agreements"); var builder = new ApiSdk.IdentityGovernance.TermsOfUse.Agreements.AgreementsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -42,11 +48,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property termsOfUse for identityGovernance"; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -68,20 +73,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -95,14 +99,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -174,42 +177,6 @@ public RequestInformation CreatePatchRequestInformation(TermsOfUseContainer body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property termsOfUse for identityGovernance - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get termsOfUse from identityGovernance - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property termsOfUse in identityGovernance - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(TermsOfUseContainer model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get termsOfUse from identityGovernance public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityProtection/IdentityProtectionRequestBuilder.cs b/src/generated/IdentityProtection/IdentityProtectionRequestBuilder.cs index 0bc198372cc..ead78037c7c 100644 --- a/src/generated/IdentityProtection/IdentityProtectionRequestBuilder.cs +++ b/src/generated/IdentityProtection/IdentityProtectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,20 +38,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -65,14 +64,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -80,6 +78,9 @@ public Command BuildPatchCommand() { public Command BuildRiskDetectionsCommand() { var command = new Command("risk-detections"); var builder = new ApiSdk.IdentityProtection.RiskDetections.RiskDetectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -87,6 +88,9 @@ public Command BuildRiskDetectionsCommand() { public Command BuildRiskyUsersCommand() { var command = new Command("risky-users"); var builder = new ApiSdk.IdentityProtection.RiskyUsers.RiskyUsersRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildConfirmCompromisedCommand()); command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildDismissCommand()); @@ -133,7 +137,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft.Graph.IdentityProtection body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(IdentityProtectionRoot body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -145,31 +149,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get identityProtection - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update identityProtection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.IdentityProtection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get identityProtection public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityProtection/RiskDetections/Item/RiskDetectionRequestBuilder.cs b/src/generated/IdentityProtection/RiskDetections/Item/RiskDetectionRequestBuilder.cs index 6879efa7b07..8d15b2c9422 100644 --- a/src/generated/IdentityProtection/RiskDetections/Item/RiskDetectionRequestBuilder.cs +++ b/src/generated/IdentityProtection/RiskDetections/Item/RiskDetectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -20,33 +20,32 @@ public class RiskDetectionRequestBuilder { /// Url template to use to build the URL for the current request builder private string UrlTemplate { get; set; } /// - /// Delete navigation property riskDetections for identityProtection + /// Risk detection in Azure AD Identity Protection and the associated information about the detection. /// public Command BuildDeleteCommand() { var command = new Command("delete"); - command.Description = "Delete navigation property riskDetections for identityProtection"; + command.Description = "Risk detection in Azure AD Identity Protection and the associated information about the detection."; // Create options for all the parameters - var riskDetectionIdOption = new Option("--riskdetection-id", description: "key: id of riskDetection") { + var riskDetectionIdOption = new Option("--risk-detection-id", description: "key: id of riskDetection") { }; riskDetectionIdOption.IsRequired = true; command.AddOption(riskDetectionIdOption); - command.SetHandler(async (string riskDetectionId) => { + command.SetHandler(async (string riskDetectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, riskDetectionIdOption); return command; } /// - /// Get riskDetections from identityProtection + /// Risk detection in Azure AD Identity Protection and the associated information about the detection. /// public Command BuildGetCommand() { var command = new Command("get"); - command.Description = "Get riskDetections from identityProtection"; + command.Description = "Risk detection in Azure AD Identity Protection and the associated information about the detection."; // Create options for all the parameters - var riskDetectionIdOption = new Option("--riskdetection-id", description: "key: id of riskDetection") { + var riskDetectionIdOption = new Option("--risk-detection-id", description: "key: id of riskDetection") { }; riskDetectionIdOption.IsRequired = true; command.AddOption(riskDetectionIdOption); @@ -60,30 +59,29 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string riskDetectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string riskDetectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, riskDetectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, riskDetectionIdOption, selectOption, expandOption, outputOption); return command; } /// - /// Update the navigation property riskDetections in identityProtection + /// Risk detection in Azure AD Identity Protection and the associated information about the detection. /// public Command BuildPatchCommand() { var command = new Command("patch"); - command.Description = "Update the navigation property riskDetections in identityProtection"; + command.Description = "Risk detection in Azure AD Identity Protection and the associated information about the detection."; // Create options for all the parameters - var riskDetectionIdOption = new Option("--riskdetection-id", description: "key: id of riskDetection") { + var riskDetectionIdOption = new Option("--risk-detection-id", description: "key: id of riskDetection") { }; riskDetectionIdOption.IsRequired = true; command.AddOption(riskDetectionIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string riskDetectionId, string body) => { + command.SetHandler(async (string riskDetectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, riskDetectionIdOption, bodyOption); return command; @@ -117,7 +114,7 @@ public RiskDetectionRequestBuilder(Dictionary pathParameters, IR RequestAdapter = requestAdapter; } /// - /// Delete navigation property riskDetections for identityProtection + /// Risk detection in Azure AD Identity Protection and the associated information about the detection. /// Request headers /// Request options /// @@ -132,7 +129,7 @@ public RequestInformation CreateDeleteRequestInformation(Action - /// Get riskDetections from identityProtection + /// Risk detection in Azure AD Identity Protection and the associated information about the detection. /// Request headers /// Request options /// Request query parameters @@ -153,7 +150,7 @@ public RequestInformation CreateGetRequestInformation(Action return requestInfo; } /// - /// Update the navigation property riskDetections in identityProtection + /// Risk detection in Azure AD Identity Protection and the associated information about the detection. /// /// Request headers /// Request options @@ -170,43 +167,7 @@ public RequestInformation CreatePatchRequestInformation(RiskDetection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property riskDetections for identityProtection - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get riskDetections from identityProtection - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property riskDetections in identityProtection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(RiskDetection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// Get riskDetections from identityProtection + /// Risk detection in Azure AD Identity Protection and the associated information about the detection. public class GetQueryParameters : QueryParametersBase { /// Expand related entities public string[] Expand { get; set; } diff --git a/src/generated/IdentityProtection/RiskDetections/RiskDetectionsRequestBuilder.cs b/src/generated/IdentityProtection/RiskDetections/RiskDetectionsRequestBuilder.cs index 604b8db8fc2..2c258282395 100644 --- a/src/generated/IdentityProtection/RiskDetections/RiskDetectionsRequestBuilder.cs +++ b/src/generated/IdentityProtection/RiskDetections/RiskDetectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,47 +22,45 @@ public class RiskDetectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new RiskDetectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// - /// Create new navigation property to riskDetections for identityProtection + /// Risk detection in Azure AD Identity Protection and the associated information about the detection. /// public Command BuildCreateCommand() { var command = new Command("create"); - command.Description = "Create new navigation property to riskDetections for identityProtection"; + command.Description = "Risk detection in Azure AD Identity Protection and the associated information about the detection."; // Create options for all the parameters var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// - /// Get riskDetections from identityProtection + /// Risk detection in Azure AD Identity Protection and the associated information about the detection. /// public Command BuildListCommand() { var command = new Command("list"); - command.Description = "Get riskDetections from identityProtection"; + command.Description = "Risk detection in Azure AD Identity Protection and the associated information about the detection."; // Create options for all the parameters var topOption = new Option("--top", description: "Show only the first n items") { }; @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -135,7 +132,7 @@ public RiskDetectionsRequestBuilder(Dictionary pathParameters, I RequestAdapter = requestAdapter; } /// - /// Get riskDetections from identityProtection + /// Risk detection in Azure AD Identity Protection and the associated information about the detection. /// Request headers /// Request options /// Request query parameters @@ -156,7 +153,7 @@ public RequestInformation CreateGetRequestInformation(Action return requestInfo; } /// - /// Create new navigation property to riskDetections for identityProtection + /// Risk detection in Azure AD Identity Protection and the associated information about the detection. /// /// Request headers /// Request options @@ -173,32 +170,7 @@ public RequestInformation CreatePostRequestInformation(RiskDetection body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get riskDetections from identityProtection - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to riskDetections for identityProtection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RiskDetection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Get riskDetections from identityProtection + /// Risk detection in Azure AD Identity Protection and the associated information about the detection. public class GetQueryParameters : QueryParametersBase { /// Include count of items public bool? Count { get; set; } diff --git a/src/generated/IdentityProtection/RiskyUsers/ConfirmCompromised/ConfirmCompromisedRequestBuilder.cs b/src/generated/IdentityProtection/RiskyUsers/ConfirmCompromised/ConfirmCompromisedRequestBuilder.cs index 59ec451a9fe..28b5a87fdda 100644 --- a/src/generated/IdentityProtection/RiskyUsers/ConfirmCompromised/ConfirmCompromisedRequestBuilder.cs +++ b/src/generated/IdentityProtection/RiskyUsers/ConfirmCompromised/ConfirmCompromisedRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,14 +29,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -72,18 +71,5 @@ public RequestInformation CreatePostRequestInformation(ConfirmCompromisedRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action confirmCompromised - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ConfirmCompromisedRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/IdentityProtection/RiskyUsers/Dismiss/DismissRequestBuilder.cs b/src/generated/IdentityProtection/RiskyUsers/Dismiss/DismissRequestBuilder.cs index 086b0e1344e..ba715980096 100644 --- a/src/generated/IdentityProtection/RiskyUsers/Dismiss/DismissRequestBuilder.cs +++ b/src/generated/IdentityProtection/RiskyUsers/Dismiss/DismissRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,14 +29,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -72,18 +71,5 @@ public RequestInformation CreatePostRequestInformation(DismissRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action dismiss - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DismissRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/IdentityProtection/RiskyUsers/Item/History/HistoryRequestBuilder.cs b/src/generated/IdentityProtection/RiskyUsers/Item/History/HistoryRequestBuilder.cs index 8e1959cdb9f..79cb57e30ff 100644 --- a/src/generated/IdentityProtection/RiskyUsers/Item/History/HistoryRequestBuilder.cs +++ b/src/generated/IdentityProtection/RiskyUsers/Item/History/HistoryRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class HistoryRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new RiskyUserHistoryItemRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The activity related to user risk level change"; // Create options for all the parameters - var riskyUserIdOption = new Option("--riskyuser-id", description: "key: id of riskyUser") { + var riskyUserIdOption = new Option("--risky-user-id", description: "key: id of riskyUser") { }; riskyUserIdOption.IsRequired = true; command.AddOption(riskyUserIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string riskyUserId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string riskyUserId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, riskyUserIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, riskyUserIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The activity related to user risk level change"; // Create options for all the parameters - var riskyUserIdOption = new Option("--riskyuser-id", description: "key: id of riskyUser") { + var riskyUserIdOption = new Option("--risky-user-id", description: "key: id of riskyUser") { }; riskyUserIdOption.IsRequired = true; command.AddOption(riskyUserIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string riskyUserId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string riskyUserId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, riskyUserIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, riskyUserIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(RiskyUserHistoryItem body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The activity related to user risk level change - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The activity related to user risk level change - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RiskyUserHistoryItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The activity related to user risk level change public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/IdentityProtection/RiskyUsers/Item/History/Item/RiskyUserHistoryItemRequestBuilder.cs b/src/generated/IdentityProtection/RiskyUsers/Item/History/Item/RiskyUserHistoryItemRequestBuilder.cs index 57f0f16e27c..e78c86d4970 100644 --- a/src/generated/IdentityProtection/RiskyUsers/Item/History/Item/RiskyUserHistoryItemRequestBuilder.cs +++ b/src/generated/IdentityProtection/RiskyUsers/Item/History/Item/RiskyUserHistoryItemRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The activity related to user risk level change"; // Create options for all the parameters - var riskyUserIdOption = new Option("--riskyuser-id", description: "key: id of riskyUser") { + var riskyUserIdOption = new Option("--risky-user-id", description: "key: id of riskyUser") { }; riskyUserIdOption.IsRequired = true; command.AddOption(riskyUserIdOption); - var riskyUserHistoryItemIdOption = new Option("--riskyuserhistoryitem-id", description: "key: id of riskyUserHistoryItem") { + var riskyUserHistoryItemIdOption = new Option("--risky-user-history-item-id", description: "key: id of riskyUserHistoryItem") { }; riskyUserHistoryItemIdOption.IsRequired = true; command.AddOption(riskyUserHistoryItemIdOption); - command.SetHandler(async (string riskyUserId, string riskyUserHistoryItemId) => { + command.SetHandler(async (string riskyUserId, string riskyUserHistoryItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, riskyUserIdOption, riskyUserHistoryItemIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The activity related to user risk level change"; // Create options for all the parameters - var riskyUserIdOption = new Option("--riskyuser-id", description: "key: id of riskyUser") { + var riskyUserIdOption = new Option("--risky-user-id", description: "key: id of riskyUser") { }; riskyUserIdOption.IsRequired = true; command.AddOption(riskyUserIdOption); - var riskyUserHistoryItemIdOption = new Option("--riskyuserhistoryitem-id", description: "key: id of riskyUserHistoryItem") { + var riskyUserHistoryItemIdOption = new Option("--risky-user-history-item-id", description: "key: id of riskyUserHistoryItem") { }; riskyUserHistoryItemIdOption.IsRequired = true; command.AddOption(riskyUserHistoryItemIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string riskyUserId, string riskyUserHistoryItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string riskyUserId, string riskyUserHistoryItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, riskyUserIdOption, riskyUserHistoryItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, riskyUserIdOption, riskyUserHistoryItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The activity related to user risk level change"; // Create options for all the parameters - var riskyUserIdOption = new Option("--riskyuser-id", description: "key: id of riskyUser") { + var riskyUserIdOption = new Option("--risky-user-id", description: "key: id of riskyUser") { }; riskyUserIdOption.IsRequired = true; command.AddOption(riskyUserIdOption); - var riskyUserHistoryItemIdOption = new Option("--riskyuserhistoryitem-id", description: "key: id of riskyUserHistoryItem") { + var riskyUserHistoryItemIdOption = new Option("--risky-user-history-item-id", description: "key: id of riskyUserHistoryItem") { }; riskyUserHistoryItemIdOption.IsRequired = true; command.AddOption(riskyUserHistoryItemIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string riskyUserId, string riskyUserHistoryItemId, string body) => { + command.SetHandler(async (string riskyUserId, string riskyUserHistoryItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, riskyUserIdOption, riskyUserHistoryItemIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(RiskyUserHistoryItem bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The activity related to user risk level change - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The activity related to user risk level change - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The activity related to user risk level change - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(RiskyUserHistoryItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The activity related to user risk level change public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/IdentityProtection/RiskyUsers/Item/RiskyUserRequestBuilder.cs b/src/generated/IdentityProtection/RiskyUsers/Item/RiskyUserRequestBuilder.cs index 36dfec5f8aa..935813d75b7 100644 --- a/src/generated/IdentityProtection/RiskyUsers/Item/RiskyUserRequestBuilder.cs +++ b/src/generated/IdentityProtection/RiskyUsers/Item/RiskyUserRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -21,33 +21,32 @@ public class RiskyUserRequestBuilder { /// Url template to use to build the URL for the current request builder private string UrlTemplate { get; set; } /// - /// Delete navigation property riskyUsers for identityProtection + /// Users that are flagged as at-risk by Azure AD Identity Protection. /// public Command BuildDeleteCommand() { var command = new Command("delete"); - command.Description = "Delete navigation property riskyUsers for identityProtection"; + command.Description = "Users that are flagged as at-risk by Azure AD Identity Protection."; // Create options for all the parameters - var riskyUserIdOption = new Option("--riskyuser-id", description: "key: id of riskyUser") { + var riskyUserIdOption = new Option("--risky-user-id", description: "key: id of riskyUser") { }; riskyUserIdOption.IsRequired = true; command.AddOption(riskyUserIdOption); - command.SetHandler(async (string riskyUserId) => { + command.SetHandler(async (string riskyUserId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, riskyUserIdOption); return command; } /// - /// Get riskyUsers from identityProtection + /// Users that are flagged as at-risk by Azure AD Identity Protection. /// public Command BuildGetCommand() { var command = new Command("get"); - command.Description = "Get riskyUsers from identityProtection"; + command.Description = "Users that are flagged as at-risk by Azure AD Identity Protection."; // Create options for all the parameters - var riskyUserIdOption = new Option("--riskyuser-id", description: "key: id of riskyUser") { + var riskyUserIdOption = new Option("--risky-user-id", description: "key: id of riskyUser") { }; riskyUserIdOption.IsRequired = true; command.AddOption(riskyUserIdOption); @@ -61,37 +60,39 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string riskyUserId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string riskyUserId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, riskyUserIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, riskyUserIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildHistoryCommand() { var command = new Command("history"); var builder = new ApiSdk.IdentityProtection.RiskyUsers.Item.History.HistoryRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; } /// - /// Update the navigation property riskyUsers in identityProtection + /// Users that are flagged as at-risk by Azure AD Identity Protection. /// public Command BuildPatchCommand() { var command = new Command("patch"); - command.Description = "Update the navigation property riskyUsers in identityProtection"; + command.Description = "Users that are flagged as at-risk by Azure AD Identity Protection."; // Create options for all the parameters - var riskyUserIdOption = new Option("--riskyuser-id", description: "key: id of riskyUser") { + var riskyUserIdOption = new Option("--risky-user-id", description: "key: id of riskyUser") { }; riskyUserIdOption.IsRequired = true; command.AddOption(riskyUserIdOption); @@ -99,14 +100,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string riskyUserId, string body) => { + command.SetHandler(async (string riskyUserId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, riskyUserIdOption, bodyOption); return command; @@ -125,7 +125,7 @@ public RiskyUserRequestBuilder(Dictionary pathParameters, IReque RequestAdapter = requestAdapter; } /// - /// Delete navigation property riskyUsers for identityProtection + /// Users that are flagged as at-risk by Azure AD Identity Protection. /// Request headers /// Request options /// @@ -140,7 +140,7 @@ public RequestInformation CreateDeleteRequestInformation(Action - /// Get riskyUsers from identityProtection + /// Users that are flagged as at-risk by Azure AD Identity Protection. /// Request headers /// Request options /// Request query parameters @@ -161,7 +161,7 @@ public RequestInformation CreateGetRequestInformation(Action return requestInfo; } /// - /// Update the navigation property riskyUsers in identityProtection + /// Users that are flagged as at-risk by Azure AD Identity Protection. /// /// Request headers /// Request options @@ -178,43 +178,7 @@ public RequestInformation CreatePatchRequestInformation(RiskyUser body, Action - /// Delete navigation property riskyUsers for identityProtection - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get riskyUsers from identityProtection - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property riskyUsers in identityProtection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(RiskyUser model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// Get riskyUsers from identityProtection + /// Users that are flagged as at-risk by Azure AD Identity Protection. public class GetQueryParameters : QueryParametersBase { /// Expand related entities public string[] Expand { get; set; } diff --git a/src/generated/IdentityProtection/RiskyUsers/RiskyUsersRequestBuilder.cs b/src/generated/IdentityProtection/RiskyUsers/RiskyUsersRequestBuilder.cs index e7ac55ea0b5..133caf1d8b2 100644 --- a/src/generated/IdentityProtection/RiskyUsers/RiskyUsersRequestBuilder.cs +++ b/src/generated/IdentityProtection/RiskyUsers/RiskyUsersRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -24,12 +24,11 @@ public class RiskyUsersRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new RiskyUserRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildHistoryCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildHistoryCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } public Command BuildConfirmCompromisedCommand() { @@ -39,31 +38,30 @@ public Command BuildConfirmCompromisedCommand() { return command; } /// - /// Create new navigation property to riskyUsers for identityProtection + /// Users that are flagged as at-risk by Azure AD Identity Protection. /// public Command BuildCreateCommand() { var command = new Command("create"); - command.Description = "Create new navigation property to riskyUsers for identityProtection"; + command.Description = "Users that are flagged as at-risk by Azure AD Identity Protection."; // Create options for all the parameters var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } public Command BuildDismissCommand() { @@ -73,11 +71,11 @@ public Command BuildDismissCommand() { return command; } /// - /// Get riskyUsers from identityProtection + /// Users that are flagged as at-risk by Azure AD Identity Protection. /// public Command BuildListCommand() { var command = new Command("list"); - command.Description = "Get riskyUsers from identityProtection"; + command.Description = "Users that are flagged as at-risk by Azure AD Identity Protection."; // Create options for all the parameters var topOption = new Option("--top", description: "Show only the first n items") { }; @@ -114,7 +112,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -125,15 +127,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -150,7 +147,7 @@ public RiskyUsersRequestBuilder(Dictionary pathParameters, IRequ RequestAdapter = requestAdapter; } /// - /// Get riskyUsers from identityProtection + /// Users that are flagged as at-risk by Azure AD Identity Protection. /// Request headers /// Request options /// Request query parameters @@ -171,7 +168,7 @@ public RequestInformation CreateGetRequestInformation(Action return requestInfo; } /// - /// Create new navigation property to riskyUsers for identityProtection + /// Users that are flagged as at-risk by Azure AD Identity Protection. /// /// Request headers /// Request options @@ -188,32 +185,7 @@ public RequestInformation CreatePostRequestInformation(RiskyUser body, Action - /// Get riskyUsers from identityProtection - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to riskyUsers for identityProtection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RiskyUser model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Get riskyUsers from identityProtection + /// Users that are flagged as at-risk by Azure AD Identity Protection. public class GetQueryParameters : QueryParametersBase { /// Include count of items public bool? Count { get; set; } diff --git a/src/generated/IdentityProviders/AvailableProviderTypes/AvailableProviderTypesRequestBuilder.cs b/src/generated/IdentityProviders/AvailableProviderTypes/AvailableProviderTypesRequestBuilder.cs index d3a8dbec7e9..10889df7b69 100644 --- a/src/generated/IdentityProviders/AvailableProviderTypes/AvailableProviderTypesRequestBuilder.cs +++ b/src/generated/IdentityProviders/AvailableProviderTypes/AvailableProviderTypesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function availableProviderTypes"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function availableProviderTypes - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/IdentityProviders/IdentityProvidersRequestBuilder.cs b/src/generated/IdentityProviders/IdentityProvidersRequestBuilder.cs index cedcfca683b..dde9e28aa68 100644 --- a/src/generated/IdentityProviders/IdentityProvidersRequestBuilder.cs +++ b/src/generated/IdentityProviders/IdentityProvidersRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,10 @@ public AvailableProviderTypesRequestBuilder AvailableProviderTypes() { } public List BuildCommand() { var builder = new IdentityProviderRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -47,21 +46,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -106,7 +104,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -117,15 +119,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -180,31 +177,6 @@ public RequestInformation CreatePostRequestInformation(IdentityProvider body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get entities from identityProviders - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to identityProviders - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(IdentityProvider model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from identityProviders public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/IdentityProviders/Item/IdentityProviderRequestBuilder.cs b/src/generated/IdentityProviders/Item/IdentityProviderRequestBuilder.cs index d0990ae636c..55660bba947 100644 --- a/src/generated/IdentityProviders/Item/IdentityProviderRequestBuilder.cs +++ b/src/generated/IdentityProviders/Item/IdentityProviderRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete entity from identityProviders"; // Create options for all the parameters - var identityProviderIdOption = new Option("--identityprovider-id", description: "key: id of identityProvider") { + var identityProviderIdOption = new Option("--identity-provider-id", description: "key: id of identityProvider") { }; identityProviderIdOption.IsRequired = true; command.AddOption(identityProviderIdOption); - command.SetHandler(async (string identityProviderId) => { + command.SetHandler(async (string identityProviderId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, identityProviderIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get entity from identityProviders by key"; // Create options for all the parameters - var identityProviderIdOption = new Option("--identityprovider-id", description: "key: id of identityProvider") { + var identityProviderIdOption = new Option("--identity-provider-id", description: "key: id of identityProvider") { }; identityProviderIdOption.IsRequired = true; command.AddOption(identityProviderIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string identityProviderId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string identityProviderId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, identityProviderIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, identityProviderIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update entity in identityProviders"; // Create options for all the parameters - var identityProviderIdOption = new Option("--identityprovider-id", description: "key: id of identityProvider") { + var identityProviderIdOption = new Option("--identity-provider-id", description: "key: id of identityProvider") { }; identityProviderIdOption.IsRequired = true; command.AddOption(identityProviderIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string identityProviderId, string body) => { + command.SetHandler(async (string identityProviderId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, identityProviderIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(IdentityProvider body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from identityProviders - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from identityProviders by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in identityProviders - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(IdentityProvider model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from identityProviders by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/InformationProtection/Bitlocker/BitlockerRequestBuilder.cs b/src/generated/InformationProtection/Bitlocker/BitlockerRequestBuilder.cs index 5ff0160c686..2348c53a3e4 100644 --- a/src/generated/InformationProtection/Bitlocker/BitlockerRequestBuilder.cs +++ b/src/generated/InformationProtection/Bitlocker/BitlockerRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,11 +27,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property bitlocker for informationProtection"; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -53,20 +52,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -80,14 +78,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -95,6 +92,9 @@ public Command BuildPatchCommand() { public Command BuildRecoveryKeysCommand() { var command = new Command("recovery-keys"); var builder = new ApiSdk.InformationProtection.Bitlocker.RecoveryKeys.RecoveryKeysRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -166,42 +166,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property bitlocker for informationProtection - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get bitlocker from informationProtection - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property bitlocker in informationProtection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Bitlocker model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get bitlocker from informationProtection public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/InformationProtection/Bitlocker/RecoveryKeys/Item/BitlockerRecoveryKeyRequestBuilder.cs b/src/generated/InformationProtection/Bitlocker/RecoveryKeys/Item/BitlockerRecoveryKeyRequestBuilder.cs index 90c856a0314..b52c888ab1e 100644 --- a/src/generated/InformationProtection/Bitlocker/RecoveryKeys/Item/BitlockerRecoveryKeyRequestBuilder.cs +++ b/src/generated/InformationProtection/Bitlocker/RecoveryKeys/Item/BitlockerRecoveryKeyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The recovery keys associated with the bitlocker entity."; // Create options for all the parameters - var bitlockerRecoveryKeyIdOption = new Option("--bitlockerrecoverykey-id", description: "key: id of bitlockerRecoveryKey") { + var bitlockerRecoveryKeyIdOption = new Option("--bitlocker-recovery-key-id", description: "key: id of bitlockerRecoveryKey") { }; bitlockerRecoveryKeyIdOption.IsRequired = true; command.AddOption(bitlockerRecoveryKeyIdOption); - command.SetHandler(async (string bitlockerRecoveryKeyId) => { + command.SetHandler(async (string bitlockerRecoveryKeyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bitlockerRecoveryKeyIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The recovery keys associated with the bitlocker entity."; // Create options for all the parameters - var bitlockerRecoveryKeyIdOption = new Option("--bitlockerrecoverykey-id", description: "key: id of bitlockerRecoveryKey") { + var bitlockerRecoveryKeyIdOption = new Option("--bitlocker-recovery-key-id", description: "key: id of bitlockerRecoveryKey") { }; bitlockerRecoveryKeyIdOption.IsRequired = true; command.AddOption(bitlockerRecoveryKeyIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string bitlockerRecoveryKeyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string bitlockerRecoveryKeyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bitlockerRecoveryKeyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bitlockerRecoveryKeyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The recovery keys associated with the bitlocker entity."; // Create options for all the parameters - var bitlockerRecoveryKeyIdOption = new Option("--bitlockerrecoverykey-id", description: "key: id of bitlockerRecoveryKey") { + var bitlockerRecoveryKeyIdOption = new Option("--bitlocker-recovery-key-id", description: "key: id of bitlockerRecoveryKey") { }; bitlockerRecoveryKeyIdOption.IsRequired = true; command.AddOption(bitlockerRecoveryKeyIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string bitlockerRecoveryKeyId, string body) => { + command.SetHandler(async (string bitlockerRecoveryKeyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bitlockerRecoveryKeyIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(BitlockerRecoveryKey bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The recovery keys associated with the bitlocker entity. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The recovery keys associated with the bitlocker entity. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The recovery keys associated with the bitlocker entity. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(BitlockerRecoveryKey model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The recovery keys associated with the bitlocker entity. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/InformationProtection/Bitlocker/RecoveryKeys/RecoveryKeysRequestBuilder.cs b/src/generated/InformationProtection/Bitlocker/RecoveryKeys/RecoveryKeysRequestBuilder.cs index e296ba89975..0dfba390589 100644 --- a/src/generated/InformationProtection/Bitlocker/RecoveryKeys/RecoveryKeysRequestBuilder.cs +++ b/src/generated/InformationProtection/Bitlocker/RecoveryKeys/RecoveryKeysRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class RecoveryKeysRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new BitlockerRecoveryKeyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(BitlockerRecoveryKey body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The recovery keys associated with the bitlocker entity. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The recovery keys associated with the bitlocker entity. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(BitlockerRecoveryKey model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The recovery keys associated with the bitlocker entity. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/InformationProtection/InformationProtectionRequestBuilder.cs b/src/generated/InformationProtection/InformationProtectionRequestBuilder.cs index 0684d2d55a3..d3d3aaf6dd2 100644 --- a/src/generated/InformationProtection/InformationProtectionRequestBuilder.cs +++ b/src/generated/InformationProtection/InformationProtectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,20 +47,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -74,14 +73,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -89,6 +87,9 @@ public Command BuildPatchCommand() { public Command BuildThreatAssessmentRequestsCommand() { var command = new Command("threat-assessment-requests"); var builder = new ApiSdk.InformationProtection.ThreatAssessmentRequests.ThreatAssessmentRequestsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -145,31 +146,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get informationProtection - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update informationProtection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.InformationProtection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get informationProtection public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/InformationProtection/ThreatAssessmentRequests/Item/Results/Item/ThreatAssessmentResultRequestBuilder.cs b/src/generated/InformationProtection/ThreatAssessmentRequests/Item/Results/Item/ThreatAssessmentResultRequestBuilder.cs index f0f2a16c7d5..1393d58fc2d 100644 --- a/src/generated/InformationProtection/ThreatAssessmentRequests/Item/Results/Item/ThreatAssessmentResultRequestBuilder.cs +++ b/src/generated/InformationProtection/ThreatAssessmentRequests/Item/Results/Item/ThreatAssessmentResultRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "A collection of threat assessment results. Read-only. By default, a GET /threatAssessmentRequests/{id} does not return this property unless you apply $expand on it."; // Create options for all the parameters - var threatAssessmentRequestIdOption = new Option("--threatassessmentrequest-id", description: "key: id of threatAssessmentRequest") { + var threatAssessmentRequestIdOption = new Option("--threat-assessment-request-id", description: "key: id of threatAssessmentRequest") { }; threatAssessmentRequestIdOption.IsRequired = true; command.AddOption(threatAssessmentRequestIdOption); - var threatAssessmentResultIdOption = new Option("--threatassessmentresult-id", description: "key: id of threatAssessmentResult") { + var threatAssessmentResultIdOption = new Option("--threat-assessment-result-id", description: "key: id of threatAssessmentResult") { }; threatAssessmentResultIdOption.IsRequired = true; command.AddOption(threatAssessmentResultIdOption); - command.SetHandler(async (string threatAssessmentRequestId, string threatAssessmentResultId) => { + command.SetHandler(async (string threatAssessmentRequestId, string threatAssessmentResultId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, threatAssessmentRequestIdOption, threatAssessmentResultIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "A collection of threat assessment results. Read-only. By default, a GET /threatAssessmentRequests/{id} does not return this property unless you apply $expand on it."; // Create options for all the parameters - var threatAssessmentRequestIdOption = new Option("--threatassessmentrequest-id", description: "key: id of threatAssessmentRequest") { + var threatAssessmentRequestIdOption = new Option("--threat-assessment-request-id", description: "key: id of threatAssessmentRequest") { }; threatAssessmentRequestIdOption.IsRequired = true; command.AddOption(threatAssessmentRequestIdOption); - var threatAssessmentResultIdOption = new Option("--threatassessmentresult-id", description: "key: id of threatAssessmentResult") { + var threatAssessmentResultIdOption = new Option("--threat-assessment-result-id", description: "key: id of threatAssessmentResult") { }; threatAssessmentResultIdOption.IsRequired = true; command.AddOption(threatAssessmentResultIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string threatAssessmentRequestId, string threatAssessmentResultId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string threatAssessmentRequestId, string threatAssessmentResultId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, threatAssessmentRequestIdOption, threatAssessmentResultIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, threatAssessmentRequestIdOption, threatAssessmentResultIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "A collection of threat assessment results. Read-only. By default, a GET /threatAssessmentRequests/{id} does not return this property unless you apply $expand on it."; // Create options for all the parameters - var threatAssessmentRequestIdOption = new Option("--threatassessmentrequest-id", description: "key: id of threatAssessmentRequest") { + var threatAssessmentRequestIdOption = new Option("--threat-assessment-request-id", description: "key: id of threatAssessmentRequest") { }; threatAssessmentRequestIdOption.IsRequired = true; command.AddOption(threatAssessmentRequestIdOption); - var threatAssessmentResultIdOption = new Option("--threatassessmentresult-id", description: "key: id of threatAssessmentResult") { + var threatAssessmentResultIdOption = new Option("--threat-assessment-result-id", description: "key: id of threatAssessmentResult") { }; threatAssessmentResultIdOption.IsRequired = true; command.AddOption(threatAssessmentResultIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string threatAssessmentRequestId, string threatAssessmentResultId, string body) => { + command.SetHandler(async (string threatAssessmentRequestId, string threatAssessmentResultId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, threatAssessmentRequestIdOption, threatAssessmentResultIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ThreatAssessmentResult b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of threat assessment results. Read-only. By default, a GET /threatAssessmentRequests/{id} does not return this property unless you apply $expand on it. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of threat assessment results. Read-only. By default, a GET /threatAssessmentRequests/{id} does not return this property unless you apply $expand on it. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of threat assessment results. Read-only. By default, a GET /threatAssessmentRequests/{id} does not return this property unless you apply $expand on it. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ThreatAssessmentResult model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of threat assessment results. Read-only. By default, a GET /threatAssessmentRequests/{id} does not return this property unless you apply $expand on it. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/InformationProtection/ThreatAssessmentRequests/Item/Results/ResultsRequestBuilder.cs b/src/generated/InformationProtection/ThreatAssessmentRequests/Item/Results/ResultsRequestBuilder.cs index 9643de46491..29b207c5aa0 100644 --- a/src/generated/InformationProtection/ThreatAssessmentRequests/Item/Results/ResultsRequestBuilder.cs +++ b/src/generated/InformationProtection/ThreatAssessmentRequests/Item/Results/ResultsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ResultsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ThreatAssessmentResultRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "A collection of threat assessment results. Read-only. By default, a GET /threatAssessmentRequests/{id} does not return this property unless you apply $expand on it."; // Create options for all the parameters - var threatAssessmentRequestIdOption = new Option("--threatassessmentrequest-id", description: "key: id of threatAssessmentRequest") { + var threatAssessmentRequestIdOption = new Option("--threat-assessment-request-id", description: "key: id of threatAssessmentRequest") { }; threatAssessmentRequestIdOption.IsRequired = true; command.AddOption(threatAssessmentRequestIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string threatAssessmentRequestId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string threatAssessmentRequestId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, threatAssessmentRequestIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, threatAssessmentRequestIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "A collection of threat assessment results. Read-only. By default, a GET /threatAssessmentRequests/{id} does not return this property unless you apply $expand on it."; // Create options for all the parameters - var threatAssessmentRequestIdOption = new Option("--threatassessmentrequest-id", description: "key: id of threatAssessmentRequest") { + var threatAssessmentRequestIdOption = new Option("--threat-assessment-request-id", description: "key: id of threatAssessmentRequest") { }; threatAssessmentRequestIdOption.IsRequired = true; command.AddOption(threatAssessmentRequestIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string threatAssessmentRequestId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string threatAssessmentRequestId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, threatAssessmentRequestIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, threatAssessmentRequestIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ThreatAssessmentResult bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of threat assessment results. Read-only. By default, a GET /threatAssessmentRequests/{id} does not return this property unless you apply $expand on it. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of threat assessment results. Read-only. By default, a GET /threatAssessmentRequests/{id} does not return this property unless you apply $expand on it. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ThreatAssessmentResult model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of threat assessment results. Read-only. By default, a GET /threatAssessmentRequests/{id} does not return this property unless you apply $expand on it. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/InformationProtection/ThreatAssessmentRequests/Item/ThreatAssessmentRequestRequestBuilder.cs b/src/generated/InformationProtection/ThreatAssessmentRequests/Item/ThreatAssessmentRequestRequestBuilder.cs index 20485e1cd1b..6b2080afbfb 100644 --- a/src/generated/InformationProtection/ThreatAssessmentRequests/Item/ThreatAssessmentRequestRequestBuilder.cs +++ b/src/generated/InformationProtection/ThreatAssessmentRequests/Item/ThreatAssessmentRequestRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,15 +27,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property threatAssessmentRequests for informationProtection"; // Create options for all the parameters - var threatAssessmentRequestIdOption = new Option("--threatassessmentrequest-id", description: "key: id of threatAssessmentRequest") { + var threatAssessmentRequestIdOption = new Option("--threat-assessment-request-id", description: "key: id of threatAssessmentRequest") { }; threatAssessmentRequestIdOption.IsRequired = true; command.AddOption(threatAssessmentRequestIdOption); - command.SetHandler(async (string threatAssessmentRequestId) => { + command.SetHandler(async (string threatAssessmentRequestId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, threatAssessmentRequestIdOption); return command; @@ -47,7 +46,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get threatAssessmentRequests from informationProtection"; // Create options for all the parameters - var threatAssessmentRequestIdOption = new Option("--threatassessmentrequest-id", description: "key: id of threatAssessmentRequest") { + var threatAssessmentRequestIdOption = new Option("--threat-assessment-request-id", description: "key: id of threatAssessmentRequest") { }; threatAssessmentRequestIdOption.IsRequired = true; command.AddOption(threatAssessmentRequestIdOption); @@ -61,20 +60,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string threatAssessmentRequestId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string threatAssessmentRequestId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, threatAssessmentRequestIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, threatAssessmentRequestIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property threatAssessmentRequests in informationProtection"; // Create options for all the parameters - var threatAssessmentRequestIdOption = new Option("--threatassessmentrequest-id", description: "key: id of threatAssessmentRequest") { + var threatAssessmentRequestIdOption = new Option("--threat-assessment-request-id", description: "key: id of threatAssessmentRequest") { }; threatAssessmentRequestIdOption.IsRequired = true; command.AddOption(threatAssessmentRequestIdOption); @@ -92,14 +90,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string threatAssessmentRequestId, string body) => { + command.SetHandler(async (string threatAssessmentRequestId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, threatAssessmentRequestIdOption, bodyOption); return command; @@ -107,6 +104,9 @@ public Command BuildPatchCommand() { public Command BuildResultsCommand() { var command = new Command("results"); var builder = new ApiSdk.InformationProtection.ThreatAssessmentRequests.Item.Results.ResultsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -178,42 +178,6 @@ public RequestInformation CreatePatchRequestInformation(ThreatAssessmentRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property threatAssessmentRequests for informationProtection - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get threatAssessmentRequests from informationProtection - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property threatAssessmentRequests in informationProtection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ThreatAssessmentRequest model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get threatAssessmentRequests from informationProtection public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/InformationProtection/ThreatAssessmentRequests/ThreatAssessmentRequestsRequestBuilder.cs b/src/generated/InformationProtection/ThreatAssessmentRequests/ThreatAssessmentRequestsRequestBuilder.cs index a1fb01d035e..745ebad36d0 100644 --- a/src/generated/InformationProtection/ThreatAssessmentRequests/ThreatAssessmentRequestsRequestBuilder.cs +++ b/src/generated/InformationProtection/ThreatAssessmentRequests/ThreatAssessmentRequestsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class ThreatAssessmentRequestsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ThreatAssessmentRequestRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildResultsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildResultsCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(ThreatAssessmentRequest b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get threatAssessmentRequests from informationProtection - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to threatAssessmentRequests for informationProtection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ThreatAssessmentRequest model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get threatAssessmentRequests from informationProtection public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Invitations/InvitationsRequestBuilder.cs b/src/generated/Invitations/InvitationsRequestBuilder.cs index ca292dc0280..41276f93c6b 100644 --- a/src/generated/Invitations/InvitationsRequestBuilder.cs +++ b/src/generated/Invitations/InvitationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class InvitationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new InvitationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildInvitedUserCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInvitedUserCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(Invitation body, Action - /// Get entities from invitations - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to invitations - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Invitation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from invitations public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Invitations/Item/InvitationRequestBuilder.cs b/src/generated/Invitations/Item/InvitationRequestBuilder.cs index a8fed0caa11..57cde6729a6 100644 --- a/src/generated/Invitations/Item/InvitationRequestBuilder.cs +++ b/src/generated/Invitations/Item/InvitationRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,11 +31,10 @@ public Command BuildDeleteCommand() { }; invitationIdOption.IsRequired = true; command.AddOption(invitationIdOption); - command.SetHandler(async (string invitationId) => { + command.SetHandler(async (string invitationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, invitationIdOption); return command; @@ -61,20 +60,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string invitationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string invitationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, invitationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, invitationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildInvitedUserCommand() { @@ -99,14 +97,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string invitationId, string body) => { + command.SetHandler(async (string invitationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, invitationIdOption, bodyOption); return command; @@ -178,42 +175,6 @@ public RequestInformation CreatePatchRequestInformation(Invitation body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from invitations - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from invitations by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in invitations - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Invitation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from invitations by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Invitations/Item/InvitedUser/@Ref/@Ref.cs b/src/generated/Invitations/Item/InvitedUser/@Ref/@Ref.cs deleted file mode 100644 index a84c233a7e1..00000000000 --- a/src/generated/Invitations/Item/InvitedUser/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Invitations.Item.InvitedUser.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Invitations/Item/InvitedUser/@Ref/RefRequestBuilder.cs b/src/generated/Invitations/Item/InvitedUser/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 68b74d14f1a..00000000000 --- a/src/generated/Invitations/Item/InvitedUser/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Invitations.Item.InvitedUser.@Ref { - /// Builds and executes requests for operations under \invitations\{invitation-id}\invitedUser\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The user created as part of the invitation creation. Read-Only - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The user created as part of the invitation creation. Read-Only"; - // Create options for all the parameters - var invitationIdOption = new Option("--invitation-id", description: "key: id of invitation") { - }; - invitationIdOption.IsRequired = true; - command.AddOption(invitationIdOption); - command.SetHandler(async (string invitationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, invitationIdOption); - return command; - } - /// - /// The user created as part of the invitation creation. Read-Only - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The user created as part of the invitation creation. Read-Only"; - // Create options for all the parameters - var invitationIdOption = new Option("--invitation-id", description: "key: id of invitation") { - }; - invitationIdOption.IsRequired = true; - command.AddOption(invitationIdOption); - command.SetHandler(async (string invitationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, invitationIdOption); - return command; - } - /// - /// The user created as part of the invitation creation. Read-Only - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The user created as part of the invitation creation. Read-Only"; - // Create options for all the parameters - var invitationIdOption = new Option("--invitation-id", description: "key: id of invitation") { - }; - invitationIdOption.IsRequired = true; - command.AddOption(invitationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string invitationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, invitationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/invitations/{invitation_id}/invitedUser/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The user created as part of the invitation creation. Read-Only - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The user created as part of the invitation creation. Read-Only - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The user created as part of the invitation creation. Read-Only - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Invitations.Item.InvitedUser.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The user created as part of the invitation creation. Read-Only - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user created as part of the invitation creation. Read-Only - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user created as part of the invitation creation. Read-Only - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Invitations.Item.InvitedUser.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Invitations/Item/InvitedUser/InvitedUserRequestBuilder.cs b/src/generated/Invitations/Item/InvitedUser/InvitedUserRequestBuilder.cs index ca1c2998e9a..c09ac7a5bd6 100644 --- a/src/generated/Invitations/Item/InvitedUser/InvitedUserRequestBuilder.cs +++ b/src/generated/Invitations/Item/InvitedUser/InvitedUserRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string invitationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string invitationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, invitationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, invitationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Invitations.Item.InvitedUser.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Invitations.Item.InvitedUser.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user created as part of the invitation creation. Read-Only - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The user created as part of the invitation creation. Read-Only public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Invitations/Item/InvitedUser/Ref/Ref.cs b/src/generated/Invitations/Item/InvitedUser/Ref/Ref.cs new file mode 100644 index 00000000000..5fd822b593b --- /dev/null +++ b/src/generated/Invitations/Item/InvitedUser/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Invitations.Item.InvitedUser.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Invitations/Item/InvitedUser/Ref/RefRequestBuilder.cs b/src/generated/Invitations/Item/InvitedUser/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..c211b34fc75 --- /dev/null +++ b/src/generated/Invitations/Item/InvitedUser/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Invitations.Item.InvitedUser.Ref { + /// Builds and executes requests for operations under \invitations\{invitation-id}\invitedUser\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The user created as part of the invitation creation. Read-Only + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The user created as part of the invitation creation. Read-Only"; + // Create options for all the parameters + var invitationIdOption = new Option("--invitation-id", description: "key: id of invitation") { + }; + invitationIdOption.IsRequired = true; + command.AddOption(invitationIdOption); + command.SetHandler(async (string invitationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, invitationIdOption); + return command; + } + /// + /// The user created as part of the invitation creation. Read-Only + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The user created as part of the invitation creation. Read-Only"; + // Create options for all the parameters + var invitationIdOption = new Option("--invitation-id", description: "key: id of invitation") { + }; + invitationIdOption.IsRequired = true; + command.AddOption(invitationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string invitationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, invitationIdOption, outputOption); + return command; + } + /// + /// The user created as part of the invitation creation. Read-Only + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The user created as part of the invitation creation. Read-Only"; + // Create options for all the parameters + var invitationIdOption = new Option("--invitation-id", description: "key: id of invitation") { + }; + invitationIdOption.IsRequired = true; + command.AddOption(invitationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string invitationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, invitationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/invitations/{invitation_id}/invitedUser/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The user created as part of the invitation creation. Read-Only + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The user created as part of the invitation creation. Read-Only + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The user created as part of the invitation creation. Read-Only + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Invitations.Item.InvitedUser.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Localizations/Item/OrganizationalBrandingLocalizationRequestBuilder.cs b/src/generated/Localizations/Item/OrganizationalBrandingLocalizationRequestBuilder.cs index ec51340a5ca..c8f7b359541 100644 --- a/src/generated/Localizations/Item/OrganizationalBrandingLocalizationRequestBuilder.cs +++ b/src/generated/Localizations/Item/OrganizationalBrandingLocalizationRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete entity from localizations"; // Create options for all the parameters - var organizationalBrandingLocalizationIdOption = new Option("--organizationalbrandinglocalization-id", description: "key: id of organizationalBrandingLocalization") { + var organizationalBrandingLocalizationIdOption = new Option("--organizational-branding-localization-id", description: "key: id of organizationalBrandingLocalization") { }; organizationalBrandingLocalizationIdOption.IsRequired = true; command.AddOption(organizationalBrandingLocalizationIdOption); - command.SetHandler(async (string organizationalBrandingLocalizationId) => { + command.SetHandler(async (string organizationalBrandingLocalizationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, organizationalBrandingLocalizationIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get entity from localizations by key"; // Create options for all the parameters - var organizationalBrandingLocalizationIdOption = new Option("--organizationalbrandinglocalization-id", description: "key: id of organizationalBrandingLocalization") { + var organizationalBrandingLocalizationIdOption = new Option("--organizational-branding-localization-id", description: "key: id of organizationalBrandingLocalization") { }; organizationalBrandingLocalizationIdOption.IsRequired = true; command.AddOption(organizationalBrandingLocalizationIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string organizationalBrandingLocalizationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string organizationalBrandingLocalizationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, organizationalBrandingLocalizationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, organizationalBrandingLocalizationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update entity in localizations"; // Create options for all the parameters - var organizationalBrandingLocalizationIdOption = new Option("--organizationalbrandinglocalization-id", description: "key: id of organizationalBrandingLocalization") { + var organizationalBrandingLocalizationIdOption = new Option("--organizational-branding-localization-id", description: "key: id of organizationalBrandingLocalization") { }; organizationalBrandingLocalizationIdOption.IsRequired = true; command.AddOption(organizationalBrandingLocalizationIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string organizationalBrandingLocalizationId, string body) => { + command.SetHandler(async (string organizationalBrandingLocalizationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, organizationalBrandingLocalizationIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(OrganizationalBrandingLo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from localizations - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from localizations by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in localizations - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OrganizationalBrandingLocalization model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from localizations by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Localizations/LocalizationsRequestBuilder.cs b/src/generated/Localizations/LocalizationsRequestBuilder.cs index 5dae9aa4cf7..765b5857a6d 100644 --- a/src/generated/Localizations/LocalizationsRequestBuilder.cs +++ b/src/generated/Localizations/LocalizationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class LocalizationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OrganizationalBrandingLocalizationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(OrganizationalBrandingLoc requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get entities from localizations - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to localizations - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OrganizationalBrandingLocalization model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from localizations public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Activities/ActivitiesRequestBuilder.cs b/src/generated/Me/Activities/ActivitiesRequestBuilder.cs index 2b77f0cf8d0..528bd4c5530 100644 --- a/src/generated/Me/Activities/ActivitiesRequestBuilder.cs +++ b/src/generated/Me/Activities/ActivitiesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,12 +23,11 @@ public class ActivitiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new UserActivityRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildHistoryItemsCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildHistoryItemsCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,21 +41,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -101,7 +99,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -112,15 +114,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -176,31 +173,6 @@ public RequestInformation CreatePostRequestInformation(UserActivity body, Action return requestInfo; } /// - /// The user's activities across devices. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's activities across devices. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UserActivity model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \me\activities\microsoft.graph.recent() /// public RecentRequestBuilder Recent() { diff --git a/src/generated/Me/Activities/Item/HistoryItems/HistoryItemsRequestBuilder.cs b/src/generated/Me/Activities/Item/HistoryItems/HistoryItemsRequestBuilder.cs index 2d596d8a51f..ddf5bbe7646 100644 --- a/src/generated/Me/Activities/Item/HistoryItems/HistoryItemsRequestBuilder.cs +++ b/src/generated/Me/Activities/Item/HistoryItems/HistoryItemsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class HistoryItemsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ActivityHistoryItemRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildActivityCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildActivityCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -37,7 +36,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Optional. NavigationProperty/Containment; navigation property to the activity's historyItems."; // Create options for all the parameters - var userActivityIdOption = new Option("--useractivity-id", description: "key: id of userActivity") { + var userActivityIdOption = new Option("--user-activity-id", description: "key: id of userActivity") { }; userActivityIdOption.IsRequired = true; command.AddOption(userActivityIdOption); @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userActivityId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userActivityId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userActivityIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userActivityIdOption, bodyOption, outputOption); return command; } /// @@ -69,7 +67,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Optional. NavigationProperty/Containment; navigation property to the activity's historyItems."; // Create options for all the parameters - var userActivityIdOption = new Option("--useractivity-id", description: "key: id of userActivity") { + var userActivityIdOption = new Option("--user-activity-id", description: "key: id of userActivity") { }; userActivityIdOption.IsRequired = true; command.AddOption(userActivityIdOption); @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userActivityId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userActivityId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userActivityIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userActivityIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(ActivityHistoryItem body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Optional. NavigationProperty/Containment; navigation property to the activity's historyItems. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Optional. NavigationProperty/Containment; navigation property to the activity's historyItems. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ActivityHistoryItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Optional. NavigationProperty/Containment; navigation property to the activity's historyItems. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Activities/Item/HistoryItems/Item/Activity/@Ref/@Ref.cs b/src/generated/Me/Activities/Item/HistoryItems/Item/Activity/@Ref/@Ref.cs deleted file mode 100644 index 65ba5f0902a..00000000000 --- a/src/generated/Me/Activities/Item/HistoryItems/Item/Activity/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.Activities.Item.HistoryItems.Item.Activity.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/Activities/Item/HistoryItems/Item/Activity/@Ref/RefRequestBuilder.cs b/src/generated/Me/Activities/Item/HistoryItems/Item/Activity/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 0b9e7f0f2ef..00000000000 --- a/src/generated/Me/Activities/Item/HistoryItems/Item/Activity/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Me.Activities.Item.HistoryItems.Item.Activity.@Ref { - /// Builds and executes requests for operations under \me\activities\{userActivity-id}\historyItems\{activityHistoryItem-id}\activity\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Optional. NavigationProperty/Containment; navigation property to the associated activity. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Optional. NavigationProperty/Containment; navigation property to the associated activity."; - // Create options for all the parameters - var userActivityIdOption = new Option("--useractivity-id", description: "key: id of userActivity") { - }; - userActivityIdOption.IsRequired = true; - command.AddOption(userActivityIdOption); - var activityHistoryItemIdOption = new Option("--activityhistoryitem-id", description: "key: id of activityHistoryItem") { - }; - activityHistoryItemIdOption.IsRequired = true; - command.AddOption(activityHistoryItemIdOption); - command.SetHandler(async (string userActivityId, string activityHistoryItemId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userActivityIdOption, activityHistoryItemIdOption); - return command; - } - /// - /// Optional. NavigationProperty/Containment; navigation property to the associated activity. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Optional. NavigationProperty/Containment; navigation property to the associated activity."; - // Create options for all the parameters - var userActivityIdOption = new Option("--useractivity-id", description: "key: id of userActivity") { - }; - userActivityIdOption.IsRequired = true; - command.AddOption(userActivityIdOption); - var activityHistoryItemIdOption = new Option("--activityhistoryitem-id", description: "key: id of activityHistoryItem") { - }; - activityHistoryItemIdOption.IsRequired = true; - command.AddOption(activityHistoryItemIdOption); - command.SetHandler(async (string userActivityId, string activityHistoryItemId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userActivityIdOption, activityHistoryItemIdOption); - return command; - } - /// - /// Optional. NavigationProperty/Containment; navigation property to the associated activity. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Optional. NavigationProperty/Containment; navigation property to the associated activity."; - // Create options for all the parameters - var userActivityIdOption = new Option("--useractivity-id", description: "key: id of userActivity") { - }; - userActivityIdOption.IsRequired = true; - command.AddOption(userActivityIdOption); - var activityHistoryItemIdOption = new Option("--activityhistoryitem-id", description: "key: id of activityHistoryItem") { - }; - activityHistoryItemIdOption.IsRequired = true; - command.AddOption(activityHistoryItemIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string userActivityId, string activityHistoryItemId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userActivityIdOption, activityHistoryItemIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/activities/{userActivity_id}/historyItems/{activityHistoryItem_id}/activity/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Optional. NavigationProperty/Containment; navigation property to the associated activity. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Optional. NavigationProperty/Containment; navigation property to the associated activity. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Optional. NavigationProperty/Containment; navigation property to the associated activity. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Me.Activities.Item.HistoryItems.Item.Activity.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Optional. NavigationProperty/Containment; navigation property to the associated activity. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Optional. NavigationProperty/Containment; navigation property to the associated activity. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Optional. NavigationProperty/Containment; navigation property to the associated activity. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Me.Activities.Item.HistoryItems.Item.Activity.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Me/Activities/Item/HistoryItems/Item/Activity/ActivityRequestBuilder.cs b/src/generated/Me/Activities/Item/HistoryItems/Item/Activity/ActivityRequestBuilder.cs index 9359ec57cae..60e1fcf69bf 100644 --- a/src/generated/Me/Activities/Item/HistoryItems/Item/Activity/ActivityRequestBuilder.cs +++ b/src/generated/Me/Activities/Item/HistoryItems/Item/Activity/ActivityRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,11 +27,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Optional. NavigationProperty/Containment; navigation property to the associated activity."; // Create options for all the parameters - var userActivityIdOption = new Option("--useractivity-id", description: "key: id of userActivity") { + var userActivityIdOption = new Option("--user-activity-id", description: "key: id of userActivity") { }; userActivityIdOption.IsRequired = true; command.AddOption(userActivityIdOption); - var activityHistoryItemIdOption = new Option("--activityhistoryitem-id", description: "key: id of activityHistoryItem") { + var activityHistoryItemIdOption = new Option("--activity-history-item-id", description: "key: id of activityHistoryItem") { }; activityHistoryItemIdOption.IsRequired = true; command.AddOption(activityHistoryItemIdOption); @@ -45,25 +45,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userActivityId, string activityHistoryItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userActivityId, string activityHistoryItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userActivityIdOption, activityHistoryItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userActivityIdOption, activityHistoryItemIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Me.Activities.Item.HistoryItems.Item.Activity.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Me.Activities.Item.HistoryItems.Item.Activity.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -103,18 +102,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Optional. NavigationProperty/Containment; navigation property to the associated activity. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Optional. NavigationProperty/Containment; navigation property to the associated activity. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Activities/Item/HistoryItems/Item/Activity/Ref/Ref.cs b/src/generated/Me/Activities/Item/HistoryItems/Item/Activity/Ref/Ref.cs new file mode 100644 index 00000000000..7ee7016126a --- /dev/null +++ b/src/generated/Me/Activities/Item/HistoryItems/Item/Activity/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.Activities.Item.HistoryItems.Item.Activity.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/Activities/Item/HistoryItems/Item/Activity/Ref/RefRequestBuilder.cs b/src/generated/Me/Activities/Item/HistoryItems/Item/Activity/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..a7c310b084a --- /dev/null +++ b/src/generated/Me/Activities/Item/HistoryItems/Item/Activity/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Me.Activities.Item.HistoryItems.Item.Activity.Ref { + /// Builds and executes requests for operations under \me\activities\{userActivity-id}\historyItems\{activityHistoryItem-id}\activity\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Optional. NavigationProperty/Containment; navigation property to the associated activity. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Optional. NavigationProperty/Containment; navigation property to the associated activity."; + // Create options for all the parameters + var userActivityIdOption = new Option("--user-activity-id", description: "key: id of userActivity") { + }; + userActivityIdOption.IsRequired = true; + command.AddOption(userActivityIdOption); + var activityHistoryItemIdOption = new Option("--activity-history-item-id", description: "key: id of activityHistoryItem") { + }; + activityHistoryItemIdOption.IsRequired = true; + command.AddOption(activityHistoryItemIdOption); + command.SetHandler(async (string userActivityId, string activityHistoryItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, userActivityIdOption, activityHistoryItemIdOption); + return command; + } + /// + /// Optional. NavigationProperty/Containment; navigation property to the associated activity. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Optional. NavigationProperty/Containment; navigation property to the associated activity."; + // Create options for all the parameters + var userActivityIdOption = new Option("--user-activity-id", description: "key: id of userActivity") { + }; + userActivityIdOption.IsRequired = true; + command.AddOption(userActivityIdOption); + var activityHistoryItemIdOption = new Option("--activity-history-item-id", description: "key: id of activityHistoryItem") { + }; + activityHistoryItemIdOption.IsRequired = true; + command.AddOption(activityHistoryItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userActivityId, string activityHistoryItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userActivityIdOption, activityHistoryItemIdOption, outputOption); + return command; + } + /// + /// Optional. NavigationProperty/Containment; navigation property to the associated activity. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Optional. NavigationProperty/Containment; navigation property to the associated activity."; + // Create options for all the parameters + var userActivityIdOption = new Option("--user-activity-id", description: "key: id of userActivity") { + }; + userActivityIdOption.IsRequired = true; + command.AddOption(userActivityIdOption); + var activityHistoryItemIdOption = new Option("--activity-history-item-id", description: "key: id of activityHistoryItem") { + }; + activityHistoryItemIdOption.IsRequired = true; + command.AddOption(activityHistoryItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string userActivityId, string activityHistoryItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, userActivityIdOption, activityHistoryItemIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/me/activities/{userActivity_id}/historyItems/{activityHistoryItem_id}/activity/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Optional. NavigationProperty/Containment; navigation property to the associated activity. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Optional. NavigationProperty/Containment; navigation property to the associated activity. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Optional. NavigationProperty/Containment; navigation property to the associated activity. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Me.Activities.Item.HistoryItems.Item.Activity.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Me/Activities/Item/HistoryItems/Item/ActivityHistoryItemRequestBuilder.cs b/src/generated/Me/Activities/Item/HistoryItems/Item/ActivityHistoryItemRequestBuilder.cs index d0aac092207..bb36b3b83d5 100644 --- a/src/generated/Me/Activities/Item/HistoryItems/Item/ActivityHistoryItemRequestBuilder.cs +++ b/src/generated/Me/Activities/Item/HistoryItems/Item/ActivityHistoryItemRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Optional. NavigationProperty/Containment; navigation property to the activity's historyItems."; // Create options for all the parameters - var userActivityIdOption = new Option("--useractivity-id", description: "key: id of userActivity") { + var userActivityIdOption = new Option("--user-activity-id", description: "key: id of userActivity") { }; userActivityIdOption.IsRequired = true; command.AddOption(userActivityIdOption); - var activityHistoryItemIdOption = new Option("--activityhistoryitem-id", description: "key: id of activityHistoryItem") { + var activityHistoryItemIdOption = new Option("--activity-history-item-id", description: "key: id of activityHistoryItem") { }; activityHistoryItemIdOption.IsRequired = true; command.AddOption(activityHistoryItemIdOption); - command.SetHandler(async (string userActivityId, string activityHistoryItemId) => { + command.SetHandler(async (string userActivityId, string activityHistoryItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userActivityIdOption, activityHistoryItemIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Optional. NavigationProperty/Containment; navigation property to the activity's historyItems."; // Create options for all the parameters - var userActivityIdOption = new Option("--useractivity-id", description: "key: id of userActivity") { + var userActivityIdOption = new Option("--user-activity-id", description: "key: id of userActivity") { }; userActivityIdOption.IsRequired = true; command.AddOption(userActivityIdOption); - var activityHistoryItemIdOption = new Option("--activityhistoryitem-id", description: "key: id of activityHistoryItem") { + var activityHistoryItemIdOption = new Option("--activity-history-item-id", description: "key: id of activityHistoryItem") { }; activityHistoryItemIdOption.IsRequired = true; command.AddOption(activityHistoryItemIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userActivityId, string activityHistoryItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userActivityId, string activityHistoryItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userActivityIdOption, activityHistoryItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userActivityIdOption, activityHistoryItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,11 +97,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Optional. NavigationProperty/Containment; navigation property to the activity's historyItems."; // Create options for all the parameters - var userActivityIdOption = new Option("--useractivity-id", description: "key: id of userActivity") { + var userActivityIdOption = new Option("--user-activity-id", description: "key: id of userActivity") { }; userActivityIdOption.IsRequired = true; command.AddOption(userActivityIdOption); - var activityHistoryItemIdOption = new Option("--activityhistoryitem-id", description: "key: id of activityHistoryItem") { + var activityHistoryItemIdOption = new Option("--activity-history-item-id", description: "key: id of activityHistoryItem") { }; activityHistoryItemIdOption.IsRequired = true; command.AddOption(activityHistoryItemIdOption); @@ -111,14 +109,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userActivityId, string activityHistoryItemId, string body) => { + command.SetHandler(async (string userActivityId, string activityHistoryItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userActivityIdOption, activityHistoryItemIdOption, bodyOption); return command; @@ -190,42 +187,6 @@ public RequestInformation CreatePatchRequestInformation(ActivityHistoryItem body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Optional. NavigationProperty/Containment; navigation property to the activity's historyItems. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Optional. NavigationProperty/Containment; navigation property to the activity's historyItems. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Optional. NavigationProperty/Containment; navigation property to the activity's historyItems. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ActivityHistoryItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Optional. NavigationProperty/Containment; navigation property to the activity's historyItems. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Activities/Item/UserActivityRequestBuilder.cs b/src/generated/Me/Activities/Item/UserActivityRequestBuilder.cs index 4de8acf163b..93ab337e3a7 100644 --- a/src/generated/Me/Activities/Item/UserActivityRequestBuilder.cs +++ b/src/generated/Me/Activities/Item/UserActivityRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,15 +27,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The user's activities across devices. Read-only. Nullable."; // Create options for all the parameters - var userActivityIdOption = new Option("--useractivity-id", description: "key: id of userActivity") { + var userActivityIdOption = new Option("--user-activity-id", description: "key: id of userActivity") { }; userActivityIdOption.IsRequired = true; command.AddOption(userActivityIdOption); - command.SetHandler(async (string userActivityId) => { + command.SetHandler(async (string userActivityId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userActivityIdOption); return command; @@ -47,7 +46,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The user's activities across devices. Read-only. Nullable."; // Create options for all the parameters - var userActivityIdOption = new Option("--useractivity-id", description: "key: id of userActivity") { + var userActivityIdOption = new Option("--user-activity-id", description: "key: id of userActivity") { }; userActivityIdOption.IsRequired = true; command.AddOption(userActivityIdOption); @@ -61,25 +60,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userActivityId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userActivityId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userActivityIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userActivityIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildHistoryItemsCommand() { var command = new Command("history-items"); var builder = new ApiSdk.Me.Activities.Item.HistoryItems.HistoryItemsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -91,7 +92,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The user's activities across devices. Read-only. Nullable."; // Create options for all the parameters - var userActivityIdOption = new Option("--useractivity-id", description: "key: id of userActivity") { + var userActivityIdOption = new Option("--user-activity-id", description: "key: id of userActivity") { }; userActivityIdOption.IsRequired = true; command.AddOption(userActivityIdOption); @@ -99,14 +100,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userActivityId, string body) => { + command.SetHandler(async (string userActivityId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userActivityIdOption, bodyOption); return command; @@ -178,42 +178,6 @@ public RequestInformation CreatePatchRequestInformation(UserActivity body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user's activities across devices. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's activities across devices. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's activities across devices. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(UserActivity model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's activities across devices. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Activities/Recent/RecentRequestBuilder.cs b/src/generated/Me/Activities/Recent/RecentRequestBuilder.cs index 920815db062..d7d91857d98 100644 --- a/src/generated/Me/Activities/Recent/RecentRequestBuilder.cs +++ b/src/generated/Me/Activities/Recent/RecentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function recent"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function recent - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/AgreementAcceptances/@Ref/@Ref.cs b/src/generated/Me/AgreementAcceptances/@Ref/@Ref.cs deleted file mode 100644 index e4d738a9a36..00000000000 --- a/src/generated/Me/AgreementAcceptances/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.AgreementAcceptances.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/AgreementAcceptances/@Ref/RefRequestBuilder.cs b/src/generated/Me/AgreementAcceptances/@Ref/RefRequestBuilder.cs deleted file mode 100644 index b8d7eda2478..00000000000 --- a/src/generated/Me/AgreementAcceptances/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,194 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Me.AgreementAcceptances.@Ref { - /// Builds and executes requests for operations under \me\agreementAcceptances\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The user's terms of use acceptance statuses. Read-only. Nullable. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The user's terms of use acceptance statuses. Read-only. Nullable."; - // Create options for all the parameters - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The user's terms of use acceptance statuses. Read-only. Nullable. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The user's terms of use acceptance statuses. Read-only. Nullable."; - // Create options for all the parameters - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/agreementAcceptances/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The user's terms of use acceptance statuses. Read-only. Nullable. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The user's terms of use acceptance statuses. Read-only. Nullable. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Me.AgreementAcceptances.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The user's terms of use acceptance statuses. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's terms of use acceptance statuses. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Me.AgreementAcceptances.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The user's terms of use acceptance statuses. Read-only. Nullable. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Me/AgreementAcceptances/@Ref/RefResponse.cs b/src/generated/Me/AgreementAcceptances/@Ref/RefResponse.cs deleted file mode 100644 index cddcf105a69..00000000000 --- a/src/generated/Me/AgreementAcceptances/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.AgreementAcceptances.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/AgreementAcceptances/AgreementAcceptancesRequestBuilder.cs b/src/generated/Me/AgreementAcceptances/AgreementAcceptancesRequestBuilder.cs index e1cc89221bf..20e58cb6d56 100644 --- a/src/generated/Me/AgreementAcceptances/AgreementAcceptancesRequestBuilder.cs +++ b/src/generated/Me/AgreementAcceptances/AgreementAcceptancesRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Me.AgreementAcceptances.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -61,7 +61,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -72,20 +76,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Me.AgreementAcceptances.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Me.AgreementAcceptances.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -124,18 +123,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user's terms of use acceptance statuses. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's terms of use acceptance statuses. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/AgreementAcceptances/Ref/Ref.cs b/src/generated/Me/AgreementAcceptances/Ref/Ref.cs new file mode 100644 index 00000000000..b9620487486 --- /dev/null +++ b/src/generated/Me/AgreementAcceptances/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.AgreementAcceptances.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/AgreementAcceptances/Ref/RefRequestBuilder.cs b/src/generated/Me/AgreementAcceptances/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..93051b97383 --- /dev/null +++ b/src/generated/Me/AgreementAcceptances/Ref/RefRequestBuilder.cs @@ -0,0 +1,167 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Me.AgreementAcceptances.Ref { + /// Builds and executes requests for operations under \me\agreementAcceptances\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The user's terms of use acceptance statuses. Read-only. Nullable. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The user's terms of use acceptance statuses. Read-only. Nullable."; + // Create options for all the parameters + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The user's terms of use acceptance statuses. Read-only. Nullable. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The user's terms of use acceptance statuses. Read-only. Nullable."; + // Create options for all the parameters + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/me/agreementAcceptances/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The user's terms of use acceptance statuses. Read-only. Nullable. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The user's terms of use acceptance statuses. Read-only. Nullable. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Me.AgreementAcceptances.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The user's terms of use acceptance statuses. Read-only. Nullable. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Me/AgreementAcceptances/Ref/RefResponse.cs b/src/generated/Me/AgreementAcceptances/Ref/RefResponse.cs new file mode 100644 index 00000000000..5163be838ab --- /dev/null +++ b/src/generated/Me/AgreementAcceptances/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.AgreementAcceptances.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/AppRoleAssignments/AppRoleAssignmentsRequestBuilder.cs b/src/generated/Me/AppRoleAssignments/AppRoleAssignmentsRequestBuilder.cs index d4d4af1ac32..8766622cb17 100644 --- a/src/generated/Me/AppRoleAssignments/AppRoleAssignmentsRequestBuilder.cs +++ b/src/generated/Me/AppRoleAssignments/AppRoleAssignmentsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AppRoleAssignmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AppRoleAssignmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(AppRoleAssignment body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the app roles a user has been granted for an application. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the app roles a user has been granted for an application. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AppRoleAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the app roles a user has been granted for an application. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/AppRoleAssignments/Item/AppRoleAssignmentRequestBuilder.cs b/src/generated/Me/AppRoleAssignments/Item/AppRoleAssignmentRequestBuilder.cs index b9626493859..c672ed0bd2f 100644 --- a/src/generated/Me/AppRoleAssignments/Item/AppRoleAssignmentRequestBuilder.cs +++ b/src/generated/Me/AppRoleAssignments/Item/AppRoleAssignmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the app roles a user has been granted for an application. Supports $expand."; // Create options for all the parameters - var appRoleAssignmentIdOption = new Option("--approleassignment-id", description: "key: id of appRoleAssignment") { + var appRoleAssignmentIdOption = new Option("--app-role-assignment-id", description: "key: id of appRoleAssignment") { }; appRoleAssignmentIdOption.IsRequired = true; command.AddOption(appRoleAssignmentIdOption); - command.SetHandler(async (string appRoleAssignmentId) => { + command.SetHandler(async (string appRoleAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, appRoleAssignmentIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the app roles a user has been granted for an application. Supports $expand."; // Create options for all the parameters - var appRoleAssignmentIdOption = new Option("--approleassignment-id", description: "key: id of appRoleAssignment") { + var appRoleAssignmentIdOption = new Option("--app-role-assignment-id", description: "key: id of appRoleAssignment") { }; appRoleAssignmentIdOption.IsRequired = true; command.AddOption(appRoleAssignmentIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string appRoleAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string appRoleAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, appRoleAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, appRoleAssignmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the app roles a user has been granted for an application. Supports $expand."; // Create options for all the parameters - var appRoleAssignmentIdOption = new Option("--approleassignment-id", description: "key: id of appRoleAssignment") { + var appRoleAssignmentIdOption = new Option("--app-role-assignment-id", description: "key: id of appRoleAssignment") { }; appRoleAssignmentIdOption.IsRequired = true; command.AddOption(appRoleAssignmentIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string appRoleAssignmentId, string body) => { + command.SetHandler(async (string appRoleAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, appRoleAssignmentIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(AppRoleAssignment body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the app roles a user has been granted for an application. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the app roles a user has been granted for an application. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the app roles a user has been granted for an application. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AppRoleAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the app roles a user has been granted for an application. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/AssignLicense/AssignLicenseRequestBuilder.cs b/src/generated/Me/AssignLicense/AssignLicenseRequestBuilder.cs index b1ae02347f1..64039cfa42b 100644 --- a/src/generated/Me/AssignLicense/AssignLicenseRequestBuilder.cs +++ b/src/generated/Me/AssignLicense/AssignLicenseRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -78,19 +77,6 @@ public RequestInformation CreatePostRequestInformation(AssignLicenseRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assignLicense - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignLicenseRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes user public class AssignLicenseResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Authentication/AuthenticationRequestBuilder.cs b/src/generated/Me/Authentication/AuthenticationRequestBuilder.cs index d04ebc59801..00c7c8f1477 100644 --- a/src/generated/Me/Authentication/AuthenticationRequestBuilder.cs +++ b/src/generated/Me/Authentication/AuthenticationRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property authentication for me"; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -42,6 +41,9 @@ public Command BuildDeleteCommand() { public Command BuildFido2MethodsCommand() { var command = new Command("fido2-methods"); var builder = new ApiSdk.Me.Authentication.Fido2Methods.Fido2MethodsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -63,25 +65,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } public Command BuildMethodsCommand() { var command = new Command("methods"); var builder = new ApiSdk.Me.Authentication.Methods.MethodsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -89,6 +93,9 @@ public Command BuildMethodsCommand() { public Command BuildMicrosoftAuthenticatorMethodsCommand() { var command = new Command("microsoft-authenticator-methods"); var builder = new ApiSdk.Me.Authentication.MicrosoftAuthenticatorMethods.MicrosoftAuthenticatorMethodsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -104,14 +111,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -119,6 +125,9 @@ public Command BuildPatchCommand() { public Command BuildWindowsHelloForBusinessMethodsCommand() { var command = new Command("windows-hello-for-business-methods"); var builder = new ApiSdk.Me.Authentication.WindowsHelloForBusinessMethods.WindowsHelloForBusinessMethodsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -190,42 +199,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property authentication for me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get authentication from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property authentication in me - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Authentication model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get authentication from me public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Authentication/Fido2Methods/Fido2MethodsRequestBuilder.cs b/src/generated/Me/Authentication/Fido2Methods/Fido2MethodsRequestBuilder.cs index 9776dd027a3..4b73e73fa04 100644 --- a/src/generated/Me/Authentication/Fido2Methods/Fido2MethodsRequestBuilder.cs +++ b/src/generated/Me/Authentication/Fido2Methods/Fido2MethodsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class Fido2MethodsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new Fido2AuthenticationMethodRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(Fido2AuthenticationMethod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get fido2Methods from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to fido2Methods for me - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Fido2AuthenticationMethod model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get fido2Methods from me public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Authentication/Fido2Methods/Item/Fido2AuthenticationMethodRequestBuilder.cs b/src/generated/Me/Authentication/Fido2Methods/Item/Fido2AuthenticationMethodRequestBuilder.cs index dc446bdc0b9..cffa69c1c5c 100644 --- a/src/generated/Me/Authentication/Fido2Methods/Item/Fido2AuthenticationMethodRequestBuilder.cs +++ b/src/generated/Me/Authentication/Fido2Methods/Item/Fido2AuthenticationMethodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property fido2Methods for me"; // Create options for all the parameters - var fido2AuthenticationMethodIdOption = new Option("--fido2authenticationmethod-id", description: "key: id of fido2AuthenticationMethod") { + var fido2AuthenticationMethodIdOption = new Option("--fido2authentication-method-id", description: "key: id of fido2AuthenticationMethod") { }; fido2AuthenticationMethodIdOption.IsRequired = true; command.AddOption(fido2AuthenticationMethodIdOption); - command.SetHandler(async (string fido2AuthenticationMethodId) => { + command.SetHandler(async (string fido2AuthenticationMethodId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, fido2AuthenticationMethodIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get fido2Methods from me"; // Create options for all the parameters - var fido2AuthenticationMethodIdOption = new Option("--fido2authenticationmethod-id", description: "key: id of fido2AuthenticationMethod") { + var fido2AuthenticationMethodIdOption = new Option("--fido2authentication-method-id", description: "key: id of fido2AuthenticationMethod") { }; fido2AuthenticationMethodIdOption.IsRequired = true; command.AddOption(fido2AuthenticationMethodIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string fido2AuthenticationMethodId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string fido2AuthenticationMethodId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, fido2AuthenticationMethodIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, fido2AuthenticationMethodIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property fido2Methods in me"; // Create options for all the parameters - var fido2AuthenticationMethodIdOption = new Option("--fido2authenticationmethod-id", description: "key: id of fido2AuthenticationMethod") { + var fido2AuthenticationMethodIdOption = new Option("--fido2authentication-method-id", description: "key: id of fido2AuthenticationMethod") { }; fido2AuthenticationMethodIdOption.IsRequired = true; command.AddOption(fido2AuthenticationMethodIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string fido2AuthenticationMethodId, string body) => { + command.SetHandler(async (string fido2AuthenticationMethodId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, fido2AuthenticationMethodIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(Fido2AuthenticationMetho requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property fido2Methods for me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get fido2Methods from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property fido2Methods in me - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Fido2AuthenticationMethod model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get fido2Methods from me public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Authentication/Methods/Item/AuthenticationMethodRequestBuilder.cs b/src/generated/Me/Authentication/Methods/Item/AuthenticationMethodRequestBuilder.cs index 41cf287f60e..d402963d7b0 100644 --- a/src/generated/Me/Authentication/Methods/Item/AuthenticationMethodRequestBuilder.cs +++ b/src/generated/Me/Authentication/Methods/Item/AuthenticationMethodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property methods for me"; // Create options for all the parameters - var authenticationMethodIdOption = new Option("--authenticationmethod-id", description: "key: id of authenticationMethod") { + var authenticationMethodIdOption = new Option("--authentication-method-id", description: "key: id of authenticationMethod") { }; authenticationMethodIdOption.IsRequired = true; command.AddOption(authenticationMethodIdOption); - command.SetHandler(async (string authenticationMethodId) => { + command.SetHandler(async (string authenticationMethodId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, authenticationMethodIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get methods from me"; // Create options for all the parameters - var authenticationMethodIdOption = new Option("--authenticationmethod-id", description: "key: id of authenticationMethod") { + var authenticationMethodIdOption = new Option("--authentication-method-id", description: "key: id of authenticationMethod") { }; authenticationMethodIdOption.IsRequired = true; command.AddOption(authenticationMethodIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string authenticationMethodId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string authenticationMethodId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, authenticationMethodIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, authenticationMethodIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property methods in me"; // Create options for all the parameters - var authenticationMethodIdOption = new Option("--authenticationmethod-id", description: "key: id of authenticationMethod") { + var authenticationMethodIdOption = new Option("--authentication-method-id", description: "key: id of authenticationMethod") { }; authenticationMethodIdOption.IsRequired = true; command.AddOption(authenticationMethodIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string authenticationMethodId, string body) => { + command.SetHandler(async (string authenticationMethodId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, authenticationMethodIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(AuthenticationMethod bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property methods for me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get methods from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property methods in me - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AuthenticationMethod model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get methods from me public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Authentication/Methods/MethodsRequestBuilder.cs b/src/generated/Me/Authentication/Methods/MethodsRequestBuilder.cs index d99afb865ed..3db00fbbf79 100644 --- a/src/generated/Me/Authentication/Methods/MethodsRequestBuilder.cs +++ b/src/generated/Me/Authentication/Methods/MethodsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MethodsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AuthenticationMethodRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(AuthenticationMethod body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get methods from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to methods for me - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AuthenticationMethod model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get methods from me public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Authentication/MicrosoftAuthenticatorMethods/Item/Device/DeviceRequestBuilder.cs b/src/generated/Me/Authentication/MicrosoftAuthenticatorMethods/Item/Device/DeviceRequestBuilder.cs index 73c15b9d53c..ad6eb9552b0 100644 --- a/src/generated/Me/Authentication/MicrosoftAuthenticatorMethods/Item/Device/DeviceRequestBuilder.cs +++ b/src/generated/Me/Authentication/MicrosoftAuthenticatorMethods/Item/Device/DeviceRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The registered device on which Microsoft Authenticator resides. This property is null if the device is not registered for passwordless Phone Sign-In."; // Create options for all the parameters - var microsoftAuthenticatorAuthenticationMethodIdOption = new Option("--microsoftauthenticatorauthenticationmethod-id", description: "key: id of microsoftAuthenticatorAuthenticationMethod") { + var microsoftAuthenticatorAuthenticationMethodIdOption = new Option("--microsoft-authenticator-authentication-method-id", description: "key: id of microsoftAuthenticatorAuthenticationMethod") { }; microsoftAuthenticatorAuthenticationMethodIdOption.IsRequired = true; command.AddOption(microsoftAuthenticatorAuthenticationMethodIdOption); - command.SetHandler(async (string microsoftAuthenticatorAuthenticationMethodId) => { + command.SetHandler(async (string microsoftAuthenticatorAuthenticationMethodId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, microsoftAuthenticatorAuthenticationMethodIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The registered device on which Microsoft Authenticator resides. This property is null if the device is not registered for passwordless Phone Sign-In."; // Create options for all the parameters - var microsoftAuthenticatorAuthenticationMethodIdOption = new Option("--microsoftauthenticatorauthenticationmethod-id", description: "key: id of microsoftAuthenticatorAuthenticationMethod") { + var microsoftAuthenticatorAuthenticationMethodIdOption = new Option("--microsoft-authenticator-authentication-method-id", description: "key: id of microsoftAuthenticatorAuthenticationMethod") { }; microsoftAuthenticatorAuthenticationMethodIdOption.IsRequired = true; command.AddOption(microsoftAuthenticatorAuthenticationMethodIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string microsoftAuthenticatorAuthenticationMethodId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string microsoftAuthenticatorAuthenticationMethodId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, microsoftAuthenticatorAuthenticationMethodIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, microsoftAuthenticatorAuthenticationMethodIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The registered device on which Microsoft Authenticator resides. This property is null if the device is not registered for passwordless Phone Sign-In."; // Create options for all the parameters - var microsoftAuthenticatorAuthenticationMethodIdOption = new Option("--microsoftauthenticatorauthenticationmethod-id", description: "key: id of microsoftAuthenticatorAuthenticationMethod") { + var microsoftAuthenticatorAuthenticationMethodIdOption = new Option("--microsoft-authenticator-authentication-method-id", description: "key: id of microsoftAuthenticatorAuthenticationMethod") { }; microsoftAuthenticatorAuthenticationMethodIdOption.IsRequired = true; command.AddOption(microsoftAuthenticatorAuthenticationMethodIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string microsoftAuthenticatorAuthenticationMethodId, string body) => { + command.SetHandler(async (string microsoftAuthenticatorAuthenticationMethodId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, microsoftAuthenticatorAuthenticationMethodIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The registered device on which Microsoft Authenticator resides. This property is null if the device is not registered for passwordless Phone Sign-In. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The registered device on which Microsoft Authenticator resides. This property is null if the device is not registered for passwordless Phone Sign-In. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The registered device on which Microsoft Authenticator resides. This property is null if the device is not registered for passwordless Phone Sign-In. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Device model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The registered device on which Microsoft Authenticator resides. This property is null if the device is not registered for passwordless Phone Sign-In. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Authentication/MicrosoftAuthenticatorMethods/Item/MicrosoftAuthenticatorAuthenticationMethodRequestBuilder.cs b/src/generated/Me/Authentication/MicrosoftAuthenticatorMethods/Item/MicrosoftAuthenticatorAuthenticationMethodRequestBuilder.cs index c6b81d10f41..b79bbc8ad3e 100644 --- a/src/generated/Me/Authentication/MicrosoftAuthenticatorMethods/Item/MicrosoftAuthenticatorAuthenticationMethodRequestBuilder.cs +++ b/src/generated/Me/Authentication/MicrosoftAuthenticatorMethods/Item/MicrosoftAuthenticatorAuthenticationMethodRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,15 +27,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property microsoftAuthenticatorMethods for me"; // Create options for all the parameters - var microsoftAuthenticatorAuthenticationMethodIdOption = new Option("--microsoftauthenticatorauthenticationmethod-id", description: "key: id of microsoftAuthenticatorAuthenticationMethod") { + var microsoftAuthenticatorAuthenticationMethodIdOption = new Option("--microsoft-authenticator-authentication-method-id", description: "key: id of microsoftAuthenticatorAuthenticationMethod") { }; microsoftAuthenticatorAuthenticationMethodIdOption.IsRequired = true; command.AddOption(microsoftAuthenticatorAuthenticationMethodIdOption); - command.SetHandler(async (string microsoftAuthenticatorAuthenticationMethodId) => { + command.SetHandler(async (string microsoftAuthenticatorAuthenticationMethodId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, microsoftAuthenticatorAuthenticationMethodIdOption); return command; @@ -55,7 +54,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get microsoftAuthenticatorMethods from me"; // Create options for all the parameters - var microsoftAuthenticatorAuthenticationMethodIdOption = new Option("--microsoftauthenticatorauthenticationmethod-id", description: "key: id of microsoftAuthenticatorAuthenticationMethod") { + var microsoftAuthenticatorAuthenticationMethodIdOption = new Option("--microsoft-authenticator-authentication-method-id", description: "key: id of microsoftAuthenticatorAuthenticationMethod") { }; microsoftAuthenticatorAuthenticationMethodIdOption.IsRequired = true; command.AddOption(microsoftAuthenticatorAuthenticationMethodIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string microsoftAuthenticatorAuthenticationMethodId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string microsoftAuthenticatorAuthenticationMethodId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, microsoftAuthenticatorAuthenticationMethodIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, microsoftAuthenticatorAuthenticationMethodIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -92,7 +90,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property microsoftAuthenticatorMethods in me"; // Create options for all the parameters - var microsoftAuthenticatorAuthenticationMethodIdOption = new Option("--microsoftauthenticatorauthenticationmethod-id", description: "key: id of microsoftAuthenticatorAuthenticationMethod") { + var microsoftAuthenticatorAuthenticationMethodIdOption = new Option("--microsoft-authenticator-authentication-method-id", description: "key: id of microsoftAuthenticatorAuthenticationMethod") { }; microsoftAuthenticatorAuthenticationMethodIdOption.IsRequired = true; command.AddOption(microsoftAuthenticatorAuthenticationMethodIdOption); @@ -100,14 +98,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string microsoftAuthenticatorAuthenticationMethodId, string body) => { + command.SetHandler(async (string microsoftAuthenticatorAuthenticationMethodId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, microsoftAuthenticatorAuthenticationMethodIdOption, bodyOption); return command; @@ -179,42 +176,6 @@ public RequestInformation CreatePatchRequestInformation(MicrosoftAuthenticatorAu requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property microsoftAuthenticatorMethods for me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get microsoftAuthenticatorMethods from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property microsoftAuthenticatorMethods in me - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MicrosoftAuthenticatorAuthenticationMethod model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get microsoftAuthenticatorMethods from me public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Authentication/MicrosoftAuthenticatorMethods/MicrosoftAuthenticatorMethodsRequestBuilder.cs b/src/generated/Me/Authentication/MicrosoftAuthenticatorMethods/MicrosoftAuthenticatorMethodsRequestBuilder.cs index 287264c53e8..9360bdb190c 100644 --- a/src/generated/Me/Authentication/MicrosoftAuthenticatorMethods/MicrosoftAuthenticatorMethodsRequestBuilder.cs +++ b/src/generated/Me/Authentication/MicrosoftAuthenticatorMethods/MicrosoftAuthenticatorMethodsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class MicrosoftAuthenticatorMethodsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MicrosoftAuthenticatorAuthenticationMethodRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildDeviceCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDeviceCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(MicrosoftAuthenticatorAut requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get microsoftAuthenticatorMethods from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to microsoftAuthenticatorMethods for me - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MicrosoftAuthenticatorAuthenticationMethod model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get microsoftAuthenticatorMethods from me public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Authentication/WindowsHelloForBusinessMethods/Item/Device/DeviceRequestBuilder.cs b/src/generated/Me/Authentication/WindowsHelloForBusinessMethods/Item/Device/DeviceRequestBuilder.cs index ceacaa1dd95..d03ad8ec0fb 100644 --- a/src/generated/Me/Authentication/WindowsHelloForBusinessMethods/Item/Device/DeviceRequestBuilder.cs +++ b/src/generated/Me/Authentication/WindowsHelloForBusinessMethods/Item/Device/DeviceRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The registered device on which this Windows Hello for Business key resides."; // Create options for all the parameters - var windowsHelloForBusinessAuthenticationMethodIdOption = new Option("--windowshelloforbusinessauthenticationmethod-id", description: "key: id of windowsHelloForBusinessAuthenticationMethod") { + var windowsHelloForBusinessAuthenticationMethodIdOption = new Option("--windows-hello-for-business-authentication-method-id", description: "key: id of windowsHelloForBusinessAuthenticationMethod") { }; windowsHelloForBusinessAuthenticationMethodIdOption.IsRequired = true; command.AddOption(windowsHelloForBusinessAuthenticationMethodIdOption); - command.SetHandler(async (string windowsHelloForBusinessAuthenticationMethodId) => { + command.SetHandler(async (string windowsHelloForBusinessAuthenticationMethodId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, windowsHelloForBusinessAuthenticationMethodIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The registered device on which this Windows Hello for Business key resides."; // Create options for all the parameters - var windowsHelloForBusinessAuthenticationMethodIdOption = new Option("--windowshelloforbusinessauthenticationmethod-id", description: "key: id of windowsHelloForBusinessAuthenticationMethod") { + var windowsHelloForBusinessAuthenticationMethodIdOption = new Option("--windows-hello-for-business-authentication-method-id", description: "key: id of windowsHelloForBusinessAuthenticationMethod") { }; windowsHelloForBusinessAuthenticationMethodIdOption.IsRequired = true; command.AddOption(windowsHelloForBusinessAuthenticationMethodIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string windowsHelloForBusinessAuthenticationMethodId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string windowsHelloForBusinessAuthenticationMethodId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, windowsHelloForBusinessAuthenticationMethodIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, windowsHelloForBusinessAuthenticationMethodIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The registered device on which this Windows Hello for Business key resides."; // Create options for all the parameters - var windowsHelloForBusinessAuthenticationMethodIdOption = new Option("--windowshelloforbusinessauthenticationmethod-id", description: "key: id of windowsHelloForBusinessAuthenticationMethod") { + var windowsHelloForBusinessAuthenticationMethodIdOption = new Option("--windows-hello-for-business-authentication-method-id", description: "key: id of windowsHelloForBusinessAuthenticationMethod") { }; windowsHelloForBusinessAuthenticationMethodIdOption.IsRequired = true; command.AddOption(windowsHelloForBusinessAuthenticationMethodIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string windowsHelloForBusinessAuthenticationMethodId, string body) => { + command.SetHandler(async (string windowsHelloForBusinessAuthenticationMethodId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, windowsHelloForBusinessAuthenticationMethodIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The registered device on which this Windows Hello for Business key resides. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The registered device on which this Windows Hello for Business key resides. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The registered device on which this Windows Hello for Business key resides. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Device model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The registered device on which this Windows Hello for Business key resides. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Authentication/WindowsHelloForBusinessMethods/Item/WindowsHelloForBusinessAuthenticationMethodRequestBuilder.cs b/src/generated/Me/Authentication/WindowsHelloForBusinessMethods/Item/WindowsHelloForBusinessAuthenticationMethodRequestBuilder.cs index 5cf369bda7a..840b1328329 100644 --- a/src/generated/Me/Authentication/WindowsHelloForBusinessMethods/Item/WindowsHelloForBusinessAuthenticationMethodRequestBuilder.cs +++ b/src/generated/Me/Authentication/WindowsHelloForBusinessMethods/Item/WindowsHelloForBusinessAuthenticationMethodRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,15 +27,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property windowsHelloForBusinessMethods for me"; // Create options for all the parameters - var windowsHelloForBusinessAuthenticationMethodIdOption = new Option("--windowshelloforbusinessauthenticationmethod-id", description: "key: id of windowsHelloForBusinessAuthenticationMethod") { + var windowsHelloForBusinessAuthenticationMethodIdOption = new Option("--windows-hello-for-business-authentication-method-id", description: "key: id of windowsHelloForBusinessAuthenticationMethod") { }; windowsHelloForBusinessAuthenticationMethodIdOption.IsRequired = true; command.AddOption(windowsHelloForBusinessAuthenticationMethodIdOption); - command.SetHandler(async (string windowsHelloForBusinessAuthenticationMethodId) => { + command.SetHandler(async (string windowsHelloForBusinessAuthenticationMethodId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, windowsHelloForBusinessAuthenticationMethodIdOption); return command; @@ -55,7 +54,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get windowsHelloForBusinessMethods from me"; // Create options for all the parameters - var windowsHelloForBusinessAuthenticationMethodIdOption = new Option("--windowshelloforbusinessauthenticationmethod-id", description: "key: id of windowsHelloForBusinessAuthenticationMethod") { + var windowsHelloForBusinessAuthenticationMethodIdOption = new Option("--windows-hello-for-business-authentication-method-id", description: "key: id of windowsHelloForBusinessAuthenticationMethod") { }; windowsHelloForBusinessAuthenticationMethodIdOption.IsRequired = true; command.AddOption(windowsHelloForBusinessAuthenticationMethodIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string windowsHelloForBusinessAuthenticationMethodId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string windowsHelloForBusinessAuthenticationMethodId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, windowsHelloForBusinessAuthenticationMethodIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, windowsHelloForBusinessAuthenticationMethodIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -92,7 +90,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property windowsHelloForBusinessMethods in me"; // Create options for all the parameters - var windowsHelloForBusinessAuthenticationMethodIdOption = new Option("--windowshelloforbusinessauthenticationmethod-id", description: "key: id of windowsHelloForBusinessAuthenticationMethod") { + var windowsHelloForBusinessAuthenticationMethodIdOption = new Option("--windows-hello-for-business-authentication-method-id", description: "key: id of windowsHelloForBusinessAuthenticationMethod") { }; windowsHelloForBusinessAuthenticationMethodIdOption.IsRequired = true; command.AddOption(windowsHelloForBusinessAuthenticationMethodIdOption); @@ -100,14 +98,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string windowsHelloForBusinessAuthenticationMethodId, string body) => { + command.SetHandler(async (string windowsHelloForBusinessAuthenticationMethodId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, windowsHelloForBusinessAuthenticationMethodIdOption, bodyOption); return command; @@ -179,42 +176,6 @@ public RequestInformation CreatePatchRequestInformation(WindowsHelloForBusinessA requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property windowsHelloForBusinessMethods for me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get windowsHelloForBusinessMethods from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property windowsHelloForBusinessMethods in me - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WindowsHelloForBusinessAuthenticationMethod model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get windowsHelloForBusinessMethods from me public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Authentication/WindowsHelloForBusinessMethods/WindowsHelloForBusinessMethodsRequestBuilder.cs b/src/generated/Me/Authentication/WindowsHelloForBusinessMethods/WindowsHelloForBusinessMethodsRequestBuilder.cs index df75e2ab75e..4dcea965f2c 100644 --- a/src/generated/Me/Authentication/WindowsHelloForBusinessMethods/WindowsHelloForBusinessMethodsRequestBuilder.cs +++ b/src/generated/Me/Authentication/WindowsHelloForBusinessMethods/WindowsHelloForBusinessMethodsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class WindowsHelloForBusinessMethodsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new WindowsHelloForBusinessAuthenticationMethodRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildDeviceCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDeviceCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(WindowsHelloForBusinessAu requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get windowsHelloForBusinessMethods from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to windowsHelloForBusinessMethods for me - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WindowsHelloForBusinessAuthenticationMethod model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get windowsHelloForBusinessMethods from me public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs b/src/generated/Me/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs index 418328e053b..ab3cdc2d9ac 100644 --- a/src/generated/Me/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs +++ b/src/generated/Me/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +29,17 @@ public Command BuildGetCommand() { }; UserOption.IsRequired = true; command.AddOption(UserOption); - command.SetHandler(async (string User) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string User, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, UserOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, UserOption, outputOption); return command; } /// @@ -73,16 +72,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function allowedCalendarSharingRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs b/src/generated/Me/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs index b25b971cc68..8b31006623d 100644 --- a/src/generated/Me/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class CalendarPermissionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new CalendarPermissionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -90,7 +88,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -99,15 +101,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -162,31 +159,6 @@ public RequestInformation CreatePostRequestInformation(CalendarPermission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CalendarPermission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions of the users with whom the calendar is shared. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs b/src/generated/Me/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs index 87398edb52f..73051a7dae0 100644 --- a/src/generated/Me/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The permissions of the users with whom the calendar is shared."; // Create options for all the parameters - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); - command.SetHandler(async (string calendarPermissionId) => { + command.SetHandler(async (string calendarPermissionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarPermissionIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The permissions of the users with whom the calendar is shared."; // Create options for all the parameters - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); @@ -55,19 +54,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarPermissionId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarPermissionId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarPermissionIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarPermissionIdOption, selectOption, outputOption); return command; } /// @@ -77,7 +75,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The permissions of the users with whom the calendar is shared."; // Create options for all the parameters - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); @@ -85,14 +83,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarPermissionId, string body) => { + command.SetHandler(async (string calendarPermissionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarPermissionIdOption, bodyOption); return command; @@ -164,42 +161,6 @@ public RequestInformation CreatePatchRequestInformation(CalendarPermission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(CalendarPermission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions of the users with whom the calendar is shared. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/Calendar/CalendarRequestBuilder.cs b/src/generated/Me/Calendar/CalendarRequestBuilder.cs index 4b5732abaa3..f19212389df 100644 --- a/src/generated/Me/Calendar/CalendarRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,6 +37,9 @@ public AllowedCalendarSharingRolesWithUserRequestBuilder AllowedCalendarSharingR public Command BuildCalendarPermissionsCommand() { var command = new Command("calendar-permissions"); var builder = new ApiSdk.Me.Calendar.CalendarPermissions.CalendarPermissionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -44,6 +47,9 @@ public Command BuildCalendarPermissionsCommand() { public Command BuildCalendarViewCommand() { var command = new Command("calendar-view"); var builder = new ApiSdk.Me.Calendar.CalendarView.CalendarViewRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -55,11 +61,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The user's primary calendar. Read-only."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -67,6 +72,9 @@ public Command BuildDeleteCommand() { public Command BuildEventsCommand() { var command = new Command("events"); var builder = new ApiSdk.Me.Calendar.Events.EventsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -83,19 +91,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, outputOption); return command; } public Command BuildGetScheduleCommand() { @@ -107,6 +114,9 @@ public Command BuildGetScheduleCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Me.Calendar.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -122,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -137,6 +146,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Me.Calendar.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -208,42 +220,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user's primary calendar. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's primary calendar. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's primary calendar. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's primary calendar. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/Calendar/CalendarView/CalendarViewRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/CalendarViewRequestBuilder.cs index 425593496fd..e7dee53a2cc 100644 --- a/src/generated/Me/Calendar/CalendarView/CalendarViewRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/CalendarViewRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,24 +23,23 @@ public class CalendarViewRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildAttachmentsCommand(), - builder.BuildCalendarCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildExtensionsCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildInstancesCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildAttachmentsCommand()); + commands.Add(builder.BuildCalendarCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInstancesCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -78,11 +76,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The calendar view for the calendar. Navigation property. Read-only."; // Create options for all the parameters - var startDateTimeOption = new Option("--startdatetime", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { + var startDateTimeOption = new Option("--start-date-time", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { }; startDateTimeOption.IsRequired = true; command.AddOption(startDateTimeOption); - var endDateTimeOption = new Option("--enddatetime", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { + var endDateTimeOption = new Option("--end-date-time", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { }; endDateTimeOption.IsRequired = true; command.AddOption(endDateTimeOption); @@ -112,7 +110,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string startDateTime, string endDateTime, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string startDateTime, string endDateTime, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { if (!String.IsNullOrEmpty(startDateTime)) q.StartDateTime = startDateTime; if (!String.IsNullOrEmpty(endDateTime)) q.EndDateTime = endDateTime; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, startDateTimeOption, endDateTimeOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, startDateTimeOption, endDateTimeOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -174,7 +171,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendar/CalendarView/CalendarViewResponse.cs b/src/generated/Me/Calendar/CalendarView/CalendarViewResponse.cs index f8343f3f3d8..9c3adfb6b88 100644 --- a/src/generated/Me/Calendar/CalendarView/CalendarViewResponse.cs +++ b/src/generated/Me/Calendar/CalendarView/CalendarViewResponse.cs @@ -9,7 +9,7 @@ public class CalendarViewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new calendarViewResponse and sets the default values. /// @@ -22,7 +22,7 @@ public CalendarViewResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as CalendarViewResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Me/Calendar/CalendarView/Delta/Delta.cs b/src/generated/Me/Calendar/CalendarView/Delta/Delta.cs deleted file mode 100644 index b50b6b75678..00000000000 --- a/src/generated/Me/Calendar/CalendarView/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.Calendar.CalendarView.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Me/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs index b7d11918e34..f45b640ffa4 100644 --- a/src/generated/Me/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +26,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +67,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs index 9f22d053f13..b065f23b7c6 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs index 15c0733438b..aca57ec3183 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class AttachmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttachmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } public Command BuildCreateUploadSessionCommand() { @@ -110,7 +108,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -120,15 +122,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -183,31 +180,6 @@ public RequestInformation CreatePostRequestInformation(Attachment body, Action - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendar/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index 40cd5e69c2d..d02123abee6 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Calendar/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs index 33731825e4f..6fc2c5ab16c 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; attachmentIdOption.IsRequired = true; command.AddOption(attachmentIdOption); - command.SetHandler(async (string eventId, string attachmentId) => { + command.SetHandler(async (string eventId, string attachmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, attachmentIdOption); return command; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, string attachmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string attachmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, attachmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, attachmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string attachmentId, string body) => { + command.SetHandler(async (string eventId, string attachmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, attachmentIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(Attachment body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Calendar/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs index 98b6ce8ff1c..3541dca28f2 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +33,17 @@ public Command BuildGetCommand() { }; UserOption.IsRequired = true; command.AddOption(UserOption); - command.SetHandler(async (string eventId, string User) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string User, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, UserOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, UserOption, outputOption); return command; } /// @@ -77,16 +76,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function allowedCalendarSharingRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/CalendarView/Item/Calendar/CalendarRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/Calendar/CalendarRequestBuilder.cs index cda7d6ff45f..59502b6b693 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/Calendar/CalendarRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/Calendar/CalendarRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -40,11 +40,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string eventId) => { + command.SetHandler(async (string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption); return command; @@ -65,19 +64,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, selectOption, outputOption); return command; } public Command BuildGetScheduleCommand() { @@ -101,14 +99,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -180,42 +177,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar that contains the event. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/Calendar/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs index c1d4b19e056..fb296600071 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetScheduleRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSchedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetScheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs index db0d235c3bd..088b2e7eb8c 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs index f1ad380be0c..59bd9d9d374 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs index 813cd8b0fd2..3abd0525812 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,10 @@ public Command BuildPostCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string eventId) => { + command.SetHandler(async (string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/CalendarView/Item/EventRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/EventRequestBuilder.cs index b3d974e40c5..e441e2d62a9 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/EventRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/EventRequestBuilder.cs @@ -14,10 +14,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,6 +41,9 @@ public Command BuildAcceptCommand() { public Command BuildAttachmentsCommand() { var command = new Command("attachments"); var builder = new ApiSdk.Me.Calendar.CalendarView.Item.Attachments.AttachmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateUploadSessionCommand()); command.AddCommand(builder.BuildListCommand()); @@ -78,11 +81,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string eventId) => { + command.SetHandler(async (string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption); return command; @@ -96,6 +98,9 @@ public Command BuildDismissReminderCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Me.Calendar.CalendarView.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -117,11 +122,11 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var startDateTimeOption = new Option("--startdatetime", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { + var startDateTimeOption = new Option("--start-date-time", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { }; startDateTimeOption.IsRequired = true; command.AddOption(startDateTimeOption); - var endDateTimeOption = new Option("--enddatetime", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { + var endDateTimeOption = new Option("--end-date-time", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { }; endDateTimeOption.IsRequired = true; command.AddOption(endDateTimeOption); @@ -130,26 +135,28 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, string startDateTime, string endDateTime, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string startDateTime, string endDateTime, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { if (!String.IsNullOrEmpty(startDateTime)) q.StartDateTime = startDateTime; if (!String.IsNullOrEmpty(endDateTime)) q.EndDateTime = endDateTime; q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, startDateTimeOption, endDateTimeOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, startDateTimeOption, endDateTimeOption, selectOption, outputOption); return command; } public Command BuildInstancesCommand() { var command = new Command("instances"); var builder = new ApiSdk.Me.Calendar.CalendarView.Item.Instances.InstancesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -157,6 +164,9 @@ public Command BuildInstancesCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Me.Calendar.CalendarView.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -176,14 +186,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -191,6 +200,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Me.Calendar.CalendarView.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -262,7 +274,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -274,42 +286,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00 diff --git a/src/generated/Me/Calendar/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs index f99567a2139..87a4363505e 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -103,7 +101,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -113,15 +115,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -176,31 +173,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendar/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs index f5a2c0c786c..4c573d3125c 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string eventId, string extensionId) => { + command.SetHandler(async (string eventId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, extensionIdOption); return command; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string extensionId, string body) => { + command.SetHandler(async (string eventId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, extensionIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs index f53c66bb475..4a8350fe094 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/CalendarView/Item/Instances/Delta/Delta.cs b/src/generated/Me/Calendar/CalendarView/Item/Instances/Delta/Delta.cs deleted file mode 100644 index 707005d872b..00000000000 --- a/src/generated/Me/Calendar/CalendarView/Item/Instances/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.Calendar.CalendarView.Item.Instances.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Me/Calendar/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs index 0a845b6a967..89765ed2934 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +30,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/CalendarView/Item/Instances/InstancesRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/Instances/InstancesRequestBuilder.cs index 07ce2f95c0c..42e986c2f64 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/Instances/InstancesRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/Instances/InstancesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class InstancesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -106,7 +104,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -115,15 +117,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -166,7 +163,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendar/CalendarView/Item/Instances/InstancesResponse.cs b/src/generated/Me/Calendar/CalendarView/Item/Instances/InstancesResponse.cs index e1f29eacbc7..da941df42ce 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/Instances/InstancesResponse.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/Instances/InstancesResponse.cs @@ -9,7 +9,7 @@ public class InstancesResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new instancesResponse and sets the default values. /// @@ -22,7 +22,7 @@ public InstancesResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as InstancesResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs index f96853a37d0..05e49be1892 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs index 3a6cac439c2..60adc234cdc 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs index bb53a6e0586..881c007af16 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs index 63a5f54932f..b8d64919434 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,11 +33,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string eventId, string eventId1) => { + command.SetHandler(async (string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/EventRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/EventRequestBuilder.cs index cee90bcfdc0..474fec615c5 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/EventRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -59,11 +59,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string eventId, string eventId1) => { + command.SetHandler(async (string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option); return command; @@ -100,19 +99,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -213,7 +210,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -225,42 +222,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs index 4e32cacdd87..a80ea487bba 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 05c058f7dae..9fb69a03274 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index fc2840ebe86..ef4bf5a96f9 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 6619c1c04b2..90f40f96060 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Calendar/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 71ad2d9e95d..8dd62286c03 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendar/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 5df8b9b0b7c..3aba27bd724 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Calendar/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 4329e684795..a4fb6131f87 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 923879f589e..1374d3b1473 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Me/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index d277a7f4221..955f3b455eb 100644 --- a/src/generated/Me/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Me/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/Events/Delta/Delta.cs b/src/generated/Me/Calendar/Events/Delta/Delta.cs deleted file mode 100644 index f4c035b30db..00000000000 --- a/src/generated/Me/Calendar/Events/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.Calendar.Events.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Me/Calendar/Events/Delta/DeltaRequestBuilder.cs b/src/generated/Me/Calendar/Events/Delta/DeltaRequestBuilder.cs index 5d05de40adc..4b91936717c 100644 --- a/src/generated/Me/Calendar/Events/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +26,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +67,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/Events/EventsRequestBuilder.cs b/src/generated/Me/Calendar/Events/EventsRequestBuilder.cs index e35079513f7..d12cc3f574b 100644 --- a/src/generated/Me/Calendar/Events/EventsRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/EventsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,24 +23,23 @@ public class EventsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildAttachmentsCommand(), - builder.BuildCalendarCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildExtensionsCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildInstancesCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildAttachmentsCommand()); + commands.Add(builder.BuildCalendarCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInstancesCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -104,7 +102,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -113,15 +115,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -164,7 +161,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The events in the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendar/Events/EventsResponse.cs b/src/generated/Me/Calendar/Events/EventsResponse.cs index 30c5cff56dc..7e20d36791f 100644 --- a/src/generated/Me/Calendar/Events/EventsResponse.cs +++ b/src/generated/Me/Calendar/Events/EventsResponse.cs @@ -9,7 +9,7 @@ public class EventsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new eventsResponse and sets the default values. /// @@ -22,7 +22,7 @@ public EventsResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as EventsResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Me/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs index 6b013cdfb66..f7864a185d8 100644 --- a/src/generated/Me/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/Events/Item/Attachments/AttachmentsRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/Attachments/AttachmentsRequestBuilder.cs index a088c2084de..f97cc77fdc5 100644 --- a/src/generated/Me/Calendar/Events/Item/Attachments/AttachmentsRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/Attachments/AttachmentsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class AttachmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttachmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } public Command BuildCreateUploadSessionCommand() { @@ -110,7 +108,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -120,15 +122,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -183,31 +180,6 @@ public RequestInformation CreatePostRequestInformation(Attachment body, Action - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendar/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index 4aa052482bc..ea4f42dd792 100644 --- a/src/generated/Me/Calendar/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Calendar/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs index db09b1b138e..2383123cecc 100644 --- a/src/generated/Me/Calendar/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; attachmentIdOption.IsRequired = true; command.AddOption(attachmentIdOption); - command.SetHandler(async (string eventId, string attachmentId) => { + command.SetHandler(async (string eventId, string attachmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, attachmentIdOption); return command; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, string attachmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string attachmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, attachmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, attachmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string attachmentId, string body) => { + command.SetHandler(async (string eventId, string attachmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, attachmentIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(Attachment body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Calendar/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs index 4582580b15b..017447590b5 100644 --- a/src/generated/Me/Calendar/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +33,17 @@ public Command BuildGetCommand() { }; UserOption.IsRequired = true; command.AddOption(UserOption); - command.SetHandler(async (string eventId, string User) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string User, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, UserOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, UserOption, outputOption); return command; } /// @@ -77,16 +76,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function allowedCalendarSharingRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/Events/Item/Calendar/CalendarRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/Calendar/CalendarRequestBuilder.cs index 99d7b0f5fd1..e6d1b51a95f 100644 --- a/src/generated/Me/Calendar/Events/Item/Calendar/CalendarRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/Calendar/CalendarRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -40,11 +40,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string eventId) => { + command.SetHandler(async (string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption); return command; @@ -65,19 +64,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, selectOption, outputOption); return command; } public Command BuildGetScheduleCommand() { @@ -101,14 +99,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -180,42 +177,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar that contains the event. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/Calendar/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs index fe0303faa48..288802f476b 100644 --- a/src/generated/Me/Calendar/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetScheduleRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSchedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetScheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs index 0a16088d8f1..e0f57da92f1 100644 --- a/src/generated/Me/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs index 33ba922e217..6345bddcc22 100644 --- a/src/generated/Me/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs index b881eb2befc..7d6659ba86a 100644 --- a/src/generated/Me/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,10 @@ public Command BuildPostCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string eventId) => { + command.SetHandler(async (string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/Events/Item/EventRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/EventRequestBuilder.cs index 11cd53d8748..b4754213df5 100644 --- a/src/generated/Me/Calendar/Events/Item/EventRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/EventRequestBuilder.cs @@ -14,10 +14,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,6 +41,9 @@ public Command BuildAcceptCommand() { public Command BuildAttachmentsCommand() { var command = new Command("attachments"); var builder = new ApiSdk.Me.Calendar.Events.Item.Attachments.AttachmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateUploadSessionCommand()); command.AddCommand(builder.BuildListCommand()); @@ -78,11 +81,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string eventId) => { + command.SetHandler(async (string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption); return command; @@ -96,6 +98,9 @@ public Command BuildDismissReminderCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Me.Calendar.Events.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -122,24 +127,26 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, selectOption, outputOption); return command; } public Command BuildInstancesCommand() { var command = new Command("instances"); var builder = new ApiSdk.Me.Calendar.Events.Item.Instances.InstancesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -147,6 +154,9 @@ public Command BuildInstancesCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Me.Calendar.Events.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -166,14 +176,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -181,6 +190,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Me.Calendar.Events.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -252,7 +264,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -264,42 +276,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The events in the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/Calendar/Events/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/Extensions/ExtensionsRequestBuilder.cs index b3078c9e094..c6bc138ff7a 100644 --- a/src/generated/Me/Calendar/Events/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -103,7 +101,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -113,15 +115,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -176,31 +173,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendar/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs index 90e84deadb8..63fbfaaaf27 100644 --- a/src/generated/Me/Calendar/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string eventId, string extensionId) => { + command.SetHandler(async (string eventId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, extensionIdOption); return command; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string extensionId, string body) => { + command.SetHandler(async (string eventId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, extensionIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs index 33d1e2db6d5..0676d2198b2 100644 --- a/src/generated/Me/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/Events/Item/Instances/Delta/Delta.cs b/src/generated/Me/Calendar/Events/Item/Instances/Delta/Delta.cs deleted file mode 100644 index 116d1b942de..00000000000 --- a/src/generated/Me/Calendar/Events/Item/Instances/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.Calendar.Events.Item.Instances.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Me/Calendar/Events/Item/Instances/Delta/DeltaRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/Instances/Delta/DeltaRequestBuilder.cs index bc0ebba2531..68eb5af43a6 100644 --- a/src/generated/Me/Calendar/Events/Item/Instances/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/Instances/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +30,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/Events/Item/Instances/InstancesRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/Instances/InstancesRequestBuilder.cs index 1d64a00e759..8d8f6c266b8 100644 --- a/src/generated/Me/Calendar/Events/Item/Instances/InstancesRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/Instances/InstancesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class InstancesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -106,7 +104,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -115,15 +117,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -166,7 +163,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendar/Events/Item/Instances/InstancesResponse.cs b/src/generated/Me/Calendar/Events/Item/Instances/InstancesResponse.cs index c30a2eda771..4f686da05cc 100644 --- a/src/generated/Me/Calendar/Events/Item/Instances/InstancesResponse.cs +++ b/src/generated/Me/Calendar/Events/Item/Instances/InstancesResponse.cs @@ -9,7 +9,7 @@ public class InstancesResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new instancesResponse and sets the default values. /// @@ -22,7 +22,7 @@ public InstancesResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as InstancesResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Me/Calendar/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs index a750b878d09..eab7a784e7b 100644 --- a/src/generated/Me/Calendar/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs index 1d1e427839f..b6e91568003 100644 --- a/src/generated/Me/Calendar/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs index 1f605b526ec..c973a83424c 100644 --- a/src/generated/Me/Calendar/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs index 8af17665b4a..ff5a9984134 100644 --- a/src/generated/Me/Calendar/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,11 +33,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string eventId, string eventId1) => { + command.SetHandler(async (string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/Events/Item/Instances/Item/EventRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/Instances/Item/EventRequestBuilder.cs index 69601be7b3b..3c886b0728d 100644 --- a/src/generated/Me/Calendar/Events/Item/Instances/Item/EventRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/Instances/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -59,11 +59,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string eventId, string eventId1) => { + command.SetHandler(async (string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option); return command; @@ -100,19 +99,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -213,7 +210,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -225,42 +222,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/Calendar/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs index 0dcd1ddcd15..c0ee91a5b4f 100644 --- a/src/generated/Me/Calendar/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index abe9123d357..ce39011a534 100644 --- a/src/generated/Me/Calendar/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index e002b361de0..7cb310ea8cc 100644 --- a/src/generated/Me/Calendar/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 1726d0e7c7c..190fbe60bf6 100644 --- a/src/generated/Me/Calendar/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Calendar/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 6f1373288c7..19142f0016f 100644 --- a/src/generated/Me/Calendar/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendar/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index d8f124299ab..8717988e23f 100644 --- a/src/generated/Me/Calendar/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Calendar/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 166f3e51ea2..19d238c6c42 100644 --- a/src/generated/Me/Calendar/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index a4c6414749b..db2b136e84f 100644 --- a/src/generated/Me/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Me/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index c84741e9daa..eac5ea03b24 100644 --- a/src/generated/Me/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Me/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/GetSchedule/GetScheduleRequestBuilder.cs b/src/generated/Me/Calendar/GetSchedule/GetScheduleRequestBuilder.cs index 4db776ab715..285121512c4 100644 --- a/src/generated/Me/Calendar/GetSchedule/GetScheduleRequestBuilder.cs +++ b/src/generated/Me/Calendar/GetSchedule/GetScheduleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +29,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +76,5 @@ public RequestInformation CreatePostRequestInformation(GetScheduleRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSchedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetScheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 3c8a127f8cf..fceeea6d5f2 100644 --- a/src/generated/Me/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of multi-value extended properties defined for the calendar. Read-only. Nullable."; // Create options for all the parameters - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, multiValueLegacyExtendedPropertyIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of multi-value extended properties defined for the calendar. Read-only. Nullable."; // Create options for all the parameters - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of multi-value extended properties defined for the calendar. Read-only. Nullable."; // Create options for all the parameters - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index b56d4752d29..cf0d57bc078 100644 --- a/src/generated/Me/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 21dedcab429..e7fe7dae340 100644 --- a/src/generated/Me/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of single-value extended properties defined for the calendar. Read-only. Nullable."; // Create options for all the parameters - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, singleValueLegacyExtendedPropertyIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of single-value extended properties defined for the calendar. Read-only. Nullable."; // Create options for all the parameters - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of single-value extended properties defined for the calendar. Read-only. Nullable."; // Create options for all the parameters - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 431878856b0..b7b740458be 100644 --- a/src/generated/Me/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarGroups/CalendarGroupsRequestBuilder.cs b/src/generated/Me/CalendarGroups/CalendarGroupsRequestBuilder.cs index 316b6045695..1133b965553 100644 --- a/src/generated/Me/CalendarGroups/CalendarGroupsRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/CalendarGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class CalendarGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new CalendarGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCalendarsCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCalendarsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -91,7 +89,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -100,15 +102,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -163,31 +160,6 @@ public RequestInformation CreatePostRequestInformation(CalendarGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user's calendar groups. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's calendar groups. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CalendarGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's calendar groups. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarGroups/Item/CalendarGroupRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/CalendarGroupRequestBuilder.cs index 13d72dcf2cb..41984a94042 100644 --- a/src/generated/Me/CalendarGroups/Item/CalendarGroupRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/CalendarGroupRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,6 +23,9 @@ public class CalendarGroupRequestBuilder { public Command BuildCalendarsCommand() { var command = new Command("calendars"); var builder = new ApiSdk.Me.CalendarGroups.Item.Calendars.CalendarsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -34,15 +37,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The user's calendar groups. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); - command.SetHandler(async (string calendarGroupId) => { + command.SetHandler(async (string calendarGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption); return command; @@ -54,7 +56,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The user's calendar groups. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -63,19 +65,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarGroupId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, selectOption, outputOption); return command; } /// @@ -85,7 +86,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The user's calendar groups. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -93,14 +94,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string body) => { + command.SetHandler(async (string calendarGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, bodyOption); return command; @@ -172,42 +172,6 @@ public RequestInformation CreatePatchRequestInformation(CalendarGroup body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user's calendar groups. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's calendar groups. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's calendar groups. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(CalendarGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's calendar groups. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/CalendarsRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/CalendarsRequestBuilder.cs index 69043ffa8df..4f327b5458f 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/CalendarsRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/CalendarsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,17 +22,16 @@ public class CalendarsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new CalendarRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCalendarPermissionsCommand(), - builder.BuildCalendarViewCommand(), - builder.BuildDeleteCommand(), - builder.BuildEventsCommand(), - builder.BuildGetCommand(), - builder.BuildGetScheduleCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCalendarPermissionsCommand()); + commands.Add(builder.BuildCalendarViewCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildEventsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildGetScheduleCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); return commands; } /// @@ -42,7 +41,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The calendars in the calendar group. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, bodyOption, outputOption); return command; } /// @@ -74,7 +72,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The calendars in the calendar group. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -104,7 +102,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarGroupId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -113,15 +115,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -176,31 +173,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The calendars in the calendar group. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendars in the calendar group. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendars in the calendar group. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs index e1417ad1b44..73b026be1b7 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function allowedCalendarSharingRoles"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -37,18 +37,17 @@ public Command BuildGetCommand() { }; UserOption.IsRequired = true; command.AddOption(UserOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string User) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string User, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, UserOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, UserOption, outputOption); return command; } /// @@ -81,16 +80,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function allowedCalendarSharingRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarPermissions/CalendarPermissionsRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarPermissions/CalendarPermissionsRequestBuilder.cs index 3b84d1fe5b5..dd2eef69a86 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarPermissions/CalendarPermissionsRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarPermissions/CalendarPermissionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class CalendarPermissionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new CalendarPermissionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The permissions of the users with whom the calendar is shared."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, bodyOption, outputOption); return command; } /// @@ -72,7 +70,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The permissions of the users with whom the calendar is shared."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -106,7 +104,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarGroupId, string calendarId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -115,15 +117,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -178,31 +175,6 @@ public RequestInformation CreatePostRequestInformation(CalendarPermission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CalendarPermission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions of the users with whom the calendar is shared. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs index 05f299212b0..2b60123d2fd 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The permissions of the users with whom the calendar is shared."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string calendarPermissionId) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string calendarPermissionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, calendarPermissionIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The permissions of the users with whom the calendar is shared."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); @@ -71,19 +70,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string calendarPermissionId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string calendarPermissionId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, calendarPermissionIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, calendarPermissionIdOption, selectOption, outputOption); return command; } /// @@ -93,7 +91,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The permissions of the users with whom the calendar is shared."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -101,7 +99,7 @@ public Command BuildPatchCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); @@ -109,14 +107,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string calendarPermissionId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string calendarPermissionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, calendarPermissionIdOption, bodyOption); return command; @@ -188,42 +185,6 @@ public RequestInformation CreatePatchRequestInformation(CalendarPermission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(CalendarPermission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions of the users with whom the calendar is shared. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarRequestBuilder.cs index 61e2ab7b4da..755a5cf22c2 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,6 +37,9 @@ public AllowedCalendarSharingRolesWithUserRequestBuilder AllowedCalendarSharingR public Command BuildCalendarPermissionsCommand() { var command = new Command("calendar-permissions"); var builder = new ApiSdk.Me.CalendarGroups.Item.Calendars.Item.CalendarPermissions.CalendarPermissionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -44,6 +47,9 @@ public Command BuildCalendarPermissionsCommand() { public Command BuildCalendarViewCommand() { var command = new Command("calendar-view"); var builder = new ApiSdk.Me.CalendarGroups.Item.Calendars.Item.CalendarView.CalendarViewRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -55,7 +61,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The calendars in the calendar group. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -63,11 +69,10 @@ public Command BuildDeleteCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - command.SetHandler(async (string calendarGroupId, string calendarId) => { + command.SetHandler(async (string calendarGroupId, string calendarId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption); return command; @@ -75,6 +80,9 @@ public Command BuildDeleteCommand() { public Command BuildEventsCommand() { var command = new Command("events"); var builder = new ApiSdk.Me.CalendarGroups.Item.Calendars.Item.Events.EventsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -86,7 +94,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The calendars in the calendar group. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -99,19 +107,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, selectOption, outputOption); return command; } public Command BuildGetScheduleCommand() { @@ -123,6 +130,9 @@ public Command BuildGetScheduleCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Me.CalendarGroups.Item.Calendars.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,7 +144,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The calendars in the calendar group. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -146,14 +156,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, bodyOption); return command; @@ -161,6 +170,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Me.CalendarGroups.Item.Calendars.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -232,42 +244,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The calendars in the calendar group. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendars in the calendar group. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendars in the calendar group. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendars in the calendar group. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/CalendarViewRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/CalendarViewRequestBuilder.cs index 8114604ada2..97d3bdf5f1e 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/CalendarViewRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/CalendarViewRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,24 +23,23 @@ public class CalendarViewRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildAttachmentsCommand(), - builder.BuildCalendarCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildExtensionsCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildInstancesCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildAttachmentsCommand()); + commands.Add(builder.BuildCalendarCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInstancesCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -50,7 +49,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The calendar view for the calendar. Navigation property. Read-only."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -62,21 +61,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, bodyOption, outputOption); return command; } /// @@ -86,7 +84,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The calendar view for the calendar. Navigation property. Read-only."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarGroupId, string calendarId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -129,15 +131,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -180,7 +177,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -198,31 +195,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/CalendarViewResponse.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/CalendarViewResponse.cs index f02ad990ae6..e6e069118e6 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/CalendarViewResponse.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/CalendarViewResponse.cs @@ -9,7 +9,7 @@ public class CalendarViewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new calendarViewResponse and sets the default values. /// @@ -22,7 +22,7 @@ public CalendarViewResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as CalendarViewResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Delta/Delta.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Delta/Delta.cs deleted file mode 100644 index ddf98028632..00000000000 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.CalendarGroups.Item.Calendars.Item.CalendarView.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Delta/DeltaRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Delta/DeltaRequestBuilder.cs index 858d958b1fb..a63370f4aaa 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -33,18 +34,17 @@ public Command BuildGetCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - command.SetHandler(async (string calendarGroupId, string calendarId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, outputOption); return command; } /// @@ -75,16 +75,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Accept/AcceptRequestBuilder.cs index db1d5bb8258..9dd8fc73243 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action accept"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs index 04970c1ea43..7a9f4abeb02 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class AttachmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttachmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -37,7 +36,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } public Command BuildCreateUploadSessionCommand() { @@ -83,7 +81,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -126,7 +124,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(Attachment body, Action - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index 757dd76552e..23bf7541dd0 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action createUploadSession"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs index 6706f50c3bb..7c0f3d619b5 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -42,11 +42,10 @@ public Command BuildDeleteCommand() { }; attachmentIdOption.IsRequired = true; command.AddOption(attachmentIdOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string attachmentId) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string attachmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, attachmentIdOption); return command; @@ -58,7 +57,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string attachmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string attachmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string attachmentId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string attachmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, attachmentIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(Attachment body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs index 2ec24e70633..77d0224223d 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function allowedCalendarSharingRoles"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -41,18 +41,17 @@ public Command BuildGetCommand() { }; UserOption.IsRequired = true; command.AddOption(UserOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string User) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string User, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, UserOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, UserOption, outputOption); return command; } /// @@ -85,16 +84,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function allowedCalendarSharingRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Calendar/CalendarRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Calendar/CalendarRequestBuilder.cs index 7a8109a4195..98dc449c842 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Calendar/CalendarRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Calendar/CalendarRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -36,7 +36,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The calendar that contains the event. Navigation property. Read-only."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -48,11 +48,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption); return command; @@ -64,7 +63,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The calendar that contains the event. Navigation property. Read-only."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -81,19 +80,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, selectOption, outputOption); return command; } public Command BuildGetScheduleCommand() { @@ -109,7 +107,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The calendar that contains the event. Navigation property. Read-only."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar that contains the event. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs index d543ebf8fb6..3aec05c9c48 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action getSchedule"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -41,21 +41,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -89,18 +88,5 @@ public RequestInformation CreatePostRequestInformation(GetScheduleRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSchedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetScheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs index 824468f114a..d4bd97cd3bb 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action cancel"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Decline/DeclineRequestBuilder.cs index de7ec2ab114..e3019726bb9 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action decline"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs index d5932c7d31e..873f81250c9 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action dismissReminder"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -37,11 +37,10 @@ public Command BuildPostCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/EventRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/EventRequestBuilder.cs index d048b3ca752..674206c460c 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/EventRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/EventRequestBuilder.cs @@ -14,10 +14,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,6 +41,9 @@ public Command BuildAcceptCommand() { public Command BuildAttachmentsCommand() { var command = new Command("attachments"); var builder = new ApiSdk.Me.CalendarGroups.Item.Calendars.Item.CalendarView.Item.Attachments.AttachmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateUploadSessionCommand()); command.AddCommand(builder.BuildListCommand()); @@ -74,7 +77,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The calendar view for the calendar. Navigation property. Read-only."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -86,11 +89,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption); return command; @@ -104,6 +106,9 @@ public Command BuildDismissReminderCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Me.CalendarGroups.Item.Calendars.Item.CalendarView.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -121,7 +126,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The calendar view for the calendar. Navigation property. Read-only."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -138,24 +143,26 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, selectOption, outputOption); return command; } public Command BuildInstancesCommand() { var command = new Command("instances"); var builder = new ApiSdk.Me.CalendarGroups.Item.Calendars.Item.CalendarView.Item.Instances.InstancesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -163,6 +170,9 @@ public Command BuildInstancesCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Me.CalendarGroups.Item.Calendars.Item.CalendarView.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -174,7 +184,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The calendar view for the calendar. Navigation property. Read-only."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -190,14 +200,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -205,6 +214,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Me.CalendarGroups.Item.Calendars.Item.CalendarView.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -276,7 +288,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -288,42 +300,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs index d43541c79c9..7553c692a06 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of open extensions defined for the event. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of open extensions defined for the event. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -129,15 +131,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs index 5270e57bd95..ea2e4a7c1a9 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of open extensions defined for the event. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -42,11 +42,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string extensionId) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, extensionIdOption); return command; @@ -58,7 +57,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of open extensions defined for the event. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of open extensions defined for the event. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string extensionId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, extensionIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Forward/ForwardRequestBuilder.cs index 07efd84455b..d1737a5f919 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action forward"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Delta/Delta.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Delta/Delta.cs deleted file mode 100644 index 29464351e7c..00000000000 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.CalendarGroups.Item.Calendars.Item.CalendarView.Item.Instances.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs index 7f56718148f..7252c793211 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -37,18 +38,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, outputOption); return command; } /// @@ -79,16 +79,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/InstancesRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/InstancesRequestBuilder.cs index 691aec6593f..e56f9461adc 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/InstancesRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/InstancesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class InstancesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -44,7 +43,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -60,21 +59,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -122,7 +120,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -182,7 +179,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -200,31 +197,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/InstancesResponse.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/InstancesResponse.cs index 147d3acb674..3655b0785ea 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/InstancesResponse.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/InstancesResponse.cs @@ -9,7 +9,7 @@ public class InstancesResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new instancesResponse and sets the default values. /// @@ -22,7 +22,7 @@ public InstancesResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as InstancesResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs index 222fbe589ba..40554197cb4 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action accept"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs index 2842be62ac2..255858b91be 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action cancel"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs index 3b42184e083..1b75878f37d 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action decline"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs index 5e46b42ab34..4552839aad7 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action dismissReminder"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -41,11 +41,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option); return command; @@ -78,16 +77,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/EventRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/EventRequestBuilder.cs index ac7b687976c..8f308afda00 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/EventRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -51,7 +51,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -67,11 +67,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option); return command; @@ -95,7 +94,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -116,19 +115,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -138,7 +136,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -158,14 +156,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -237,7 +234,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -249,42 +246,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs index 102631b7831..95b4ac8ab83 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action forward"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 71979dfc056..024a93c88a3 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action snoozeReminder"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index 6978c5e2e12..ec7e1a7a9c8 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action tentativelyAccept"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 1b8d172e268..854bf80593a 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of multi-value extended properties defined for the event. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -58,7 +57,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of multi-value extended properties defined for the event. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -70,7 +69,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of multi-value extended properties defined for the event. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -119,7 +117,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 1a393a21f67..16e47b33f6d 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of multi-value extended properties defined for the event. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of multi-value extended properties defined for the event. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index f1b87fed9ea..f0221f02fa5 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of single-value extended properties defined for the event. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -58,7 +57,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of single-value extended properties defined for the event. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -70,7 +69,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of single-value extended properties defined for the event. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -119,7 +117,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index fc422f4a458..958096bdd99 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of single-value extended properties defined for the event. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of single-value extended properties defined for the event. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 1dab7050a52..fe995c6e311 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action snoozeReminder"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index a9f29728d6b..2bbebab1e26 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action tentativelyAccept"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Delta/Delta.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Delta/Delta.cs deleted file mode 100644 index 435d254739a..00000000000 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.CalendarGroups.Item.Calendars.Item.Events.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Delta/DeltaRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Delta/DeltaRequestBuilder.cs index 0d7d1d5c345..5395842f767 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -33,18 +34,17 @@ public Command BuildGetCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - command.SetHandler(async (string calendarGroupId, string calendarId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, outputOption); return command; } /// @@ -75,16 +75,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/EventsRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/EventsRequestBuilder.cs index f03798cb794..76eca79434a 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/EventsRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/EventsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,24 +23,23 @@ public class EventsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildAttachmentsCommand(), - builder.BuildCalendarCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildExtensionsCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildInstancesCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildAttachmentsCommand()); + commands.Add(builder.BuildCalendarCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInstancesCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -50,7 +49,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The events in the calendar. Navigation property. Read-only."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -62,21 +61,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, bodyOption, outputOption); return command; } /// @@ -86,7 +84,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The events in the calendar. Navigation property. Read-only."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarGroupId, string calendarId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -129,15 +131,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -180,7 +177,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -198,31 +195,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The events in the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/EventsResponse.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/EventsResponse.cs index 487808278f6..713ee1458ed 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/EventsResponse.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/EventsResponse.cs @@ -9,7 +9,7 @@ public class EventsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new eventsResponse and sets the default values. /// @@ -22,7 +22,7 @@ public EventsResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as EventsResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Accept/AcceptRequestBuilder.cs index 1b8cf935814..c9f5cc9ba61 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action accept"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Attachments/AttachmentsRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Attachments/AttachmentsRequestBuilder.cs index 368c1cb5919..0536c13f6f6 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Attachments/AttachmentsRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Attachments/AttachmentsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class AttachmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttachmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -37,7 +36,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } public Command BuildCreateUploadSessionCommand() { @@ -83,7 +81,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -126,7 +124,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(Attachment body, Action - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index f567d7181d5..d7df5b3c9f7 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action createUploadSession"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs index 96cb252dc04..04eaffaa6e9 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -42,11 +42,10 @@ public Command BuildDeleteCommand() { }; attachmentIdOption.IsRequired = true; command.AddOption(attachmentIdOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string attachmentId) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string attachmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, attachmentIdOption); return command; @@ -58,7 +57,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string attachmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string attachmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string attachmentId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string attachmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, attachmentIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(Attachment body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs index b54f6f4b706..63039528b58 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function allowedCalendarSharingRoles"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -41,18 +41,17 @@ public Command BuildGetCommand() { }; UserOption.IsRequired = true; command.AddOption(UserOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string User) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string User, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, UserOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, UserOption, outputOption); return command; } /// @@ -85,16 +84,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function allowedCalendarSharingRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Calendar/CalendarRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Calendar/CalendarRequestBuilder.cs index eef48f8fc9f..b4bf7689ede 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Calendar/CalendarRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Calendar/CalendarRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -36,7 +36,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The calendar that contains the event. Navigation property. Read-only."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -48,11 +48,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption); return command; @@ -64,7 +63,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The calendar that contains the event. Navigation property. Read-only."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -81,19 +80,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, selectOption, outputOption); return command; } public Command BuildGetScheduleCommand() { @@ -109,7 +107,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The calendar that contains the event. Navigation property. Read-only."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar that contains the event. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs index 3346ca4d1a7..28a74ed6473 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action getSchedule"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -41,21 +41,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -89,18 +88,5 @@ public RequestInformation CreatePostRequestInformation(GetScheduleRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSchedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetScheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Cancel/CancelRequestBuilder.cs index c81ac881481..14f27e5ebe0 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action cancel"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Decline/DeclineRequestBuilder.cs index f347a2faaac..cc26a36a2c7 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action decline"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs index b122cbb144f..fa11bb8769a 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action dismissReminder"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -37,11 +37,10 @@ public Command BuildPostCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/EventRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/EventRequestBuilder.cs index 41ab94dbe24..3206283c732 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/EventRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/EventRequestBuilder.cs @@ -14,10 +14,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,6 +41,9 @@ public Command BuildAcceptCommand() { public Command BuildAttachmentsCommand() { var command = new Command("attachments"); var builder = new ApiSdk.Me.CalendarGroups.Item.Calendars.Item.Events.Item.Attachments.AttachmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateUploadSessionCommand()); command.AddCommand(builder.BuildListCommand()); @@ -74,7 +77,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The events in the calendar. Navigation property. Read-only."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -86,11 +89,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption); return command; @@ -104,6 +106,9 @@ public Command BuildDismissReminderCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Me.CalendarGroups.Item.Calendars.Item.Events.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -121,7 +126,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The events in the calendar. Navigation property. Read-only."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -138,24 +143,26 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, selectOption, outputOption); return command; } public Command BuildInstancesCommand() { var command = new Command("instances"); var builder = new ApiSdk.Me.CalendarGroups.Item.Calendars.Item.Events.Item.Instances.InstancesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -163,6 +170,9 @@ public Command BuildInstancesCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Me.CalendarGroups.Item.Calendars.Item.Events.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -174,7 +184,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The events in the calendar. Navigation property. Read-only."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -190,14 +200,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -205,6 +214,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Me.CalendarGroups.Item.Calendars.Item.Events.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -276,7 +288,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -288,42 +300,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The events in the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Extensions/ExtensionsRequestBuilder.cs index 55f91590dac..357fc74a826 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of open extensions defined for the event. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of open extensions defined for the event. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -129,15 +131,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs index 11341e015ce..5f4c88a0fc8 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of open extensions defined for the event. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -42,11 +42,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string extensionId) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, extensionIdOption); return command; @@ -58,7 +57,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of open extensions defined for the event. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of open extensions defined for the event. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string extensionId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, extensionIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Forward/ForwardRequestBuilder.cs index 252022c383a..646cfc96bef 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action forward"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Delta/Delta.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Delta/Delta.cs deleted file mode 100644 index c91536acde8..00000000000 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.CalendarGroups.Item.Calendars.Item.Events.Item.Instances.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Delta/DeltaRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Delta/DeltaRequestBuilder.cs index 926d840b6d1..028ee57ca9b 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -37,18 +38,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, outputOption); return command; } /// @@ -79,16 +79,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/InstancesRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/InstancesRequestBuilder.cs index 978e399c6b3..4b90ac4d675 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/InstancesRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/InstancesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class InstancesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -44,7 +43,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -60,21 +59,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -122,7 +120,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -182,7 +179,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -200,31 +197,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/InstancesResponse.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/InstancesResponse.cs index d2c8263de14..cd3c681fcfc 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/InstancesResponse.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/InstancesResponse.cs @@ -9,7 +9,7 @@ public class InstancesResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new instancesResponse and sets the default values. /// @@ -22,7 +22,7 @@ public InstancesResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as InstancesResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs index 4e5a72f2698..0e78cee90f4 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action accept"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs index b9452ffdab8..733cfe791f3 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action cancel"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs index 32fa0ff72aa..b14a8e45598 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action decline"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs index 9717b71c8ea..bac541306e7 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action dismissReminder"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -41,11 +41,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option); return command; @@ -78,16 +77,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/EventRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/EventRequestBuilder.cs index bcd83e97a12..518dc82b780 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/EventRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -51,7 +51,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -67,11 +67,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option); return command; @@ -95,7 +94,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -116,19 +115,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -138,7 +136,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -158,14 +156,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -237,7 +234,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -249,42 +246,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs index a7b9da5b797..33443738eb7 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action forward"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index d63d56574f7..86414abe3d7 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action snoozeReminder"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index 2caafd5b82e..b96373121d3 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action tentativelyAccept"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 5804394575b..78c171548e9 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of multi-value extended properties defined for the event. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -58,7 +57,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of multi-value extended properties defined for the event. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -70,7 +69,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of multi-value extended properties defined for the event. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -119,7 +117,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 97e8204070f..759c017ca3c 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of multi-value extended properties defined for the event. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of multi-value extended properties defined for the event. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 181c23e4d06..3406cc4f3e2 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of single-value extended properties defined for the event. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -58,7 +57,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of single-value extended properties defined for the event. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -70,7 +69,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of single-value extended properties defined for the event. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -119,7 +117,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 008d28f450c..f70a38af51b 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of single-value extended properties defined for the event. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of single-value extended properties defined for the event. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 4b78b0d330d..290ef00a6fe 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action snoozeReminder"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index c994340ff16..48e543efc6a 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action tentativelyAccept"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/GetSchedule/GetScheduleRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/GetSchedule/GetScheduleRequestBuilder.cs index 7e21ca0c07c..fa9f19183be 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/GetSchedule/GetScheduleRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/GetSchedule/GetScheduleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action getSchedule"; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -37,21 +37,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, bodyOption, outputOption); return command; } /// @@ -85,18 +84,5 @@ public RequestInformation CreatePostRequestInformation(GetScheduleRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSchedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetScheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 51096397760..f2fbf031d35 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of multi-value extended properties defined for the calendar. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of multi-value extended properties defined for the calendar. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,7 +97,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of multi-value extended properties defined for the calendar. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 7dc63e6e406..8bd047fd2dd 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of multi-value extended properties defined for the calendar. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, bodyOption, outputOption); return command; } /// @@ -72,7 +70,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of multi-value extended properties defined for the calendar. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarGroupId, string calendarId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 381bc650f11..7bd37ade741 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of single-value extended properties defined for the calendar. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of single-value extended properties defined for the calendar. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,7 +97,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of single-value extended properties defined for the calendar. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string calendarGroupId, string calendarId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarGroupIdOption, calendarIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/CalendarGroups/Item/Calendars/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/CalendarGroups/Item/Calendars/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 574cdac6197..10cf8795bd6 100644 --- a/src/generated/Me/CalendarGroups/Item/Calendars/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/CalendarGroups/Item/Calendars/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of single-value extended properties defined for the calendar. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarGroupId, string calendarId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, bodyOption, outputOption); return command; } /// @@ -72,7 +70,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of single-value extended properties defined for the calendar. Read-only. Nullable."; // Create options for all the parameters - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarGroupId, string calendarId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarGroupId, string calendarId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarGroupIdOption, calendarIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarGroupIdOption, calendarIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarView/CalendarViewRequestBuilder.cs b/src/generated/Me/CalendarView/CalendarViewRequestBuilder.cs index f891681732a..555e750e4fd 100644 --- a/src/generated/Me/CalendarView/CalendarViewRequestBuilder.cs +++ b/src/generated/Me/CalendarView/CalendarViewRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,24 +23,23 @@ public class CalendarViewRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildAttachmentsCommand(), - builder.BuildCalendarCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildExtensionsCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildInstancesCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildAttachmentsCommand()); + commands.Add(builder.BuildCalendarCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInstancesCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -78,11 +76,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The calendar view for the calendar. Read-only. Nullable."; // Create options for all the parameters - var startDateTimeOption = new Option("--startdatetime", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { + var startDateTimeOption = new Option("--start-date-time", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { }; startDateTimeOption.IsRequired = true; command.AddOption(startDateTimeOption); - var endDateTimeOption = new Option("--enddatetime", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { + var endDateTimeOption = new Option("--end-date-time", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { }; endDateTimeOption.IsRequired = true; command.AddOption(endDateTimeOption); @@ -112,7 +110,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string startDateTime, string endDateTime, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string startDateTime, string endDateTime, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { if (!String.IsNullOrEmpty(startDateTime)) q.StartDateTime = startDateTime; if (!String.IsNullOrEmpty(endDateTime)) q.EndDateTime = endDateTime; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, startDateTimeOption, endDateTimeOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, startDateTimeOption, endDateTimeOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -174,7 +171,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The calendar view for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarView/CalendarViewResponse.cs b/src/generated/Me/CalendarView/CalendarViewResponse.cs index 4183df03bc7..96b12b878a1 100644 --- a/src/generated/Me/CalendarView/CalendarViewResponse.cs +++ b/src/generated/Me/CalendarView/CalendarViewResponse.cs @@ -9,7 +9,7 @@ public class CalendarViewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new calendarViewResponse and sets the default values. /// @@ -22,7 +22,7 @@ public CalendarViewResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as CalendarViewResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Me/CalendarView/Delta/Delta.cs b/src/generated/Me/CalendarView/Delta/Delta.cs deleted file mode 100644 index 6606e6adce7..00000000000 --- a/src/generated/Me/CalendarView/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.CalendarView.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Me/CalendarView/Delta/DeltaRequestBuilder.cs b/src/generated/Me/CalendarView/Delta/DeltaRequestBuilder.cs index 03dcf82da90..71594606dc5 100644 --- a/src/generated/Me/CalendarView/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +26,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +67,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Accept/AcceptRequestBuilder.cs index 5fa6d0c53fa..f1c24f15e22 100644 --- a/src/generated/Me/CalendarView/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs index a1335d5c230..33182f54f9e 100644 --- a/src/generated/Me/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class AttachmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttachmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } public Command BuildCreateUploadSessionCommand() { @@ -110,7 +108,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -120,15 +122,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -183,31 +180,6 @@ public RequestInformation CreatePostRequestInformation(Attachment body, Action - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index 67338576851..b6518962aea 100644 --- a/src/generated/Me/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs index 4ed1302c1cd..65774e2c0b6 100644 --- a/src/generated/Me/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; attachmentIdOption.IsRequired = true; command.AddOption(attachmentIdOption); - command.SetHandler(async (string eventId, string attachmentId) => { + command.SetHandler(async (string eventId, string attachmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, attachmentIdOption); return command; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, string attachmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string attachmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, attachmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, attachmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string attachmentId, string body) => { + command.SetHandler(async (string eventId, string attachmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, attachmentIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(Attachment body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs index 2ca01174af4..484372b7d20 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +33,17 @@ public Command BuildGetCommand() { }; UserOption.IsRequired = true; command.AddOption(UserOption); - command.SetHandler(async (string eventId, string User) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string User, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, UserOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, UserOption, outputOption); return command; } /// @@ -77,16 +76,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function allowedCalendarSharingRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs index 18c765a722d..940dd54a535 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class CalendarPermissionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new CalendarPermissionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -98,7 +96,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -107,15 +109,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -170,31 +167,6 @@ public RequestInformation CreatePostRequestInformation(CalendarPermission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CalendarPermission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions of the users with whom the calendar is shared. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarView/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs index 1c0c15fd200..b32b4625e07 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); - command.SetHandler(async (string eventId, string calendarPermissionId) => { + command.SetHandler(async (string eventId, string calendarPermissionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, calendarPermissionIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); @@ -63,19 +62,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, string calendarPermissionId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string calendarPermissionId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, calendarPermissionIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, calendarPermissionIdOption, selectOption, outputOption); return command; } /// @@ -89,7 +87,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); @@ -97,14 +95,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string calendarPermissionId, string body) => { + command.SetHandler(async (string eventId, string calendarPermissionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, calendarPermissionIdOption, bodyOption); return command; @@ -176,42 +173,6 @@ public RequestInformation CreatePatchRequestInformation(CalendarPermission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(CalendarPermission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions of the users with whom the calendar is shared. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/CalendarView/Item/Calendar/CalendarRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/CalendarRequestBuilder.cs index 94de72c807b..53ac048cf4b 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/CalendarRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/CalendarRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,6 +37,9 @@ public AllowedCalendarSharingRolesWithUserRequestBuilder AllowedCalendarSharingR public Command BuildCalendarPermissionsCommand() { var command = new Command("calendar-permissions"); var builder = new ApiSdk.Me.CalendarView.Item.Calendar.CalendarPermissions.CalendarPermissionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -44,6 +47,9 @@ public Command BuildCalendarPermissionsCommand() { public Command BuildCalendarViewCommand() { var command = new Command("calendar-view"); var builder = new ApiSdk.Me.CalendarView.Item.Calendar.CalendarView.CalendarViewRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -59,11 +65,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string eventId) => { + command.SetHandler(async (string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption); return command; @@ -71,6 +76,9 @@ public Command BuildDeleteCommand() { public Command BuildEventsCommand() { var command = new Command("events"); var builder = new ApiSdk.Me.CalendarView.Item.Calendar.Events.EventsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -91,19 +99,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, selectOption, outputOption); return command; } public Command BuildGetScheduleCommand() { @@ -115,6 +122,9 @@ public Command BuildGetScheduleCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Me.CalendarView.Item.Calendar.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -149,6 +158,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Me.CalendarView.Item.Calendar.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -220,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar that contains the event. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/CalendarView/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs index df4a39bc128..c5ae4023f3d 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class CalendarViewRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -106,7 +104,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -115,15 +117,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -166,7 +163,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarView/Item/Calendar/CalendarView/CalendarViewResponse.cs b/src/generated/Me/CalendarView/Item/Calendar/CalendarView/CalendarViewResponse.cs index 703ce4dc172..9f0551c982a 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/CalendarView/CalendarViewResponse.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/CalendarView/CalendarViewResponse.cs @@ -9,7 +9,7 @@ public class CalendarViewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new calendarViewResponse and sets the default values. /// @@ -22,7 +22,7 @@ public CalendarViewResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as CalendarViewResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Delta/Delta.cs b/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Delta/Delta.cs deleted file mode 100644 index b633428dcf5..00000000000 --- a/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.CalendarView.Item.Calendar.CalendarView.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs index 7774e0de9d5..62f5e40a2bc 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +30,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs index c17d18ae345..3a1f2746c9c 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs index e7bf1e4d4d7..4eee109b2c3 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs index d9704d450e0..29901c261c1 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs index 9900e095efb..5bb0e58e00c 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,11 +33,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string eventId, string eventId1) => { + command.SetHandler(async (string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs index baa5d18ea05..29bb3853f99 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -59,11 +59,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string eventId, string eventId1) => { + command.SetHandler(async (string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option); return command; @@ -100,19 +99,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -213,7 +210,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -225,42 +222,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs index 26baaf6d49a..00159f9c1f7 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index efc97b125d2..8735889a5f2 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index 714eac70df2..b0a0e75d304 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Calendar/Events/Delta/Delta.cs b/src/generated/Me/CalendarView/Item/Calendar/Events/Delta/Delta.cs deleted file mode 100644 index aa9039efd95..00000000000 --- a/src/generated/Me/CalendarView/Item/Calendar/Events/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.CalendarView.Item.Calendar.Events.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Me/CalendarView/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs index 311cc75e96f..78262066210 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +30,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Calendar/Events/EventsRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/Events/EventsRequestBuilder.cs index aa4f26d723f..22ab2a28373 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/Events/EventsRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/Events/EventsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class EventsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -106,7 +104,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -115,15 +117,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -166,7 +163,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The events in the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarView/Item/Calendar/Events/EventsResponse.cs b/src/generated/Me/CalendarView/Item/Calendar/Events/EventsResponse.cs index d20ed6e2382..4e49819c380 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/Events/EventsResponse.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/Events/EventsResponse.cs @@ -9,7 +9,7 @@ public class EventsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new eventsResponse and sets the default values. /// @@ -22,7 +22,7 @@ public EventsResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as EventsResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Me/CalendarView/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs index 24725d4a201..38584ce4cc7 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs index 9212474c48e..2266d0bf455 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs index 55fc35c2629..618abe4904f 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs index df75f9fc1fc..bee67470381 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,11 +33,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string eventId, string eventId1) => { + command.SetHandler(async (string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Calendar/Events/Item/EventRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/Events/Item/EventRequestBuilder.cs index 9a8b0af910d..993ba451153 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/Events/Item/EventRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/Events/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -59,11 +59,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string eventId, string eventId1) => { + command.SetHandler(async (string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option); return command; @@ -100,19 +99,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -213,7 +210,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -225,42 +222,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The events in the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/CalendarView/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs index 4d82389fbc7..07e5104d86c 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index e662563f824..ad38d6d946f 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index 901154190cb..1cd92d3a2b1 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs index 749f9d90eec..93c7bbdde7c 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetScheduleRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSchedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetScheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index ffb7bdc9114..aecc8eb5a3d 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/CalendarView/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index a5163488994..50c06a5ea71 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarView/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 9ba79ac55ff..8bf854553ad 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/CalendarView/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index aa8be55d2b1..a05c6cf6390 100644 --- a/src/generated/Me/CalendarView/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarView/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Cancel/CancelRequestBuilder.cs index dceae936356..46daf764734 100644 --- a/src/generated/Me/CalendarView/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Decline/DeclineRequestBuilder.cs index 44817b1c4d1..4985d7dae6c 100644 --- a/src/generated/Me/CalendarView/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Me/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs index 548218d135b..ad18b39592f 100644 --- a/src/generated/Me/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,10 @@ public Command BuildPostCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string eventId) => { + command.SetHandler(async (string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/EventRequestBuilder.cs b/src/generated/Me/CalendarView/Item/EventRequestBuilder.cs index 797a99d35fb..e88beb6f8a4 100644 --- a/src/generated/Me/CalendarView/Item/EventRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/EventRequestBuilder.cs @@ -14,10 +14,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,6 +41,9 @@ public Command BuildAcceptCommand() { public Command BuildAttachmentsCommand() { var command = new Command("attachments"); var builder = new ApiSdk.Me.CalendarView.Item.Attachments.AttachmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateUploadSessionCommand()); command.AddCommand(builder.BuildListCommand()); @@ -83,11 +86,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string eventId) => { + command.SetHandler(async (string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption); return command; @@ -101,6 +103,9 @@ public Command BuildDismissReminderCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Me.CalendarView.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -122,11 +127,11 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var startDateTimeOption = new Option("--startdatetime", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { + var startDateTimeOption = new Option("--start-date-time", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { }; startDateTimeOption.IsRequired = true; command.AddOption(startDateTimeOption); - var endDateTimeOption = new Option("--enddatetime", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { + var endDateTimeOption = new Option("--end-date-time", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { }; endDateTimeOption.IsRequired = true; command.AddOption(endDateTimeOption); @@ -135,26 +140,28 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, string startDateTime, string endDateTime, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string startDateTime, string endDateTime, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { if (!String.IsNullOrEmpty(startDateTime)) q.StartDateTime = startDateTime; if (!String.IsNullOrEmpty(endDateTime)) q.EndDateTime = endDateTime; q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, startDateTimeOption, endDateTimeOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, startDateTimeOption, endDateTimeOption, selectOption, outputOption); return command; } public Command BuildInstancesCommand() { var command = new Command("instances"); var builder = new ApiSdk.Me.CalendarView.Item.Instances.InstancesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -162,6 +169,9 @@ public Command BuildInstancesCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Me.CalendarView.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -181,14 +191,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -196,6 +205,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Me.CalendarView.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -267,7 +279,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -279,42 +291,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The calendar view for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00 diff --git a/src/generated/Me/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs index 0981bb6c87d..b2dbebb52da 100644 --- a/src/generated/Me/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -103,7 +101,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -113,15 +115,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -176,31 +173,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs index f87af8459e8..a96a3a93b3b 100644 --- a/src/generated/Me/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string eventId, string extensionId) => { + command.SetHandler(async (string eventId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, extensionIdOption); return command; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string extensionId, string body) => { + command.SetHandler(async (string eventId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, extensionIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/CalendarView/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Forward/ForwardRequestBuilder.cs index 961faeea806..dc899a6547e 100644 --- a/src/generated/Me/CalendarView/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Instances/Delta/Delta.cs b/src/generated/Me/CalendarView/Item/Instances/Delta/Delta.cs deleted file mode 100644 index c5ea1a645bb..00000000000 --- a/src/generated/Me/CalendarView/Item/Instances/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.CalendarView.Item.Instances.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Me/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs index 527f679c257..fc193678fc4 100644 --- a/src/generated/Me/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +30,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Instances/InstancesRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Instances/InstancesRequestBuilder.cs index 2c9c4fa7180..62f16e7a46d 100644 --- a/src/generated/Me/CalendarView/Item/Instances/InstancesRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Instances/InstancesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class InstancesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -106,7 +104,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -115,15 +117,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -166,7 +163,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarView/Item/Instances/InstancesResponse.cs b/src/generated/Me/CalendarView/Item/Instances/InstancesResponse.cs index bc62a55f511..9d8febb980b 100644 --- a/src/generated/Me/CalendarView/Item/Instances/InstancesResponse.cs +++ b/src/generated/Me/CalendarView/Item/Instances/InstancesResponse.cs @@ -9,7 +9,7 @@ public class InstancesResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new instancesResponse and sets the default values. /// @@ -22,7 +22,7 @@ public InstancesResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as InstancesResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Me/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs index 1266dd9b186..7e078f0d7f4 100644 --- a/src/generated/Me/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs index d1a59c4d1f5..a98b9faa119 100644 --- a/src/generated/Me/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs index 1d2ad7ee4e0..a6523efd15c 100644 --- a/src/generated/Me/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs index a786ef948bc..dfc5796c952 100644 --- a/src/generated/Me/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,11 +33,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string eventId, string eventId1) => { + command.SetHandler(async (string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Instances/Item/EventRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Instances/Item/EventRequestBuilder.cs index 213457aced8..4a866087209 100644 --- a/src/generated/Me/CalendarView/Item/Instances/Item/EventRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Instances/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -59,11 +59,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string eventId, string eventId1) => { + command.SetHandler(async (string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option); return command; @@ -100,19 +99,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -213,7 +210,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -225,42 +222,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs index 2db798d4e7b..8e77d70a87b 100644 --- a/src/generated/Me/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 7980071a638..cc70adeace4 100644 --- a/src/generated/Me/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Me/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index 04d45545b94..a72ae20fa0e 100644 --- a/src/generated/Me/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 12b76d2150e..adce41c299a 100644 --- a/src/generated/Me/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index d464121490c..f5b809d0e1f 100644 --- a/src/generated/Me/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 16107c117a2..e23d752bfa2 100644 --- a/src/generated/Me/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 788c7c381c8..6ef53d06673 100644 --- a/src/generated/Me/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Me/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 4faad6d48c1..91723606239 100644 --- a/src/generated/Me/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Me/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index b399480ceed..bea5f7cda2a 100644 --- a/src/generated/Me/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Me/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/CalendarsRequestBuilder.cs b/src/generated/Me/Calendars/CalendarsRequestBuilder.cs index dcb18ffb8a0..2f45887da1f 100644 --- a/src/generated/Me/Calendars/CalendarsRequestBuilder.cs +++ b/src/generated/Me/Calendars/CalendarsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,17 +22,16 @@ public class CalendarsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new CalendarRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCalendarPermissionsCommand(), - builder.BuildCalendarViewCommand(), - builder.BuildDeleteCommand(), - builder.BuildEventsCommand(), - builder.BuildGetCommand(), - builder.BuildGetScheduleCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCalendarPermissionsCommand()); + commands.Add(builder.BuildCalendarViewCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildEventsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildGetScheduleCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); return commands; } /// @@ -46,21 +45,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -96,7 +94,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -105,15 +107,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -168,31 +165,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user's calendars. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's calendars. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's calendars. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendars/Item/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs b/src/generated/Me/Calendars/Item/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs index aa248bbcfd0..4280b489556 100644 --- a/src/generated/Me/Calendars/Item/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +33,17 @@ public Command BuildGetCommand() { }; UserOption.IsRequired = true; command.AddOption(UserOption); - command.SetHandler(async (string calendarId, string User) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string User, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, UserOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, UserOption, outputOption); return command; } /// @@ -77,16 +76,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function allowedCalendarSharingRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/CalendarPermissions/CalendarPermissionsRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarPermissions/CalendarPermissionsRequestBuilder.cs index 9a55f1db203..e61f0e0647d 100644 --- a/src/generated/Me/Calendars/Item/CalendarPermissions/CalendarPermissionsRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarPermissions/CalendarPermissionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class CalendarPermissionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new CalendarPermissionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, bodyOption, outputOption); return command; } /// @@ -98,7 +96,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -107,15 +109,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -170,31 +167,6 @@ public RequestInformation CreatePostRequestInformation(CalendarPermission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CalendarPermission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions of the users with whom the calendar is shared. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendars/Item/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs index d961e852107..e9b87a12c3b 100644 --- a/src/generated/Me/Calendars/Item/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); - command.SetHandler(async (string calendarId, string calendarPermissionId) => { + command.SetHandler(async (string calendarId, string calendarPermissionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, calendarPermissionIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); @@ -63,19 +62,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarId, string calendarPermissionId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string calendarPermissionId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, calendarPermissionIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, calendarPermissionIdOption, selectOption, outputOption); return command; } /// @@ -89,7 +87,7 @@ public Command BuildPatchCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); @@ -97,14 +95,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string calendarPermissionId, string body) => { + command.SetHandler(async (string calendarId, string calendarPermissionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, calendarPermissionIdOption, bodyOption); return command; @@ -176,42 +173,6 @@ public RequestInformation CreatePatchRequestInformation(CalendarPermission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(CalendarPermission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions of the users with whom the calendar is shared. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/Calendars/Item/CalendarRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarRequestBuilder.cs index 0a3dea67cd6..b0429db8013 100644 --- a/src/generated/Me/Calendars/Item/CalendarRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,6 +37,9 @@ public AllowedCalendarSharingRolesWithUserRequestBuilder AllowedCalendarSharingR public Command BuildCalendarPermissionsCommand() { var command = new Command("calendar-permissions"); var builder = new ApiSdk.Me.Calendars.Item.CalendarPermissions.CalendarPermissionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -44,6 +47,9 @@ public Command BuildCalendarPermissionsCommand() { public Command BuildCalendarViewCommand() { var command = new Command("calendar-view"); var builder = new ApiSdk.Me.Calendars.Item.CalendarView.CalendarViewRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -59,11 +65,10 @@ public Command BuildDeleteCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - command.SetHandler(async (string calendarId) => { + command.SetHandler(async (string calendarId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption); return command; @@ -71,6 +76,9 @@ public Command BuildDeleteCommand() { public Command BuildEventsCommand() { var command = new Command("events"); var builder = new ApiSdk.Me.Calendars.Item.Events.EventsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -91,19 +99,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, selectOption, outputOption); return command; } public Command BuildGetScheduleCommand() { @@ -115,6 +122,9 @@ public Command BuildGetScheduleCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Me.Calendars.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string body) => { + command.SetHandler(async (string calendarId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, bodyOption); return command; @@ -149,6 +158,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Me.Calendars.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -220,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user's calendars. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's calendars. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's calendars. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's calendars. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/Calendars/Item/CalendarView/CalendarViewRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/CalendarViewRequestBuilder.cs index 57c61d25f59..feb5b2a3cc9 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/CalendarViewRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/CalendarViewRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,24 +23,23 @@ public class CalendarViewRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildAttachmentsCommand(), - builder.BuildCalendarCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildExtensionsCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildInstancesCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildAttachmentsCommand()); + commands.Add(builder.BuildCalendarCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInstancesCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -58,21 +57,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, bodyOption, outputOption); return command; } /// @@ -86,11 +84,11 @@ public Command BuildListCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var startDateTimeOption = new Option("--startdatetime", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { + var startDateTimeOption = new Option("--start-date-time", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { }; startDateTimeOption.IsRequired = true; command.AddOption(startDateTimeOption); - var endDateTimeOption = new Option("--enddatetime", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { + var endDateTimeOption = new Option("--end-date-time", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { }; endDateTimeOption.IsRequired = true; command.AddOption(endDateTimeOption); @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarId, string startDateTime, string endDateTime, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string startDateTime, string endDateTime, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { if (!String.IsNullOrEmpty(startDateTime)) q.StartDateTime = startDateTime; if (!String.IsNullOrEmpty(endDateTime)) q.EndDateTime = endDateTime; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, startDateTimeOption, endDateTimeOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, startDateTimeOption, endDateTimeOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -182,7 +179,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -200,31 +197,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendars/Item/CalendarView/CalendarViewResponse.cs b/src/generated/Me/Calendars/Item/CalendarView/CalendarViewResponse.cs index ae49b046805..7eae7a7bba2 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/CalendarViewResponse.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/CalendarViewResponse.cs @@ -9,7 +9,7 @@ public class CalendarViewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new calendarViewResponse and sets the default values. /// @@ -22,7 +22,7 @@ public CalendarViewResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as CalendarViewResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Me/Calendars/Item/CalendarView/Delta/Delta.cs b/src/generated/Me/Calendars/Item/CalendarView/Delta/Delta.cs deleted file mode 100644 index 36f05674aab..00000000000 --- a/src/generated/Me/Calendars/Item/CalendarView/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.Calendars.Item.CalendarView.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Me/Calendars/Item/CalendarView/Delta/DeltaRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Delta/DeltaRequestBuilder.cs index d93b2beb5f2..ab06a7c76f9 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +30,17 @@ public Command BuildGetCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - command.SetHandler(async (string calendarId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/Accept/AcceptRequestBuilder.cs index ca9272d3368..14be9540396 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs index ef0c5e820ba..1ad9ffdf9cc 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class AttachmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttachmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } public Command BuildCreateUploadSessionCommand() { @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(Attachment body, Action - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index 8ccb482d400..df557055d6d 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs index 75be30b7fbc..f05a7a1660b 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; attachmentIdOption.IsRequired = true; command.AddOption(attachmentIdOption); - command.SetHandler(async (string calendarId, string eventId, string attachmentId) => { + command.SetHandler(async (string calendarId, string eventId, string attachmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, attachmentIdOption); return command; @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarId, string eventId, string attachmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string attachmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string attachmentId, string body) => { + command.SetHandler(async (string calendarId, string eventId, string attachmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, attachmentIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Attachment body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs index aeec7b51baa..4b48b6f93a0 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,18 +37,17 @@ public Command BuildGetCommand() { }; UserOption.IsRequired = true; command.AddOption(UserOption); - command.SetHandler(async (string calendarId, string eventId, string User) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string User, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, UserOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, UserOption, outputOption); return command; } /// @@ -81,16 +80,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function allowedCalendarSharingRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/Calendar/CalendarRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/Calendar/CalendarRequestBuilder.cs index eaf8260eb2c..3c9844c24e5 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/Calendar/CalendarRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/Calendar/CalendarRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,11 +44,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string calendarId, string eventId) => { + command.SetHandler(async (string calendarId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption); return command; @@ -73,19 +72,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarId, string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, selectOption, outputOption); return command; } public Command BuildGetScheduleCommand() { @@ -113,14 +111,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, bodyOption); return command; @@ -192,42 +189,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar that contains the event. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs index bfcf1d54ceb..8e3ca70894a 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,21 +37,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -85,18 +84,5 @@ public RequestInformation CreatePostRequestInformation(GetScheduleRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSchedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetScheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs index d4fc530d5ed..3d3553c49ce 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/Decline/DeclineRequestBuilder.cs index 8fe0989bac1..9beb22c84ea 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs index d528348e842..4e5a6f7c9e3 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,11 +33,10 @@ public Command BuildPostCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string calendarId, string eventId) => { + command.SetHandler(async (string calendarId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/EventRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/EventRequestBuilder.cs index 7e495a43e67..970720576e6 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/EventRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/EventRequestBuilder.cs @@ -14,10 +14,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,6 +41,9 @@ public Command BuildAcceptCommand() { public Command BuildAttachmentsCommand() { var command = new Command("attachments"); var builder = new ApiSdk.Me.Calendars.Item.CalendarView.Item.Attachments.AttachmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateUploadSessionCommand()); command.AddCommand(builder.BuildListCommand()); @@ -82,11 +85,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string calendarId, string eventId) => { + command.SetHandler(async (string calendarId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption); return command; @@ -100,6 +102,9 @@ public Command BuildDismissReminderCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Me.Calendars.Item.CalendarView.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -125,11 +130,11 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var startDateTimeOption = new Option("--startdatetime", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { + var startDateTimeOption = new Option("--start-date-time", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { }; startDateTimeOption.IsRequired = true; command.AddOption(startDateTimeOption); - var endDateTimeOption = new Option("--enddatetime", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { + var endDateTimeOption = new Option("--end-date-time", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { }; endDateTimeOption.IsRequired = true; command.AddOption(endDateTimeOption); @@ -138,26 +143,28 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarId, string eventId, string startDateTime, string endDateTime, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string startDateTime, string endDateTime, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { if (!String.IsNullOrEmpty(startDateTime)) q.StartDateTime = startDateTime; if (!String.IsNullOrEmpty(endDateTime)) q.EndDateTime = endDateTime; q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, startDateTimeOption, endDateTimeOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, startDateTimeOption, endDateTimeOption, selectOption, outputOption); return command; } public Command BuildInstancesCommand() { var command = new Command("instances"); var builder = new ApiSdk.Me.Calendars.Item.CalendarView.Item.Instances.InstancesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -165,6 +172,9 @@ public Command BuildInstancesCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Me.Calendars.Item.CalendarView.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -188,14 +198,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, bodyOption); return command; @@ -203,6 +212,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Me.Calendars.Item.CalendarView.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -274,7 +286,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -286,42 +298,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00 diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs index 7e9d7fff936..627a6dce4ed 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs index d4c331ea17b..f28d090b81b 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string calendarId, string eventId, string extensionId) => { + command.SetHandler(async (string calendarId, string eventId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, extensionIdOption); return command; @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarId, string eventId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string extensionId, string body) => { + command.SetHandler(async (string calendarId, string eventId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, extensionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/Forward/ForwardRequestBuilder.cs index aa94ae08bc8..a58c9608733 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Delta/Delta.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Delta/Delta.cs deleted file mode 100644 index 41430a8d6d8..00000000000 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.Calendars.Item.CalendarView.Item.Instances.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs index 23726d23475..03b56d1df7c 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +34,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string calendarId, string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, outputOption); return command; } /// @@ -75,16 +75,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/InstancesRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/InstancesRequestBuilder.cs index 43518e2b268..764a6131d3b 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/InstancesRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/InstancesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class InstancesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -114,7 +112,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -174,7 +171,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/InstancesResponse.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/InstancesResponse.cs index f321cef0fc2..f22023b801c 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/InstancesResponse.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/InstancesResponse.cs @@ -9,7 +9,7 @@ public class InstancesResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new instancesResponse and sets the default values. /// @@ -22,7 +22,7 @@ public InstancesResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as InstancesResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs index 1ad39a8189e..c9a178e833e 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs index 6916c8815f3..694703380a7 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs index bd3f06d532b..08675a1eb68 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs index 37b128aac02..47f20373fd9 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,11 +37,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string calendarId, string eventId, string eventId1) => { + command.SetHandler(async (string calendarId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, eventId1Option); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/EventRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/EventRequestBuilder.cs index 8ae55d9b18e..147bab6adc9 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/EventRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -63,11 +63,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string calendarId, string eventId, string eventId1) => { + command.SetHandler(async (string calendarId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, eventId1Option); return command; @@ -108,19 +107,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarId, string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -146,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -225,7 +222,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -237,42 +234,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs index 0294b385f69..6ac1db7cf04 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 62c5f751d64..e6d0cb094aa 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index e82281a270f..15947ccb49d 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 2dbca6d4512..3fb40fe163b 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string calendarId, string eventId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index c64f56b203e..33570788465 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index b2379c6beef..ed83130e2d2 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string calendarId, string eventId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 4284ed41cd8..63966e64f36 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index d811ccc38f9..1ac60bf2f89 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Me/Calendars/Item/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index f6f8841def3..919ae2ea4d1 100644 --- a/src/generated/Me/Calendars/Item/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/Events/Delta/Delta.cs b/src/generated/Me/Calendars/Item/Events/Delta/Delta.cs deleted file mode 100644 index 2371a849db8..00000000000 --- a/src/generated/Me/Calendars/Item/Events/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.Calendars.Item.Events.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Me/Calendars/Item/Events/Delta/DeltaRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Delta/DeltaRequestBuilder.cs index 0002ab6889f..755335cd415 100644 --- a/src/generated/Me/Calendars/Item/Events/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +30,17 @@ public Command BuildGetCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - command.SetHandler(async (string calendarId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/Events/EventsRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/EventsRequestBuilder.cs index 1f6dee98c5d..b8b571cf4ed 100644 --- a/src/generated/Me/Calendars/Item/Events/EventsRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/EventsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,24 +23,23 @@ public class EventsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildAttachmentsCommand(), - builder.BuildCalendarCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildExtensionsCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildInstancesCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildAttachmentsCommand()); + commands.Add(builder.BuildCalendarCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInstancesCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -58,21 +57,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, bodyOption, outputOption); return command; } /// @@ -112,7 +110,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -172,7 +169,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -190,31 +187,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The events in the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendars/Item/Events/EventsResponse.cs b/src/generated/Me/Calendars/Item/Events/EventsResponse.cs index 6a6c4b562da..14181ff2406 100644 --- a/src/generated/Me/Calendars/Item/Events/EventsResponse.cs +++ b/src/generated/Me/Calendars/Item/Events/EventsResponse.cs @@ -9,7 +9,7 @@ public class EventsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new eventsResponse and sets the default values. /// @@ -22,7 +22,7 @@ public EventsResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as EventsResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Me/Calendars/Item/Events/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/Accept/AcceptRequestBuilder.cs index 5ad42829f06..b695c264954 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/Events/Item/Attachments/AttachmentsRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/Attachments/AttachmentsRequestBuilder.cs index 0605f32d32c..10ac22147bd 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/Attachments/AttachmentsRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/Attachments/AttachmentsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class AttachmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttachmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } public Command BuildCreateUploadSessionCommand() { @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(Attachment body, Action - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendars/Item/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index 57d3e4a2733..5e398a160b2 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Calendars/Item/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs index 55a56f03590..55dcfd918c7 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; attachmentIdOption.IsRequired = true; command.AddOption(attachmentIdOption); - command.SetHandler(async (string calendarId, string eventId, string attachmentId) => { + command.SetHandler(async (string calendarId, string eventId, string attachmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, attachmentIdOption); return command; @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarId, string eventId, string attachmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string attachmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string attachmentId, string body) => { + command.SetHandler(async (string calendarId, string eventId, string attachmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, attachmentIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Attachment body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Calendars/Item/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs index e676cd1f41b..81f171fab4e 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,18 +37,17 @@ public Command BuildGetCommand() { }; UserOption.IsRequired = true; command.AddOption(UserOption); - command.SetHandler(async (string calendarId, string eventId, string User) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string User, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, UserOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, UserOption, outputOption); return command; } /// @@ -81,16 +80,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function allowedCalendarSharingRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/Events/Item/Calendar/CalendarRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/Calendar/CalendarRequestBuilder.cs index 7bdbda8ab78..0f1fced1d4e 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/Calendar/CalendarRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/Calendar/CalendarRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,11 +44,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string calendarId, string eventId) => { + command.SetHandler(async (string calendarId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption); return command; @@ -73,19 +72,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarId, string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, selectOption, outputOption); return command; } public Command BuildGetScheduleCommand() { @@ -113,14 +111,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, bodyOption); return command; @@ -192,42 +189,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar that contains the event. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/Calendars/Item/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs index 0fa1c8fe965..2c0aaeb2c1b 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,21 +37,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -85,18 +84,5 @@ public RequestInformation CreatePostRequestInformation(GetScheduleRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSchedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetScheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/Events/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/Cancel/CancelRequestBuilder.cs index 82b9e4810f2..5bfbb477fdf 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/Events/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/Decline/DeclineRequestBuilder.cs index 5e8b314adf6..814ed5f10de 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs index 7a174378547..71a7f1dddbd 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,11 +33,10 @@ public Command BuildPostCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string calendarId, string eventId) => { + command.SetHandler(async (string calendarId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/Events/Item/EventRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/EventRequestBuilder.cs index ce8ba6678f0..062dee1ac75 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/EventRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/EventRequestBuilder.cs @@ -14,10 +14,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,6 +41,9 @@ public Command BuildAcceptCommand() { public Command BuildAttachmentsCommand() { var command = new Command("attachments"); var builder = new ApiSdk.Me.Calendars.Item.Events.Item.Attachments.AttachmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateUploadSessionCommand()); command.AddCommand(builder.BuildListCommand()); @@ -82,11 +85,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string calendarId, string eventId) => { + command.SetHandler(async (string calendarId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption); return command; @@ -100,6 +102,9 @@ public Command BuildDismissReminderCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Me.Calendars.Item.Events.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -130,24 +135,26 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarId, string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, selectOption, outputOption); return command; } public Command BuildInstancesCommand() { var command = new Command("instances"); var builder = new ApiSdk.Me.Calendars.Item.Events.Item.Instances.InstancesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -155,6 +162,9 @@ public Command BuildInstancesCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Me.Calendars.Item.Events.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -178,14 +188,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, bodyOption); return command; @@ -193,6 +202,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Me.Calendars.Item.Events.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -264,7 +276,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -276,42 +288,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The events in the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/Calendars/Item/Events/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/Extensions/ExtensionsRequestBuilder.cs index 141de1981a3..40358741f90 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendars/Item/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs index cd8cadf9b25..4a503a7f15b 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string calendarId, string eventId, string extensionId) => { + command.SetHandler(async (string calendarId, string eventId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, extensionIdOption); return command; @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarId, string eventId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string extensionId, string body) => { + command.SetHandler(async (string calendarId, string eventId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, extensionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Calendars/Item/Events/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/Forward/ForwardRequestBuilder.cs index 4de2008fe5a..756c7abbd25 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/Events/Item/Instances/Delta/Delta.cs b/src/generated/Me/Calendars/Item/Events/Item/Instances/Delta/Delta.cs deleted file mode 100644 index 9839b40ea5f..00000000000 --- a/src/generated/Me/Calendars/Item/Events/Item/Instances/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.Calendars.Item.Events.Item.Instances.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Me/Calendars/Item/Events/Item/Instances/Delta/DeltaRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/Instances/Delta/DeltaRequestBuilder.cs index 9b35fcd3a16..d778b391b6e 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/Instances/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/Instances/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +34,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string calendarId, string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, outputOption); return command; } /// @@ -75,16 +75,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/Events/Item/Instances/InstancesRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/Instances/InstancesRequestBuilder.cs index 6a1de9eb9d2..ecad7919c42 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/Instances/InstancesRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/Instances/InstancesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class InstancesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -114,7 +112,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -174,7 +171,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendars/Item/Events/Item/Instances/InstancesResponse.cs b/src/generated/Me/Calendars/Item/Events/Item/Instances/InstancesResponse.cs index 57538159575..f6fab9e80b9 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/Instances/InstancesResponse.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/Instances/InstancesResponse.cs @@ -9,7 +9,7 @@ public class InstancesResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new instancesResponse and sets the default values. /// @@ -22,7 +22,7 @@ public InstancesResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as InstancesResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs index a0101a6729a..ce7cf907afd 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs index be4fa412e24..4ce53cc4188 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs index 7de8c7e7992..1d33876ea5e 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs index 3ef06d0468a..64fe44d562d 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,11 +37,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string calendarId, string eventId, string eventId1) => { + command.SetHandler(async (string calendarId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, eventId1Option); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/EventRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/EventRequestBuilder.cs index 3e870a32d7a..9ba8892289e 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/EventRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -63,11 +63,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string calendarId, string eventId, string eventId1) => { + command.SetHandler(async (string calendarId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, eventId1Option); return command; @@ -108,19 +107,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string calendarId, string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -146,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -225,7 +222,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -237,42 +234,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs index cd3b2e92d74..6ffb2cf7f1b 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index fb8102ba4bb..5f7884dc50b 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index e96e5ca2d89..c8ff11d35e1 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index b1f734fd033..e73d4a950e0 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string calendarId, string eventId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Calendars/Item/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index e1f8627edb8..e20a201f738 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendars/Item/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 6ad6792ac46..aa87cf1e4c9 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string calendarId, string eventId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Calendars/Item/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 15632f82134..c29c6268fd9 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendars/Item/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 4c3e484c08a..d1fb7168112 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Me/Calendars/Item/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index ca2d21ef8fa..ffa72e5249e 100644 --- a/src/generated/Me/Calendars/Item/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string eventId, string body) => { + command.SetHandler(async (string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/GetSchedule/GetScheduleRequestBuilder.cs b/src/generated/Me/Calendars/Item/GetSchedule/GetScheduleRequestBuilder.cs index fcbba1692c5..1483e24b4f7 100644 --- a/src/generated/Me/Calendars/Item/GetSchedule/GetScheduleRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/GetSchedule/GetScheduleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetScheduleRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSchedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetScheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Calendars/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/Calendars/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index b44f7cb4f7b..fa75c444fdd 100644 --- a/src/generated/Me/Calendars/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string calendarId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string calendarId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string calendarId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Calendars/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/Calendars/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 697ec745a8e..dad1806a79a 100644 --- a/src/generated/Me/Calendars/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Calendars/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/Calendars/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 7e3afc4de36..b9d2ea1f978 100644 --- a/src/generated/Me/Calendars/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string calendarId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string calendarId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string calendarId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, calendarIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Calendars/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/Calendars/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index f51be8b0e09..4f37039c7d9 100644 --- a/src/generated/Me/Calendars/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/Calendars/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string calendarId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string calendarId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string calendarId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, calendarIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, calendarIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/ChangePassword/ChangePasswordRequestBuilder.cs b/src/generated/Me/ChangePassword/ChangePasswordRequestBuilder.cs index 14628bdbaeb..bc64c58fe25 100644 --- a/src/generated/Me/ChangePassword/ChangePasswordRequestBuilder.cs +++ b/src/generated/Me/ChangePassword/ChangePasswordRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,14 +29,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -72,18 +71,5 @@ public RequestInformation CreatePostRequestInformation(ChangePasswordRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action changePassword - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ChangePasswordRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Chats/ChatsRequestBuilder.cs b/src/generated/Me/Chats/ChatsRequestBuilder.cs index 42a46fbc759..1a50d33ecbb 100644 --- a/src/generated/Me/Chats/ChatsRequestBuilder.cs +++ b/src/generated/Me/Chats/ChatsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ChatsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ChatRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get chats from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to chats for me - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Chat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get chats from me public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Chats/Item/ChatRequestBuilder.cs b/src/generated/Me/Chats/Item/ChatRequestBuilder.cs index a277139d408..18d128081c2 100644 --- a/src/generated/Me/Chats/Item/ChatRequestBuilder.cs +++ b/src/generated/Me/Chats/Item/ChatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,10 @@ public Command BuildDeleteCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - command.SetHandler(async (string chatId) => { + command.SetHandler(async (string chatId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, chatIdOption); return command; @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string chatId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string chatId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, chatIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, chatIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string chatId, string body) => { + command.SetHandler(async (string chatId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, chatIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property chats for me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get chats from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property chats in me - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Chat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get chats from me public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs b/src/generated/Me/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs index 2fba5b539fa..fce0e11fb91 100644 --- a/src/generated/Me/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs +++ b/src/generated/Me/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +29,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +76,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberGroupsRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs b/src/generated/Me/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs index 55d71e47c33..93328292809 100644 --- a/src/generated/Me/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs +++ b/src/generated/Me/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +29,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +76,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberObjectsRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/ContactFolders/ContactFoldersRequestBuilder.cs b/src/generated/Me/ContactFolders/ContactFoldersRequestBuilder.cs index ebdac3f4fce..7e45c762f13 100644 --- a/src/generated/Me/ContactFolders/ContactFoldersRequestBuilder.cs +++ b/src/generated/Me/ContactFolders/ContactFoldersRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,15 +23,14 @@ public class ContactFoldersRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ContactFolderRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildChildFoldersCommand(), - builder.BuildContactsCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildChildFoldersCommand()); + commands.Add(builder.BuildContactsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -95,7 +93,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -104,15 +106,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(ContactFolder body, Actio public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// The user's contacts folders. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's contacts folders. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ContactFolder model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's contacts folders. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/ContactFolders/Delta/Delta.cs b/src/generated/Me/ContactFolders/Delta/Delta.cs deleted file mode 100644 index 00e417a26cf..00000000000 --- a/src/generated/Me/ContactFolders/Delta/Delta.cs +++ /dev/null @@ -1,49 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.ContactFolders.Delta { - public class Delta : Entity, IParsable { - /// The collection of child folders in the folder. Navigation property. Read-only. Nullable. - public List ChildFolders { get; set; } - /// The contacts in the folder. Navigation property. Read-only. Nullable. - public List Contacts { get; set; } - /// The folder's display name. - public string DisplayName { get; set; } - /// The collection of multi-value extended properties defined for the contactFolder. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - /// The ID of the folder's parent folder. - public string ParentFolderId { get; set; } - /// The collection of single-value extended properties defined for the contactFolder. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"childFolders", (o,n) => { (o as Delta).ChildFolders = n.GetCollectionOfObjectValues().ToList(); } }, - {"contacts", (o,n) => { (o as Delta).Contacts = n.GetCollectionOfObjectValues().ToList(); } }, - {"displayName", (o,n) => { (o as Delta).DisplayName = n.GetStringValue(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"parentFolderId", (o,n) => { (o as Delta).ParentFolderId = n.GetStringValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteCollectionOfObjectValues("childFolders", ChildFolders); - writer.WriteCollectionOfObjectValues("contacts", Contacts); - writer.WriteStringValue("displayName", DisplayName); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteStringValue("parentFolderId", ParentFolderId); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - } - } -} diff --git a/src/generated/Me/ContactFolders/Delta/DeltaRequestBuilder.cs b/src/generated/Me/ContactFolders/Delta/DeltaRequestBuilder.cs index cb2dd941fc4..55423808ef6 100644 --- a/src/generated/Me/ContactFolders/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/ContactFolders/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +26,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +67,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/ContactFolders/Item/ChildFolders/ChildFoldersRequestBuilder.cs b/src/generated/Me/ContactFolders/Item/ChildFolders/ChildFoldersRequestBuilder.cs index 2ccf19e3052..ddc13d83629 100644 --- a/src/generated/Me/ContactFolders/Item/ChildFolders/ChildFoldersRequestBuilder.cs +++ b/src/generated/Me/ContactFolders/Item/ChildFolders/ChildFoldersRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class ChildFoldersRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ContactFolderRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -37,7 +36,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of child folders in the folder. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contactFolderId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactFolderId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactFolderIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactFolderIdOption, bodyOption, outputOption); return command; } /// @@ -69,7 +67,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of child folders in the folder. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -104,7 +102,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contactFolderId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactFolderId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -114,15 +116,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactFolderIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactFolderIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -183,31 +180,6 @@ public RequestInformation CreatePostRequestInformation(ContactFolder body, Actio public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// The collection of child folders in the folder. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of child folders in the folder. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ContactFolder model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of child folders in the folder. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/ContactFolders/Item/ChildFolders/Delta/Delta.cs b/src/generated/Me/ContactFolders/Item/ChildFolders/Delta/Delta.cs deleted file mode 100644 index 564ef4cddfe..00000000000 --- a/src/generated/Me/ContactFolders/Item/ChildFolders/Delta/Delta.cs +++ /dev/null @@ -1,49 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.ContactFolders.Item.ChildFolders.Delta { - public class Delta : Entity, IParsable { - /// The collection of child folders in the folder. Navigation property. Read-only. Nullable. - public List ChildFolders { get; set; } - /// The contacts in the folder. Navigation property. Read-only. Nullable. - public List Contacts { get; set; } - /// The folder's display name. - public string DisplayName { get; set; } - /// The collection of multi-value extended properties defined for the contactFolder. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - /// The ID of the folder's parent folder. - public string ParentFolderId { get; set; } - /// The collection of single-value extended properties defined for the contactFolder. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"childFolders", (o,n) => { (o as Delta).ChildFolders = n.GetCollectionOfObjectValues().ToList(); } }, - {"contacts", (o,n) => { (o as Delta).Contacts = n.GetCollectionOfObjectValues().ToList(); } }, - {"displayName", (o,n) => { (o as Delta).DisplayName = n.GetStringValue(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"parentFolderId", (o,n) => { (o as Delta).ParentFolderId = n.GetStringValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteCollectionOfObjectValues("childFolders", ChildFolders); - writer.WriteCollectionOfObjectValues("contacts", Contacts); - writer.WriteStringValue("displayName", DisplayName); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteStringValue("parentFolderId", ParentFolderId); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - } - } -} diff --git a/src/generated/Me/ContactFolders/Item/ChildFolders/Delta/DeltaRequestBuilder.cs b/src/generated/Me/ContactFolders/Item/ChildFolders/Delta/DeltaRequestBuilder.cs index 93c85bcea9f..854964ab66d 100644 --- a/src/generated/Me/ContactFolders/Item/ChildFolders/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/ContactFolders/Item/ChildFolders/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); - command.SetHandler(async (string contactFolderId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactFolderId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactFolderIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactFolderIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/ContactFolders/Item/ChildFolders/Item/ContactFolderRequestBuilder.cs b/src/generated/Me/ContactFolders/Item/ChildFolders/Item/ContactFolderRequestBuilder.cs index 9665fe8360d..12f5e5c93ea 100644 --- a/src/generated/Me/ContactFolders/Item/ChildFolders/Item/ContactFolderRequestBuilder.cs +++ b/src/generated/Me/ContactFolders/Item/ChildFolders/Item/ContactFolderRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of child folders in the folder. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); - var contactFolderId1Option = new Option("--contactfolder-id1", description: "key: id of contactFolder") { + var contactFolderId1Option = new Option("--contact-folder-id1", description: "key: id of contactFolder") { }; contactFolderId1Option.IsRequired = true; command.AddOption(contactFolderId1Option); - command.SetHandler(async (string contactFolderId, string contactFolderId1) => { + command.SetHandler(async (string contactFolderId, string contactFolderId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactFolderIdOption, contactFolderId1Option); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of child folders in the folder. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); - var contactFolderId1Option = new Option("--contactfolder-id1", description: "key: id of contactFolder") { + var contactFolderId1Option = new Option("--contact-folder-id1", description: "key: id of contactFolder") { }; contactFolderId1Option.IsRequired = true; command.AddOption(contactFolderId1Option); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contactFolderId, string contactFolderId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactFolderId, string contactFolderId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactFolderIdOption, contactFolderId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactFolderIdOption, contactFolderId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of child folders in the folder. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); - var contactFolderId1Option = new Option("--contactfolder-id1", description: "key: id of contactFolder") { + var contactFolderId1Option = new Option("--contact-folder-id1", description: "key: id of contactFolder") { }; contactFolderId1Option.IsRequired = true; command.AddOption(contactFolderId1Option); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contactFolderId, string contactFolderId1, string body) => { + command.SetHandler(async (string contactFolderId, string contactFolderId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactFolderIdOption, contactFolderId1Option, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ContactFolder body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of child folders in the folder. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of child folders in the folder. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of child folders in the folder. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ContactFolder model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of child folders in the folder. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/ContactFolders/Item/ContactFolderRequestBuilder.cs b/src/generated/Me/ContactFolders/Item/ContactFolderRequestBuilder.cs index 8bee03ce2ff..b3d7e42928e 100644 --- a/src/generated/Me/ContactFolders/Item/ContactFolderRequestBuilder.cs +++ b/src/generated/Me/ContactFolders/Item/ContactFolderRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,6 +26,9 @@ public class ContactFolderRequestBuilder { public Command BuildChildFoldersCommand() { var command = new Command("child-folders"); var builder = new ApiSdk.Me.ContactFolders.Item.ChildFolders.ChildFoldersRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -33,6 +36,9 @@ public Command BuildChildFoldersCommand() { public Command BuildContactsCommand() { var command = new Command("contacts"); var builder = new ApiSdk.Me.ContactFolders.Item.Contacts.ContactsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -44,15 +50,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The user's contacts folders. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); - command.SetHandler(async (string contactFolderId) => { + command.SetHandler(async (string contactFolderId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactFolderIdOption); return command; @@ -64,7 +69,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The user's contacts folders. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -73,24 +78,26 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string contactFolderId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactFolderId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactFolderIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactFolderIdOption, selectOption, outputOption); return command; } public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Me.ContactFolders.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -102,7 +109,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The user's contacts folders. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -110,14 +117,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contactFolderId, string body) => { + command.SetHandler(async (string contactFolderId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactFolderIdOption, bodyOption); return command; @@ -125,6 +131,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Me.ContactFolders.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -196,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(ContactFolder body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user's contacts folders. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's contacts folders. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's contacts folders. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ContactFolder model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's contacts folders. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/ContactFolders/Item/Contacts/ContactsRequestBuilder.cs b/src/generated/Me/ContactFolders/Item/Contacts/ContactsRequestBuilder.cs index 188e90f058f..16c117dd8fa 100644 --- a/src/generated/Me/ContactFolders/Item/Contacts/ContactsRequestBuilder.cs +++ b/src/generated/Me/ContactFolders/Item/Contacts/ContactsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,15 +23,14 @@ public class ContactsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ContactRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildExtensionsCommand(), - builder.BuildGetCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildPhotoCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPhotoCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); return commands; } /// @@ -41,7 +40,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The contacts in the folder. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contactFolderId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactFolderId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactFolderIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactFolderIdOption, bodyOption, outputOption); return command; } /// @@ -73,7 +71,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The contacts in the folder. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contactFolderId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactFolderId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactFolderIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactFolderIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -187,31 +184,6 @@ public RequestInformation CreatePostRequestInformation(Contact body, Action - /// The contacts in the folder. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The contacts in the folder. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Contact model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The contacts in the folder. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/ContactFolders/Item/Contacts/Delta/Delta.cs b/src/generated/Me/ContactFolders/Item/Contacts/Delta/Delta.cs deleted file mode 100644 index bc661841a88..00000000000 --- a/src/generated/Me/ContactFolders/Item/Contacts/Delta/Delta.cs +++ /dev/null @@ -1,155 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.ContactFolders.Item.Contacts.Delta { - public class Delta : OutlookItem, IParsable { - /// The name of the contact's assistant. - public string AssistantName { get; set; } - /// The contact's birthday. The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time. For example, midnight UTC on Jan 1, 2014 is 2014-01-01T00:00:00Z - public DateTimeOffset? Birthday { get; set; } - /// The contact's business address. - public PhysicalAddress BusinessAddress { get; set; } - /// The business home page of the contact. - public string BusinessHomePage { get; set; } - /// The contact's business phone numbers. - public List BusinessPhones { get; set; } - /// The names of the contact's children. - public List Children { get; set; } - /// The name of the contact's company. - public string CompanyName { get; set; } - /// The contact's department. - public string Department { get; set; } - /// The contact's display name. You can specify the display name in a create or update operation. Note that later updates to other properties may cause an automatically generated value to overwrite the displayName value you have specified. To preserve a pre-existing value, always include it as displayName in an update operation. - public string DisplayName { get; set; } - /// The contact's email addresses. - public List EmailAddresses { get; set; } - /// The collection of open extensions defined for the contact. Nullable. - public List Extensions { get; set; } - /// The name the contact is filed under. - public string FileAs { get; set; } - /// The contact's generation. - public string Generation { get; set; } - /// The contact's given name. - public string GivenName { get; set; } - /// The contact's home address. - public PhysicalAddress HomeAddress { get; set; } - /// The contact's home phone numbers. - public List HomePhones { get; set; } - public List ImAddresses { get; set; } - public string Initials { get; set; } - public string JobTitle { get; set; } - public string Manager { get; set; } - public string MiddleName { get; set; } - public string MobilePhone { get; set; } - /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public string NickName { get; set; } - public string OfficeLocation { get; set; } - public PhysicalAddress OtherAddress { get; set; } - public string ParentFolderId { get; set; } - public string PersonalNotes { get; set; } - /// Optional contact picture. You can get or set a photo for a contact. - public ProfilePhoto Photo { get; set; } - public string Profession { get; set; } - /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public string SpouseName { get; set; } - public string Surname { get; set; } - public string Title { get; set; } - public string YomiCompanyName { get; set; } - public string YomiGivenName { get; set; } - public string YomiSurname { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"assistantName", (o,n) => { (o as Delta).AssistantName = n.GetStringValue(); } }, - {"birthday", (o,n) => { (o as Delta).Birthday = n.GetDateTimeOffsetValue(); } }, - {"businessAddress", (o,n) => { (o as Delta).BusinessAddress = n.GetObjectValue(); } }, - {"businessHomePage", (o,n) => { (o as Delta).BusinessHomePage = n.GetStringValue(); } }, - {"businessPhones", (o,n) => { (o as Delta).BusinessPhones = n.GetCollectionOfPrimitiveValues().ToList(); } }, - {"children", (o,n) => { (o as Delta).Children = n.GetCollectionOfPrimitiveValues().ToList(); } }, - {"companyName", (o,n) => { (o as Delta).CompanyName = n.GetStringValue(); } }, - {"department", (o,n) => { (o as Delta).Department = n.GetStringValue(); } }, - {"displayName", (o,n) => { (o as Delta).DisplayName = n.GetStringValue(); } }, - {"emailAddresses", (o,n) => { (o as Delta).EmailAddresses = n.GetCollectionOfObjectValues().ToList(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"fileAs", (o,n) => { (o as Delta).FileAs = n.GetStringValue(); } }, - {"generation", (o,n) => { (o as Delta).Generation = n.GetStringValue(); } }, - {"givenName", (o,n) => { (o as Delta).GivenName = n.GetStringValue(); } }, - {"homeAddress", (o,n) => { (o as Delta).HomeAddress = n.GetObjectValue(); } }, - {"homePhones", (o,n) => { (o as Delta).HomePhones = n.GetCollectionOfPrimitiveValues().ToList(); } }, - {"imAddresses", (o,n) => { (o as Delta).ImAddresses = n.GetCollectionOfPrimitiveValues().ToList(); } }, - {"initials", (o,n) => { (o as Delta).Initials = n.GetStringValue(); } }, - {"jobTitle", (o,n) => { (o as Delta).JobTitle = n.GetStringValue(); } }, - {"manager", (o,n) => { (o as Delta).Manager = n.GetStringValue(); } }, - {"middleName", (o,n) => { (o as Delta).MiddleName = n.GetStringValue(); } }, - {"mobilePhone", (o,n) => { (o as Delta).MobilePhone = n.GetStringValue(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"nickName", (o,n) => { (o as Delta).NickName = n.GetStringValue(); } }, - {"officeLocation", (o,n) => { (o as Delta).OfficeLocation = n.GetStringValue(); } }, - {"otherAddress", (o,n) => { (o as Delta).OtherAddress = n.GetObjectValue(); } }, - {"parentFolderId", (o,n) => { (o as Delta).ParentFolderId = n.GetStringValue(); } }, - {"personalNotes", (o,n) => { (o as Delta).PersonalNotes = n.GetStringValue(); } }, - {"photo", (o,n) => { (o as Delta).Photo = n.GetObjectValue(); } }, - {"profession", (o,n) => { (o as Delta).Profession = n.GetStringValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"spouseName", (o,n) => { (o as Delta).SpouseName = n.GetStringValue(); } }, - {"surname", (o,n) => { (o as Delta).Surname = n.GetStringValue(); } }, - {"title", (o,n) => { (o as Delta).Title = n.GetStringValue(); } }, - {"yomiCompanyName", (o,n) => { (o as Delta).YomiCompanyName = n.GetStringValue(); } }, - {"yomiGivenName", (o,n) => { (o as Delta).YomiGivenName = n.GetStringValue(); } }, - {"yomiSurname", (o,n) => { (o as Delta).YomiSurname = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteStringValue("assistantName", AssistantName); - writer.WriteDateTimeOffsetValue("birthday", Birthday); - writer.WriteObjectValue("businessAddress", BusinessAddress); - writer.WriteStringValue("businessHomePage", BusinessHomePage); - writer.WriteCollectionOfPrimitiveValues("businessPhones", BusinessPhones); - writer.WriteCollectionOfPrimitiveValues("children", Children); - writer.WriteStringValue("companyName", CompanyName); - writer.WriteStringValue("department", Department); - writer.WriteStringValue("displayName", DisplayName); - writer.WriteCollectionOfObjectValues("emailAddresses", EmailAddresses); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteStringValue("fileAs", FileAs); - writer.WriteStringValue("generation", Generation); - writer.WriteStringValue("givenName", GivenName); - writer.WriteObjectValue("homeAddress", HomeAddress); - writer.WriteCollectionOfPrimitiveValues("homePhones", HomePhones); - writer.WriteCollectionOfPrimitiveValues("imAddresses", ImAddresses); - writer.WriteStringValue("initials", Initials); - writer.WriteStringValue("jobTitle", JobTitle); - writer.WriteStringValue("manager", Manager); - writer.WriteStringValue("middleName", MiddleName); - writer.WriteStringValue("mobilePhone", MobilePhone); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteStringValue("nickName", NickName); - writer.WriteStringValue("officeLocation", OfficeLocation); - writer.WriteObjectValue("otherAddress", OtherAddress); - writer.WriteStringValue("parentFolderId", ParentFolderId); - writer.WriteStringValue("personalNotes", PersonalNotes); - writer.WriteObjectValue("photo", Photo); - writer.WriteStringValue("profession", Profession); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteStringValue("spouseName", SpouseName); - writer.WriteStringValue("surname", Surname); - writer.WriteStringValue("title", Title); - writer.WriteStringValue("yomiCompanyName", YomiCompanyName); - writer.WriteStringValue("yomiGivenName", YomiGivenName); - writer.WriteStringValue("yomiSurname", YomiSurname); - } - } -} diff --git a/src/generated/Me/ContactFolders/Item/Contacts/Delta/DeltaRequestBuilder.cs b/src/generated/Me/ContactFolders/Item/Contacts/Delta/DeltaRequestBuilder.cs index e37a31df4ae..fc891310e36 100644 --- a/src/generated/Me/ContactFolders/Item/Contacts/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/ContactFolders/Item/Contacts/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); - command.SetHandler(async (string contactFolderId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactFolderId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactFolderIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactFolderIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/ContactFolders/Item/Contacts/Item/ContactRequestBuilder.cs b/src/generated/Me/ContactFolders/Item/Contacts/Item/ContactRequestBuilder.cs index 44f85230ed5..8f8d291737a 100644 --- a/src/generated/Me/ContactFolders/Item/Contacts/Item/ContactRequestBuilder.cs +++ b/src/generated/Me/ContactFolders/Item/Contacts/Item/ContactRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The contacts in the folder. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - command.SetHandler(async (string contactFolderId, string contactId) => { + command.SetHandler(async (string contactFolderId, string contactId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactFolderIdOption, contactIdOption); return command; @@ -50,6 +49,9 @@ public Command BuildDeleteCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Me.ContactFolders.Item.Contacts.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -61,7 +63,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The contacts in the folder. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -79,25 +81,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contactFolderId, string contactId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactFolderId, string contactId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactFolderIdOption, contactIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactFolderIdOption, contactIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Me.ContactFolders.Item.Contacts.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -109,7 +113,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The contacts in the folder. Navigation property. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -121,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contactFolderId, string contactId, string body) => { + command.SetHandler(async (string contactFolderId, string contactId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactFolderIdOption, contactIdOption, bodyOption); return command; @@ -145,6 +148,9 @@ public Command BuildPhotoCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Me.ContactFolders.Item.Contacts.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -216,42 +222,6 @@ public RequestInformation CreatePatchRequestInformation(Contact body, Action - /// The contacts in the folder. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The contacts in the folder. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The contacts in the folder. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Contact model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The contacts in the folder. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/ContactFolders/Item/Contacts/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Me/ContactFolders/Item/Contacts/Item/Extensions/ExtensionsRequestBuilder.cs index 448a9336330..27f1732299a 100644 --- a/src/generated/Me/ContactFolders/Item/Contacts/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Me/ContactFolders/Item/Contacts/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of open extensions defined for the contact. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contactFolderId, string contactId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactFolderId, string contactId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactFolderIdOption, contactIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactFolderIdOption, contactIdOption, bodyOption, outputOption); return command; } /// @@ -72,7 +70,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of open extensions defined for the contact. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contactFolderId, string contactId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactFolderId, string contactId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactFolderIdOption, contactIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactFolderIdOption, contactIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the contact. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the contact. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the contact. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/ContactFolders/Item/Contacts/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Me/ContactFolders/Item/Contacts/Item/Extensions/Item/ExtensionRequestBuilder.cs index 1497e4f80cc..4a8f11b4d1b 100644 --- a/src/generated/Me/ContactFolders/Item/Contacts/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Me/ContactFolders/Item/Contacts/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of open extensions defined for the contact. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string contactFolderId, string contactId, string extensionId) => { + command.SetHandler(async (string contactFolderId, string contactId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactFolderIdOption, contactIdOption, extensionIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of open extensions defined for the contact. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contactFolderId, string contactId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactFolderId, string contactId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactFolderIdOption, contactIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactFolderIdOption, contactIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,7 +97,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of open extensions defined for the contact. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contactFolderId, string contactId, string extensionId, string body) => { + command.SetHandler(async (string contactFolderId, string contactId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactFolderIdOption, contactIdOption, extensionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the contact. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the contact. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the contact. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the contact. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/ContactFolders/Item/Contacts/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/ContactFolders/Item/Contacts/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index ef708d31d9d..4b045b352a4 100644 --- a/src/generated/Me/ContactFolders/Item/Contacts/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/ContactFolders/Item/Contacts/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of multi-value extended properties defined for the contact. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string contactFolderId, string contactId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string contactFolderId, string contactId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactFolderIdOption, contactIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of multi-value extended properties defined for the contact. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contactFolderId, string contactId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactFolderId, string contactId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactFolderIdOption, contactIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactFolderIdOption, contactIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,7 +97,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of multi-value extended properties defined for the contact. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contactFolderId, string contactId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string contactFolderId, string contactId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactFolderIdOption, contactIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/ContactFolders/Item/Contacts/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/ContactFolders/Item/Contacts/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 41786ea6b27..66f6694f58f 100644 --- a/src/generated/Me/ContactFolders/Item/Contacts/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/ContactFolders/Item/Contacts/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of multi-value extended properties defined for the contact. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contactFolderId, string contactId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactFolderId, string contactId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactFolderIdOption, contactIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactFolderIdOption, contactIdOption, bodyOption, outputOption); return command; } /// @@ -72,7 +70,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of multi-value extended properties defined for the contact. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contactFolderId, string contactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactFolderId, string contactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactFolderIdOption, contactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactFolderIdOption, contactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/ContactFolders/Item/Contacts/Item/Photo/PhotoRequestBuilder.cs b/src/generated/Me/ContactFolders/Item/Contacts/Item/Photo/PhotoRequestBuilder.cs index 036bda3c456..0fcfc4df388 100644 --- a/src/generated/Me/ContactFolders/Item/Contacts/Item/Photo/PhotoRequestBuilder.cs +++ b/src/generated/Me/ContactFolders/Item/Contacts/Item/Photo/PhotoRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,7 +34,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Optional contact picture. You can get or set a photo for a contact."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -42,11 +42,10 @@ public Command BuildDeleteCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - command.SetHandler(async (string contactFolderId, string contactId) => { + command.SetHandler(async (string contactFolderId, string contactId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactFolderIdOption, contactIdOption); return command; @@ -58,7 +57,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Optional contact picture. You can get or set a photo for a contact."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -71,19 +70,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string contactFolderId, string contactId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactFolderId, string contactId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactFolderIdOption, contactIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactFolderIdOption, contactIdOption, selectOption, outputOption); return command; } /// @@ -93,7 +91,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Optional contact picture. You can get or set a photo for a contact."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -105,14 +103,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contactFolderId, string contactId, string body) => { + command.SetHandler(async (string contactFolderId, string contactId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactFolderIdOption, contactIdOption, bodyOption); return command; @@ -184,42 +181,6 @@ public RequestInformation CreatePatchRequestInformation(ProfilePhoto body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Optional contact picture. You can get or set a photo for a contact. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Optional contact picture. You can get or set a photo for a contact. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Optional contact picture. You can get or set a photo for a contact. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ProfilePhoto model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Optional contact picture. You can get or set a photo for a contact. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/ContactFolders/Item/Contacts/Item/Photo/Value/ContentRequestBuilder.cs b/src/generated/Me/ContactFolders/Item/Contacts/Item/Photo/Value/ContentRequestBuilder.cs index 05ad4a7a402..6088b56c21f 100644 --- a/src/generated/Me/ContactFolders/Item/Contacts/Item/Photo/Value/ContentRequestBuilder.cs +++ b/src/generated/Me/ContactFolders/Item/Contacts/Item/Photo/Value/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The user's profile photo. Read-only."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -33,24 +33,26 @@ public Command BuildGetCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string contactFolderId, string contactId, FileInfo output) => { + command.SetHandler(async (string contactFolderId, string contactId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, contactFolderIdOption, contactIdOption, outputOption); + }, contactFolderIdOption, contactIdOption, fileOption, outputOption); return command; } /// @@ -60,7 +62,7 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "The user's profile photo. Read-only."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -72,12 +74,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contactFolderId, string contactId, FileInfo file) => { + command.SetHandler(async (string contactFolderId, string contactId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactFolderIdOption, contactIdOption, bodyOption); return command; @@ -128,29 +129,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// The user's profile photo. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's profile photo. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/ContactFolders/Item/Contacts/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/ContactFolders/Item/Contacts/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index ead92cce668..bd4a0e1f1f6 100644 --- a/src/generated/Me/ContactFolders/Item/Contacts/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/ContactFolders/Item/Contacts/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of single-value extended properties defined for the contact. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string contactFolderId, string contactId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string contactFolderId, string contactId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactFolderIdOption, contactIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of single-value extended properties defined for the contact. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contactFolderId, string contactId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactFolderId, string contactId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactFolderIdOption, contactIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactFolderIdOption, contactIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,7 +97,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of single-value extended properties defined for the contact. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contactFolderId, string contactId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string contactFolderId, string contactId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactFolderIdOption, contactIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/ContactFolders/Item/Contacts/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/ContactFolders/Item/Contacts/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index eb873454acd..403821577d8 100644 --- a/src/generated/Me/ContactFolders/Item/Contacts/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/ContactFolders/Item/Contacts/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of single-value extended properties defined for the contact. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contactFolderId, string contactId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactFolderId, string contactId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactFolderIdOption, contactIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactFolderIdOption, contactIdOption, bodyOption, outputOption); return command; } /// @@ -72,7 +70,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of single-value extended properties defined for the contact. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contactFolderId, string contactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactFolderId, string contactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactFolderIdOption, contactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactFolderIdOption, contactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/ContactFolders/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/ContactFolders/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 7006f5b3097..98c930037ee 100644 --- a/src/generated/Me/ContactFolders/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/ContactFolders/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of multi-value extended properties defined for the contactFolder. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string contactFolderId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string contactFolderId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactFolderIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of multi-value extended properties defined for the contactFolder. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contactFolderId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactFolderId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactFolderIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactFolderIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of multi-value extended properties defined for the contactFolder. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contactFolderId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string contactFolderId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactFolderIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the contactFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the contactFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the contactFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the contactFolder. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/ContactFolders/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/ContactFolders/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 01d83767478..7a818126d02 100644 --- a/src/generated/Me/ContactFolders/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/ContactFolders/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of multi-value extended properties defined for the contactFolder. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contactFolderId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactFolderId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactFolderIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactFolderIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of multi-value extended properties defined for the contactFolder. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contactFolderId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactFolderId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactFolderIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactFolderIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the contactFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the contactFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the contactFolder. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/ContactFolders/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/ContactFolders/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 92df74d48df..03f74006779 100644 --- a/src/generated/Me/ContactFolders/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/ContactFolders/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of single-value extended properties defined for the contactFolder. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string contactFolderId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string contactFolderId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactFolderIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of single-value extended properties defined for the contactFolder. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contactFolderId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactFolderId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactFolderIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactFolderIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of single-value extended properties defined for the contactFolder. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contactFolderId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string contactFolderId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactFolderIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the contactFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the contactFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the contactFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the contactFolder. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/ContactFolders/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/ContactFolders/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 5b968983799..f19f7c1cfeb 100644 --- a/src/generated/Me/ContactFolders/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/ContactFolders/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of single-value extended properties defined for the contactFolder. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contactFolderId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactFolderId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactFolderIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactFolderIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of single-value extended properties defined for the contactFolder. Read-only. Nullable."; // Create options for all the parameters - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contactFolderId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactFolderId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactFolderIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactFolderIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the contactFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the contactFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the contactFolder. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Contacts/ContactsRequestBuilder.cs b/src/generated/Me/Contacts/ContactsRequestBuilder.cs index 3cfa30a8487..74dc4dc43df 100644 --- a/src/generated/Me/Contacts/ContactsRequestBuilder.cs +++ b/src/generated/Me/Contacts/ContactsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,15 +23,14 @@ public class ContactsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ContactRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildExtensionsCommand(), - builder.BuildGetCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildPhotoCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPhotoCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -109,15 +111,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -178,31 +175,6 @@ public RequestInformation CreatePostRequestInformation(Contact body, Action - /// The user's contacts. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's contacts. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Contact model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's contacts. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Contacts/Delta/Delta.cs b/src/generated/Me/Contacts/Delta/Delta.cs deleted file mode 100644 index 0f8ba224eaf..00000000000 --- a/src/generated/Me/Contacts/Delta/Delta.cs +++ /dev/null @@ -1,155 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.Contacts.Delta { - public class Delta : OutlookItem, IParsable { - /// The name of the contact's assistant. - public string AssistantName { get; set; } - /// The contact's birthday. The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time. For example, midnight UTC on Jan 1, 2014 is 2014-01-01T00:00:00Z - public DateTimeOffset? Birthday { get; set; } - /// The contact's business address. - public PhysicalAddress BusinessAddress { get; set; } - /// The business home page of the contact. - public string BusinessHomePage { get; set; } - /// The contact's business phone numbers. - public List BusinessPhones { get; set; } - /// The names of the contact's children. - public List Children { get; set; } - /// The name of the contact's company. - public string CompanyName { get; set; } - /// The contact's department. - public string Department { get; set; } - /// The contact's display name. You can specify the display name in a create or update operation. Note that later updates to other properties may cause an automatically generated value to overwrite the displayName value you have specified. To preserve a pre-existing value, always include it as displayName in an update operation. - public string DisplayName { get; set; } - /// The contact's email addresses. - public List EmailAddresses { get; set; } - /// The collection of open extensions defined for the contact. Nullable. - public List Extensions { get; set; } - /// The name the contact is filed under. - public string FileAs { get; set; } - /// The contact's generation. - public string Generation { get; set; } - /// The contact's given name. - public string GivenName { get; set; } - /// The contact's home address. - public PhysicalAddress HomeAddress { get; set; } - /// The contact's home phone numbers. - public List HomePhones { get; set; } - public List ImAddresses { get; set; } - public string Initials { get; set; } - public string JobTitle { get; set; } - public string Manager { get; set; } - public string MiddleName { get; set; } - public string MobilePhone { get; set; } - /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public string NickName { get; set; } - public string OfficeLocation { get; set; } - public PhysicalAddress OtherAddress { get; set; } - public string ParentFolderId { get; set; } - public string PersonalNotes { get; set; } - /// Optional contact picture. You can get or set a photo for a contact. - public ProfilePhoto Photo { get; set; } - public string Profession { get; set; } - /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public string SpouseName { get; set; } - public string Surname { get; set; } - public string Title { get; set; } - public string YomiCompanyName { get; set; } - public string YomiGivenName { get; set; } - public string YomiSurname { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"assistantName", (o,n) => { (o as Delta).AssistantName = n.GetStringValue(); } }, - {"birthday", (o,n) => { (o as Delta).Birthday = n.GetDateTimeOffsetValue(); } }, - {"businessAddress", (o,n) => { (o as Delta).BusinessAddress = n.GetObjectValue(); } }, - {"businessHomePage", (o,n) => { (o as Delta).BusinessHomePage = n.GetStringValue(); } }, - {"businessPhones", (o,n) => { (o as Delta).BusinessPhones = n.GetCollectionOfPrimitiveValues().ToList(); } }, - {"children", (o,n) => { (o as Delta).Children = n.GetCollectionOfPrimitiveValues().ToList(); } }, - {"companyName", (o,n) => { (o as Delta).CompanyName = n.GetStringValue(); } }, - {"department", (o,n) => { (o as Delta).Department = n.GetStringValue(); } }, - {"displayName", (o,n) => { (o as Delta).DisplayName = n.GetStringValue(); } }, - {"emailAddresses", (o,n) => { (o as Delta).EmailAddresses = n.GetCollectionOfObjectValues().ToList(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"fileAs", (o,n) => { (o as Delta).FileAs = n.GetStringValue(); } }, - {"generation", (o,n) => { (o as Delta).Generation = n.GetStringValue(); } }, - {"givenName", (o,n) => { (o as Delta).GivenName = n.GetStringValue(); } }, - {"homeAddress", (o,n) => { (o as Delta).HomeAddress = n.GetObjectValue(); } }, - {"homePhones", (o,n) => { (o as Delta).HomePhones = n.GetCollectionOfPrimitiveValues().ToList(); } }, - {"imAddresses", (o,n) => { (o as Delta).ImAddresses = n.GetCollectionOfPrimitiveValues().ToList(); } }, - {"initials", (o,n) => { (o as Delta).Initials = n.GetStringValue(); } }, - {"jobTitle", (o,n) => { (o as Delta).JobTitle = n.GetStringValue(); } }, - {"manager", (o,n) => { (o as Delta).Manager = n.GetStringValue(); } }, - {"middleName", (o,n) => { (o as Delta).MiddleName = n.GetStringValue(); } }, - {"mobilePhone", (o,n) => { (o as Delta).MobilePhone = n.GetStringValue(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"nickName", (o,n) => { (o as Delta).NickName = n.GetStringValue(); } }, - {"officeLocation", (o,n) => { (o as Delta).OfficeLocation = n.GetStringValue(); } }, - {"otherAddress", (o,n) => { (o as Delta).OtherAddress = n.GetObjectValue(); } }, - {"parentFolderId", (o,n) => { (o as Delta).ParentFolderId = n.GetStringValue(); } }, - {"personalNotes", (o,n) => { (o as Delta).PersonalNotes = n.GetStringValue(); } }, - {"photo", (o,n) => { (o as Delta).Photo = n.GetObjectValue(); } }, - {"profession", (o,n) => { (o as Delta).Profession = n.GetStringValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"spouseName", (o,n) => { (o as Delta).SpouseName = n.GetStringValue(); } }, - {"surname", (o,n) => { (o as Delta).Surname = n.GetStringValue(); } }, - {"title", (o,n) => { (o as Delta).Title = n.GetStringValue(); } }, - {"yomiCompanyName", (o,n) => { (o as Delta).YomiCompanyName = n.GetStringValue(); } }, - {"yomiGivenName", (o,n) => { (o as Delta).YomiGivenName = n.GetStringValue(); } }, - {"yomiSurname", (o,n) => { (o as Delta).YomiSurname = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteStringValue("assistantName", AssistantName); - writer.WriteDateTimeOffsetValue("birthday", Birthday); - writer.WriteObjectValue("businessAddress", BusinessAddress); - writer.WriteStringValue("businessHomePage", BusinessHomePage); - writer.WriteCollectionOfPrimitiveValues("businessPhones", BusinessPhones); - writer.WriteCollectionOfPrimitiveValues("children", Children); - writer.WriteStringValue("companyName", CompanyName); - writer.WriteStringValue("department", Department); - writer.WriteStringValue("displayName", DisplayName); - writer.WriteCollectionOfObjectValues("emailAddresses", EmailAddresses); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteStringValue("fileAs", FileAs); - writer.WriteStringValue("generation", Generation); - writer.WriteStringValue("givenName", GivenName); - writer.WriteObjectValue("homeAddress", HomeAddress); - writer.WriteCollectionOfPrimitiveValues("homePhones", HomePhones); - writer.WriteCollectionOfPrimitiveValues("imAddresses", ImAddresses); - writer.WriteStringValue("initials", Initials); - writer.WriteStringValue("jobTitle", JobTitle); - writer.WriteStringValue("manager", Manager); - writer.WriteStringValue("middleName", MiddleName); - writer.WriteStringValue("mobilePhone", MobilePhone); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteStringValue("nickName", NickName); - writer.WriteStringValue("officeLocation", OfficeLocation); - writer.WriteObjectValue("otherAddress", OtherAddress); - writer.WriteStringValue("parentFolderId", ParentFolderId); - writer.WriteStringValue("personalNotes", PersonalNotes); - writer.WriteObjectValue("photo", Photo); - writer.WriteStringValue("profession", Profession); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteStringValue("spouseName", SpouseName); - writer.WriteStringValue("surname", Surname); - writer.WriteStringValue("title", Title); - writer.WriteStringValue("yomiCompanyName", YomiCompanyName); - writer.WriteStringValue("yomiGivenName", YomiGivenName); - writer.WriteStringValue("yomiSurname", YomiSurname); - } - } -} diff --git a/src/generated/Me/Contacts/Delta/DeltaRequestBuilder.cs b/src/generated/Me/Contacts/Delta/DeltaRequestBuilder.cs index 22e3872c43b..6a065e05682 100644 --- a/src/generated/Me/Contacts/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/Contacts/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +26,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +67,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Contacts/Item/ContactRequestBuilder.cs b/src/generated/Me/Contacts/Item/ContactRequestBuilder.cs index be1f11c270d..4e936b8f5a3 100644 --- a/src/generated/Me/Contacts/Item/ContactRequestBuilder.cs +++ b/src/generated/Me/Contacts/Item/ContactRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - command.SetHandler(async (string contactId) => { + command.SetHandler(async (string contactId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactIdOption); return command; @@ -46,6 +45,9 @@ public Command BuildDeleteCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Me.Contacts.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -66,24 +68,26 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string contactId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactIdOption, selectOption, outputOption); return command; } public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Me.Contacts.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -103,14 +107,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contactId, string body) => { + command.SetHandler(async (string contactId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactIdOption, bodyOption); return command; @@ -127,6 +130,9 @@ public Command BuildPhotoCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Me.Contacts.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -198,42 +204,6 @@ public RequestInformation CreatePatchRequestInformation(Contact body, Action - /// The user's contacts. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's contacts. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's contacts. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Contact model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's contacts. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/Contacts/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Me/Contacts/Item/Extensions/ExtensionsRequestBuilder.cs index 4c51bcf86a5..eac30e179f9 100644 --- a/src/generated/Me/Contacts/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Me/Contacts/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contactId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactIdOption, bodyOption, outputOption); return command; } /// @@ -103,7 +101,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contactId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -113,15 +115,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -176,31 +173,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the contact. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the contact. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the contact. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Contacts/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Me/Contacts/Item/Extensions/Item/ExtensionRequestBuilder.cs index 970b8f4a248..c695a58574d 100644 --- a/src/generated/Me/Contacts/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Me/Contacts/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string contactId, string extensionId) => { + command.SetHandler(async (string contactId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactIdOption, extensionIdOption); return command; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contactId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contactId, string extensionId, string body) => { + command.SetHandler(async (string contactId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactIdOption, extensionIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the contact. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the contact. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the contact. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the contact. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Contacts/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/Contacts/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 5f3a8d8065d..55e5508a62e 100644 --- a/src/generated/Me/Contacts/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/Contacts/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string contactId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string contactId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contactId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contactId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string contactId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Contacts/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/Contacts/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 21a845c3752..801a52b7cd1 100644 --- a/src/generated/Me/Contacts/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/Contacts/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contactId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Contacts/Item/Photo/PhotoRequestBuilder.cs b/src/generated/Me/Contacts/Item/Photo/PhotoRequestBuilder.cs index cb56574c2f6..4f5d985e741 100644 --- a/src/generated/Me/Contacts/Item/Photo/PhotoRequestBuilder.cs +++ b/src/generated/Me/Contacts/Item/Photo/PhotoRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - command.SetHandler(async (string contactId) => { + command.SetHandler(async (string contactId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactIdOption); return command; @@ -63,19 +62,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string contactId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactIdOption, selectOption, outputOption); return command; } /// @@ -93,14 +91,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contactId, string body) => { + command.SetHandler(async (string contactId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactIdOption, bodyOption); return command; @@ -172,42 +169,6 @@ public RequestInformation CreatePatchRequestInformation(ProfilePhoto body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Optional contact picture. You can get or set a photo for a contact. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Optional contact picture. You can get or set a photo for a contact. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Optional contact picture. You can get or set a photo for a contact. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ProfilePhoto model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Optional contact picture. You can get or set a photo for a contact. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/Contacts/Item/Photo/Value/ContentRequestBuilder.cs b/src/generated/Me/Contacts/Item/Photo/Value/ContentRequestBuilder.cs index 03e1f4d91c1..2bc62aeb44b 100644 --- a/src/generated/Me/Contacts/Item/Photo/Value/ContentRequestBuilder.cs +++ b/src/generated/Me/Contacts/Item/Photo/Value/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string contactId, FileInfo output) => { + command.SetHandler(async (string contactId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, contactIdOption, outputOption); + }, contactIdOption, fileOption, outputOption); return command; } /// @@ -64,12 +66,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contactId, FileInfo file) => { + command.SetHandler(async (string contactId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactIdOption, bodyOption); return command; @@ -120,29 +121,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// The user's profile photo. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's profile photo. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Contacts/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/Contacts/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 38392c16a10..47dff5b01ae 100644 --- a/src/generated/Me/Contacts/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/Contacts/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string contactId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string contactId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contactId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contactId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string contactId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, contactIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Contacts/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/Contacts/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 35ef1f98f13..2367dcd451d 100644 --- a/src/generated/Me/Contacts/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/Contacts/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string contactId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string contactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string contactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, contactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, contactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CreatedObjects/@Ref/@Ref.cs b/src/generated/Me/CreatedObjects/@Ref/@Ref.cs deleted file mode 100644 index 301037406b1..00000000000 --- a/src/generated/Me/CreatedObjects/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.CreatedObjects.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/CreatedObjects/@Ref/RefRequestBuilder.cs b/src/generated/Me/CreatedObjects/@Ref/RefRequestBuilder.cs deleted file mode 100644 index a5ad8810f09..00000000000 --- a/src/generated/Me/CreatedObjects/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,194 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Me.CreatedObjects.@Ref { - /// Builds and executes requests for operations under \me\createdObjects\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Directory objects that were created by the user. Read-only. Nullable. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Directory objects that were created by the user. Read-only. Nullable."; - // Create options for all the parameters - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Directory objects that were created by the user. Read-only. Nullable. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Directory objects that were created by the user. Read-only. Nullable."; - // Create options for all the parameters - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/createdObjects/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Directory objects that were created by the user. Read-only. Nullable. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Directory objects that were created by the user. Read-only. Nullable. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Me.CreatedObjects.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Directory objects that were created by the user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Directory objects that were created by the user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Me.CreatedObjects.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Directory objects that were created by the user. Read-only. Nullable. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Me/CreatedObjects/@Ref/RefResponse.cs b/src/generated/Me/CreatedObjects/@Ref/RefResponse.cs deleted file mode 100644 index 7e175b8b606..00000000000 --- a/src/generated/Me/CreatedObjects/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.CreatedObjects.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/CreatedObjects/CreatedObjectsRequestBuilder.cs b/src/generated/Me/CreatedObjects/CreatedObjectsRequestBuilder.cs index 145575b53a1..55c3a107fcb 100644 --- a/src/generated/Me/CreatedObjects/CreatedObjectsRequestBuilder.cs +++ b/src/generated/Me/CreatedObjects/CreatedObjectsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Me.CreatedObjects.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -61,7 +61,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -72,20 +76,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Me.CreatedObjects.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Me.CreatedObjects.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -124,18 +123,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Directory objects that were created by the user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Directory objects that were created by the user. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/CreatedObjects/Ref/Ref.cs b/src/generated/Me/CreatedObjects/Ref/Ref.cs new file mode 100644 index 00000000000..30e86ae2095 --- /dev/null +++ b/src/generated/Me/CreatedObjects/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.CreatedObjects.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/CreatedObjects/Ref/RefRequestBuilder.cs b/src/generated/Me/CreatedObjects/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..2c5a06d533d --- /dev/null +++ b/src/generated/Me/CreatedObjects/Ref/RefRequestBuilder.cs @@ -0,0 +1,167 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Me.CreatedObjects.Ref { + /// Builds and executes requests for operations under \me\createdObjects\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Directory objects that were created by the user. Read-only. Nullable. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Directory objects that were created by the user. Read-only. Nullable."; + // Create options for all the parameters + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Directory objects that were created by the user. Read-only. Nullable. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Directory objects that were created by the user. Read-only. Nullable."; + // Create options for all the parameters + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/me/createdObjects/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Directory objects that were created by the user. Read-only. Nullable. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Directory objects that were created by the user. Read-only. Nullable. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Me.CreatedObjects.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Directory objects that were created by the user. Read-only. Nullable. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Me/CreatedObjects/Ref/RefResponse.cs b/src/generated/Me/CreatedObjects/Ref/RefResponse.cs new file mode 100644 index 00000000000..5a85e304658 --- /dev/null +++ b/src/generated/Me/CreatedObjects/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.CreatedObjects.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/DeviceManagementTroubleshootingEvents/DeviceManagementTroubleshootingEventsRequestBuilder.cs b/src/generated/Me/DeviceManagementTroubleshootingEvents/DeviceManagementTroubleshootingEventsRequestBuilder.cs index 351d3aff51d..cbde221694f 100644 --- a/src/generated/Me/DeviceManagementTroubleshootingEvents/DeviceManagementTroubleshootingEventsRequestBuilder.cs +++ b/src/generated/Me/DeviceManagementTroubleshootingEvents/DeviceManagementTroubleshootingEventsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DeviceManagementTroubleshootingEventsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceManagementTroubleshootingEventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(DeviceManagementTroublesh requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of troubleshooting events for this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of troubleshooting events for this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceManagementTroubleshootingEvent model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of troubleshooting events for this user. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/DeviceManagementTroubleshootingEvents/Item/DeviceManagementTroubleshootingEventRequestBuilder.cs b/src/generated/Me/DeviceManagementTroubleshootingEvents/Item/DeviceManagementTroubleshootingEventRequestBuilder.cs index 88587546012..ee549ee90ab 100644 --- a/src/generated/Me/DeviceManagementTroubleshootingEvents/Item/DeviceManagementTroubleshootingEventRequestBuilder.cs +++ b/src/generated/Me/DeviceManagementTroubleshootingEvents/Item/DeviceManagementTroubleshootingEventRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of troubleshooting events for this user."; // Create options for all the parameters - var deviceManagementTroubleshootingEventIdOption = new Option("--devicemanagementtroubleshootingevent-id", description: "key: id of deviceManagementTroubleshootingEvent") { + var deviceManagementTroubleshootingEventIdOption = new Option("--device-management-troubleshooting-event-id", description: "key: id of deviceManagementTroubleshootingEvent") { }; deviceManagementTroubleshootingEventIdOption.IsRequired = true; command.AddOption(deviceManagementTroubleshootingEventIdOption); - command.SetHandler(async (string deviceManagementTroubleshootingEventId) => { + command.SetHandler(async (string deviceManagementTroubleshootingEventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceManagementTroubleshootingEventIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of troubleshooting events for this user."; // Create options for all the parameters - var deviceManagementTroubleshootingEventIdOption = new Option("--devicemanagementtroubleshootingevent-id", description: "key: id of deviceManagementTroubleshootingEvent") { + var deviceManagementTroubleshootingEventIdOption = new Option("--device-management-troubleshooting-event-id", description: "key: id of deviceManagementTroubleshootingEvent") { }; deviceManagementTroubleshootingEventIdOption.IsRequired = true; command.AddOption(deviceManagementTroubleshootingEventIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string deviceManagementTroubleshootingEventId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string deviceManagementTroubleshootingEventId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, deviceManagementTroubleshootingEventIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, deviceManagementTroubleshootingEventIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of troubleshooting events for this user."; // Create options for all the parameters - var deviceManagementTroubleshootingEventIdOption = new Option("--devicemanagementtroubleshootingevent-id", description: "key: id of deviceManagementTroubleshootingEvent") { + var deviceManagementTroubleshootingEventIdOption = new Option("--device-management-troubleshooting-event-id", description: "key: id of deviceManagementTroubleshootingEvent") { }; deviceManagementTroubleshootingEventIdOption.IsRequired = true; command.AddOption(deviceManagementTroubleshootingEventIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string deviceManagementTroubleshootingEventId, string body) => { + command.SetHandler(async (string deviceManagementTroubleshootingEventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, deviceManagementTroubleshootingEventIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceManagementTroubles requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of troubleshooting events for this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of troubleshooting events for this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of troubleshooting events for this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceManagementTroubleshootingEvent model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of troubleshooting events for this user. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/DirectReports/@Ref/@Ref.cs b/src/generated/Me/DirectReports/@Ref/@Ref.cs deleted file mode 100644 index 790dda03996..00000000000 --- a/src/generated/Me/DirectReports/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.DirectReports.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/DirectReports/@Ref/RefRequestBuilder.cs b/src/generated/Me/DirectReports/@Ref/RefRequestBuilder.cs deleted file mode 100644 index ff761b75f3f..00000000000 --- a/src/generated/Me/DirectReports/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,194 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Me.DirectReports.@Ref { - /// Builds and executes requests for operations under \me\directReports\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/directReports/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Me.DirectReports.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Me.DirectReports.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Me/DirectReports/@Ref/RefResponse.cs b/src/generated/Me/DirectReports/@Ref/RefResponse.cs deleted file mode 100644 index 87631adaf69..00000000000 --- a/src/generated/Me/DirectReports/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.DirectReports.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/DirectReports/DirectReportsRequestBuilder.cs b/src/generated/Me/DirectReports/DirectReportsRequestBuilder.cs index 7e9bd2f127b..6cad8142cc2 100644 --- a/src/generated/Me/DirectReports/DirectReportsRequestBuilder.cs +++ b/src/generated/Me/DirectReports/DirectReportsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Me.DirectReports.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -61,7 +61,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -72,20 +76,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Me.DirectReports.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Me.DirectReports.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -124,18 +123,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/DirectReports/Ref/Ref.cs b/src/generated/Me/DirectReports/Ref/Ref.cs new file mode 100644 index 00000000000..d6e8a970748 --- /dev/null +++ b/src/generated/Me/DirectReports/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.DirectReports.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/DirectReports/Ref/RefRequestBuilder.cs b/src/generated/Me/DirectReports/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..d3052182e6d --- /dev/null +++ b/src/generated/Me/DirectReports/Ref/RefRequestBuilder.cs @@ -0,0 +1,167 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Me.DirectReports.Ref { + /// Builds and executes requests for operations under \me\directReports\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/me/directReports/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Me.DirectReports.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Me/DirectReports/Ref/RefResponse.cs b/src/generated/Me/DirectReports/Ref/RefResponse.cs new file mode 100644 index 00000000000..134b72c8b90 --- /dev/null +++ b/src/generated/Me/DirectReports/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.DirectReports.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/Drive/DriveRequestBuilder.cs b/src/generated/Me/Drive/DriveRequestBuilder.cs index d9576b8d3ed..e4ed210b18e 100644 --- a/src/generated/Me/Drive/DriveRequestBuilder.cs +++ b/src/generated/Me/Drive/DriveRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The user's OneDrive. Read-only."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -52,20 +51,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -79,14 +77,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -158,42 +155,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user's OneDrive. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's OneDrive. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's OneDrive. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Drive model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's OneDrive. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Drives/DrivesRequestBuilder.cs b/src/generated/Me/Drives/DrivesRequestBuilder.cs index 4b932e99b9f..e737219c2ba 100644 --- a/src/generated/Me/Drives/DrivesRequestBuilder.cs +++ b/src/generated/Me/Drives/DrivesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DrivesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DriveRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of drives available for this user. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of drives available for this user. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Drive model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of drives available for this user. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Drives/Item/DriveRequestBuilder.cs b/src/generated/Me/Drives/Item/DriveRequestBuilder.cs index 1ac48531534..7b69b86f5ba 100644 --- a/src/generated/Me/Drives/Item/DriveRequestBuilder.cs +++ b/src/generated/Me/Drives/Item/DriveRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,10 @@ public Command BuildDeleteCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - command.SetHandler(async (string driveId) => { + command.SetHandler(async (string driveId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption); return command; @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveId, string body) => { + command.SetHandler(async (string driveId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of drives available for this user. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of drives available for this user. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of drives available for this user. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Drive model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of drives available for this user. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Events/Delta/Delta.cs b/src/generated/Me/Events/Delta/Delta.cs deleted file mode 100644 index 47940ca3a35..00000000000 --- a/src/generated/Me/Events/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.Events.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Me/Events/Delta/DeltaRequestBuilder.cs b/src/generated/Me/Events/Delta/DeltaRequestBuilder.cs index 07f391427da..c69018d2d29 100644 --- a/src/generated/Me/Events/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/Events/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +26,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +67,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/EventsRequestBuilder.cs b/src/generated/Me/Events/EventsRequestBuilder.cs index 0b94255576a..8f0e1599bd3 100644 --- a/src/generated/Me/Events/EventsRequestBuilder.cs +++ b/src/generated/Me/Events/EventsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,24 +23,23 @@ public class EventsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildAttachmentsCommand(), - builder.BuildCalendarCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildExtensionsCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildInstancesCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildAttachmentsCommand()); + commands.Add(builder.BuildCalendarCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInstancesCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -104,7 +102,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -113,15 +115,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -164,7 +161,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The user's events. Default is to show events under the Default Calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's events. Default is to show events under the Default Calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The user's events. Default is to show events under the Default Calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Events/EventsResponse.cs b/src/generated/Me/Events/EventsResponse.cs index 6c2d458035d..fd4b7507140 100644 --- a/src/generated/Me/Events/EventsResponse.cs +++ b/src/generated/Me/Events/EventsResponse.cs @@ -9,7 +9,7 @@ public class EventsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new eventsResponse and sets the default values. /// @@ -22,7 +22,7 @@ public EventsResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as EventsResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Me/Events/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Me/Events/Item/Accept/AcceptRequestBuilder.cs index cb391d00aea..098719bf1d9 100644 --- a/src/generated/Me/Events/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Attachments/AttachmentsRequestBuilder.cs b/src/generated/Me/Events/Item/Attachments/AttachmentsRequestBuilder.cs index 7fb13245d7e..52c79bf019a 100644 --- a/src/generated/Me/Events/Item/Attachments/AttachmentsRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Attachments/AttachmentsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class AttachmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttachmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } public Command BuildCreateUploadSessionCommand() { @@ -110,7 +108,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -120,15 +122,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -183,31 +180,6 @@ public RequestInformation CreatePostRequestInformation(Attachment body, Action - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Me/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index e7024b22f5e..2913ab06be4 100644 --- a/src/generated/Me/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs b/src/generated/Me/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs index a8bc261b6f2..7b8b81e8b7d 100644 --- a/src/generated/Me/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; attachmentIdOption.IsRequired = true; command.AddOption(attachmentIdOption); - command.SetHandler(async (string eventId, string attachmentId) => { + command.SetHandler(async (string eventId, string attachmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, attachmentIdOption); return command; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, string attachmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string attachmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, attachmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, attachmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string attachmentId, string body) => { + command.SetHandler(async (string eventId, string attachmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, attachmentIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(Attachment body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs index 4c78dde19c1..c69753e3b31 100644 --- a/src/generated/Me/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +33,17 @@ public Command BuildGetCommand() { }; UserOption.IsRequired = true; command.AddOption(UserOption); - command.SetHandler(async (string eventId, string User) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string User, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, UserOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, UserOption, outputOption); return command; } /// @@ -77,16 +76,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function allowedCalendarSharingRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs index d174f07d45f..854e791854e 100644 --- a/src/generated/Me/Events/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class CalendarPermissionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new CalendarPermissionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -98,7 +96,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -107,15 +109,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -170,31 +167,6 @@ public RequestInformation CreatePostRequestInformation(CalendarPermission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CalendarPermission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions of the users with whom the calendar is shared. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Events/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs index edbdced7fc2..6369888694f 100644 --- a/src/generated/Me/Events/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); - command.SetHandler(async (string eventId, string calendarPermissionId) => { + command.SetHandler(async (string eventId, string calendarPermissionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, calendarPermissionIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); @@ -63,19 +62,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, string calendarPermissionId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string calendarPermissionId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, calendarPermissionIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, calendarPermissionIdOption, selectOption, outputOption); return command; } /// @@ -89,7 +87,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); @@ -97,14 +95,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string calendarPermissionId, string body) => { + command.SetHandler(async (string eventId, string calendarPermissionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, calendarPermissionIdOption, bodyOption); return command; @@ -176,42 +173,6 @@ public RequestInformation CreatePatchRequestInformation(CalendarPermission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(CalendarPermission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions of the users with whom the calendar is shared. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/Events/Item/Calendar/CalendarRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/CalendarRequestBuilder.cs index 40cc010bc5a..1045ef09ed5 100644 --- a/src/generated/Me/Events/Item/Calendar/CalendarRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/CalendarRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,6 +37,9 @@ public AllowedCalendarSharingRolesWithUserRequestBuilder AllowedCalendarSharingR public Command BuildCalendarPermissionsCommand() { var command = new Command("calendar-permissions"); var builder = new ApiSdk.Me.Events.Item.Calendar.CalendarPermissions.CalendarPermissionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -44,6 +47,9 @@ public Command BuildCalendarPermissionsCommand() { public Command BuildCalendarViewCommand() { var command = new Command("calendar-view"); var builder = new ApiSdk.Me.Events.Item.Calendar.CalendarView.CalendarViewRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -59,11 +65,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string eventId) => { + command.SetHandler(async (string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption); return command; @@ -71,6 +76,9 @@ public Command BuildDeleteCommand() { public Command BuildEventsCommand() { var command = new Command("events"); var builder = new ApiSdk.Me.Events.Item.Calendar.Events.EventsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -91,19 +99,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, selectOption, outputOption); return command; } public Command BuildGetScheduleCommand() { @@ -115,6 +122,9 @@ public Command BuildGetScheduleCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Me.Events.Item.Calendar.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -149,6 +158,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Me.Events.Item.Calendar.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -220,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar that contains the event. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/Events/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs index b3b6af50e97..561de5bc4c0 100644 --- a/src/generated/Me/Events/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class CalendarViewRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -106,7 +104,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -115,15 +117,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -166,7 +163,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Events/Item/Calendar/CalendarView/CalendarViewResponse.cs b/src/generated/Me/Events/Item/Calendar/CalendarView/CalendarViewResponse.cs index 7631b5ad321..c0bc87d57f4 100644 --- a/src/generated/Me/Events/Item/Calendar/CalendarView/CalendarViewResponse.cs +++ b/src/generated/Me/Events/Item/Calendar/CalendarView/CalendarViewResponse.cs @@ -9,7 +9,7 @@ public class CalendarViewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new calendarViewResponse and sets the default values. /// @@ -22,7 +22,7 @@ public CalendarViewResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as CalendarViewResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Me/Events/Item/Calendar/CalendarView/Delta/Delta.cs b/src/generated/Me/Events/Item/Calendar/CalendarView/Delta/Delta.cs deleted file mode 100644 index 4676e295d11..00000000000 --- a/src/generated/Me/Events/Item/Calendar/CalendarView/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.Events.Item.Calendar.CalendarView.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Me/Events/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs index 63af7c21193..f96f1d90840 100644 --- a/src/generated/Me/Events/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +30,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs index 5656497b60c..12b083927b9 100644 --- a/src/generated/Me/Events/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs index 72a7cbcdf51..1089fc2c27a 100644 --- a/src/generated/Me/Events/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs index ca00cfaa5c5..9be6596e876 100644 --- a/src/generated/Me/Events/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs index 23ef17b377a..ad0b32e921d 100644 --- a/src/generated/Me/Events/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,11 +33,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string eventId, string eventId1) => { + command.SetHandler(async (string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs index a3bba9c53d5..5508bb5f235 100644 --- a/src/generated/Me/Events/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -59,11 +59,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string eventId, string eventId1) => { + command.SetHandler(async (string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option); return command; @@ -100,19 +99,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -213,7 +210,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -225,42 +222,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/Events/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs index 38d4f64aa42..ccfb4eab31f 100644 --- a/src/generated/Me/Events/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 4e670538845..026ee312bc8 100644 --- a/src/generated/Me/Events/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index c8e18624586..761e20b6503 100644 --- a/src/generated/Me/Events/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Calendar/Events/Delta/Delta.cs b/src/generated/Me/Events/Item/Calendar/Events/Delta/Delta.cs deleted file mode 100644 index 7a4a66a1a41..00000000000 --- a/src/generated/Me/Events/Item/Calendar/Events/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.Events.Item.Calendar.Events.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Me/Events/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs index 16845b98c90..2f9b56aa096 100644 --- a/src/generated/Me/Events/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +30,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Calendar/Events/EventsRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/Events/EventsRequestBuilder.cs index 737d2b09ff1..6593ae4f045 100644 --- a/src/generated/Me/Events/Item/Calendar/Events/EventsRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/Events/EventsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class EventsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -106,7 +104,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -115,15 +117,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -166,7 +163,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The events in the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Events/Item/Calendar/Events/EventsResponse.cs b/src/generated/Me/Events/Item/Calendar/Events/EventsResponse.cs index 1977dd65d67..8c078804ca4 100644 --- a/src/generated/Me/Events/Item/Calendar/Events/EventsResponse.cs +++ b/src/generated/Me/Events/Item/Calendar/Events/EventsResponse.cs @@ -9,7 +9,7 @@ public class EventsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new eventsResponse and sets the default values. /// @@ -22,7 +22,7 @@ public EventsResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as EventsResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Me/Events/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs index d086c24ba73..3f3a10d272e 100644 --- a/src/generated/Me/Events/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs index bdc966e5cd4..b67f3d7d014 100644 --- a/src/generated/Me/Events/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs index 9dd2e69d74b..25576d130b3 100644 --- a/src/generated/Me/Events/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs index 6452debf750..f4674e395f1 100644 --- a/src/generated/Me/Events/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,11 +33,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string eventId, string eventId1) => { + command.SetHandler(async (string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Calendar/Events/Item/EventRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/Events/Item/EventRequestBuilder.cs index 97f84f35d04..6cbd4aaa98a 100644 --- a/src/generated/Me/Events/Item/Calendar/Events/Item/EventRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/Events/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -59,11 +59,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string eventId, string eventId1) => { + command.SetHandler(async (string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option); return command; @@ -100,19 +99,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -213,7 +210,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -225,42 +222,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The events in the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/Events/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs index 3c5f86b9d21..e4c1654fc17 100644 --- a/src/generated/Me/Events/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 9e3557083a3..0a33bd91b0b 100644 --- a/src/generated/Me/Events/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index fb4a9afcd11..f8914a34ddc 100644 --- a/src/generated/Me/Events/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs index c8dad52e315..7f66372b85e 100644 --- a/src/generated/Me/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetScheduleRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSchedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetScheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index b1dc7bb6b39..ccdb8deb8d4 100644 --- a/src/generated/Me/Events/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Events/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index c824a61f798..223b0a33e5d 100644 --- a/src/generated/Me/Events/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Events/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 3e5c3d3ef8a..491bc8aa358 100644 --- a/src/generated/Me/Events/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Events/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/Events/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 339979dbd35..e5a9ce2bbb6 100644 --- a/src/generated/Me/Events/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Events/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Me/Events/Item/Cancel/CancelRequestBuilder.cs index e8ee4aab0f2..05ec09c661a 100644 --- a/src/generated/Me/Events/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Me/Events/Item/Decline/DeclineRequestBuilder.cs index 51f8e7bca0f..c404e409d1c 100644 --- a/src/generated/Me/Events/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Me/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs index 23e49cf94b5..fd705178ab5 100644 --- a/src/generated/Me/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Me/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,10 @@ public Command BuildPostCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string eventId) => { + command.SetHandler(async (string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/EventRequestBuilder.cs b/src/generated/Me/Events/Item/EventRequestBuilder.cs index 3b63995321b..f000d56e5f3 100644 --- a/src/generated/Me/Events/Item/EventRequestBuilder.cs +++ b/src/generated/Me/Events/Item/EventRequestBuilder.cs @@ -14,10 +14,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,6 +41,9 @@ public Command BuildAcceptCommand() { public Command BuildAttachmentsCommand() { var command = new Command("attachments"); var builder = new ApiSdk.Me.Events.Item.Attachments.AttachmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateUploadSessionCommand()); command.AddCommand(builder.BuildListCommand()); @@ -83,11 +86,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string eventId) => { + command.SetHandler(async (string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption); return command; @@ -101,6 +103,9 @@ public Command BuildDismissReminderCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Me.Events.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -127,24 +132,26 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, selectOption, outputOption); return command; } public Command BuildInstancesCommand() { var command = new Command("instances"); var builder = new ApiSdk.Me.Events.Item.Instances.InstancesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -152,6 +159,9 @@ public Command BuildInstancesCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Me.Events.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -171,14 +181,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -186,6 +195,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Me.Events.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -257,7 +269,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -269,42 +281,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The user's events. Default is to show events under the Default Calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's events. Default is to show events under the Default Calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's events. Default is to show events under the Default Calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's events. Default is to show events under the Default Calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/Events/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Me/Events/Item/Extensions/ExtensionsRequestBuilder.cs index 7fed35f6655..238b85ca55b 100644 --- a/src/generated/Me/Events/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -103,7 +101,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -113,15 +115,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -176,31 +173,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Me/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs index d7d068aa189..dbbb4d25fb1 100644 --- a/src/generated/Me/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string eventId, string extensionId) => { + command.SetHandler(async (string eventId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, extensionIdOption); return command; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string extensionId, string body) => { + command.SetHandler(async (string eventId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, extensionIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Events/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Me/Events/Item/Forward/ForwardRequestBuilder.cs index e769b9f04f6..e8c4b331cd3 100644 --- a/src/generated/Me/Events/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Instances/Delta/Delta.cs b/src/generated/Me/Events/Item/Instances/Delta/Delta.cs deleted file mode 100644 index 4e5d1968115..00000000000 --- a/src/generated/Me/Events/Item/Instances/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.Events.Item.Instances.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Me/Events/Item/Instances/Delta/DeltaRequestBuilder.cs b/src/generated/Me/Events/Item/Instances/Delta/DeltaRequestBuilder.cs index 86e04be01c7..134115bb6a9 100644 --- a/src/generated/Me/Events/Item/Instances/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Instances/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +30,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Instances/InstancesRequestBuilder.cs b/src/generated/Me/Events/Item/Instances/InstancesRequestBuilder.cs index ef24564dbb6..1d27ca3e827 100644 --- a/src/generated/Me/Events/Item/Instances/InstancesRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Instances/InstancesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class InstancesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -106,7 +104,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -115,15 +117,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -166,7 +163,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Events/Item/Instances/InstancesResponse.cs b/src/generated/Me/Events/Item/Instances/InstancesResponse.cs index 50d467d53d0..bd62884c868 100644 --- a/src/generated/Me/Events/Item/Instances/InstancesResponse.cs +++ b/src/generated/Me/Events/Item/Instances/InstancesResponse.cs @@ -9,7 +9,7 @@ public class InstancesResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new instancesResponse and sets the default values. /// @@ -22,7 +22,7 @@ public InstancesResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as InstancesResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Me/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Me/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs index fd6a335f061..be2c04dc3af 100644 --- a/src/generated/Me/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Me/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs index 5cf79910ecb..ca3956d4dff 100644 --- a/src/generated/Me/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Me/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs index be76bb60132..8bf95512d91 100644 --- a/src/generated/Me/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Me/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs index c689a18cbf5..6eafb9e6817 100644 --- a/src/generated/Me/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,11 +33,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string eventId, string eventId1) => { + command.SetHandler(async (string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Instances/Item/EventRequestBuilder.cs b/src/generated/Me/Events/Item/Instances/Item/EventRequestBuilder.cs index 517dc23af1e..ed4c37613b9 100644 --- a/src/generated/Me/Events/Item/Instances/Item/EventRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Instances/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -59,11 +59,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string eventId, string eventId1) => { + command.SetHandler(async (string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option); return command; @@ -100,19 +99,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -213,7 +210,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -225,42 +222,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Me/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs index 48a5d31bbaf..5ca81c3ff19 100644 --- a/src/generated/Me/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Me/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 03ec5ccf3ec..e56802267dd 100644 --- a/src/generated/Me/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Me/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index a71dd859f39..857458f73dc 100644 --- a/src/generated/Me/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Me/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string eventId1, string body) => { + command.SetHandler(async (string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, eventId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 9feffafb6d9..67f5134b442 100644 --- a/src/generated/Me/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string eventId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 372a6eb68bd..26c1c47d91a 100644 --- a/src/generated/Me/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index ae12e0cc8ec..b1916be82f3 100644 --- a/src/generated/Me/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string eventId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index e5ceee08fe6..41222161315 100644 --- a/src/generated/Me/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Me/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 354cb3fb291..997f0309a5e 100644 --- a/src/generated/Me/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Me/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Me/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index caa69be3e34..ba694b89f53 100644 --- a/src/generated/Me/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Me/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string eventId, string body) => { + command.SetHandler(async (string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, eventIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/ExportPersonalData/ExportPersonalDataRequestBuilder.cs b/src/generated/Me/ExportPersonalData/ExportPersonalDataRequestBuilder.cs index 3f63ed3832d..0b99f05e987 100644 --- a/src/generated/Me/ExportPersonalData/ExportPersonalDataRequestBuilder.cs +++ b/src/generated/Me/ExportPersonalData/ExportPersonalDataRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,14 +29,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -72,18 +71,5 @@ public RequestInformation CreatePostRequestInformation(ExportPersonalDataRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action exportPersonalData - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ExportPersonalDataRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Me/Extensions/ExtensionsRequestBuilder.cs index 4350331666d..fe67e4a04ab 100644 --- a/src/generated/Me/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Me/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the user. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the user. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the user. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Me/Extensions/Item/ExtensionRequestBuilder.cs index 34100b27846..03e3804bf96 100644 --- a/src/generated/Me/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Me/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string extensionId) => { + command.SetHandler(async (string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, extensionIdOption); return command; @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string extensionId, string body) => { + command.SetHandler(async (string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, extensionIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the user. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the user. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the user. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the user. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/FindMeetingTimes/FindMeetingTimesRequestBody.cs b/src/generated/Me/FindMeetingTimes/FindMeetingTimesRequestBody.cs index bf90fe3aafc..a52610c22af 100644 --- a/src/generated/Me/FindMeetingTimes/FindMeetingTimesRequestBody.cs +++ b/src/generated/Me/FindMeetingTimes/FindMeetingTimesRequestBody.cs @@ -12,7 +12,7 @@ public class FindMeetingTimesRequestBody : IParsable { public bool? IsOrganizerOptional { get; set; } public LocationConstraint LocationConstraint { get; set; } public int? MaxCandidates { get; set; } - public string MeetingDuration { get; set; } + public TimeSpan? MeetingDuration { get; set; } public double? MinimumAttendeePercentage { get; set; } public bool? ReturnSuggestionReasons { get; set; } public TimeConstraint TimeConstraint { get; set; } @@ -31,7 +31,7 @@ public IDictionary> GetFieldDeserializers() { {"isOrganizerOptional", (o,n) => { (o as FindMeetingTimesRequestBody).IsOrganizerOptional = n.GetBoolValue(); } }, {"locationConstraint", (o,n) => { (o as FindMeetingTimesRequestBody).LocationConstraint = n.GetObjectValue(); } }, {"maxCandidates", (o,n) => { (o as FindMeetingTimesRequestBody).MaxCandidates = n.GetIntValue(); } }, - {"meetingDuration", (o,n) => { (o as FindMeetingTimesRequestBody).MeetingDuration = n.GetStringValue(); } }, + {"meetingDuration", (o,n) => { (o as FindMeetingTimesRequestBody).MeetingDuration = n.GetTimeSpanValue(); } }, {"minimumAttendeePercentage", (o,n) => { (o as FindMeetingTimesRequestBody).MinimumAttendeePercentage = n.GetDoubleValue(); } }, {"returnSuggestionReasons", (o,n) => { (o as FindMeetingTimesRequestBody).ReturnSuggestionReasons = n.GetBoolValue(); } }, {"timeConstraint", (o,n) => { (o as FindMeetingTimesRequestBody).TimeConstraint = n.GetObjectValue(); } }, @@ -47,7 +47,7 @@ public void Serialize(ISerializationWriter writer) { writer.WriteBoolValue("isOrganizerOptional", IsOrganizerOptional); writer.WriteObjectValue("locationConstraint", LocationConstraint); writer.WriteIntValue("maxCandidates", MaxCandidates); - writer.WriteStringValue("meetingDuration", MeetingDuration); + writer.WriteTimeSpanValue("meetingDuration", MeetingDuration); writer.WriteDoubleValue("minimumAttendeePercentage", MinimumAttendeePercentage); writer.WriteBoolValue("returnSuggestionReasons", ReturnSuggestionReasons); writer.WriteObjectValue("timeConstraint", TimeConstraint); diff --git a/src/generated/Me/FindMeetingTimes/FindMeetingTimesRequestBuilder.cs b/src/generated/Me/FindMeetingTimes/FindMeetingTimesRequestBuilder.cs index f9d2f14bc34..8a5df00c6b8 100644 --- a/src/generated/Me/FindMeetingTimes/FindMeetingTimesRequestBuilder.cs +++ b/src/generated/Me/FindMeetingTimes/FindMeetingTimesRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -78,19 +77,6 @@ public RequestInformation CreatePostRequestInformation(FindMeetingTimesRequestBo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action findMeetingTimes - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(FindMeetingTimesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes meetingTimeSuggestionsResult public class FindMeetingTimesResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/FollowedSites/@Ref/@Ref.cs b/src/generated/Me/FollowedSites/@Ref/@Ref.cs deleted file mode 100644 index c342579c983..00000000000 --- a/src/generated/Me/FollowedSites/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.FollowedSites.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/FollowedSites/@Ref/RefRequestBuilder.cs b/src/generated/Me/FollowedSites/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 03d05e63a57..00000000000 --- a/src/generated/Me/FollowedSites/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,194 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Me.FollowedSites.@Ref { - /// Builds and executes requests for operations under \me\followedSites\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Get ref of followedSites from me - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Get ref of followedSites from me"; - // Create options for all the parameters - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Create new navigation property ref to followedSites for me - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Create new navigation property ref to followedSites for me"; - // Create options for all the parameters - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/followedSites/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Get ref of followedSites from me - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Create new navigation property ref to followedSites for me - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Me.FollowedSites.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Get ref of followedSites from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property ref to followedSites for me - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Me.FollowedSites.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Get ref of followedSites from me - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Me/FollowedSites/@Ref/RefResponse.cs b/src/generated/Me/FollowedSites/@Ref/RefResponse.cs deleted file mode 100644 index faff8fcc7a1..00000000000 --- a/src/generated/Me/FollowedSites/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.FollowedSites.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/FollowedSites/FollowedSitesRequestBuilder.cs b/src/generated/Me/FollowedSites/FollowedSitesRequestBuilder.cs index b0eab793035..a98b25d4be4 100644 --- a/src/generated/Me/FollowedSites/FollowedSitesRequestBuilder.cs +++ b/src/generated/Me/FollowedSites/FollowedSitesRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Me.FollowedSites.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -61,7 +61,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -72,20 +76,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Me.FollowedSites.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Me.FollowedSites.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -124,18 +123,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get followedSites from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get followedSites from me public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/FollowedSites/Ref/Ref.cs b/src/generated/Me/FollowedSites/Ref/Ref.cs new file mode 100644 index 00000000000..bdc3de63d6e --- /dev/null +++ b/src/generated/Me/FollowedSites/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.FollowedSites.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/FollowedSites/Ref/RefRequestBuilder.cs b/src/generated/Me/FollowedSites/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..69c9d7d5dda --- /dev/null +++ b/src/generated/Me/FollowedSites/Ref/RefRequestBuilder.cs @@ -0,0 +1,167 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Me.FollowedSites.Ref { + /// Builds and executes requests for operations under \me\followedSites\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Get ref of followedSites from me + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Get ref of followedSites from me"; + // Create options for all the parameters + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Create new navigation property ref to followedSites for me + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Create new navigation property ref to followedSites for me"; + // Create options for all the parameters + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/me/followedSites/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Get ref of followedSites from me + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Create new navigation property ref to followedSites for me + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Me.FollowedSites.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Get ref of followedSites from me + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Me/FollowedSites/Ref/RefResponse.cs b/src/generated/Me/FollowedSites/Ref/RefResponse.cs new file mode 100644 index 00000000000..734eb66bf6f --- /dev/null +++ b/src/generated/Me/FollowedSites/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.FollowedSites.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/GetMailTips/GetMailTips.cs b/src/generated/Me/GetMailTips/GetMailTips.cs deleted file mode 100644 index 25fc2f36883..00000000000 --- a/src/generated/Me/GetMailTips/GetMailTips.cs +++ /dev/null @@ -1,81 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.GetMailTips { - public class GetMailTips : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Mail tips for automatic reply if it has been set up by the recipient. - public AutomaticRepliesMailTips AutomaticReplies { get; set; } - /// A custom mail tip that can be set on the recipient's mailbox. - public string CustomMailTip { get; set; } - /// Whether the recipient's mailbox is restricted, for example, accepting messages from only a predefined list of senders, rejecting messages from a predefined list of senders, or accepting messages from only authenticated senders. - public bool? DeliveryRestricted { get; set; } - /// The email address of the recipient to get mailtips for. - public EmailAddress EmailAddress { get; set; } - /// Errors that occur during the getMailTips action. - public MailTipsError Error { get; set; } - /// The number of external members if the recipient is a distribution list. - public int? ExternalMemberCount { get; set; } - /// Whether sending messages to the recipient requires approval. For example, if the recipient is a large distribution list and a moderator has been set up to approve messages sent to that distribution list, or if sending messages to a recipient requires approval of the recipient's manager. - public bool? IsModerated { get; set; } - /// The mailbox full status of the recipient. - public bool? MailboxFull { get; set; } - /// The maximum message size that has been configured for the recipient's organization or mailbox. - public int? MaxMessageSize { get; set; } - /// The scope of the recipient. Possible values are: none, internal, external, externalPartner, externalNonParther. For example, an administrator can set another organization to be its 'partner'. The scope is useful if an administrator wants certain mailtips to be accessible to certain scopes. It's also useful to senders to inform them that their message may leave the organization, helping them make the correct decisions about wording, tone and content. - public RecipientScopeType? RecipientScope { get; set; } - /// Recipients suggested based on previous contexts where they appear in the same message. - public List RecipientSuggestions { get; set; } - /// The number of members if the recipient is a distribution list. - public int? TotalMemberCount { get; set; } - /// - /// Instantiates a new getMailTips and sets the default values. - /// - public GetMailTips() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"automaticReplies", (o,n) => { (o as GetMailTips).AutomaticReplies = n.GetObjectValue(); } }, - {"customMailTip", (o,n) => { (o as GetMailTips).CustomMailTip = n.GetStringValue(); } }, - {"deliveryRestricted", (o,n) => { (o as GetMailTips).DeliveryRestricted = n.GetBoolValue(); } }, - {"emailAddress", (o,n) => { (o as GetMailTips).EmailAddress = n.GetObjectValue(); } }, - {"error", (o,n) => { (o as GetMailTips).Error = n.GetObjectValue(); } }, - {"externalMemberCount", (o,n) => { (o as GetMailTips).ExternalMemberCount = n.GetIntValue(); } }, - {"isModerated", (o,n) => { (o as GetMailTips).IsModerated = n.GetBoolValue(); } }, - {"mailboxFull", (o,n) => { (o as GetMailTips).MailboxFull = n.GetBoolValue(); } }, - {"maxMessageSize", (o,n) => { (o as GetMailTips).MaxMessageSize = n.GetIntValue(); } }, - {"recipientScope", (o,n) => { (o as GetMailTips).RecipientScope = n.GetEnumValue(); } }, - {"recipientSuggestions", (o,n) => { (o as GetMailTips).RecipientSuggestions = n.GetCollectionOfObjectValues().ToList(); } }, - {"totalMemberCount", (o,n) => { (o as GetMailTips).TotalMemberCount = n.GetIntValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("automaticReplies", AutomaticReplies); - writer.WriteStringValue("customMailTip", CustomMailTip); - writer.WriteBoolValue("deliveryRestricted", DeliveryRestricted); - writer.WriteObjectValue("emailAddress", EmailAddress); - writer.WriteObjectValue("error", Error); - writer.WriteIntValue("externalMemberCount", ExternalMemberCount); - writer.WriteBoolValue("isModerated", IsModerated); - writer.WriteBoolValue("mailboxFull", MailboxFull); - writer.WriteIntValue("maxMessageSize", MaxMessageSize); - writer.WriteEnumValue("recipientScope", RecipientScope); - writer.WriteCollectionOfObjectValues("recipientSuggestions", RecipientSuggestions); - writer.WriteIntValue("totalMemberCount", TotalMemberCount); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/GetMailTips/GetMailTipsRequestBuilder.cs b/src/generated/Me/GetMailTips/GetMailTipsRequestBuilder.cs index 7a7c4240d04..cdd1fb3b1c3 100644 --- a/src/generated/Me/GetMailTips/GetMailTipsRequestBuilder.cs +++ b/src/generated/Me/GetMailTips/GetMailTipsRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(GetMailTipsRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMailTips - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMailTipsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/GetManagedAppDiagnosticStatuses/GetManagedAppDiagnosticStatusesRequestBuilder.cs b/src/generated/Me/GetManagedAppDiagnosticStatuses/GetManagedAppDiagnosticStatusesRequestBuilder.cs index 768f6a18ee8..76fd9612551 100644 --- a/src/generated/Me/GetManagedAppDiagnosticStatuses/GetManagedAppDiagnosticStatusesRequestBuilder.cs +++ b/src/generated/Me/GetManagedAppDiagnosticStatuses/GetManagedAppDiagnosticStatusesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Gets diagnostics validation status for a given user."; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Gets diagnostics validation status for a given user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/GetManagedAppPolicies/GetManagedAppPoliciesRequestBuilder.cs b/src/generated/Me/GetManagedAppPolicies/GetManagedAppPoliciesRequestBuilder.cs index b4878fb0b3b..2485161eb44 100644 --- a/src/generated/Me/GetManagedAppPolicies/GetManagedAppPoliciesRequestBuilder.cs +++ b/src/generated/Me/GetManagedAppPolicies/GetManagedAppPoliciesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Gets app restrictions for a given user."; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Gets app restrictions for a given user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/GetMemberGroups/GetMemberGroupsRequestBuilder.cs b/src/generated/Me/GetMemberGroups/GetMemberGroupsRequestBuilder.cs index 67e09b931f2..c5c9260ee5c 100644 --- a/src/generated/Me/GetMemberGroups/GetMemberGroupsRequestBuilder.cs +++ b/src/generated/Me/GetMemberGroups/GetMemberGroupsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +29,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +76,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberGroupsRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/GetMemberObjects/GetMemberObjectsRequestBuilder.cs b/src/generated/Me/GetMemberObjects/GetMemberObjectsRequestBuilder.cs index 52f840db5e7..987ac7e1ea1 100644 --- a/src/generated/Me/GetMemberObjects/GetMemberObjectsRequestBuilder.cs +++ b/src/generated/Me/GetMemberObjects/GetMemberObjectsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +29,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +76,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberObjectsRequestBo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/InferenceClassification/InferenceClassificationRequestBuilder.cs b/src/generated/Me/InferenceClassification/InferenceClassificationRequestBuilder.cs index a58c2cdea29..64ea808e0ef 100644 --- a/src/generated/Me/InferenceClassification/InferenceClassificationRequestBuilder.cs +++ b/src/generated/Me/InferenceClassification/InferenceClassificationRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,11 +27,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Relevance classification of the user's messages based on explicit designations which override inferred relevance or importance."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -48,24 +47,26 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, outputOption); return command; } public Command BuildOverridesCommand() { var command = new Command("overrides"); var builder = new ApiSdk.Me.InferenceClassification.Overrides.OverridesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -81,14 +82,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -160,42 +160,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Relevance classification of the user's messages based on explicit designations which override inferred relevance or importance. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Relevance classification of the user's messages based on explicit designations which override inferred relevance or importance. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Relevance classification of the user's messages based on explicit designations which override inferred relevance or importance. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.InferenceClassification model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Relevance classification of the user's messages based on explicit designations which override inferred relevance or importance. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/InferenceClassification/Overrides/Item/InferenceClassificationOverrideRequestBuilder.cs b/src/generated/Me/InferenceClassification/Overrides/Item/InferenceClassificationOverrideRequestBuilder.cs index ec09a3d1c45..f61ae1319c2 100644 --- a/src/generated/Me/InferenceClassification/Overrides/Item/InferenceClassificationOverrideRequestBuilder.cs +++ b/src/generated/Me/InferenceClassification/Overrides/Item/InferenceClassificationOverrideRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "A set of overrides for a user to always classify messages from specific senders in certain ways: focused, or other. Read-only. Nullable."; // Create options for all the parameters - var inferenceClassificationOverrideIdOption = new Option("--inferenceclassificationoverride-id", description: "key: id of inferenceClassificationOverride") { + var inferenceClassificationOverrideIdOption = new Option("--inference-classification-override-id", description: "key: id of inferenceClassificationOverride") { }; inferenceClassificationOverrideIdOption.IsRequired = true; command.AddOption(inferenceClassificationOverrideIdOption); - command.SetHandler(async (string inferenceClassificationOverrideId) => { + command.SetHandler(async (string inferenceClassificationOverrideId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, inferenceClassificationOverrideIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "A set of overrides for a user to always classify messages from specific senders in certain ways: focused, or other. Read-only. Nullable."; // Create options for all the parameters - var inferenceClassificationOverrideIdOption = new Option("--inferenceclassificationoverride-id", description: "key: id of inferenceClassificationOverride") { + var inferenceClassificationOverrideIdOption = new Option("--inference-classification-override-id", description: "key: id of inferenceClassificationOverride") { }; inferenceClassificationOverrideIdOption.IsRequired = true; command.AddOption(inferenceClassificationOverrideIdOption); @@ -55,19 +54,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string inferenceClassificationOverrideId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string inferenceClassificationOverrideId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, inferenceClassificationOverrideIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, inferenceClassificationOverrideIdOption, selectOption, outputOption); return command; } /// @@ -77,7 +75,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "A set of overrides for a user to always classify messages from specific senders in certain ways: focused, or other. Read-only. Nullable."; // Create options for all the parameters - var inferenceClassificationOverrideIdOption = new Option("--inferenceclassificationoverride-id", description: "key: id of inferenceClassificationOverride") { + var inferenceClassificationOverrideIdOption = new Option("--inference-classification-override-id", description: "key: id of inferenceClassificationOverride") { }; inferenceClassificationOverrideIdOption.IsRequired = true; command.AddOption(inferenceClassificationOverrideIdOption); @@ -85,14 +83,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string inferenceClassificationOverrideId, string body) => { + command.SetHandler(async (string inferenceClassificationOverrideId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, inferenceClassificationOverrideIdOption, bodyOption); return command; @@ -164,42 +161,6 @@ public RequestInformation CreatePatchRequestInformation(InferenceClassificationO requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A set of overrides for a user to always classify messages from specific senders in certain ways: focused, or other. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A set of overrides for a user to always classify messages from specific senders in certain ways: focused, or other. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A set of overrides for a user to always classify messages from specific senders in certain ways: focused, or other. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(InferenceClassificationOverride model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A set of overrides for a user to always classify messages from specific senders in certain ways: focused, or other. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/InferenceClassification/Overrides/OverridesRequestBuilder.cs b/src/generated/Me/InferenceClassification/Overrides/OverridesRequestBuilder.cs index ce92460e98b..99ac6ec8a39 100644 --- a/src/generated/Me/InferenceClassification/Overrides/OverridesRequestBuilder.cs +++ b/src/generated/Me/InferenceClassification/Overrides/OverridesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class OverridesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new InferenceClassificationOverrideRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -90,7 +88,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -99,15 +101,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -162,31 +159,6 @@ public RequestInformation CreatePostRequestInformation(InferenceClassificationOv requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A set of overrides for a user to always classify messages from specific senders in certain ways: focused, or other. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A set of overrides for a user to always classify messages from specific senders in certain ways: focused, or other. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(InferenceClassificationOverride model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A set of overrides for a user to always classify messages from specific senders in certain ways: focused, or other. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Insights/InsightsRequestBuilder.cs b/src/generated/Me/Insights/InsightsRequestBuilder.cs index 59dbf9f94a9..77e235bf19f 100644 --- a/src/generated/Me/Insights/InsightsRequestBuilder.cs +++ b/src/generated/Me/Insights/InsightsRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -55,20 +54,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -82,14 +80,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -97,6 +94,9 @@ public Command BuildPatchCommand() { public Command BuildSharedCommand() { var command = new Command("shared"); var builder = new ApiSdk.Me.Insights.Shared.SharedRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -104,6 +104,9 @@ public Command BuildSharedCommand() { public Command BuildTrendingCommand() { var command = new Command("trending"); var builder = new ApiSdk.Me.Insights.Trending.TrendingRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -111,6 +114,9 @@ public Command BuildTrendingCommand() { public Command BuildUsedCommand() { var command = new Command("used"); var builder = new ApiSdk.Me.Insights.Used.UsedRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -182,42 +188,6 @@ public RequestInformation CreatePatchRequestInformation(OfficeGraphInsights body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OfficeGraphInsights model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/@Ref/@Ref.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/@Ref/@Ref.cs deleted file mode 100644 index afab824b5ae..00000000000 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/@Ref/RefRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/@Ref/RefRequestBuilder.cs deleted file mode 100644 index d29abb3e9f5..00000000000 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.@Ref { - /// Builds and executes requests for operations under \me\insights\shared\{sharedInsight-id}\lastSharedMethod\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Delete ref of navigation property lastSharedMethod for me - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Delete ref of navigation property lastSharedMethod for me"; - // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { - }; - sharedInsightIdOption.IsRequired = true; - command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, sharedInsightIdOption); - return command; - } - /// - /// Get ref of lastSharedMethod from me - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Get ref of lastSharedMethod from me"; - // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { - }; - sharedInsightIdOption.IsRequired = true; - command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); - return command; - } - /// - /// Update the ref of navigation property lastSharedMethod in me - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Update the ref of navigation property lastSharedMethod in me"; - // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { - }; - sharedInsightIdOption.IsRequired = true; - command.AddOption(sharedInsightIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, sharedInsightIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/shared/{sharedInsight_id}/lastSharedMethod/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Delete ref of navigation property lastSharedMethod for me - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Get ref of lastSharedMethod from me - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Update the ref of navigation property lastSharedMethod in me - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Delete ref of navigation property lastSharedMethod for me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get ref of lastSharedMethod from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the ref of navigation property lastSharedMethod in me - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs index 1daddfd2cc2..5ecafb62044 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action accept"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,16 +71,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs index 11ee1dd6ce5..c9fc66e56b6 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.CalendarSharingMessage.Accept; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/LastSharedMethodRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/LastSharedMethodRequestBuilder.cs index 1574677b5d0..5a97aff706d 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/LastSharedMethodRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/LastSharedMethodRequestBuilder.cs @@ -15,10 +15,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -46,7 +46,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get lastSharedMethod from me"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -60,20 +60,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedInsightId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildManagedAppProtectionCommand() { @@ -106,7 +105,7 @@ public Command BuildPrintJobCommand() { } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -200,18 +199,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get lastSharedMethod from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get lastSharedMethod from me public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs index ca252dd7939..6b3ee582e20 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.ManagedAppProtection.TargetApps; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs index c68e6b67ef0..5d011245e57 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action targetApps"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + command.SetHandler(async (string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(TargetAppsRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action targetApps - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetAppsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/MobileAppContentFile/Commit/CommitRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/MobileAppContentFile/Commit/CommitRequestBuilder.cs index 7c3b18a4669..ca58b239cc1 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/MobileAppContentFile/Commit/CommitRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/MobileAppContentFile/Commit/CommitRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Commits a file of a given app."; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + command.SetHandler(async (string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(CommitRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Commits a file of a given app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CommitRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs index 65b4ca625a5..b19b56e9023 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.MobileAppContentFile.Commit; using ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.MobileAppContentFile.RenewUpload; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs index 824dd7e2cff..9583d7b693c 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Renews the SAS URI for an application file upload."; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + command.SetHandler(async (string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Renews the SAS URI for an application file upload. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index 76d061bd484..65a66222bf4 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action createUploadSession"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintDocument/PrintDocumentRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintDocument/PrintDocumentRequestBuilder.cs index 4f3e401a203..d03cd241be8 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintDocument/PrintDocumentRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintDocument/PrintDocumentRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.PrintDocument.CreateUploadSession; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintJob/Abort/AbortRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintJob/Abort/AbortRequestBuilder.cs index 1d8a8c91eed..3ad21527ea0 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintJob/Abort/AbortRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintJob/Abort/AbortRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action abort"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + command.SetHandler(async (string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(AbortRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action abort - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AbortRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintJob/Cancel/CancelRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintJob/Cancel/CancelRequestBuilder.cs index 1e03a9be9bc..48dedfa9e02 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintJob/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintJob/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action cancel"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + command.SetHandler(async (string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintJob/PrintJobRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintJob/PrintJobRequestBuilder.cs index d3cccdac906..9327089655a 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintJob/PrintJobRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintJob/PrintJobRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.PrintJob.Redirect; using ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.PrintJob.Start; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintJob/Redirect/RedirectRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintJob/Redirect/RedirectRequestBuilder.cs index 00fad284c5f..b025080c0f6 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintJob/Redirect/RedirectRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintJob/Redirect/RedirectRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action redirect"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(RedirectRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action redirect - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RedirectRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes printJob public class RedirectResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintJob/Start/StartRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintJob/Start/StartRequestBuilder.cs index ee8bae38224..a228e5c0afa 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintJob/Start/StartRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/PrintJob/Start/StartRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action start"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action start - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes printJobStatus public class StartResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/Ref/Ref.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/Ref/Ref.cs new file mode 100644 index 00000000000..3d6d5e6672d --- /dev/null +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/Ref/RefRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..ff18dbd0366 --- /dev/null +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.Ref { + /// Builds and executes requests for operations under \me\insights\shared\{sharedInsight-id}\lastSharedMethod\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Delete ref of navigation property lastSharedMethod for me + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Delete ref of navigation property lastSharedMethod for me"; + // Create options for all the parameters + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { + }; + sharedInsightIdOption.IsRequired = true; + command.AddOption(sharedInsightIdOption); + command.SetHandler(async (string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, sharedInsightIdOption); + return command; + } + /// + /// Get ref of lastSharedMethod from me + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Get ref of lastSharedMethod from me"; + // Create options for all the parameters + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { + }; + sharedInsightIdOption.IsRequired = true; + command.AddOption(sharedInsightIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); + return command; + } + /// + /// Update the ref of navigation property lastSharedMethod in me + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Update the ref of navigation property lastSharedMethod in me"; + // Create options for all the parameters + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { + }; + sharedInsightIdOption.IsRequired = true; + command.AddOption(sharedInsightIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, sharedInsightIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/me/insights/shared/{sharedInsight_id}/lastSharedMethod/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Delete ref of navigation property lastSharedMethod for me + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Get ref of lastSharedMethod from me + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Update the ref of navigation property lastSharedMethod in me + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs index 28d4364be6f..25ace052e96 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action approve"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + command.SetHandler(async (string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ApproveRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action approve - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApproveRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs index 8f9ebb60e6a..cfcabcfab42 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action decline"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + command.SetHandler(async (string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs index 034b57ecdf0..ad033b61517 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.ScheduleChangeRequest.Approve; using ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.ScheduleChangeRequest.Decline; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs index aa995b9a8d2..b9f18e9c98d 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action assign"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + command.SetHandler(async (string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs index a45f31d2710..8707fc66a39 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action targetApps"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + command.SetHandler(async (string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(TargetAppsRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action targetApps - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetAppsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs index 621c89e3fd4..513089a1056 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.TargetedManagedAppProtection.Assign; using ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.TargetedManagedAppProtection.TargetApps; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WindowsInformationProtection/Assign/AssignRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WindowsInformationProtection/Assign/AssignRequestBuilder.cs index 0cb82fadf6c..9976450e113 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WindowsInformationProtection/Assign/AssignRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WindowsInformationProtection/Assign/AssignRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action assign"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + command.SetHandler(async (string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs index 002dace36d0..d66e16b9671 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.WindowsInformationProtection.Assign; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs index f152d5f0622..8562e1fee0d 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function boundingRect"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - var anotherRangeOption = new Option("--anotherrange", description: "Usage: anotherRange={anotherRange}") { + var anotherRangeOption = new Option("--another-range", description: "Usage: anotherRange={anotherRange}") { }; anotherRangeOption.IsRequired = true; command.AddOption(anotherRangeOption); - command.SetHandler(async (string sharedInsightId, string anotherRange) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, string anotherRange, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, anotherRangeOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, anotherRangeOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function boundingRect - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class BoundingRectWithAnotherRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs index 6ee4dc3e664..1d3acd4cc02 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function cell"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string sharedInsightId, int? row, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, int? row, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, rowOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, rowOption, columnOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function cell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class CellWithRowWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Clear/ClearRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Clear/ClearRequestBuilder.cs index a25ce952f77..fbe06d40678 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Clear/ClearRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + command.SetHandler(async (string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ClearRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ClearRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs index 65c63ad30e4..5660f38eae8 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function column"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -34,18 +34,17 @@ public Command BuildGetCommand() { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string sharedInsightId, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, columnOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function column - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs index 87e939de1fa..6dbf4acace3 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function columnsAfter"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsAfter - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsAfterResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs index bd6831e4686..28ab1dbc5b9 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function columnsAfter"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -34,18 +34,17 @@ public Command BuildGetCommand() { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string sharedInsightId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, countOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsAfter - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsAfterWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs index 08799ab0e49..5c1645b7008 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function columnsBefore"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsBefore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsBeforeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs index 8af54bb81cb..e838b0cb41f 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function columnsBefore"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -34,18 +34,17 @@ public Command BuildGetCommand() { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string sharedInsightId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, countOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsBefore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsBeforeWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Delete/DeleteRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Delete/DeleteRequestBuilder.cs index c8d33a3a106..b58348a8fbb 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Delete/DeleteRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Delete/DeleteRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action delete"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + command.SetHandler(async (string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(DeleteRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action delete - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeleteRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs index ca006093efd..be0cd68e4e9 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function entireColumn"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function entireColumn - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class EntireColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs index 5aae6345b12..5cc6e9a67c7 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function entireRow"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function entireRow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class EntireRowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Insert/InsertRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Insert/InsertRequestBuilder.cs index be883f363c8..9c153734493 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Insert/InsertRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Insert/InsertRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action insert"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(InsertRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action insert - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(InsertRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class InsertResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs index bc12e2e029a..4c6b172c442 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function intersection"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - var anotherRangeOption = new Option("--anotherrange", description: "Usage: anotherRange={anotherRange}") { + var anotherRangeOption = new Option("--another-range", description: "Usage: anotherRange={anotherRange}") { }; anotherRangeOption.IsRequired = true; command.AddOption(anotherRangeOption); - command.SetHandler(async (string sharedInsightId, string anotherRange) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, string anotherRange, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, anotherRangeOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, anotherRangeOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function intersection - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class IntersectionWithAnotherRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/LastCell/LastCellRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/LastCell/LastCellRequestBuilder.cs index efe9ba2a8f4..e176f85529e 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/LastCell/LastCellRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/LastCell/LastCellRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function lastCell"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function lastCell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class LastCellResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs index 5cdd3d890fa..701f8ff3a1b 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function lastColumn"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function lastColumn - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class LastColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/LastRow/LastRowRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/LastRow/LastRowRequestBuilder.cs index e4c78d80131..9bc9bc8f0cf 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/LastRow/LastRowRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/LastRow/LastRowRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function lastRow"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function lastRow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class LastRowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Merge/MergeRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Merge/MergeRequestBuilder.cs index e9ab5ac3e1f..3dffb066730 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Merge/MergeRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Merge/MergeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action merge"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + command.SetHandler(async (string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(MergeRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action merge - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MergeRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs index 0e6baaa867e..308fc2853a1 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function offsetRange"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - var rowOffsetOption = new Option("--rowoffset", description: "Usage: rowOffset={rowOffset}") { + var rowOffsetOption = new Option("--row-offset", description: "Usage: rowOffset={rowOffset}") { }; rowOffsetOption.IsRequired = true; command.AddOption(rowOffsetOption); - var columnOffsetOption = new Option("--columnoffset", description: "Usage: columnOffset={columnOffset}") { + var columnOffsetOption = new Option("--column-offset", description: "Usage: columnOffset={columnOffset}") { }; columnOffsetOption.IsRequired = true; command.AddOption(columnOffsetOption); - command.SetHandler(async (string sharedInsightId, int? rowOffset, int? columnOffset) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, int? rowOffset, int? columnOffset, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, rowOffsetOption, columnOffsetOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, rowOffsetOption, columnOffsetOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function offsetRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class OffsetRangeWithRowOffsetWithColumnOffsetResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs index 59c831fa66f..8c963ed18cb 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function resizedRange"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - var deltaRowsOption = new Option("--deltarows", description: "Usage: deltaRows={deltaRows}") { + var deltaRowsOption = new Option("--delta-rows", description: "Usage: deltaRows={deltaRows}") { }; deltaRowsOption.IsRequired = true; command.AddOption(deltaRowsOption); - var deltaColumnsOption = new Option("--deltacolumns", description: "Usage: deltaColumns={deltaColumns}") { + var deltaColumnsOption = new Option("--delta-columns", description: "Usage: deltaColumns={deltaColumns}") { }; deltaColumnsOption.IsRequired = true; command.AddOption(deltaColumnsOption); - command.SetHandler(async (string sharedInsightId, int? deltaRows, int? deltaColumns) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, int? deltaRows, int? deltaColumns, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, deltaRowsOption, deltaColumnsOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, deltaRowsOption, deltaColumnsOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function resizedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ResizedRangeWithDeltaRowsWithDeltaColumnsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs index a0bec151247..39d61de2777 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function row"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -34,18 +34,17 @@ public Command BuildGetCommand() { }; rowOption.IsRequired = true; command.AddOption(rowOption); - command.SetHandler(async (string sharedInsightId, int? row) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, int? row, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, rowOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, rowOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function row - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowWithRowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs index dad41e74cad..786b4ebe2ef 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function rowsAbove"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsAbove - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsAboveResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs index d4a48e95aaf..8574e525d37 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function rowsAbove"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -34,18 +34,17 @@ public Command BuildGetCommand() { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string sharedInsightId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, countOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsAbove - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsAboveWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs index bb88ae69e93..798265655c4 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function rowsBelow"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsBelow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsBelowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs index 897b3d8cb02..31581a916d9 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function rowsBelow"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -34,18 +34,17 @@ public Command BuildGetCommand() { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string sharedInsightId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, countOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsBelow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsBelowWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs index fee32bb0f96..33afff87808 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action unmerge"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + command.SetHandler(async (string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action unmerge - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs index d0a2e4616dd..c4cbbed4929 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs index 2941e988c85..8e098435296 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - var valuesOnlyOption = new Option("--valuesonly", description: "Usage: valuesOnly={valuesOnly}") { + var valuesOnlyOption = new Option("--values-only", description: "Usage: valuesOnly={valuesOnly}") { }; valuesOnlyOption.IsRequired = true; command.AddOption(valuesOnlyOption); - command.SetHandler(async (string sharedInsightId, bool? valuesOnly) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, bool? valuesOnly, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, valuesOnlyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, valuesOnlyOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeWithValuesOnlyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs index 8a683f733f9..535321b0d65 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function visibleView"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function visibleView - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRangeView public class VisibleViewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/WorkbookRangeRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/WorkbookRangeRequestBuilder.cs index b0ca2782ba4..c38e68bc587 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/WorkbookRangeRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRange/WorkbookRangeRequestBuilder.cs @@ -27,10 +27,10 @@ using ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.WorkbookRange.UsedRangeWithValuesOnly; using ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.WorkbookRange.VisibleView; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFill/Clear/ClearRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFill/Clear/ClearRequestBuilder.cs index d680c195e9c..2206b3dccd4 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFill/Clear/ClearRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFill/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + command.SetHandler(async (string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs index 88c1dbd2561..f2f8196eac8 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.WorkbookRangeFill.Clear; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs index 484af7eb6f2..aca0419e523 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action autofitColumns"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + command.SetHandler(async (string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action autofitColumns - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs index 2298cb27a38..4bd082f3892 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action autofitRows"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + command.SetHandler(async (string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action autofitRows - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs index 711d9efae59..b479c2e2556 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.WorkbookRangeFormat.AutofitColumns; using ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.WorkbookRangeFormat.AutofitRows; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs index e3776e8128f..b000fca5549 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action apply"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + command.SetHandler(async (string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ApplyRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action apply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs index 8f822d76fa0..70a8adfaa28 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.WorkbookRangeSort.Apply; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeView/Range/RangeRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeView/Range/RangeRequestBuilder.cs index 237e14cfe94..714b7dc3141 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeView/Range/RangeRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeView/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs index de4089cdabe..f64c963fd4b 100644 --- a/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/LastSharedMethod/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Me.Insights.Shared.Item.LastSharedMethod.WorkbookRangeView.Range; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Shared/Item/Resource/@Ref/@Ref.cs b/src/generated/Me/Insights/Shared/Item/Resource/@Ref/@Ref.cs deleted file mode 100644 index 735aa254a68..00000000000 --- a/src/generated/Me/Insights/Shared/Item/Resource/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.Insights.Shared.Item.Resource.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/Insights/Shared/Item/Resource/@Ref/RefRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 13e59054267..00000000000 --- a/src/generated/Me/Insights/Shared/Item/Resource/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Me.Insights.Shared.Item.Resource.@Ref { - /// Builds and executes requests for operations under \me\insights\shared\{sharedInsight-id}\resource\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem."; - // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { - }; - sharedInsightIdOption.IsRequired = true; - command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, sharedInsightIdOption); - return command; - } - /// - /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem."; - // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { - }; - sharedInsightIdOption.IsRequired = true; - command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); - return command; - } - /// - /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem."; - // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { - }; - sharedInsightIdOption.IsRequired = true; - command.AddOption(sharedInsightIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, sharedInsightIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/shared/{sharedInsight_id}/resource/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Me.Insights.Shared.Item.Resource.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Me.Insights.Shared.Item.Resource.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Me/Insights/Shared/Item/Resource/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs index 3dd66c62049..84aeaaec5ff 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action accept"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,16 +71,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/Resource/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs index fcf6ac1b0de..4d092990da5 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Me.Insights.Shared.Item.Resource.CalendarSharingMessage.Accept; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Shared/Item/Resource/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs index d228694a3df..e01e50b5379 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Me.Insights.Shared.Item.Resource.ManagedAppProtection.TargetApps; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Shared/Item/Resource/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs index 4c3d707f90e..5cc584836e3 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action targetApps"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + command.SetHandler(async (string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(TargetAppsRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action targetApps - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetAppsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/Resource/MobileAppContentFile/Commit/CommitRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/MobileAppContentFile/Commit/CommitRequestBuilder.cs index c9ddbcfb103..3a7ef06db66 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/MobileAppContentFile/Commit/CommitRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/MobileAppContentFile/Commit/CommitRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Commits a file of a given app."; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + command.SetHandler(async (string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(CommitRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Commits a file of a given app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CommitRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/Resource/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs index 5fee38e2cd5..756823d14ef 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Me.Insights.Shared.Item.Resource.MobileAppContentFile.Commit; using ApiSdk.Me.Insights.Shared.Item.Resource.MobileAppContentFile.RenewUpload; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Shared/Item/Resource/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs index def800683d2..b9a59343604 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Renews the SAS URI for an application file upload."; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + command.SetHandler(async (string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Renews the SAS URI for an application file upload. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/Resource/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index 63ab4c3ab59..3d1cffc1672 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action createUploadSession"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/PrintDocument/PrintDocumentRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/PrintDocument/PrintDocumentRequestBuilder.cs index ce9df05c2ef..60940556735 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/PrintDocument/PrintDocumentRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/PrintDocument/PrintDocumentRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Me.Insights.Shared.Item.Resource.PrintDocument.CreateUploadSession; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Shared/Item/Resource/PrintJob/Abort/AbortRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/PrintJob/Abort/AbortRequestBuilder.cs index cc1130040cb..93a76aef97b 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/PrintJob/Abort/AbortRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/PrintJob/Abort/AbortRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action abort"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + command.SetHandler(async (string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(AbortRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action abort - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AbortRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/Resource/PrintJob/Cancel/CancelRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/PrintJob/Cancel/CancelRequestBuilder.cs index 9ae17392064..af1a4d4e138 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/PrintJob/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/PrintJob/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action cancel"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + command.SetHandler(async (string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/Resource/PrintJob/PrintJobRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/PrintJob/PrintJobRequestBuilder.cs index a2a1c5f8555..c68ef121ce2 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/PrintJob/PrintJobRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/PrintJob/PrintJobRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Me.Insights.Shared.Item.Resource.PrintJob.Redirect; using ApiSdk.Me.Insights.Shared.Item.Resource.PrintJob.Start; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Shared/Item/Resource/PrintJob/Redirect/RedirectRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/PrintJob/Redirect/RedirectRequestBuilder.cs index 7dc080d166e..8d1526fa83a 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/PrintJob/Redirect/RedirectRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/PrintJob/Redirect/RedirectRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action redirect"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(RedirectRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action redirect - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RedirectRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes printJob public class RedirectResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/PrintJob/Start/StartRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/PrintJob/Start/StartRequestBuilder.cs index a2b5877fe6f..69e88800dc2 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/PrintJob/Start/StartRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/PrintJob/Start/StartRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action start"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action start - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes printJobStatus public class StartResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/Ref/Ref.cs b/src/generated/Me/Insights/Shared/Item/Resource/Ref/Ref.cs new file mode 100644 index 00000000000..cbc03319913 --- /dev/null +++ b/src/generated/Me/Insights/Shared/Item/Resource/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.Insights.Shared.Item.Resource.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/Insights/Shared/Item/Resource/Ref/RefRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..7726eaaedad --- /dev/null +++ b/src/generated/Me/Insights/Shared/Item/Resource/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Me.Insights.Shared.Item.Resource.Ref { + /// Builds and executes requests for operations under \me\insights\shared\{sharedInsight-id}\resource\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem."; + // Create options for all the parameters + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { + }; + sharedInsightIdOption.IsRequired = true; + command.AddOption(sharedInsightIdOption); + command.SetHandler(async (string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, sharedInsightIdOption); + return command; + } + /// + /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem."; + // Create options for all the parameters + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { + }; + sharedInsightIdOption.IsRequired = true; + command.AddOption(sharedInsightIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); + return command; + } + /// + /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem."; + // Create options for all the parameters + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { + }; + sharedInsightIdOption.IsRequired = true; + command.AddOption(sharedInsightIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, sharedInsightIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/me/insights/shared/{sharedInsight_id}/resource/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Me.Insights.Shared.Item.Resource.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Me/Insights/Shared/Item/Resource/ResourceRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/ResourceRequestBuilder.cs index f213685314b..91b2a33e3c2 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/ResourceRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/ResourceRequestBuilder.cs @@ -15,10 +15,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -46,7 +46,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem."; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -60,20 +60,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedInsightId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildManagedAppProtectionCommand() { @@ -106,7 +105,7 @@ public Command BuildPrintJobCommand() { } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Me.Insights.Shared.Item.Resource.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Me.Insights.Shared.Item.Resource.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -200,18 +199,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Insights/Shared/Item/Resource/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs index a3c48b9c3bb..549071dea3d 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action approve"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + command.SetHandler(async (string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ApproveRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action approve - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApproveRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/Resource/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs index ff75f6c7396..80984096862 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action decline"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + command.SetHandler(async (string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/Resource/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs index f1a0e30f0e7..6bb3d9399f6 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Me.Insights.Shared.Item.Resource.ScheduleChangeRequest.Approve; using ApiSdk.Me.Insights.Shared.Item.Resource.ScheduleChangeRequest.Decline; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Shared/Item/Resource/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs index 1863afc6a2f..8040eaed299 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action assign"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + command.SetHandler(async (string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/Resource/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs index 567a39c7426..f28f7bd9fed 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action targetApps"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + command.SetHandler(async (string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(TargetAppsRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action targetApps - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetAppsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/Resource/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs index bbf414794f8..1a11deee994 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Me.Insights.Shared.Item.Resource.TargetedManagedAppProtection.Assign; using ApiSdk.Me.Insights.Shared.Item.Resource.TargetedManagedAppProtection.TargetApps; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WindowsInformationProtection/Assign/AssignRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WindowsInformationProtection/Assign/AssignRequestBuilder.cs index 970f9863bb8..e2e9d963cb6 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WindowsInformationProtection/Assign/AssignRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WindowsInformationProtection/Assign/AssignRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action assign"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + command.SetHandler(async (string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs index b131247eeee..7c11cba4a6f 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Me.Insights.Shared.Item.Resource.WindowsInformationProtection.Assign; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs index 0b4ed8a35cb..30e71555a30 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function boundingRect"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - var anotherRangeOption = new Option("--anotherrange", description: "Usage: anotherRange={anotherRange}") { + var anotherRangeOption = new Option("--another-range", description: "Usage: anotherRange={anotherRange}") { }; anotherRangeOption.IsRequired = true; command.AddOption(anotherRangeOption); - command.SetHandler(async (string sharedInsightId, string anotherRange) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, string anotherRange, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, anotherRangeOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, anotherRangeOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function boundingRect - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class BoundingRectWithAnotherRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs index 895698b65d1..42f131ae652 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function cell"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string sharedInsightId, int? row, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, int? row, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, rowOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, rowOption, columnOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function cell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class CellWithRowWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/Clear/ClearRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/Clear/ClearRequestBuilder.cs index 6d253e38101..de33b93ac6b 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/Clear/ClearRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + command.SetHandler(async (string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ClearRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ClearRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs index fcc82837d61..e166a50f496 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function column"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -34,18 +34,17 @@ public Command BuildGetCommand() { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string sharedInsightId, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, columnOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function column - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs index bbc24133e70..ae0dcb344be 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function columnsAfter"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsAfter - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsAfterResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs index 8ad59a1927d..58cc68ce86c 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function columnsAfter"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -34,18 +34,17 @@ public Command BuildGetCommand() { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string sharedInsightId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, countOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsAfter - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsAfterWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs index c43cd39326f..9e054d42020 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function columnsBefore"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsBefore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsBeforeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs index 383f2b43318..086e16d6c44 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function columnsBefore"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -34,18 +34,17 @@ public Command BuildGetCommand() { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string sharedInsightId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, countOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsBefore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsBeforeWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/Delete/DeleteRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/Delete/DeleteRequestBuilder.cs index c3f99401cee..23e6f0bc386 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/Delete/DeleteRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/Delete/DeleteRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action delete"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + command.SetHandler(async (string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(DeleteRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action delete - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeleteRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs index 9f50cb8ebdc..b982b2b6fa3 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function entireColumn"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function entireColumn - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class EntireColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs index e22c238bb8c..64c5042d038 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function entireRow"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function entireRow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class EntireRowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/Insert/InsertRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/Insert/InsertRequestBuilder.cs index 67690f051a9..da8afdf8dec 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/Insert/InsertRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/Insert/InsertRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action insert"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(InsertRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action insert - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(InsertRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class InsertResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs index b226a4cb5d0..47acf697610 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function intersection"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - var anotherRangeOption = new Option("--anotherrange", description: "Usage: anotherRange={anotherRange}") { + var anotherRangeOption = new Option("--another-range", description: "Usage: anotherRange={anotherRange}") { }; anotherRangeOption.IsRequired = true; command.AddOption(anotherRangeOption); - command.SetHandler(async (string sharedInsightId, string anotherRange) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, string anotherRange, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, anotherRangeOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, anotherRangeOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function intersection - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class IntersectionWithAnotherRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/LastCell/LastCellRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/LastCell/LastCellRequestBuilder.cs index 647b4ab3055..2917c49b8ad 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/LastCell/LastCellRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/LastCell/LastCellRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function lastCell"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function lastCell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class LastCellResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs index 883452a88a6..1d79575f80d 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function lastColumn"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function lastColumn - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class LastColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/LastRow/LastRowRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/LastRow/LastRowRequestBuilder.cs index 323c3fb9ae9..70a7da8a730 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/LastRow/LastRowRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/LastRow/LastRowRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function lastRow"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function lastRow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class LastRowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/Merge/MergeRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/Merge/MergeRequestBuilder.cs index 759b71d5aab..93f9cc00ad5 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/Merge/MergeRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/Merge/MergeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action merge"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + command.SetHandler(async (string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(MergeRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action merge - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MergeRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs index c41ba43281b..b6eafeb487b 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function offsetRange"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - var rowOffsetOption = new Option("--rowoffset", description: "Usage: rowOffset={rowOffset}") { + var rowOffsetOption = new Option("--row-offset", description: "Usage: rowOffset={rowOffset}") { }; rowOffsetOption.IsRequired = true; command.AddOption(rowOffsetOption); - var columnOffsetOption = new Option("--columnoffset", description: "Usage: columnOffset={columnOffset}") { + var columnOffsetOption = new Option("--column-offset", description: "Usage: columnOffset={columnOffset}") { }; columnOffsetOption.IsRequired = true; command.AddOption(columnOffsetOption); - command.SetHandler(async (string sharedInsightId, int? rowOffset, int? columnOffset) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, int? rowOffset, int? columnOffset, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, rowOffsetOption, columnOffsetOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, rowOffsetOption, columnOffsetOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function offsetRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class OffsetRangeWithRowOffsetWithColumnOffsetResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs index 1be07ac0873..70eb96e1ce2 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function resizedRange"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - var deltaRowsOption = new Option("--deltarows", description: "Usage: deltaRows={deltaRows}") { + var deltaRowsOption = new Option("--delta-rows", description: "Usage: deltaRows={deltaRows}") { }; deltaRowsOption.IsRequired = true; command.AddOption(deltaRowsOption); - var deltaColumnsOption = new Option("--deltacolumns", description: "Usage: deltaColumns={deltaColumns}") { + var deltaColumnsOption = new Option("--delta-columns", description: "Usage: deltaColumns={deltaColumns}") { }; deltaColumnsOption.IsRequired = true; command.AddOption(deltaColumnsOption); - command.SetHandler(async (string sharedInsightId, int? deltaRows, int? deltaColumns) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, int? deltaRows, int? deltaColumns, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, deltaRowsOption, deltaColumnsOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, deltaRowsOption, deltaColumnsOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function resizedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ResizedRangeWithDeltaRowsWithDeltaColumnsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs index 315a3b71581..0b3625d0dc7 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function row"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -34,18 +34,17 @@ public Command BuildGetCommand() { }; rowOption.IsRequired = true; command.AddOption(rowOption); - command.SetHandler(async (string sharedInsightId, int? row) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, int? row, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, rowOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, rowOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function row - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowWithRowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs index 63798a5861e..971343b4166 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function rowsAbove"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsAbove - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsAboveResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs index 318468bab3b..10d71624b84 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function rowsAbove"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -34,18 +34,17 @@ public Command BuildGetCommand() { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string sharedInsightId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, countOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsAbove - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsAboveWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs index 29a88cf8911..e748969ee90 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function rowsBelow"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsBelow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsBelowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs index ad8a6aa151f..962cffea7fe 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function rowsBelow"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -34,18 +34,17 @@ public Command BuildGetCommand() { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string sharedInsightId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, countOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsBelow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsBelowWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs index 7feb31939c7..6cd38f0f2b7 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action unmerge"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + command.SetHandler(async (string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action unmerge - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs index 472a749edd9..9a4af718a09 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs index 12fcf3c9ee2..a988995cecc 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - var valuesOnlyOption = new Option("--valuesonly", description: "Usage: valuesOnly={valuesOnly}") { + var valuesOnlyOption = new Option("--values-only", description: "Usage: valuesOnly={valuesOnly}") { }; valuesOnlyOption.IsRequired = true; command.AddOption(valuesOnlyOption); - command.SetHandler(async (string sharedInsightId, bool? valuesOnly) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, bool? valuesOnly, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, valuesOnlyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, valuesOnlyOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeWithValuesOnlyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs index 4165d76b4ec..cc2407bfeee 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function visibleView"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function visibleView - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRangeView public class VisibleViewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/WorkbookRangeRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/WorkbookRangeRequestBuilder.cs index 36b54fa0c00..9d3a978a7ce 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/WorkbookRangeRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRange/WorkbookRangeRequestBuilder.cs @@ -27,10 +27,10 @@ using ApiSdk.Me.Insights.Shared.Item.Resource.WorkbookRange.UsedRangeWithValuesOnly; using ApiSdk.Me.Insights.Shared.Item.Resource.WorkbookRange.VisibleView; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeFill/Clear/ClearRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeFill/Clear/ClearRequestBuilder.cs index 663b842d8d7..70cca1fcb38 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeFill/Clear/ClearRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeFill/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + command.SetHandler(async (string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs index ed209cf48ed..4fc9ad06c00 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Me.Insights.Shared.Item.Resource.WorkbookRangeFill.Clear; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs index 93035bdfe7e..604b22d2ab4 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action autofitColumns"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + command.SetHandler(async (string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action autofitColumns - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs index 6cb14fcdbcf..8ed9ee02c8e 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action autofitRows"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + command.SetHandler(async (string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action autofitRows - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs index 450edf19394..ccea68e9c89 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Me.Insights.Shared.Item.Resource.WorkbookRangeFormat.AutofitColumns; using ApiSdk.Me.Insights.Shared.Item.Resource.WorkbookRangeFormat.AutofitRows; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs index c48100fecfd..ee961d43ae8 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action apply"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + command.SetHandler(async (string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ApplyRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action apply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs index 3681e75bc80..47f79270c5f 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Me.Insights.Shared.Item.Resource.WorkbookRangeSort.Apply; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeView/Range/RangeRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeView/Range/RangeRequestBuilder.cs index d55ef2f549d..c55622f0fac 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeView/Range/RangeRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeView/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs index a2b80fbb4f5..0d40dd4784d 100644 --- a/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/Resource/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Me.Insights.Shared.Item.Resource.WorkbookRangeView.Range; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Shared/Item/SharedInsightRequestBuilder.cs b/src/generated/Me/Insights/Shared/Item/SharedInsightRequestBuilder.cs index e4b1bc63d30..6894f646841 100644 --- a/src/generated/Me/Insights/Shared/Item/SharedInsightRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/Item/SharedInsightRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,15 +28,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Access this property from the derived type itemInsights."; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string sharedInsightId) => { + command.SetHandler(async (string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption); return command; @@ -48,7 +47,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Access this property from the derived type itemInsights."; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -62,20 +61,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedInsightId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedInsightId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedInsightIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedInsightIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLastSharedMethodCommand() { @@ -105,7 +103,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Access this property from the derived type itemInsights."; // Create options for all the parameters - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -113,14 +111,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedInsightId, string body) => { + command.SetHandler(async (string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedInsightIdOption, bodyOption); return command; @@ -212,42 +209,6 @@ public RequestInformation CreatePatchRequestInformation(SharedInsight body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SharedInsight model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Access this property from the derived type itemInsights. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Insights/Shared/SharedRequestBuilder.cs b/src/generated/Me/Insights/Shared/SharedRequestBuilder.cs index 70824a23159..ece1cb3a393 100644 --- a/src/generated/Me/Insights/Shared/SharedRequestBuilder.cs +++ b/src/generated/Me/Insights/Shared/SharedRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SharedRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SharedInsightRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildLastSharedMethodCommand(), - builder.BuildPatchCommand(), - builder.BuildResourceCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildLastSharedMethodCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildResourceCommand()); return commands; } /// @@ -42,21 +41,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -101,7 +99,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -112,15 +114,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -175,31 +172,6 @@ public RequestInformation CreatePostRequestInformation(SharedInsight body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SharedInsight model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Access this property from the derived type itemInsights. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Insights/Trending/Item/Resource/@Ref/@Ref.cs b/src/generated/Me/Insights/Trending/Item/Resource/@Ref/@Ref.cs deleted file mode 100644 index 00a1dd6b390..00000000000 --- a/src/generated/Me/Insights/Trending/Item/Resource/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.Insights.Trending.Item.Resource.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/Insights/Trending/Item/Resource/@Ref/RefRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/@Ref/RefRequestBuilder.cs deleted file mode 100644 index c194121fda8..00000000000 --- a/src/generated/Me/Insights/Trending/Item/Resource/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Me.Insights.Trending.Item.Resource.@Ref { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Used for navigating to the trending document. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Used for navigating to the trending document."; - // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { - }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string trendingId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, trendingIdOption); - return command; - } - /// - /// Used for navigating to the trending document. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Used for navigating to the trending document."; - // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { - }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string trendingId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption); - return command; - } - /// - /// Used for navigating to the trending document. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Used for navigating to the trending document."; - // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { - }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string trendingId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, trendingIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Used for navigating to the trending document. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Used for navigating to the trending document. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Used for navigating to the trending document. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Me.Insights.Trending.Item.Resource.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Used for navigating to the trending document. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used for navigating to the trending document. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used for navigating to the trending document. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Me.Insights.Trending.Item.Resource.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Me/Insights/Trending/Item/Resource/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs index 8dbd068bec3..addea1f0b8d 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.CalendarSharingMessage.Accept { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.calendarSharingMessage\microsoft.graph.accept + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.calendarSharingMessage\microsoft.graph.accept public class AcceptRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,22 +26,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action accept"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, outputOption); return command; } /// @@ -52,7 +51,7 @@ public Command BuildPostCommand() { public AcceptRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.calendarSharingMessage/microsoft.graph.accept"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.calendarSharingMessage/microsoft.graph.accept"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -72,16 +71,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Trending/Item/Resource/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs index f91f101406f..a418f7d6ea8 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs @@ -1,15 +1,15 @@ using ApiSdk.Me.Insights.Trending.Item.Resource.CalendarSharingMessage.Accept; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.CalendarSharingMessage { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.calendarSharingMessage + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.calendarSharingMessage public class CalendarSharingMessageRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -31,7 +31,7 @@ public Command BuildAcceptCommand() { public CalendarSharingMessageRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.calendarSharingMessage"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.calendarSharingMessage"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; diff --git a/src/generated/Me/Insights/Trending/Item/Resource/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs index 408c2ceb910..b979da3ad9e 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs @@ -1,15 +1,15 @@ using ApiSdk.Me.Insights.Trending.Item.Resource.ManagedAppProtection.TargetApps; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.ManagedAppProtection { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.managedAppProtection + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.managedAppProtection public class ManagedAppProtectionRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -31,7 +31,7 @@ public Command BuildTargetAppsCommand() { public ManagedAppProtectionRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.managedAppProtection"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.managedAppProtection"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; diff --git a/src/generated/Me/Insights/Trending/Item/Resource/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs index 688739c56e0..4dca455ddd0 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.ManagedAppProtection.TargetApps { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.managedAppProtection\microsoft.graph.targetApps + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.managedAppProtection\microsoft.graph.targetApps public class TargetAppsRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -25,24 +25,23 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action targetApps"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string trendingId, string body) => { + command.SetHandler(async (string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, trendingIdOption, bodyOption); + }, trendingItemIdOption, bodyOption); return command; } /// @@ -53,7 +52,7 @@ public Command BuildPostCommand() { public TargetAppsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.managedAppProtection/microsoft.graph.targetApps"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.managedAppProtection/microsoft.graph.targetApps"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(TargetAppsRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action targetApps - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetAppsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Trending/Item/Resource/MobileAppContentFile/Commit/CommitRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/MobileAppContentFile/Commit/CommitRequestBuilder.cs index ce639e96622..6f959ef01de 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/MobileAppContentFile/Commit/CommitRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/MobileAppContentFile/Commit/CommitRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.MobileAppContentFile.Commit { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.mobileAppContentFile\microsoft.graph.commit + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.mobileAppContentFile\microsoft.graph.commit public class CommitRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -25,24 +25,23 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Commits a file of a given app."; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string trendingId, string body) => { + command.SetHandler(async (string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, trendingIdOption, bodyOption); + }, trendingItemIdOption, bodyOption); return command; } /// @@ -53,7 +52,7 @@ public Command BuildPostCommand() { public CommitRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.mobileAppContentFile/microsoft.graph.commit"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.mobileAppContentFile/microsoft.graph.commit"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(CommitRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Commits a file of a given app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CommitRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Trending/Item/Resource/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs index 7ac8a08e779..42168811cfc 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs @@ -1,16 +1,16 @@ using ApiSdk.Me.Insights.Trending.Item.Resource.MobileAppContentFile.Commit; using ApiSdk.Me.Insights.Trending.Item.Resource.MobileAppContentFile.RenewUpload; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.MobileAppContentFile { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.mobileAppContentFile + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.mobileAppContentFile public class MobileAppContentFileRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -38,7 +38,7 @@ public Command BuildRenewUploadCommand() { public MobileAppContentFileRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.mobileAppContentFile"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.mobileAppContentFile"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; diff --git a/src/generated/Me/Insights/Trending/Item/Resource/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs index 3f96bb0fc69..4e38799a152 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.MobileAppContentFile.RenewUpload { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.mobileAppContentFile\microsoft.graph.renewUpload + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.mobileAppContentFile\microsoft.graph.renewUpload public class RenewUploadRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -25,17 +25,16 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Renews the SAS URI for an application file upload."; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + command.SetHandler(async (string trendingItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, trendingIdOption); + }, trendingItemIdOption); return command; } /// @@ -46,7 +45,7 @@ public Command BuildPostCommand() { public RenewUploadRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.mobileAppContentFile/microsoft.graph.renewUpload"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.mobileAppContentFile/microsoft.graph.renewUpload"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Renews the SAS URI for an application file upload. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Trending/Item/Resource/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index 9176b6ce98b..4ae4e0c446c 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.PrintDocument.CreateUploadSession { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.printDocument\microsoft.graph.createUploadSession + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.printDocument\microsoft.graph.createUploadSession public class CreateUploadSessionRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,29 +26,28 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action createUploadSession"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string trendingId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, bodyOption, outputOption); return command; } /// @@ -59,7 +58,7 @@ public Command BuildPostCommand() { public CreateUploadSessionRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.printDocument/microsoft.graph.createUploadSession"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.printDocument/microsoft.graph.createUploadSession"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/PrintDocument/PrintDocumentRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/PrintDocument/PrintDocumentRequestBuilder.cs index 1413a9c14a6..084eb537291 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/PrintDocument/PrintDocumentRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/PrintDocument/PrintDocumentRequestBuilder.cs @@ -1,15 +1,15 @@ using ApiSdk.Me.Insights.Trending.Item.Resource.PrintDocument.CreateUploadSession; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.PrintDocument { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.printDocument + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.printDocument public class PrintDocumentRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -31,7 +31,7 @@ public Command BuildCreateUploadSessionCommand() { public PrintDocumentRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.printDocument"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.printDocument"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; diff --git a/src/generated/Me/Insights/Trending/Item/Resource/PrintJob/Abort/AbortRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/PrintJob/Abort/AbortRequestBuilder.cs index 8465a4b9d48..424a6cdfc3d 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/PrintJob/Abort/AbortRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/PrintJob/Abort/AbortRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.PrintJob.Abort { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.printJob\microsoft.graph.abort + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.printJob\microsoft.graph.abort public class AbortRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -25,24 +25,23 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action abort"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string trendingId, string body) => { + command.SetHandler(async (string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, trendingIdOption, bodyOption); + }, trendingItemIdOption, bodyOption); return command; } /// @@ -53,7 +52,7 @@ public Command BuildPostCommand() { public AbortRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.printJob/microsoft.graph.abort"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.printJob/microsoft.graph.abort"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(AbortRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action abort - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AbortRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Trending/Item/Resource/PrintJob/Cancel/CancelRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/PrintJob/Cancel/CancelRequestBuilder.cs index 3bcef9e650c..79175197efe 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/PrintJob/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/PrintJob/Cancel/CancelRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.PrintJob.Cancel { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.printJob\microsoft.graph.cancel + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.printJob\microsoft.graph.cancel public class CancelRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -25,17 +25,16 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action cancel"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + command.SetHandler(async (string trendingItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, trendingIdOption); + }, trendingItemIdOption); return command; } /// @@ -46,7 +45,7 @@ public Command BuildPostCommand() { public CancelRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.printJob/microsoft.graph.cancel"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.printJob/microsoft.graph.cancel"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Trending/Item/Resource/PrintJob/PrintJobRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/PrintJob/PrintJobRequestBuilder.cs index b19d6f032ba..3b61ee6e324 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/PrintJob/PrintJobRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/PrintJob/PrintJobRequestBuilder.cs @@ -3,16 +3,16 @@ using ApiSdk.Me.Insights.Trending.Item.Resource.PrintJob.Redirect; using ApiSdk.Me.Insights.Trending.Item.Resource.PrintJob.Start; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.PrintJob { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.printJob + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.printJob public class PrintJobRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -52,7 +52,7 @@ public Command BuildStartCommand() { public PrintJobRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.printJob"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.printJob"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; diff --git a/src/generated/Me/Insights/Trending/Item/Resource/PrintJob/Redirect/RedirectRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/PrintJob/Redirect/RedirectRequestBuilder.cs index 9cd2c27a0c7..ffa39ade585 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/PrintJob/Redirect/RedirectRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/PrintJob/Redirect/RedirectRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.PrintJob.Redirect { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.printJob\microsoft.graph.redirect + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.printJob\microsoft.graph.redirect public class RedirectRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,29 +26,28 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action redirect"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string trendingId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, bodyOption, outputOption); return command; } /// @@ -59,7 +58,7 @@ public Command BuildPostCommand() { public RedirectRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.printJob/microsoft.graph.redirect"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.printJob/microsoft.graph.redirect"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(RedirectRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action redirect - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RedirectRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes printJob public class RedirectResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/PrintJob/Start/StartRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/PrintJob/Start/StartRequestBuilder.cs index 6a97a73bdb6..cbbd54ad308 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/PrintJob/Start/StartRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/PrintJob/Start/StartRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.PrintJob.Start { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.printJob\microsoft.graph.start + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.printJob\microsoft.graph.start public class StartRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,22 +26,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action start"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, outputOption); return command; } /// @@ -52,7 +51,7 @@ public Command BuildPostCommand() { public StartRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.printJob/microsoft.graph.start"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.printJob/microsoft.graph.start"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action start - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes printJobStatus public class StartResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/Ref/Ref.cs b/src/generated/Me/Insights/Trending/Item/Resource/Ref/Ref.cs new file mode 100644 index 00000000000..ebd8cd01e07 --- /dev/null +++ b/src/generated/Me/Insights/Trending/Item/Resource/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.Insights.Trending.Item.Resource.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/Insights/Trending/Item/Resource/Ref/RefRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..31a02da8b06 --- /dev/null +++ b/src/generated/Me/Insights/Trending/Item/Resource/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Me.Insights.Trending.Item.Resource.Ref { + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Used for navigating to the trending document. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Used for navigating to the trending document."; + // Create options for all the parameters + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { + }; + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + command.SetHandler(async (string trendingItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, trendingItemIdOption); + return command; + } + /// + /// Used for navigating to the trending document. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Used for navigating to the trending document."; + // Create options for all the parameters + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { + }; + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, outputOption); + return command; + } + /// + /// Used for navigating to the trending document. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Used for navigating to the trending document."; + // Create options for all the parameters + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { + }; + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, trendingItemIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Used for navigating to the trending document. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Used for navigating to the trending document. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Used for navigating to the trending document. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Me.Insights.Trending.Item.Resource.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Me/Insights/Trending/Item/Resource/ResourceRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/ResourceRequestBuilder.cs index 1df279aea87..8326f876736 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/ResourceRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/ResourceRequestBuilder.cs @@ -15,17 +15,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource public class ResourceRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -46,10 +46,10 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Used for navigating to the trending document."; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var selectOption = new Option("--select", description: "Select properties to be returned") { Arity = ArgumentArity.ZeroOrMore }; @@ -60,20 +60,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string trendingId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildManagedAppProtectionCommand() { @@ -106,7 +105,7 @@ public Command BuildPrintJobCommand() { } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Me.Insights.Trending.Item.Resource.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Me.Insights.Trending.Item.Resource.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -174,7 +173,7 @@ public Command BuildWorkbookRangeViewCommand() { public ResourceRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource{?select,expand}"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource{?select,expand}"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -200,18 +199,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Used for navigating to the trending document. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Used for navigating to the trending document. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Insights/Trending/Item/Resource/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs index b1a9d4c13c5..1055c43522d 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.ScheduleChangeRequest.Approve { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.scheduleChangeRequest\microsoft.graph.approve + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.scheduleChangeRequest\microsoft.graph.approve public class ApproveRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -25,24 +25,23 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action approve"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string trendingId, string body) => { + command.SetHandler(async (string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, trendingIdOption, bodyOption); + }, trendingItemIdOption, bodyOption); return command; } /// @@ -53,7 +52,7 @@ public Command BuildPostCommand() { public ApproveRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.scheduleChangeRequest/microsoft.graph.approve"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.scheduleChangeRequest/microsoft.graph.approve"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ApproveRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action approve - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApproveRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Trending/Item/Resource/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs index 6ecc2b6201f..12cba5a7a84 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.ScheduleChangeRequest.Decline { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.scheduleChangeRequest\microsoft.graph.decline + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.scheduleChangeRequest\microsoft.graph.decline public class DeclineRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -25,24 +25,23 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action decline"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string trendingId, string body) => { + command.SetHandler(async (string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, trendingIdOption, bodyOption); + }, trendingItemIdOption, bodyOption); return command; } /// @@ -53,7 +52,7 @@ public Command BuildPostCommand() { public DeclineRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.scheduleChangeRequest/microsoft.graph.decline"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.scheduleChangeRequest/microsoft.graph.decline"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Trending/Item/Resource/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs index 11b2c26d974..512670b4fca 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs @@ -1,16 +1,16 @@ using ApiSdk.Me.Insights.Trending.Item.Resource.ScheduleChangeRequest.Approve; using ApiSdk.Me.Insights.Trending.Item.Resource.ScheduleChangeRequest.Decline; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.ScheduleChangeRequest { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.scheduleChangeRequest + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.scheduleChangeRequest public class ScheduleChangeRequestRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -38,7 +38,7 @@ public Command BuildDeclineCommand() { public ScheduleChangeRequestRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.scheduleChangeRequest"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.scheduleChangeRequest"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; diff --git a/src/generated/Me/Insights/Trending/Item/Resource/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs index 4abcba38d83..565ce3d8105 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.TargetedManagedAppProtection.Assign { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.targetedManagedAppProtection\microsoft.graph.assign + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.targetedManagedAppProtection\microsoft.graph.assign public class AssignRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -25,24 +25,23 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action assign"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string trendingId, string body) => { + command.SetHandler(async (string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, trendingIdOption, bodyOption); + }, trendingItemIdOption, bodyOption); return command; } /// @@ -53,7 +52,7 @@ public Command BuildPostCommand() { public AssignRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.targetedManagedAppProtection/microsoft.graph.assign"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.targetedManagedAppProtection/microsoft.graph.assign"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Trending/Item/Resource/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs index bae97cec1ef..3181edb0ff3 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.TargetedManagedAppProtection.TargetApps { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.targetedManagedAppProtection\microsoft.graph.targetApps + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.targetedManagedAppProtection\microsoft.graph.targetApps public class TargetAppsRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -25,24 +25,23 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action targetApps"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string trendingId, string body) => { + command.SetHandler(async (string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, trendingIdOption, bodyOption); + }, trendingItemIdOption, bodyOption); return command; } /// @@ -53,7 +52,7 @@ public Command BuildPostCommand() { public TargetAppsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.targetedManagedAppProtection/microsoft.graph.targetApps"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.targetedManagedAppProtection/microsoft.graph.targetApps"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(TargetAppsRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action targetApps - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetAppsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Trending/Item/Resource/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs index 07a6dc2370f..f780bc6175f 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs @@ -1,16 +1,16 @@ using ApiSdk.Me.Insights.Trending.Item.Resource.TargetedManagedAppProtection.Assign; using ApiSdk.Me.Insights.Trending.Item.Resource.TargetedManagedAppProtection.TargetApps; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.TargetedManagedAppProtection { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.targetedManagedAppProtection + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.targetedManagedAppProtection public class TargetedManagedAppProtectionRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -38,7 +38,7 @@ public Command BuildTargetAppsCommand() { public TargetedManagedAppProtectionRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.targetedManagedAppProtection"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.targetedManagedAppProtection"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WindowsInformationProtection/Assign/AssignRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WindowsInformationProtection/Assign/AssignRequestBuilder.cs index 7943203404d..a99b4a51d3a 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WindowsInformationProtection/Assign/AssignRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WindowsInformationProtection/Assign/AssignRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WindowsInformationProtection.Assign { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.windowsInformationProtection\microsoft.graph.assign + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.windowsInformationProtection\microsoft.graph.assign public class AssignRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -25,24 +25,23 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action assign"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string trendingId, string body) => { + command.SetHandler(async (string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, trendingIdOption, bodyOption); + }, trendingItemIdOption, bodyOption); return command; } /// @@ -53,7 +52,7 @@ public Command BuildPostCommand() { public AssignRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.windowsInformationProtection/microsoft.graph.assign"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.windowsInformationProtection/microsoft.graph.assign"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs index 3a71c39c8f8..75d25bc3359 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs @@ -1,15 +1,15 @@ using ApiSdk.Me.Insights.Trending.Item.Resource.WindowsInformationProtection.Assign; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WindowsInformationProtection { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.windowsInformationProtection + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.windowsInformationProtection public class WindowsInformationProtectionRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -31,7 +31,7 @@ public Command BuildAssignCommand() { public WindowsInformationProtectionRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.windowsInformationProtection"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.windowsInformationProtection"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs index fbfbf763b42..610235d2f92 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.BoundingRectWithAnotherRange { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.boundingRect(anotherRange='{anotherRange}') + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.boundingRect(anotherRange='{anotherRange}') public class BoundingRectWithAnotherRangeRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function boundingRect"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - var anotherRangeOption = new Option("--anotherrange", description: "Usage: anotherRange={anotherRange}") { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var anotherRangeOption = new Option("--another-range", description: "Usage: anotherRange={anotherRange}") { }; anotherRangeOption.IsRequired = true; command.AddOption(anotherRangeOption); - command.SetHandler(async (string trendingId, string anotherRange) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, string anotherRange, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption, anotherRangeOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, anotherRangeOption, outputOption); return command; } /// @@ -57,7 +56,7 @@ public Command BuildGetCommand() { public BoundingRectWithAnotherRangeRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, string anotherRange = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.boundingRect(anotherRange='{anotherRange}')"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.boundingRect(anotherRange='{anotherRange}')"; var urlTplParams = new Dictionary(pathParameters); urlTplParams.Add("anotherRange", anotherRange); PathParameters = urlTplParams; @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function boundingRect - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class BoundingRectWithAnotherRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs index 7f101a53c40..049cab31552 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.CellWithRowWithColumn { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.cell(row={row},column={column}) + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.cell(row={row},column={column}) public class CellWithRowWithColumnRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,10 +26,10 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function cell"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var rowOption = new Option("--row", description: "Usage: row={row}") { }; rowOption.IsRequired = true; @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string trendingId, int? row, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, int? row, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption, rowOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, rowOption, columnOption, outputOption); return command; } /// @@ -62,7 +61,7 @@ public Command BuildGetCommand() { public CellWithRowWithColumnRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, int? row = default, int? column = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.cell(row={row},column={column})"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.cell(row={row},column={column})"; var urlTplParams = new Dictionary(pathParameters); urlTplParams.Add("row", row); urlTplParams.Add("column", column); @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function cell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class CellWithRowWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/Clear/ClearRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/Clear/ClearRequestBuilder.cs index f642557192e..ee1847f0f1b 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/Clear/ClearRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/Clear/ClearRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.Clear { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.clear + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.clear public class ClearRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -25,24 +25,23 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string trendingId, string body) => { + command.SetHandler(async (string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, trendingIdOption, bodyOption); + }, trendingItemIdOption, bodyOption); return command; } /// @@ -53,7 +52,7 @@ public Command BuildPostCommand() { public ClearRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.clear"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.clear"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ClearRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ClearRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs index c64bed989cd..de69bd2ce54 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.ColumnWithColumn { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.column(column={column}) + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.column(column={column}) public class ColumnWithColumnRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function column"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var columnOption = new Option("--column", description: "Usage: column={column}") { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string trendingId, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, columnOption, outputOption); return command; } /// @@ -57,7 +56,7 @@ public Command BuildGetCommand() { public ColumnWithColumnRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, int? column = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.column(column={column})"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.column(column={column})"; var urlTplParams = new Dictionary(pathParameters); urlTplParams.Add("column", column); PathParameters = urlTplParams; @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function column - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs index 072346afd8f..7f144e45135 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.ColumnsAfter { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsAfter() + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsAfter() public class ColumnsAfterRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function columnsAfter"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, outputOption); return command; } /// @@ -52,7 +51,7 @@ public Command BuildGetCommand() { public ColumnsAfterRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.columnsAfter()"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.columnsAfter()"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsAfter - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsAfterResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs index 5ea93d60efe..c5ddd4b7bb0 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.ColumnsAfterWithCount { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsAfter(count={count}) + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsAfter(count={count}) public class ColumnsAfterWithCountRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function columnsAfter"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var countOption = new Option("--count", description: "Usage: count={count}") { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string trendingId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, countOption, outputOption); return command; } /// @@ -57,7 +56,7 @@ public Command BuildGetCommand() { public ColumnsAfterWithCountRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, int? count = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.columnsAfter(count={count})"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.columnsAfter(count={count})"; var urlTplParams = new Dictionary(pathParameters); urlTplParams.Add("count", count); PathParameters = urlTplParams; @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsAfter - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsAfterWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs index 3652cf01ca2..d15cf611b9a 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.ColumnsBefore { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsBefore() + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsBefore() public class ColumnsBeforeRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function columnsBefore"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, outputOption); return command; } /// @@ -52,7 +51,7 @@ public Command BuildGetCommand() { public ColumnsBeforeRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.columnsBefore()"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.columnsBefore()"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsBefore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsBeforeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs index 3ede379213e..857fb6cce4a 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.ColumnsBeforeWithCount { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsBefore(count={count}) + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsBefore(count={count}) public class ColumnsBeforeWithCountRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function columnsBefore"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var countOption = new Option("--count", description: "Usage: count={count}") { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string trendingId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, countOption, outputOption); return command; } /// @@ -57,7 +56,7 @@ public Command BuildGetCommand() { public ColumnsBeforeWithCountRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, int? count = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.columnsBefore(count={count})"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.columnsBefore(count={count})"; var urlTplParams = new Dictionary(pathParameters); urlTplParams.Add("count", count); PathParameters = urlTplParams; @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsBefore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsBeforeWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/Delete/DeleteRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/Delete/DeleteRequestBuilder.cs index 0a3da2e8a96..84d1ae98f25 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/Delete/DeleteRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/Delete/DeleteRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.Delete { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.delete + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.delete public class DeleteRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -25,24 +25,23 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action delete"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string trendingId, string body) => { + command.SetHandler(async (string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, trendingIdOption, bodyOption); + }, trendingItemIdOption, bodyOption); return command; } /// @@ -53,7 +52,7 @@ public Command BuildPostCommand() { public DeleteRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.delete"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.delete"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(DeleteRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action delete - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeleteRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs index 0edcf635c8e..1c6d46db074 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.EntireColumn { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.entireColumn() + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.entireColumn() public class EntireColumnRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function entireColumn"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, outputOption); return command; } /// @@ -52,7 +51,7 @@ public Command BuildGetCommand() { public EntireColumnRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.entireColumn()"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.entireColumn()"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function entireColumn - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class EntireColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs index e8c515843b0..de7e246b467 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.EntireRow { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.entireRow() + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.entireRow() public class EntireRowRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function entireRow"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, outputOption); return command; } /// @@ -52,7 +51,7 @@ public Command BuildGetCommand() { public EntireRowRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.entireRow()"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.entireRow()"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function entireRow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class EntireRowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/Insert/InsertRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/Insert/InsertRequestBuilder.cs index 03d549865bd..07adae0ce05 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/Insert/InsertRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/Insert/InsertRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.Insert { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.insert + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.insert public class InsertRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,29 +26,28 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action insert"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string trendingId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, bodyOption, outputOption); return command; } /// @@ -59,7 +58,7 @@ public Command BuildPostCommand() { public InsertRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.insert"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.insert"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(InsertRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action insert - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(InsertRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class InsertResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs index fc58eb48406..69157211148 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.IntersectionWithAnotherRange { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.intersection(anotherRange='{anotherRange}') + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.intersection(anotherRange='{anotherRange}') public class IntersectionWithAnotherRangeRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function intersection"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - var anotherRangeOption = new Option("--anotherrange", description: "Usage: anotherRange={anotherRange}") { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var anotherRangeOption = new Option("--another-range", description: "Usage: anotherRange={anotherRange}") { }; anotherRangeOption.IsRequired = true; command.AddOption(anotherRangeOption); - command.SetHandler(async (string trendingId, string anotherRange) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, string anotherRange, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption, anotherRangeOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, anotherRangeOption, outputOption); return command; } /// @@ -57,7 +56,7 @@ public Command BuildGetCommand() { public IntersectionWithAnotherRangeRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, string anotherRange = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.intersection(anotherRange='{anotherRange}')"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.intersection(anotherRange='{anotherRange}')"; var urlTplParams = new Dictionary(pathParameters); urlTplParams.Add("anotherRange", anotherRange); PathParameters = urlTplParams; @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function intersection - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class IntersectionWithAnotherRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/LastCell/LastCellRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/LastCell/LastCellRequestBuilder.cs index 95310d250fb..95b53166fd8 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/LastCell/LastCellRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/LastCell/LastCellRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.LastCell { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.lastCell() + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.lastCell() public class LastCellRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function lastCell"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, outputOption); return command; } /// @@ -52,7 +51,7 @@ public Command BuildGetCommand() { public LastCellRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.lastCell()"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.lastCell()"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function lastCell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class LastCellResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs index 6cbf56b9eae..f2551842e96 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.LastColumn { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.lastColumn() + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.lastColumn() public class LastColumnRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function lastColumn"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, outputOption); return command; } /// @@ -52,7 +51,7 @@ public Command BuildGetCommand() { public LastColumnRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.lastColumn()"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.lastColumn()"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function lastColumn - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class LastColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/LastRow/LastRowRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/LastRow/LastRowRequestBuilder.cs index 6b4334ff8eb..03d5a8cc954 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/LastRow/LastRowRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/LastRow/LastRowRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.LastRow { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.lastRow() + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.lastRow() public class LastRowRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function lastRow"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, outputOption); return command; } /// @@ -52,7 +51,7 @@ public Command BuildGetCommand() { public LastRowRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.lastRow()"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.lastRow()"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function lastRow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class LastRowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/Merge/MergeRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/Merge/MergeRequestBuilder.cs index cfcc8cc1ec7..f0ee8bf89f6 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/Merge/MergeRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/Merge/MergeRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.Merge { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.merge + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.merge public class MergeRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -25,24 +25,23 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action merge"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string trendingId, string body) => { + command.SetHandler(async (string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, trendingIdOption, bodyOption); + }, trendingItemIdOption, bodyOption); return command; } /// @@ -53,7 +52,7 @@ public Command BuildPostCommand() { public MergeRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.merge"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.merge"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(MergeRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action merge - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MergeRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs index 7c46f5b89f0..c8179769fb9 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.OffsetRangeWithRowOffsetWithColumnOffset { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.offsetRange(rowOffset={rowOffset},columnOffset={columnOffset}) + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.offsetRange(rowOffset={rowOffset},columnOffset={columnOffset}) public class OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function offsetRange"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - var rowOffsetOption = new Option("--rowoffset", description: "Usage: rowOffset={rowOffset}") { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var rowOffsetOption = new Option("--row-offset", description: "Usage: rowOffset={rowOffset}") { }; rowOffsetOption.IsRequired = true; command.AddOption(rowOffsetOption); - var columnOffsetOption = new Option("--columnoffset", description: "Usage: columnOffset={columnOffset}") { + var columnOffsetOption = new Option("--column-offset", description: "Usage: columnOffset={columnOffset}") { }; columnOffsetOption.IsRequired = true; command.AddOption(columnOffsetOption); - command.SetHandler(async (string trendingId, int? rowOffset, int? columnOffset) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, int? rowOffset, int? columnOffset, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption, rowOffsetOption, columnOffsetOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, rowOffsetOption, columnOffsetOption, outputOption); return command; } /// @@ -62,7 +61,7 @@ public Command BuildGetCommand() { public OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, int? rowOffset = default, int? columnOffset = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.offsetRange(rowOffset={rowOffset},columnOffset={columnOffset})"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.offsetRange(rowOffset={rowOffset},columnOffset={columnOffset})"; var urlTplParams = new Dictionary(pathParameters); urlTplParams.Add("rowOffset", rowOffset); urlTplParams.Add("columnOffset", columnOffset); @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function offsetRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class OffsetRangeWithRowOffsetWithColumnOffsetResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs index 24127769af1..8c2d7cb7e03 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.ResizedRangeWithDeltaRowsWithDeltaColumns { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.resizedRange(deltaRows={deltaRows},deltaColumns={deltaColumns}) + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.resizedRange(deltaRows={deltaRows},deltaColumns={deltaColumns}) public class ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function resizedRange"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - var deltaRowsOption = new Option("--deltarows", description: "Usage: deltaRows={deltaRows}") { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var deltaRowsOption = new Option("--delta-rows", description: "Usage: deltaRows={deltaRows}") { }; deltaRowsOption.IsRequired = true; command.AddOption(deltaRowsOption); - var deltaColumnsOption = new Option("--deltacolumns", description: "Usage: deltaColumns={deltaColumns}") { + var deltaColumnsOption = new Option("--delta-columns", description: "Usage: deltaColumns={deltaColumns}") { }; deltaColumnsOption.IsRequired = true; command.AddOption(deltaColumnsOption); - command.SetHandler(async (string trendingId, int? deltaRows, int? deltaColumns) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, int? deltaRows, int? deltaColumns, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption, deltaRowsOption, deltaColumnsOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, deltaRowsOption, deltaColumnsOption, outputOption); return command; } /// @@ -62,7 +61,7 @@ public Command BuildGetCommand() { public ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, int? deltaRows = default, int? deltaColumns = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.resizedRange(deltaRows={deltaRows},deltaColumns={deltaColumns})"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.resizedRange(deltaRows={deltaRows},deltaColumns={deltaColumns})"; var urlTplParams = new Dictionary(pathParameters); urlTplParams.Add("deltaRows", deltaRows); urlTplParams.Add("deltaColumns", deltaColumns); @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function resizedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ResizedRangeWithDeltaRowsWithDeltaColumnsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs index 3dcfc97042a..732af6829e3 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.RowWithRow { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.row(row={row}) + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.row(row={row}) public class RowWithRowRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function row"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var rowOption = new Option("--row", description: "Usage: row={row}") { }; rowOption.IsRequired = true; command.AddOption(rowOption); - command.SetHandler(async (string trendingId, int? row) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, int? row, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption, rowOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, rowOption, outputOption); return command; } /// @@ -57,7 +56,7 @@ public Command BuildGetCommand() { public RowWithRowRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, int? row = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.row(row={row})"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.row(row={row})"; var urlTplParams = new Dictionary(pathParameters); urlTplParams.Add("row", row); PathParameters = urlTplParams; @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function row - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowWithRowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs index b9a534b5dad..b6e5b6d7237 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.RowsAbove { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsAbove() + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsAbove() public class RowsAboveRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function rowsAbove"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, outputOption); return command; } /// @@ -52,7 +51,7 @@ public Command BuildGetCommand() { public RowsAboveRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.rowsAbove()"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.rowsAbove()"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsAbove - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsAboveResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs index 975582c3003..81c3afc7452 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.RowsAboveWithCount { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsAbove(count={count}) + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsAbove(count={count}) public class RowsAboveWithCountRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function rowsAbove"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var countOption = new Option("--count", description: "Usage: count={count}") { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string trendingId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, countOption, outputOption); return command; } /// @@ -57,7 +56,7 @@ public Command BuildGetCommand() { public RowsAboveWithCountRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, int? count = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.rowsAbove(count={count})"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.rowsAbove(count={count})"; var urlTplParams = new Dictionary(pathParameters); urlTplParams.Add("count", count); PathParameters = urlTplParams; @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsAbove - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsAboveWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs index 2e42cf31c76..f8908caeb39 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.RowsBelow { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsBelow() + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsBelow() public class RowsBelowRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function rowsBelow"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, outputOption); return command; } /// @@ -52,7 +51,7 @@ public Command BuildGetCommand() { public RowsBelowRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.rowsBelow()"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.rowsBelow()"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsBelow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsBelowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs index 048a034bf41..6580989a6f3 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.RowsBelowWithCount { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsBelow(count={count}) + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsBelow(count={count}) public class RowsBelowWithCountRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function rowsBelow"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var countOption = new Option("--count", description: "Usage: count={count}") { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string trendingId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, countOption, outputOption); return command; } /// @@ -57,7 +56,7 @@ public Command BuildGetCommand() { public RowsBelowWithCountRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, int? count = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.rowsBelow(count={count})"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.rowsBelow(count={count})"; var urlTplParams = new Dictionary(pathParameters); urlTplParams.Add("count", count); PathParameters = urlTplParams; @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsBelow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsBelowWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs index be207f0a592..b4783d213fd 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.Unmerge { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.unmerge + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.unmerge public class UnmergeRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -25,17 +25,16 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action unmerge"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + command.SetHandler(async (string trendingItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, trendingIdOption); + }, trendingItemIdOption); return command; } /// @@ -46,7 +45,7 @@ public Command BuildPostCommand() { public UnmergeRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.unmerge"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.unmerge"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action unmerge - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs index 8c31ed49911..805df1dee60 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.UsedRange { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.usedRange() + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.usedRange() public class UsedRangeRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, outputOption); return command; } /// @@ -52,7 +51,7 @@ public Command BuildGetCommand() { public UsedRangeRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.usedRange()"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.usedRange()"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs index 4fcc5fa6384..fdd36e0cc82 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.UsedRangeWithValuesOnly { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.usedRange(valuesOnly={valuesOnly}) + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.usedRange(valuesOnly={valuesOnly}) public class UsedRangeWithValuesOnlyRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - var valuesOnlyOption = new Option("--valuesonly", description: "Usage: valuesOnly={valuesOnly}") { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var valuesOnlyOption = new Option("--values-only", description: "Usage: valuesOnly={valuesOnly}") { }; valuesOnlyOption.IsRequired = true; command.AddOption(valuesOnlyOption); - command.SetHandler(async (string trendingId, bool? valuesOnly) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, bool? valuesOnly, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption, valuesOnlyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, valuesOnlyOption, outputOption); return command; } /// @@ -57,7 +56,7 @@ public Command BuildGetCommand() { public UsedRangeWithValuesOnlyRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, bool? valuesOnly = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.usedRange(valuesOnly={valuesOnly})"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.usedRange(valuesOnly={valuesOnly})"; var urlTplParams = new Dictionary(pathParameters); urlTplParams.Add("valuesOnly", valuesOnly); PathParameters = urlTplParams; @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeWithValuesOnlyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs index e22f053cbed..65daec73628 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.VisibleView { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.visibleView() + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.visibleView() public class VisibleViewRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function visibleView"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, outputOption); return command; } /// @@ -52,7 +51,7 @@ public Command BuildGetCommand() { public VisibleViewRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.visibleView()"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.visibleView()"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function visibleView - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRangeView public class VisibleViewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/WorkbookRangeRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/WorkbookRangeRequestBuilder.cs index bcb0783a447..f2d48798825 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/WorkbookRangeRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRange/WorkbookRangeRequestBuilder.cs @@ -27,16 +27,16 @@ using ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.UsedRangeWithValuesOnly; using ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange.VisibleView; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRange { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange public class WorkbookRangeRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -45,7 +45,7 @@ public class WorkbookRangeRequestBuilder { /// Url template to use to build the URL for the current request builder private string UrlTemplate { get; set; } /// - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.boundingRect(anotherRange='{anotherRange}') + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.boundingRect(anotherRange='{anotherRange}') /// Usage: anotherRange={anotherRange} /// public BoundingRectWithAnotherRangeRequestBuilder BoundingRectWithAnotherRange(string anotherRange) { @@ -83,7 +83,7 @@ public Command BuildUnmergeCommand() { return command; } /// - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.cell(row={row},column={column}) + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.cell(row={row},column={column}) /// Usage: column={column} /// Usage: row={row} /// @@ -93,13 +93,13 @@ public CellWithRowWithColumnRequestBuilder CellWithRowWithColumn(int? row, int? return new CellWithRowWithColumnRequestBuilder(PathParameters, RequestAdapter, row, column); } /// - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsAfter() + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsAfter() /// public ColumnsAfterRequestBuilder ColumnsAfter() { return new ColumnsAfterRequestBuilder(PathParameters, RequestAdapter); } /// - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsAfter(count={count}) + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsAfter(count={count}) /// Usage: count={count} /// public ColumnsAfterWithCountRequestBuilder ColumnsAfterWithCount(int? count) { @@ -107,13 +107,13 @@ public ColumnsAfterWithCountRequestBuilder ColumnsAfterWithCount(int? count) { return new ColumnsAfterWithCountRequestBuilder(PathParameters, RequestAdapter, count); } /// - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsBefore() + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsBefore() /// public ColumnsBeforeRequestBuilder ColumnsBefore() { return new ColumnsBeforeRequestBuilder(PathParameters, RequestAdapter); } /// - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsBefore(count={count}) + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsBefore(count={count}) /// Usage: count={count} /// public ColumnsBeforeWithCountRequestBuilder ColumnsBeforeWithCount(int? count) { @@ -121,7 +121,7 @@ public ColumnsBeforeWithCountRequestBuilder ColumnsBeforeWithCount(int? count) { return new ColumnsBeforeWithCountRequestBuilder(PathParameters, RequestAdapter, count); } /// - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.column(column={column}) + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.column(column={column}) /// Usage: column={column} /// public ColumnWithColumnRequestBuilder ColumnWithColumn(int? column) { @@ -136,25 +136,25 @@ public ColumnWithColumnRequestBuilder ColumnWithColumn(int? column) { public WorkbookRangeRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; } /// - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.entireColumn() + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.entireColumn() /// public EntireColumnRequestBuilder EntireColumn() { return new EntireColumnRequestBuilder(PathParameters, RequestAdapter); } /// - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.entireRow() + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.entireRow() /// public EntireRowRequestBuilder EntireRow() { return new EntireRowRequestBuilder(PathParameters, RequestAdapter); } /// - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.intersection(anotherRange='{anotherRange}') + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.intersection(anotherRange='{anotherRange}') /// Usage: anotherRange={anotherRange} /// public IntersectionWithAnotherRangeRequestBuilder IntersectionWithAnotherRange(string anotherRange) { @@ -162,25 +162,25 @@ public IntersectionWithAnotherRangeRequestBuilder IntersectionWithAnotherRange(s return new IntersectionWithAnotherRangeRequestBuilder(PathParameters, RequestAdapter, anotherRange); } /// - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.lastCell() + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.lastCell() /// public LastCellRequestBuilder LastCell() { return new LastCellRequestBuilder(PathParameters, RequestAdapter); } /// - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.lastColumn() + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.lastColumn() /// public LastColumnRequestBuilder LastColumn() { return new LastColumnRequestBuilder(PathParameters, RequestAdapter); } /// - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.lastRow() + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.lastRow() /// public LastRowRequestBuilder LastRow() { return new LastRowRequestBuilder(PathParameters, RequestAdapter); } /// - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.offsetRange(rowOffset={rowOffset},columnOffset={columnOffset}) + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.offsetRange(rowOffset={rowOffset},columnOffset={columnOffset}) /// Usage: columnOffset={columnOffset} /// Usage: rowOffset={rowOffset} /// @@ -190,7 +190,7 @@ public OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder OffsetRangeWithRow return new OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder(PathParameters, RequestAdapter, rowOffset, columnOffset); } /// - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.resizedRange(deltaRows={deltaRows},deltaColumns={deltaColumns}) + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.resizedRange(deltaRows={deltaRows},deltaColumns={deltaColumns}) /// Usage: deltaColumns={deltaColumns} /// Usage: deltaRows={deltaRows} /// @@ -200,13 +200,13 @@ public ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder ResizedRangeWithD return new ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder(PathParameters, RequestAdapter, deltaRows, deltaColumns); } /// - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsAbove() + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsAbove() /// public RowsAboveRequestBuilder RowsAbove() { return new RowsAboveRequestBuilder(PathParameters, RequestAdapter); } /// - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsAbove(count={count}) + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsAbove(count={count}) /// Usage: count={count} /// public RowsAboveWithCountRequestBuilder RowsAboveWithCount(int? count) { @@ -214,13 +214,13 @@ public RowsAboveWithCountRequestBuilder RowsAboveWithCount(int? count) { return new RowsAboveWithCountRequestBuilder(PathParameters, RequestAdapter, count); } /// - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsBelow() + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsBelow() /// public RowsBelowRequestBuilder RowsBelow() { return new RowsBelowRequestBuilder(PathParameters, RequestAdapter); } /// - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsBelow(count={count}) + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsBelow(count={count}) /// Usage: count={count} /// public RowsBelowWithCountRequestBuilder RowsBelowWithCount(int? count) { @@ -228,7 +228,7 @@ public RowsBelowWithCountRequestBuilder RowsBelowWithCount(int? count) { return new RowsBelowWithCountRequestBuilder(PathParameters, RequestAdapter, count); } /// - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.row(row={row}) + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.row(row={row}) /// Usage: row={row} /// public RowWithRowRequestBuilder RowWithRow(int? row) { @@ -236,13 +236,13 @@ public RowWithRowRequestBuilder RowWithRow(int? row) { return new RowWithRowRequestBuilder(PathParameters, RequestAdapter, row); } /// - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.usedRange() + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.usedRange() /// public UsedRangeRequestBuilder UsedRange() { return new UsedRangeRequestBuilder(PathParameters, RequestAdapter); } /// - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.usedRange(valuesOnly={valuesOnly}) + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.usedRange(valuesOnly={valuesOnly}) /// Usage: valuesOnly={valuesOnly} /// public UsedRangeWithValuesOnlyRequestBuilder UsedRangeWithValuesOnly(bool? valuesOnly) { @@ -250,7 +250,7 @@ public UsedRangeWithValuesOnlyRequestBuilder UsedRangeWithValuesOnly(bool? value return new UsedRangeWithValuesOnlyRequestBuilder(PathParameters, RequestAdapter, valuesOnly); } /// - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.visibleView() + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.visibleView() /// public VisibleViewRequestBuilder VisibleView() { return new VisibleViewRequestBuilder(PathParameters, RequestAdapter); diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeFill/Clear/ClearRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeFill/Clear/ClearRequestBuilder.cs index 65143add167..0d24c406015 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeFill/Clear/ClearRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeFill/Clear/ClearRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRangeFill.Clear { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRangeFill\microsoft.graph.clear + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRangeFill\microsoft.graph.clear public class ClearRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -25,17 +25,16 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + command.SetHandler(async (string trendingItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, trendingIdOption); + }, trendingItemIdOption); return command; } /// @@ -46,7 +45,7 @@ public Command BuildPostCommand() { public ClearRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRangeFill/microsoft.graph.clear"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRangeFill/microsoft.graph.clear"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs index 1d60aeac0c4..72f1b32db96 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs @@ -1,15 +1,15 @@ using ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRangeFill.Clear; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRangeFill { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRangeFill + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRangeFill public class WorkbookRangeFillRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -31,7 +31,7 @@ public Command BuildClearCommand() { public WorkbookRangeFillRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRangeFill"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRangeFill"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs index 4aefd06cff9..1f7f0d746de 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRangeFormat.AutofitColumns { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRangeFormat\microsoft.graph.autofitColumns + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRangeFormat\microsoft.graph.autofitColumns public class AutofitColumnsRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -25,17 +25,16 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action autofitColumns"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + command.SetHandler(async (string trendingItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, trendingIdOption); + }, trendingItemIdOption); return command; } /// @@ -46,7 +45,7 @@ public Command BuildPostCommand() { public AutofitColumnsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRangeFormat/microsoft.graph.autofitColumns"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRangeFormat/microsoft.graph.autofitColumns"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action autofitColumns - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs index cc3048c2727..27639aa5c95 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRangeFormat.AutofitRows { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRangeFormat\microsoft.graph.autofitRows + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRangeFormat\microsoft.graph.autofitRows public class AutofitRowsRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -25,17 +25,16 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action autofitRows"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + command.SetHandler(async (string trendingItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, trendingIdOption); + }, trendingItemIdOption); return command; } /// @@ -46,7 +45,7 @@ public Command BuildPostCommand() { public AutofitRowsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRangeFormat/microsoft.graph.autofitRows"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRangeFormat/microsoft.graph.autofitRows"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action autofitRows - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs index f3aa444b17e..a65549ec883 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs @@ -1,16 +1,16 @@ using ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRangeFormat.AutofitColumns; using ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRangeFormat.AutofitRows; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRangeFormat { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRangeFormat + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRangeFormat public class WorkbookRangeFormatRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -38,7 +38,7 @@ public Command BuildAutofitRowsCommand() { public WorkbookRangeFormatRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRangeFormat"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRangeFormat"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs index 9562e658af6..50b801d1912 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRangeSort.Apply { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRangeSort\microsoft.graph.apply + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRangeSort\microsoft.graph.apply public class ApplyRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -25,24 +25,23 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action apply"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string trendingId, string body) => { + command.SetHandler(async (string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, trendingIdOption, bodyOption); + }, trendingItemIdOption, bodyOption); return command; } /// @@ -53,7 +52,7 @@ public Command BuildPostCommand() { public ApplyRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRangeSort/microsoft.graph.apply"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRangeSort/microsoft.graph.apply"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ApplyRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action apply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs index 09596f26f3d..8128f45e4ab 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs @@ -1,15 +1,15 @@ using ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRangeSort.Apply; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRangeSort { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRangeSort + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRangeSort public class WorkbookRangeSortRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -31,7 +31,7 @@ public Command BuildApplyCommand() { public WorkbookRangeSortRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRangeSort"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRangeSort"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeView/Range/RangeRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeView/Range/RangeRequestBuilder.cs index 17a74e014a8..18e9de5abf1 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeView/Range/RangeRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeView/Range/RangeRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRangeView.Range { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRangeView\microsoft.graph.range() + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRangeView\microsoft.graph.range() public class RangeRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, outputOption); return command; } /// @@ -52,7 +51,7 @@ public Command BuildGetCommand() { public RangeRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRangeView/microsoft.graph.range()"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRangeView/microsoft.graph.range()"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs index 2c73e5227d2..1ce2806996a 100644 --- a/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/Item/Resource/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs @@ -1,15 +1,15 @@ using ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRangeView.Range; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ApiSdk.Me.Insights.Trending.Item.Resource.WorkbookRangeView { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRangeView + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRangeView public class WorkbookRangeViewRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -25,13 +25,13 @@ public class WorkbookRangeViewRequestBuilder { public WorkbookRangeViewRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}/resource/microsoft.graph.workbookRangeView"; + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRangeView"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; } /// - /// Builds and executes requests for operations under \me\insights\trending\{trending-id}\resource\microsoft.graph.workbookRangeView\microsoft.graph.range() + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRangeView\microsoft.graph.range() /// public RangeRequestBuilder Range() { return new RangeRequestBuilder(PathParameters, RequestAdapter); diff --git a/src/generated/Me/Insights/Trending/Item/TrendingItemRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/TrendingItemRequestBuilder.cs new file mode 100644 index 00000000000..c5947e09034 --- /dev/null +++ b/src/generated/Me/Insights/Trending/Item/TrendingItemRequestBuilder.cs @@ -0,0 +1,199 @@ +using ApiSdk.Me.Insights.Trending.Item.Resource; +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Me.Insights.Trending.Item { + /// Builds and executes requests for operations under \me\insights\trending\{trendingItem-Id} + public class TrendingItemRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Access this property from the derived type itemInsights. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Access this property from the derived type itemInsights."; + // Create options for all the parameters + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { + }; + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + command.SetHandler(async (string trendingItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, trendingItemIdOption); + return command; + } + /// + /// Access this property from the derived type itemInsights. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Access this property from the derived type itemInsights."; + // Create options for all the parameters + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { + }; + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var selectOption = new Option("--select", description: "Select properties to be returned") { + Arity = ArgumentArity.ZeroOrMore + }; + selectOption.IsRequired = false; + command.AddOption(selectOption); + var expandOption = new Option("--expand", description: "Expand related entities") { + Arity = ArgumentArity.ZeroOrMore + }; + expandOption.IsRequired = false; + command.AddOption(expandOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string trendingItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Select = select; + q.Expand = expand; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, trendingItemIdOption, selectOption, expandOption, outputOption); + return command; + } + /// + /// Access this property from the derived type itemInsights. + /// + public Command BuildPatchCommand() { + var command = new Command("patch"); + command.Description = "Access this property from the derived type itemInsights."; + // Create options for all the parameters + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { + }; + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePatchRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, trendingItemIdOption, bodyOption); + return command; + } + public Command BuildResourceCommand() { + var command = new Command("resource"); + var builder = new ApiSdk.Me.Insights.Trending.Item.Resource.ResourceRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildCalendarSharingMessageCommand()); + command.AddCommand(builder.BuildGetCommand()); + command.AddCommand(builder.BuildManagedAppProtectionCommand()); + command.AddCommand(builder.BuildMobileAppContentFileCommand()); + command.AddCommand(builder.BuildPrintDocumentCommand()); + command.AddCommand(builder.BuildPrintJobCommand()); + command.AddCommand(builder.BuildRefCommand()); + command.AddCommand(builder.BuildScheduleChangeRequestCommand()); + command.AddCommand(builder.BuildTargetedManagedAppProtectionCommand()); + command.AddCommand(builder.BuildWindowsInformationProtectionCommand()); + command.AddCommand(builder.BuildWorkbookRangeCommand()); + command.AddCommand(builder.BuildWorkbookRangeFillCommand()); + command.AddCommand(builder.BuildWorkbookRangeFormatCommand()); + command.AddCommand(builder.BuildWorkbookRangeSortCommand()); + command.AddCommand(builder.BuildWorkbookRangeViewCommand()); + return command; + } + /// + /// Instantiates a new TrendingItemRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public TrendingItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/me/insights/trending/{trendingItem_Id}{?select,expand}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Access this property from the derived type itemInsights. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Access this property from the derived type itemInsights. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Access this property from the derived type itemInsights. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft.Graph.Trending body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PATCH, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Access this property from the derived type itemInsights. + public class GetQueryParameters : QueryParametersBase { + /// Expand related entities + public string[] Expand { get; set; } + /// Select properties to be returned + public string[] Select { get; set; } + } + } +} diff --git a/src/generated/Me/Insights/Trending/Item/TrendingRequestBuilder.cs b/src/generated/Me/Insights/Trending/Item/TrendingRequestBuilder.cs deleted file mode 100644 index 92c7246f3fa..00000000000 --- a/src/generated/Me/Insights/Trending/Item/TrendingRequestBuilder.cs +++ /dev/null @@ -1,238 +0,0 @@ -using ApiSdk.Me.Insights.Trending.Item.Resource; -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Me.Insights.Trending.Item { - /// Builds and executes requests for operations under \me\insights\trending\{trending-id} - public class TrendingRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Access this property from the derived type itemInsights. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Access this property from the derived type itemInsights."; - // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { - }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string trendingId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, trendingIdOption); - return command; - } - /// - /// Access this property from the derived type itemInsights. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Access this property from the derived type itemInsights."; - // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { - }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string trendingId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, trendingIdOption, selectOption, expandOption); - return command; - } - /// - /// Access this property from the derived type itemInsights. - /// - public Command BuildPatchCommand() { - var command = new Command("patch"); - command.Description = "Access this property from the derived type itemInsights."; - // Create options for all the parameters - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { - }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string trendingId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePatchRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, trendingIdOption, bodyOption); - return command; - } - public Command BuildResourceCommand() { - var command = new Command("resource"); - var builder = new ApiSdk.Me.Insights.Trending.Item.Resource.ResourceRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildCalendarSharingMessageCommand()); - command.AddCommand(builder.BuildGetCommand()); - command.AddCommand(builder.BuildManagedAppProtectionCommand()); - command.AddCommand(builder.BuildMobileAppContentFileCommand()); - command.AddCommand(builder.BuildPrintDocumentCommand()); - command.AddCommand(builder.BuildPrintJobCommand()); - command.AddCommand(builder.BuildRefCommand()); - command.AddCommand(builder.BuildScheduleChangeRequestCommand()); - command.AddCommand(builder.BuildTargetedManagedAppProtectionCommand()); - command.AddCommand(builder.BuildWindowsInformationProtectionCommand()); - command.AddCommand(builder.BuildWorkbookRangeCommand()); - command.AddCommand(builder.BuildWorkbookRangeFillCommand()); - command.AddCommand(builder.BuildWorkbookRangeFormatCommand()); - command.AddCommand(builder.BuildWorkbookRangeSortCommand()); - command.AddCommand(builder.BuildWorkbookRangeViewCommand()); - return command; - } - /// - /// Instantiates a new TrendingRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public TrendingRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/trending/{trending_id}{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Access this property from the derived type itemInsights. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Access this property from the derived type itemInsights. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Access this property from the derived type itemInsights. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft.Graph.Trending body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PATCH, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Trending model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// Access this property from the derived type itemInsights. - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/Me/Insights/Trending/TrendingRequestBuilder.cs b/src/generated/Me/Insights/Trending/TrendingRequestBuilder.cs index 3d902a5b3c3..8378177343d 100644 --- a/src/generated/Me/Insights/Trending/TrendingRequestBuilder.cs +++ b/src/generated/Me/Insights/Trending/TrendingRequestBuilder.cs @@ -1,10 +1,11 @@ +using ApiSdk.Me.Insights.Trending.Item; using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -20,11 +21,12 @@ public class TrendingRequestBuilder { /// Url template to use to build the URL for the current request builder private string UrlTemplate { get; set; } public List BuildCommand() { - var builder = new TrendingRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCreateCommand(), - builder.BuildListCommand(), - }; + var builder = new TrendingItemRequestBuilder(PathParameters, RequestAdapter); + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildResourceCommand()); return commands; } /// @@ -38,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -97,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -108,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -171,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Trending model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Access this property from the derived type itemInsights. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Insights/Used/Item/Resource/@Ref/@Ref.cs b/src/generated/Me/Insights/Used/Item/Resource/@Ref/@Ref.cs deleted file mode 100644 index 823fa9e099f..00000000000 --- a/src/generated/Me/Insights/Used/Item/Resource/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.Insights.Used.Item.Resource.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/Insights/Used/Item/Resource/@Ref/RefRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/@Ref/RefRequestBuilder.cs deleted file mode 100644 index c941270d8b6..00000000000 --- a/src/generated/Me/Insights/Used/Item/Resource/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Me.Insights.Used.Item.Resource.@Ref { - /// Builds and executes requests for operations under \me\insights\used\{usedInsight-id}\resource\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem."; - // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { - }; - usedInsightIdOption.IsRequired = true; - command.AddOption(usedInsightIdOption); - command.SetHandler(async (string usedInsightId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, usedInsightIdOption); - return command; - } - /// - /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem."; - // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { - }; - usedInsightIdOption.IsRequired = true; - command.AddOption(usedInsightIdOption); - command.SetHandler(async (string usedInsightId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption); - return command; - } - /// - /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem."; - // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { - }; - usedInsightIdOption.IsRequired = true; - command.AddOption(usedInsightIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string usedInsightId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, usedInsightIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/insights/used/{usedInsight_id}/resource/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Me.Insights.Used.Item.Resource.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Me.Insights.Used.Item.Resource.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Me/Insights/Used/Item/Resource/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs index 891ba736c8d..1a1db856231 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action accept"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, outputOption); return command; } /// @@ -72,16 +71,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Used/Item/Resource/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs index 489e6170ad3..3f33a2e3eed 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Me.Insights.Used.Item.Resource.CalendarSharingMessage.Accept; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Used/Item/Resource/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs index 310b384739a..c7615294b9f 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Me.Insights.Used.Item.Resource.ManagedAppProtection.TargetApps; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Used/Item/Resource/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs index 1e189914a51..32df51598d2 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action targetApps"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string usedInsightId, string body) => { + command.SetHandler(async (string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, usedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(TargetAppsRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action targetApps - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetAppsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Used/Item/Resource/MobileAppContentFile/Commit/CommitRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/MobileAppContentFile/Commit/CommitRequestBuilder.cs index 8a16f8335dd..48033ae1927 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/MobileAppContentFile/Commit/CommitRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/MobileAppContentFile/Commit/CommitRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Commits a file of a given app."; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string usedInsightId, string body) => { + command.SetHandler(async (string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, usedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(CommitRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Commits a file of a given app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CommitRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Used/Item/Resource/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs index d2f76868cdf..0f7960bf295 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Me.Insights.Used.Item.Resource.MobileAppContentFile.Commit; using ApiSdk.Me.Insights.Used.Item.Resource.MobileAppContentFile.RenewUpload; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Used/Item/Resource/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs index 20b4287f7d7..4cc30d2c0fa 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Renews the SAS URI for an application file upload."; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string usedInsightId) => { + command.SetHandler(async (string usedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, usedInsightIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Renews the SAS URI for an application file upload. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Used/Item/Resource/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index 32e20a38d27..8521009c9fa 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action createUploadSession"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string usedInsightId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/PrintDocument/PrintDocumentRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/PrintDocument/PrintDocumentRequestBuilder.cs index 7b5012fb6ba..01782978ff6 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/PrintDocument/PrintDocumentRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/PrintDocument/PrintDocumentRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Me.Insights.Used.Item.Resource.PrintDocument.CreateUploadSession; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Used/Item/Resource/PrintJob/Abort/AbortRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/PrintJob/Abort/AbortRequestBuilder.cs index 97c530ac130..b45622f3769 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/PrintJob/Abort/AbortRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/PrintJob/Abort/AbortRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action abort"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string usedInsightId, string body) => { + command.SetHandler(async (string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, usedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(AbortRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action abort - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AbortRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Used/Item/Resource/PrintJob/Cancel/CancelRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/PrintJob/Cancel/CancelRequestBuilder.cs index acb5e2255e0..eb1ff6e22cd 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/PrintJob/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/PrintJob/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action cancel"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string usedInsightId) => { + command.SetHandler(async (string usedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, usedInsightIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Used/Item/Resource/PrintJob/PrintJobRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/PrintJob/PrintJobRequestBuilder.cs index 7d69af07512..09c656b39b1 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/PrintJob/PrintJobRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/PrintJob/PrintJobRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Me.Insights.Used.Item.Resource.PrintJob.Redirect; using ApiSdk.Me.Insights.Used.Item.Resource.PrintJob.Start; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Used/Item/Resource/PrintJob/Redirect/RedirectRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/PrintJob/Redirect/RedirectRequestBuilder.cs index 81aa2a7751a..3eef8f8f6bf 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/PrintJob/Redirect/RedirectRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/PrintJob/Redirect/RedirectRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action redirect"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string usedInsightId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(RedirectRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action redirect - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RedirectRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes printJob public class RedirectResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/PrintJob/Start/StartRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/PrintJob/Start/StartRequestBuilder.cs index 647b493dda9..ee825c70c7f 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/PrintJob/Start/StartRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/PrintJob/Start/StartRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action start"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action start - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes printJobStatus public class StartResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/Ref/Ref.cs b/src/generated/Me/Insights/Used/Item/Resource/Ref/Ref.cs new file mode 100644 index 00000000000..86026066ce6 --- /dev/null +++ b/src/generated/Me/Insights/Used/Item/Resource/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.Insights.Used.Item.Resource.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/Insights/Used/Item/Resource/Ref/RefRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..c4497957937 --- /dev/null +++ b/src/generated/Me/Insights/Used/Item/Resource/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Me.Insights.Used.Item.Resource.Ref { + /// Builds and executes requests for operations under \me\insights\used\{usedInsight-id}\resource\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem."; + // Create options for all the parameters + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { + }; + usedInsightIdOption.IsRequired = true; + command.AddOption(usedInsightIdOption); + command.SetHandler(async (string usedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, usedInsightIdOption); + return command; + } + /// + /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem."; + // Create options for all the parameters + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { + }; + usedInsightIdOption.IsRequired = true; + command.AddOption(usedInsightIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, outputOption); + return command; + } + /// + /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem."; + // Create options for all the parameters + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { + }; + usedInsightIdOption.IsRequired = true; + command.AddOption(usedInsightIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, usedInsightIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/me/insights/used/{usedInsight_id}/resource/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Me.Insights.Used.Item.Resource.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Me/Insights/Used/Item/Resource/ResourceRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/ResourceRequestBuilder.cs index c3a63e97ca2..fe2ed8039c6 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/ResourceRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/ResourceRequestBuilder.cs @@ -15,10 +15,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -46,7 +46,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem."; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -60,20 +60,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string usedInsightId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildManagedAppProtectionCommand() { @@ -106,7 +105,7 @@ public Command BuildPrintJobCommand() { } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Me.Insights.Used.Item.Resource.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Me.Insights.Used.Item.Resource.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -200,18 +199,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Insights/Used/Item/Resource/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs index 935f4b4df64..0cdd1f13afb 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action approve"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string usedInsightId, string body) => { + command.SetHandler(async (string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, usedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ApproveRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action approve - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApproveRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Used/Item/Resource/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs index 81b0f9c59ad..29220a7aef4 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action decline"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string usedInsightId, string body) => { + command.SetHandler(async (string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, usedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Used/Item/Resource/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs index 74a95ff753e..66739bcc13a 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Me.Insights.Used.Item.Resource.ScheduleChangeRequest.Approve; using ApiSdk.Me.Insights.Used.Item.Resource.ScheduleChangeRequest.Decline; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Used/Item/Resource/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs index d188e2a354d..0e120044015 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action assign"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string usedInsightId, string body) => { + command.SetHandler(async (string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, usedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Used/Item/Resource/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs index 7d44cf89195..1124b5effdc 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action targetApps"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string usedInsightId, string body) => { + command.SetHandler(async (string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, usedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(TargetAppsRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action targetApps - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetAppsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Used/Item/Resource/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs index dab2d9f0e95..e9a431a9424 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Me.Insights.Used.Item.Resource.TargetedManagedAppProtection.Assign; using ApiSdk.Me.Insights.Used.Item.Resource.TargetedManagedAppProtection.TargetApps; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Used/Item/Resource/WindowsInformationProtection/Assign/AssignRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WindowsInformationProtection/Assign/AssignRequestBuilder.cs index 1d1fe10f883..e297176930f 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WindowsInformationProtection/Assign/AssignRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WindowsInformationProtection/Assign/AssignRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action assign"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string usedInsightId, string body) => { + command.SetHandler(async (string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, usedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Used/Item/Resource/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs index a8d00475e18..d225b74bad0 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Me.Insights.Used.Item.Resource.WindowsInformationProtection.Assign; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs index e9c9882deac..b2552f25179 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function boundingRect"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - var anotherRangeOption = new Option("--anotherrange", description: "Usage: anotherRange={anotherRange}") { + var anotherRangeOption = new Option("--another-range", description: "Usage: anotherRange={anotherRange}") { }; anotherRangeOption.IsRequired = true; command.AddOption(anotherRangeOption); - command.SetHandler(async (string usedInsightId, string anotherRange) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, string anotherRange, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption, anotherRangeOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, anotherRangeOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function boundingRect - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class BoundingRectWithAnotherRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs index 24f48033852..0406f7580ef 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function cell"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string usedInsightId, int? row, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, int? row, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption, rowOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, rowOption, columnOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function cell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class CellWithRowWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/Clear/ClearRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/Clear/ClearRequestBuilder.cs index ee28f6b7bcc..e89ffb8f348 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/Clear/ClearRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string usedInsightId, string body) => { + command.SetHandler(async (string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, usedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ClearRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ClearRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs index 1e566d67f90..050b5819bb9 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function column"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -34,18 +34,17 @@ public Command BuildGetCommand() { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string usedInsightId, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, columnOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function column - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs index 1697a44dc65..26eaa5474ac 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function columnsAfter"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsAfter - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsAfterResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs index 3fbbd7b22ed..a1d4877d5a1 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function columnsAfter"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -34,18 +34,17 @@ public Command BuildGetCommand() { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string usedInsightId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, countOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsAfter - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsAfterWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs index 1194fee8458..b3b572a3038 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function columnsBefore"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsBefore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsBeforeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs index ff7821659e0..a85ff0ebb76 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function columnsBefore"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -34,18 +34,17 @@ public Command BuildGetCommand() { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string usedInsightId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, countOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsBefore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsBeforeWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/Delete/DeleteRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/Delete/DeleteRequestBuilder.cs index 46b1d2c22ba..b20fdf0dc86 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/Delete/DeleteRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/Delete/DeleteRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action delete"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string usedInsightId, string body) => { + command.SetHandler(async (string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, usedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(DeleteRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action delete - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeleteRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs index 93608aa66d5..96ac0c1773e 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function entireColumn"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function entireColumn - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class EntireColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs index fac1c46b413..c2d531f606d 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function entireRow"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function entireRow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class EntireRowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/Insert/InsertRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/Insert/InsertRequestBuilder.cs index 62fe97013b0..700f1e836df 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/Insert/InsertRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/Insert/InsertRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action insert"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string usedInsightId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(InsertRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action insert - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(InsertRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class InsertResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs index 63bafcd6b80..18fb71dfbc9 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function intersection"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - var anotherRangeOption = new Option("--anotherrange", description: "Usage: anotherRange={anotherRange}") { + var anotherRangeOption = new Option("--another-range", description: "Usage: anotherRange={anotherRange}") { }; anotherRangeOption.IsRequired = true; command.AddOption(anotherRangeOption); - command.SetHandler(async (string usedInsightId, string anotherRange) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, string anotherRange, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption, anotherRangeOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, anotherRangeOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function intersection - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class IntersectionWithAnotherRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/LastCell/LastCellRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/LastCell/LastCellRequestBuilder.cs index a01d195d73a..846899c031b 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/LastCell/LastCellRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/LastCell/LastCellRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function lastCell"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function lastCell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class LastCellResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs index 0d83be87132..b5627c0a67d 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function lastColumn"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function lastColumn - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class LastColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/LastRow/LastRowRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/LastRow/LastRowRequestBuilder.cs index 29f99ca13f8..5981d98d547 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/LastRow/LastRowRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/LastRow/LastRowRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function lastRow"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function lastRow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class LastRowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/Merge/MergeRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/Merge/MergeRequestBuilder.cs index d3af281c62d..ca68c06036f 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/Merge/MergeRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/Merge/MergeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action merge"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string usedInsightId, string body) => { + command.SetHandler(async (string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, usedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(MergeRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action merge - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MergeRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs index 04c7a84e6c3..8f5553bf1d7 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function offsetRange"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - var rowOffsetOption = new Option("--rowoffset", description: "Usage: rowOffset={rowOffset}") { + var rowOffsetOption = new Option("--row-offset", description: "Usage: rowOffset={rowOffset}") { }; rowOffsetOption.IsRequired = true; command.AddOption(rowOffsetOption); - var columnOffsetOption = new Option("--columnoffset", description: "Usage: columnOffset={columnOffset}") { + var columnOffsetOption = new Option("--column-offset", description: "Usage: columnOffset={columnOffset}") { }; columnOffsetOption.IsRequired = true; command.AddOption(columnOffsetOption); - command.SetHandler(async (string usedInsightId, int? rowOffset, int? columnOffset) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, int? rowOffset, int? columnOffset, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption, rowOffsetOption, columnOffsetOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, rowOffsetOption, columnOffsetOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function offsetRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class OffsetRangeWithRowOffsetWithColumnOffsetResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs index da8e5fb53c3..7ba780706f8 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function resizedRange"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - var deltaRowsOption = new Option("--deltarows", description: "Usage: deltaRows={deltaRows}") { + var deltaRowsOption = new Option("--delta-rows", description: "Usage: deltaRows={deltaRows}") { }; deltaRowsOption.IsRequired = true; command.AddOption(deltaRowsOption); - var deltaColumnsOption = new Option("--deltacolumns", description: "Usage: deltaColumns={deltaColumns}") { + var deltaColumnsOption = new Option("--delta-columns", description: "Usage: deltaColumns={deltaColumns}") { }; deltaColumnsOption.IsRequired = true; command.AddOption(deltaColumnsOption); - command.SetHandler(async (string usedInsightId, int? deltaRows, int? deltaColumns) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, int? deltaRows, int? deltaColumns, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption, deltaRowsOption, deltaColumnsOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, deltaRowsOption, deltaColumnsOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function resizedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ResizedRangeWithDeltaRowsWithDeltaColumnsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs index b544d355ebc..9f2245201b1 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function row"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -34,18 +34,17 @@ public Command BuildGetCommand() { }; rowOption.IsRequired = true; command.AddOption(rowOption); - command.SetHandler(async (string usedInsightId, int? row) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, int? row, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption, rowOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, rowOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function row - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowWithRowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs index 89fd73af64d..302238ce17d 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function rowsAbove"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsAbove - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsAboveResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs index 329f835a41a..fe2728ebb2f 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function rowsAbove"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -34,18 +34,17 @@ public Command BuildGetCommand() { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string usedInsightId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, countOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsAbove - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsAboveWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs index 1c8530108c0..7b0c8573dbb 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function rowsBelow"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsBelow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsBelowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs index aba9cee8c3b..d50e8d758c8 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function rowsBelow"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -34,18 +34,17 @@ public Command BuildGetCommand() { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string usedInsightId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, countOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsBelow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsBelowWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs index c09397a1dea..a2df15ccca1 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action unmerge"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string usedInsightId) => { + command.SetHandler(async (string usedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, usedInsightIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action unmerge - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs index 6fadc5efb7e..fea7eaa95f3 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs index e1484734c7b..4d03dead97f 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - var valuesOnlyOption = new Option("--valuesonly", description: "Usage: valuesOnly={valuesOnly}") { + var valuesOnlyOption = new Option("--values-only", description: "Usage: valuesOnly={valuesOnly}") { }; valuesOnlyOption.IsRequired = true; command.AddOption(valuesOnlyOption); - command.SetHandler(async (string usedInsightId, bool? valuesOnly) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, bool? valuesOnly, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption, valuesOnlyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, valuesOnlyOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeWithValuesOnlyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs index 693a8f4454a..802f7f5a583 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function visibleView"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function visibleView - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRangeView public class VisibleViewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/WorkbookRangeRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/WorkbookRangeRequestBuilder.cs index f427d02db16..a56c7bd7a66 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/WorkbookRangeRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRange/WorkbookRangeRequestBuilder.cs @@ -27,10 +27,10 @@ using ApiSdk.Me.Insights.Used.Item.Resource.WorkbookRange.UsedRangeWithValuesOnly; using ApiSdk.Me.Insights.Used.Item.Resource.WorkbookRange.VisibleView; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeFill/Clear/ClearRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeFill/Clear/ClearRequestBuilder.cs index 48a8b8a7a8c..02440e7aa06 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeFill/Clear/ClearRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeFill/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string usedInsightId) => { + command.SetHandler(async (string usedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, usedInsightIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs index c86aa59a6dc..3d6cd708e63 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Me.Insights.Used.Item.Resource.WorkbookRangeFill.Clear; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs index bc1ce7ddd44..cd9236ab9c8 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action autofitColumns"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string usedInsightId) => { + command.SetHandler(async (string usedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, usedInsightIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action autofitColumns - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs index 01b92a55d70..99360e7093d 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action autofitRows"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string usedInsightId) => { + command.SetHandler(async (string usedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, usedInsightIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action autofitRows - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs index 749c6bae103..2a5cdf89c3e 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Me.Insights.Used.Item.Resource.WorkbookRangeFormat.AutofitColumns; using ApiSdk.Me.Insights.Used.Item.Resource.WorkbookRangeFormat.AutofitRows; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs index b8cd8a719fb..0a5e4fbac70 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action apply"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string usedInsightId, string body) => { + command.SetHandler(async (string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, usedInsightIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ApplyRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action apply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs index 1cc16a10f56..2a88641b87c 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Me.Insights.Used.Item.Resource.WorkbookRangeSort.Apply; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeView/Range/RangeRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeView/Range/RangeRequestBuilder.cs index 956cc7bbf93..8541c2e04a8 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeView/Range/RangeRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeView/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs index c13f3b2719e..9f968825976 100644 --- a/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/Resource/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Me.Insights.Used.Item.Resource.WorkbookRangeView.Range; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Insights/Used/Item/UsedInsightRequestBuilder.cs b/src/generated/Me/Insights/Used/Item/UsedInsightRequestBuilder.cs index e19145002fe..177fefeeac2 100644 --- a/src/generated/Me/Insights/Used/Item/UsedInsightRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/Item/UsedInsightRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,15 +27,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Access this property from the derived type itemInsights."; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string usedInsightId) => { + command.SetHandler(async (string usedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, usedInsightIdOption); return command; @@ -47,7 +46,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Access this property from the derived type itemInsights."; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -61,20 +60,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string usedInsightId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string usedInsightId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, usedInsightIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, usedInsightIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Access this property from the derived type itemInsights."; // Create options for all the parameters - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -92,14 +90,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string usedInsightId, string body) => { + command.SetHandler(async (string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, usedInsightIdOption, bodyOption); return command; @@ -191,42 +188,6 @@ public RequestInformation CreatePatchRequestInformation(UsedInsight body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(UsedInsight model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Access this property from the derived type itemInsights. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Insights/Used/UsedRequestBuilder.cs b/src/generated/Me/Insights/Used/UsedRequestBuilder.cs index 9450d9048c2..960db7e3b15 100644 --- a/src/generated/Me/Insights/Used/UsedRequestBuilder.cs +++ b/src/generated/Me/Insights/Used/UsedRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class UsedRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new UsedInsightRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildResourceCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildResourceCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(UsedInsight body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UsedInsight model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Access this property from the derived type itemInsights. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/JoinedTeams/Item/TeamRequestBuilder.cs b/src/generated/Me/JoinedTeams/Item/TeamRequestBuilder.cs index 26bb0d176b7..690f50b7abb 100644 --- a/src/generated/Me/JoinedTeams/Item/TeamRequestBuilder.cs +++ b/src/generated/Me/JoinedTeams/Item/TeamRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,10 @@ public Command BuildDeleteCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - command.SetHandler(async (string teamId) => { + command.SetHandler(async (string teamId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption); return command; @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { + command.SetHandler(async (string teamId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The Microsoft Teams teams that the user is a member of. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Microsoft Teams teams that the user is a member of. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Microsoft Teams teams that the user is a member of. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Team model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The Microsoft Teams teams that the user is a member of. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/JoinedTeams/JoinedTeamsRequestBuilder.cs b/src/generated/Me/JoinedTeams/JoinedTeamsRequestBuilder.cs index a00595e503d..3600797d708 100644 --- a/src/generated/Me/JoinedTeams/JoinedTeamsRequestBuilder.cs +++ b/src/generated/Me/JoinedTeams/JoinedTeamsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class JoinedTeamsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TeamRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The Microsoft Teams teams that the user is a member of. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Microsoft Teams teams that the user is a member of. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Team model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The Microsoft Teams teams that the user is a member of. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/LicenseDetails/Item/LicenseDetailsItemRequestBuilder.cs b/src/generated/Me/LicenseDetails/Item/LicenseDetailsItemRequestBuilder.cs new file mode 100644 index 00000000000..207f4c18e0f --- /dev/null +++ b/src/generated/Me/LicenseDetails/Item/LicenseDetailsItemRequestBuilder.cs @@ -0,0 +1,178 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Me.LicenseDetails.Item { + /// Builds and executes requests for operations under \me\licenseDetails\{licenseDetailsItem-id} + public class LicenseDetailsItemRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// A collection of this user's license details. Read-only. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "A collection of this user's license details. Read-only."; + // Create options for all the parameters + var licenseDetailsItemIdOption = new Option("--license-details-item-id", description: "key: id of licenseDetails") { + }; + licenseDetailsItemIdOption.IsRequired = true; + command.AddOption(licenseDetailsItemIdOption); + command.SetHandler(async (string licenseDetailsItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, licenseDetailsItemIdOption); + return command; + } + /// + /// A collection of this user's license details. Read-only. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "A collection of this user's license details. Read-only."; + // Create options for all the parameters + var licenseDetailsItemIdOption = new Option("--license-details-item-id", description: "key: id of licenseDetails") { + }; + licenseDetailsItemIdOption.IsRequired = true; + command.AddOption(licenseDetailsItemIdOption); + var selectOption = new Option("--select", description: "Select properties to be returned") { + Arity = ArgumentArity.ZeroOrMore + }; + selectOption.IsRequired = false; + command.AddOption(selectOption); + var expandOption = new Option("--expand", description: "Expand related entities") { + Arity = ArgumentArity.ZeroOrMore + }; + expandOption.IsRequired = false; + command.AddOption(expandOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string licenseDetailsItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Select = select; + q.Expand = expand; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, licenseDetailsItemIdOption, selectOption, expandOption, outputOption); + return command; + } + /// + /// A collection of this user's license details. Read-only. + /// + public Command BuildPatchCommand() { + var command = new Command("patch"); + command.Description = "A collection of this user's license details. Read-only."; + // Create options for all the parameters + var licenseDetailsItemIdOption = new Option("--license-details-item-id", description: "key: id of licenseDetails") { + }; + licenseDetailsItemIdOption.IsRequired = true; + command.AddOption(licenseDetailsItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string licenseDetailsItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePatchRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, licenseDetailsItemIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new LicenseDetailsItemRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public LicenseDetailsItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/me/licenseDetails/{licenseDetailsItem_id}{?select,expand}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// A collection of this user's license details. Read-only. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// A collection of this user's license details. Read-only. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// A collection of this user's license details. Read-only. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft.Graph.LicenseDetails body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PATCH, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// A collection of this user's license details. Read-only. + public class GetQueryParameters : QueryParametersBase { + /// Expand related entities + public string[] Expand { get; set; } + /// Select properties to be returned + public string[] Select { get; set; } + } + } +} diff --git a/src/generated/Me/LicenseDetails/Item/LicenseDetailsRequestBuilder.cs b/src/generated/Me/LicenseDetails/Item/LicenseDetailsRequestBuilder.cs deleted file mode 100644 index 40f8ace087a..00000000000 --- a/src/generated/Me/LicenseDetails/Item/LicenseDetailsRequestBuilder.cs +++ /dev/null @@ -1,217 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Me.LicenseDetails.Item { - /// Builds and executes requests for operations under \me\licenseDetails\{licenseDetails-id} - public class LicenseDetailsRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// A collection of this user's license details. Read-only. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "A collection of this user's license details. Read-only."; - // Create options for all the parameters - var licenseDetailsIdOption = new Option("--licensedetails-id", description: "key: id of licenseDetails") { - }; - licenseDetailsIdOption.IsRequired = true; - command.AddOption(licenseDetailsIdOption); - command.SetHandler(async (string licenseDetailsId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, licenseDetailsIdOption); - return command; - } - /// - /// A collection of this user's license details. Read-only. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "A collection of this user's license details. Read-only."; - // Create options for all the parameters - var licenseDetailsIdOption = new Option("--licensedetails-id", description: "key: id of licenseDetails") { - }; - licenseDetailsIdOption.IsRequired = true; - command.AddOption(licenseDetailsIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string licenseDetailsId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, licenseDetailsIdOption, selectOption, expandOption); - return command; - } - /// - /// A collection of this user's license details. Read-only. - /// - public Command BuildPatchCommand() { - var command = new Command("patch"); - command.Description = "A collection of this user's license details. Read-only."; - // Create options for all the parameters - var licenseDetailsIdOption = new Option("--licensedetails-id", description: "key: id of licenseDetails") { - }; - licenseDetailsIdOption.IsRequired = true; - command.AddOption(licenseDetailsIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string licenseDetailsId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePatchRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, licenseDetailsIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new LicenseDetailsRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public LicenseDetailsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/licenseDetails/{licenseDetails_id}{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// A collection of this user's license details. Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// A collection of this user's license details. Read-only. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// A collection of this user's license details. Read-only. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft.Graph.LicenseDetails body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PATCH, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// A collection of this user's license details. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of this user's license details. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of this user's license details. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.LicenseDetails model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// A collection of this user's license details. Read-only. - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/Me/LicenseDetails/LicenseDetailsRequestBuilder.cs b/src/generated/Me/LicenseDetails/LicenseDetailsRequestBuilder.cs index 365a730cd0d..724298e5eb6 100644 --- a/src/generated/Me/LicenseDetails/LicenseDetailsRequestBuilder.cs +++ b/src/generated/Me/LicenseDetails/LicenseDetailsRequestBuilder.cs @@ -1,10 +1,11 @@ +using ApiSdk.Me.LicenseDetails.Item; using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -20,11 +21,11 @@ public class LicenseDetailsRequestBuilder { /// Url template to use to build the URL for the current request builder private string UrlTemplate { get; set; } public List BuildCommand() { - var builder = new LicenseDetailsRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCreateCommand(), - builder.BuildListCommand(), - }; + var builder = new LicenseDetailsItemRequestBuilder(PathParameters, RequestAdapter); + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -38,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -97,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -108,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -171,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of this user's license details. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of this user's license details. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.LicenseDetails model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of this user's license details. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/MailFolders/Delta/Delta.cs b/src/generated/Me/MailFolders/Delta/Delta.cs deleted file mode 100644 index 725c4d2febf..00000000000 --- a/src/generated/Me/MailFolders/Delta/Delta.cs +++ /dev/null @@ -1,69 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.MailFolders.Delta { - public class Delta : Entity, IParsable { - /// The number of immediate child mailFolders in the current mailFolder. - public int? ChildFolderCount { get; set; } - /// The collection of child folders in the mailFolder. - public List ChildFolders { get; set; } - /// The mailFolder's display name. - public string DisplayName { get; set; } - /// Indicates whether the mailFolder is hidden. This property can be set only when creating the folder. Find more information in Hidden mail folders. - public bool? IsHidden { get; set; } - /// The collection of rules that apply to the user's Inbox folder. - public List MessageRules { get; set; } - /// The collection of messages in the mailFolder. - public List Messages { get; set; } - /// The collection of multi-value extended properties defined for the mailFolder. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - /// The unique identifier for the mailFolder's parent mailFolder. - public string ParentFolderId { get; set; } - /// The collection of single-value extended properties defined for the mailFolder. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - /// The number of items in the mailFolder. - public int? TotalItemCount { get; set; } - /// The number of items in the mailFolder marked as unread. - public int? UnreadItemCount { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"childFolderCount", (o,n) => { (o as Delta).ChildFolderCount = n.GetIntValue(); } }, - {"childFolders", (o,n) => { (o as Delta).ChildFolders = n.GetCollectionOfObjectValues().ToList(); } }, - {"displayName", (o,n) => { (o as Delta).DisplayName = n.GetStringValue(); } }, - {"isHidden", (o,n) => { (o as Delta).IsHidden = n.GetBoolValue(); } }, - {"messageRules", (o,n) => { (o as Delta).MessageRules = n.GetCollectionOfObjectValues().ToList(); } }, - {"messages", (o,n) => { (o as Delta).Messages = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"parentFolderId", (o,n) => { (o as Delta).ParentFolderId = n.GetStringValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"totalItemCount", (o,n) => { (o as Delta).TotalItemCount = n.GetIntValue(); } }, - {"unreadItemCount", (o,n) => { (o as Delta).UnreadItemCount = n.GetIntValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteIntValue("childFolderCount", ChildFolderCount); - writer.WriteCollectionOfObjectValues("childFolders", ChildFolders); - writer.WriteStringValue("displayName", DisplayName); - writer.WriteBoolValue("isHidden", IsHidden); - writer.WriteCollectionOfObjectValues("messageRules", MessageRules); - writer.WriteCollectionOfObjectValues("messages", Messages); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteStringValue("parentFolderId", ParentFolderId); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteIntValue("totalItemCount", TotalItemCount); - writer.WriteIntValue("unreadItemCount", UnreadItemCount); - } - } -} diff --git a/src/generated/Me/MailFolders/Delta/DeltaRequestBuilder.cs b/src/generated/Me/MailFolders/Delta/DeltaRequestBuilder.cs index 79eb2b334fa..874bb086485 100644 --- a/src/generated/Me/MailFolders/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +26,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +67,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/MailFolders/Item/ChildFolders/ChildFoldersRequestBuilder.cs b/src/generated/Me/MailFolders/Item/ChildFolders/ChildFoldersRequestBuilder.cs index 43f5d744ef5..ae41c4b296a 100644 --- a/src/generated/Me/MailFolders/Item/ChildFolders/ChildFoldersRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/ChildFolders/ChildFoldersRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,13 +23,12 @@ public class ChildFoldersRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MailFolderRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildMoveCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildMoveCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -39,7 +38,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of child folders in the mailFolder."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -47,21 +46,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, bodyOption, outputOption); return command; } /// @@ -71,7 +69,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of child folders in the mailFolder."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -106,7 +104,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string mailFolderId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -116,15 +118,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -185,31 +182,6 @@ public RequestInformation CreatePostRequestInformation(MailFolder body, Action - /// The collection of child folders in the mailFolder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of child folders in the mailFolder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MailFolder model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of child folders in the mailFolder. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/MailFolders/Item/ChildFolders/Delta/Delta.cs b/src/generated/Me/MailFolders/Item/ChildFolders/Delta/Delta.cs deleted file mode 100644 index b216abe223e..00000000000 --- a/src/generated/Me/MailFolders/Item/ChildFolders/Delta/Delta.cs +++ /dev/null @@ -1,69 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.MailFolders.Item.ChildFolders.Delta { - public class Delta : Entity, IParsable { - /// The number of immediate child mailFolders in the current mailFolder. - public int? ChildFolderCount { get; set; } - /// The collection of child folders in the mailFolder. - public List ChildFolders { get; set; } - /// The mailFolder's display name. - public string DisplayName { get; set; } - /// Indicates whether the mailFolder is hidden. This property can be set only when creating the folder. Find more information in Hidden mail folders. - public bool? IsHidden { get; set; } - /// The collection of rules that apply to the user's Inbox folder. - public List MessageRules { get; set; } - /// The collection of messages in the mailFolder. - public List Messages { get; set; } - /// The collection of multi-value extended properties defined for the mailFolder. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - /// The unique identifier for the mailFolder's parent mailFolder. - public string ParentFolderId { get; set; } - /// The collection of single-value extended properties defined for the mailFolder. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - /// The number of items in the mailFolder. - public int? TotalItemCount { get; set; } - /// The number of items in the mailFolder marked as unread. - public int? UnreadItemCount { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"childFolderCount", (o,n) => { (o as Delta).ChildFolderCount = n.GetIntValue(); } }, - {"childFolders", (o,n) => { (o as Delta).ChildFolders = n.GetCollectionOfObjectValues().ToList(); } }, - {"displayName", (o,n) => { (o as Delta).DisplayName = n.GetStringValue(); } }, - {"isHidden", (o,n) => { (o as Delta).IsHidden = n.GetBoolValue(); } }, - {"messageRules", (o,n) => { (o as Delta).MessageRules = n.GetCollectionOfObjectValues().ToList(); } }, - {"messages", (o,n) => { (o as Delta).Messages = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"parentFolderId", (o,n) => { (o as Delta).ParentFolderId = n.GetStringValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"totalItemCount", (o,n) => { (o as Delta).TotalItemCount = n.GetIntValue(); } }, - {"unreadItemCount", (o,n) => { (o as Delta).UnreadItemCount = n.GetIntValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteIntValue("childFolderCount", ChildFolderCount); - writer.WriteCollectionOfObjectValues("childFolders", ChildFolders); - writer.WriteStringValue("displayName", DisplayName); - writer.WriteBoolValue("isHidden", IsHidden); - writer.WriteCollectionOfObjectValues("messageRules", MessageRules); - writer.WriteCollectionOfObjectValues("messages", Messages); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteStringValue("parentFolderId", ParentFolderId); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteIntValue("totalItemCount", TotalItemCount); - writer.WriteIntValue("unreadItemCount", UnreadItemCount); - } - } -} diff --git a/src/generated/Me/MailFolders/Item/ChildFolders/Delta/DeltaRequestBuilder.cs b/src/generated/Me/MailFolders/Item/ChildFolders/Delta/DeltaRequestBuilder.cs index 950d07f4bb0..d4aee6e784d 100644 --- a/src/generated/Me/MailFolders/Item/ChildFolders/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/ChildFolders/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - command.SetHandler(async (string mailFolderId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/MailFolders/Item/ChildFolders/Item/Copy/CopyRequestBuilder.cs b/src/generated/Me/MailFolders/Item/ChildFolders/Item/Copy/CopyRequestBuilder.cs index 764764bc35d..e2f49357aef 100644 --- a/src/generated/Me/MailFolders/Item/ChildFolders/Item/Copy/CopyRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/ChildFolders/Item/Copy/CopyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copy"; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var mailFolderId1Option = new Option("--mailfolder-id1", description: "key: id of mailFolder") { + var mailFolderId1Option = new Option("--mail-folder-id1", description: "key: id of mailFolder") { }; mailFolderId1Option.IsRequired = true; command.AddOption(mailFolderId1Option); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string mailFolderId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string mailFolderId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, mailFolderId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, mailFolderId1Option, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copy - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes mailFolder public class CopyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/MailFolders/Item/ChildFolders/Item/MailFolderRequestBuilder.cs b/src/generated/Me/MailFolders/Item/ChildFolders/Item/MailFolderRequestBuilder.cs index 4c7a8d68c71..ea712daa391 100644 --- a/src/generated/Me/MailFolders/Item/ChildFolders/Item/MailFolderRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/ChildFolders/Item/MailFolderRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of child folders in the mailFolder."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var mailFolderId1Option = new Option("--mailfolder-id1", description: "key: id of mailFolder") { + var mailFolderId1Option = new Option("--mail-folder-id1", description: "key: id of mailFolder") { }; mailFolderId1Option.IsRequired = true; command.AddOption(mailFolderId1Option); - command.SetHandler(async (string mailFolderId, string mailFolderId1) => { + command.SetHandler(async (string mailFolderId, string mailFolderId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mailFolderIdOption, mailFolderId1Option); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of child folders in the mailFolder."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var mailFolderId1Option = new Option("--mailfolder-id1", description: "key: id of mailFolder") { + var mailFolderId1Option = new Option("--mail-folder-id1", description: "key: id of mailFolder") { }; mailFolderId1Option.IsRequired = true; command.AddOption(mailFolderId1Option); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string mailFolderId, string mailFolderId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string mailFolderId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, mailFolderId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, mailFolderId1Option, selectOption, expandOption, outputOption); return command; } public Command BuildMoveCommand() { @@ -105,11 +103,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of child folders in the mailFolder."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var mailFolderId1Option = new Option("--mailfolder-id1", description: "key: id of mailFolder") { + var mailFolderId1Option = new Option("--mail-folder-id1", description: "key: id of mailFolder") { }; mailFolderId1Option.IsRequired = true; command.AddOption(mailFolderId1Option); @@ -117,14 +115,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string mailFolderId1, string body) => { + command.SetHandler(async (string mailFolderId, string mailFolderId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mailFolderIdOption, mailFolderId1Option, bodyOption); return command; @@ -196,42 +193,6 @@ public RequestInformation CreatePatchRequestInformation(MailFolder body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of child folders in the mailFolder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of child folders in the mailFolder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of child folders in the mailFolder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MailFolder model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of child folders in the mailFolder. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/MailFolders/Item/ChildFolders/Item/Move/MoveRequestBuilder.cs b/src/generated/Me/MailFolders/Item/ChildFolders/Item/Move/MoveRequestBuilder.cs index a137406fe6a..07697a55380 100644 --- a/src/generated/Me/MailFolders/Item/ChildFolders/Item/Move/MoveRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/ChildFolders/Item/Move/MoveRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action move"; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var mailFolderId1Option = new Option("--mailfolder-id1", description: "key: id of mailFolder") { + var mailFolderId1Option = new Option("--mail-folder-id1", description: "key: id of mailFolder") { }; mailFolderId1Option.IsRequired = true; command.AddOption(mailFolderId1Option); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string mailFolderId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string mailFolderId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, mailFolderId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, mailFolderId1Option, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(MoveRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action move - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MoveRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes mailFolder public class MoveResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/MailFolders/Item/Copy/CopyRequestBuilder.cs b/src/generated/Me/MailFolders/Item/Copy/CopyRequestBuilder.cs index b003e0c1ebd..a412a53af57 100644 --- a/src/generated/Me/MailFolders/Item/Copy/CopyRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/Copy/CopyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copy"; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CopyRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copy - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes mailFolder public class CopyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/MailFolders/Item/MailFolderRequestBuilder.cs b/src/generated/Me/MailFolders/Item/MailFolderRequestBuilder.cs index 81c0fc57d41..fff34195293 100644 --- a/src/generated/Me/MailFolders/Item/MailFolderRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/MailFolderRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,6 +29,9 @@ public class MailFolderRequestBuilder { public Command BuildChildFoldersCommand() { var command = new Command("child-folders"); var builder = new ApiSdk.Me.MailFolders.Item.ChildFolders.ChildFoldersRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -46,15 +49,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The user's mail folders. Read-only. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - command.SetHandler(async (string mailFolderId) => { + command.SetHandler(async (string mailFolderId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mailFolderIdOption); return command; @@ -66,7 +68,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The user's mail folders. Read-only. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -75,24 +77,26 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string mailFolderId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, selectOption, outputOption); return command; } public Command BuildMessageRulesCommand() { var command = new Command("message-rules"); var builder = new ApiSdk.Me.MailFolders.Item.MessageRules.MessageRulesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -100,6 +104,9 @@ public Command BuildMessageRulesCommand() { public Command BuildMessagesCommand() { var command = new Command("messages"); var builder = new ApiSdk.Me.MailFolders.Item.Messages.MessagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -113,6 +120,9 @@ public Command BuildMoveCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Me.MailFolders.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -124,7 +134,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The user's mail folders. Read-only. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -132,14 +142,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string body) => { + command.SetHandler(async (string mailFolderId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mailFolderIdOption, bodyOption); return command; @@ -147,6 +156,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Me.MailFolders.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -218,42 +230,6 @@ public RequestInformation CreatePatchRequestInformation(MailFolder body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user's mail folders. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's mail folders. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's mail folders. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MailFolder model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's mail folders. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/MailFolders/Item/MessageRules/Item/MessageRuleRequestBuilder.cs b/src/generated/Me/MailFolders/Item/MessageRules/Item/MessageRuleRequestBuilder.cs index 30d733a3a17..3556d5eb9cb 100644 --- a/src/generated/Me/MailFolders/Item/MessageRules/Item/MessageRuleRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/MessageRules/Item/MessageRuleRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of rules that apply to the user's Inbox folder."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var messageRuleIdOption = new Option("--messagerule-id", description: "key: id of messageRule") { + var messageRuleIdOption = new Option("--message-rule-id", description: "key: id of messageRule") { }; messageRuleIdOption.IsRequired = true; command.AddOption(messageRuleIdOption); - command.SetHandler(async (string mailFolderId, string messageRuleId) => { + command.SetHandler(async (string mailFolderId, string messageRuleId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mailFolderIdOption, messageRuleIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of rules that apply to the user's Inbox folder."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var messageRuleIdOption = new Option("--messagerule-id", description: "key: id of messageRule") { + var messageRuleIdOption = new Option("--message-rule-id", description: "key: id of messageRule") { }; messageRuleIdOption.IsRequired = true; command.AddOption(messageRuleIdOption); @@ -63,19 +62,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string mailFolderId, string messageRuleId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string messageRuleId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, messageRuleIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, messageRuleIdOption, selectOption, outputOption); return command; } /// @@ -85,11 +83,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of rules that apply to the user's Inbox folder."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var messageRuleIdOption = new Option("--messagerule-id", description: "key: id of messageRule") { + var messageRuleIdOption = new Option("--message-rule-id", description: "key: id of messageRule") { }; messageRuleIdOption.IsRequired = true; command.AddOption(messageRuleIdOption); @@ -97,14 +95,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string messageRuleId, string body) => { + command.SetHandler(async (string mailFolderId, string messageRuleId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mailFolderIdOption, messageRuleIdOption, bodyOption); return command; @@ -176,42 +173,6 @@ public RequestInformation CreatePatchRequestInformation(MessageRule body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of rules that apply to the user's Inbox folder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of rules that apply to the user's Inbox folder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of rules that apply to the user's Inbox folder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MessageRule model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of rules that apply to the user's Inbox folder. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/MailFolders/Item/MessageRules/MessageRulesRequestBuilder.cs b/src/generated/Me/MailFolders/Item/MessageRules/MessageRulesRequestBuilder.cs index 5ae9f1376eb..73ad200df86 100644 --- a/src/generated/Me/MailFolders/Item/MessageRules/MessageRulesRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/MessageRules/MessageRulesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MessageRulesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MessageRuleRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of rules that apply to the user's Inbox folder."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of rules that apply to the user's Inbox folder."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -98,7 +96,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string mailFolderId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -107,15 +109,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -170,31 +167,6 @@ public RequestInformation CreatePostRequestInformation(MessageRule body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of rules that apply to the user's Inbox folder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of rules that apply to the user's Inbox folder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MessageRule model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of rules that apply to the user's Inbox folder. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/MailFolders/Item/Messages/Delta/Delta.cs b/src/generated/Me/MailFolders/Item/Messages/Delta/Delta.cs deleted file mode 100644 index 76e9aacf707..00000000000 --- a/src/generated/Me/MailFolders/Item/Messages/Delta/Delta.cs +++ /dev/null @@ -1,128 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.MailFolders.Item.Messages.Delta { - public class Delta : OutlookItem, IParsable { - /// The fileAttachment and itemAttachment attachments for the message. - public List Attachments { get; set; } - /// The Bcc: recipients for the message. - public List BccRecipients { get; set; } - /// The body of the message. It can be in HTML or text format. Find out about safe HTML in a message body. - public ItemBody Body { get; set; } - /// The first 255 characters of the message body. It is in text format. If the message contains instances of mention, this property would contain a concatenation of these mentions as well. - public string BodyPreview { get; set; } - /// The Cc: recipients for the message. - public List CcRecipients { get; set; } - /// The ID of the conversation the email belongs to. - public string ConversationId { get; set; } - /// Indicates the position of the message within the conversation. - public byte[] ConversationIndex { get; set; } - /// The collection of open extensions defined for the message. Nullable. - public List Extensions { get; set; } - /// The flag value that indicates the status, start date, due date, or completion date for the message. - public FollowupFlag Flag { get; set; } - /// The owner of the mailbox from which the message is sent. In most cases, this value is the same as the sender property, except for sharing or delegation scenarios. The value must correspond to the actual mailbox used. Find out more about setting the from and sender properties of a message. - public Recipient From { get; set; } - /// Indicates whether the message has attachments. This property doesn't include inline attachments, so if a message contains only inline attachments, this property is false. To verify the existence of inline attachments, parse the body property to look for a src attribute, such as . - public bool? HasAttachments { get; set; } - public Importance? Importance { get; set; } - public InferenceClassificationType? InferenceClassification { get; set; } - public List InternetMessageHeaders { get; set; } - public string InternetMessageId { get; set; } - public bool? IsDeliveryReceiptRequested { get; set; } - public bool? IsDraft { get; set; } - public bool? IsRead { get; set; } - public bool? IsReadReceiptRequested { get; set; } - /// The collection of multi-value extended properties defined for the message. Nullable. - public List MultiValueExtendedProperties { get; set; } - public string ParentFolderId { get; set; } - public DateTimeOffset? ReceivedDateTime { get; set; } - public List ReplyTo { get; set; } - public Recipient Sender { get; set; } - public DateTimeOffset? SentDateTime { get; set; } - /// The collection of single-value extended properties defined for the message. Nullable. - public List SingleValueExtendedProperties { get; set; } - public string Subject { get; set; } - public List ToRecipients { get; set; } - public ItemBody UniqueBody { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"bccRecipients", (o,n) => { (o as Delta).BccRecipients = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"ccRecipients", (o,n) => { (o as Delta).CcRecipients = n.GetCollectionOfObjectValues().ToList(); } }, - {"conversationId", (o,n) => { (o as Delta).ConversationId = n.GetStringValue(); } }, - {"conversationIndex", (o,n) => { (o as Delta).ConversationIndex = n.GetByteArrayValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"flag", (o,n) => { (o as Delta).Flag = n.GetObjectValue(); } }, - {"from", (o,n) => { (o as Delta).From = n.GetObjectValue(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"inferenceClassification", (o,n) => { (o as Delta).InferenceClassification = n.GetEnumValue(); } }, - {"internetMessageHeaders", (o,n) => { (o as Delta).InternetMessageHeaders = n.GetCollectionOfObjectValues().ToList(); } }, - {"internetMessageId", (o,n) => { (o as Delta).InternetMessageId = n.GetStringValue(); } }, - {"isDeliveryReceiptRequested", (o,n) => { (o as Delta).IsDeliveryReceiptRequested = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isRead", (o,n) => { (o as Delta).IsRead = n.GetBoolValue(); } }, - {"isReadReceiptRequested", (o,n) => { (o as Delta).IsReadReceiptRequested = n.GetBoolValue(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"parentFolderId", (o,n) => { (o as Delta).ParentFolderId = n.GetStringValue(); } }, - {"receivedDateTime", (o,n) => { (o as Delta).ReceivedDateTime = n.GetDateTimeOffsetValue(); } }, - {"replyTo", (o,n) => { (o as Delta).ReplyTo = n.GetCollectionOfObjectValues().ToList(); } }, - {"sender", (o,n) => { (o as Delta).Sender = n.GetObjectValue(); } }, - {"sentDateTime", (o,n) => { (o as Delta).SentDateTime = n.GetDateTimeOffsetValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"toRecipients", (o,n) => { (o as Delta).ToRecipients = n.GetCollectionOfObjectValues().ToList(); } }, - {"uniqueBody", (o,n) => { (o as Delta).UniqueBody = n.GetObjectValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("bccRecipients", BccRecipients); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteCollectionOfObjectValues("ccRecipients", CcRecipients); - writer.WriteStringValue("conversationId", ConversationId); - writer.WriteByteArrayValue("conversationIndex", ConversationIndex); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteObjectValue("flag", Flag); - writer.WriteObjectValue("from", From); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteEnumValue("importance", Importance); - writer.WriteEnumValue("inferenceClassification", InferenceClassification); - writer.WriteCollectionOfObjectValues("internetMessageHeaders", InternetMessageHeaders); - writer.WriteStringValue("internetMessageId", InternetMessageId); - writer.WriteBoolValue("isDeliveryReceiptRequested", IsDeliveryReceiptRequested); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isRead", IsRead); - writer.WriteBoolValue("isReadReceiptRequested", IsReadReceiptRequested); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteStringValue("parentFolderId", ParentFolderId); - writer.WriteDateTimeOffsetValue("receivedDateTime", ReceivedDateTime); - writer.WriteCollectionOfObjectValues("replyTo", ReplyTo); - writer.WriteObjectValue("sender", Sender); - writer.WriteDateTimeOffsetValue("sentDateTime", SentDateTime); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteStringValue("subject", Subject); - writer.WriteCollectionOfObjectValues("toRecipients", ToRecipients); - writer.WriteObjectValue("uniqueBody", UniqueBody); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Me/MailFolders/Item/Messages/Delta/DeltaRequestBuilder.cs b/src/generated/Me/MailFolders/Item/Messages/Delta/DeltaRequestBuilder.cs index 7bb45ab20ea..7fddcf2f6bf 100644 --- a/src/generated/Me/MailFolders/Item/Messages/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/Messages/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - command.SetHandler(async (string mailFolderId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/MailFolders/Item/Messages/Item/Attachments/AttachmentsRequestBuilder.cs b/src/generated/Me/MailFolders/Item/Messages/Item/Attachments/AttachmentsRequestBuilder.cs index 9394fb994e5..3a29ba70cf6 100644 --- a/src/generated/Me/MailFolders/Item/Messages/Item/Attachments/AttachmentsRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/Messages/Item/Attachments/AttachmentsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class AttachmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttachmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -37,7 +36,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The fileAttachment and itemAttachment attachments for the message."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, messageIdOption, bodyOption, outputOption); return command; } public Command BuildCreateUploadSessionCommand() { @@ -79,7 +77,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The fileAttachment and itemAttachment attachments for the message."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string mailFolderId, string messageId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string messageId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, messageIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, messageIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(Attachment body, Action - /// The fileAttachment and itemAttachment attachments for the message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The fileAttachment and itemAttachment attachments for the message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The fileAttachment and itemAttachment attachments for the message. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/MailFolders/Item/Messages/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Me/MailFolders/Item/Messages/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index 83b54b5021f..b02ceb488ec 100644 --- a/src/generated/Me/MailFolders/Item/Messages/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/Messages/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action createUploadSession"; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, messageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/MailFolders/Item/Messages/Item/Attachments/Item/AttachmentRequestBuilder.cs b/src/generated/Me/MailFolders/Item/Messages/Item/Attachments/Item/AttachmentRequestBuilder.cs index 06ca910a5e6..e6b5b4169e0 100644 --- a/src/generated/Me/MailFolders/Item/Messages/Item/Attachments/Item/AttachmentRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/Messages/Item/Attachments/Item/AttachmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The fileAttachment and itemAttachment attachments for the message."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; attachmentIdOption.IsRequired = true; command.AddOption(attachmentIdOption); - command.SetHandler(async (string mailFolderId, string messageId, string attachmentId) => { + command.SetHandler(async (string mailFolderId, string messageId, string attachmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mailFolderIdOption, messageIdOption, attachmentIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The fileAttachment and itemAttachment attachments for the message."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string mailFolderId, string messageId, string attachmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string messageId, string attachmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, messageIdOption, attachmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, messageIdOption, attachmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,7 +97,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The fileAttachment and itemAttachment attachments for the message."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string messageId, string attachmentId, string body) => { + command.SetHandler(async (string mailFolderId, string messageId, string attachmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mailFolderIdOption, messageIdOption, attachmentIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Attachment body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The fileAttachment and itemAttachment attachments for the message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The fileAttachment and itemAttachment attachments for the message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The fileAttachment and itemAttachment attachments for the message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The fileAttachment and itemAttachment attachments for the message. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/MailFolders/Item/Messages/Item/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs b/src/generated/Me/MailFolders/Item/Messages/Item/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs index 7fedb4227ef..207b1b446a6 100644 --- a/src/generated/Me/MailFolders/Item/Messages/Item/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/Messages/Item/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action accept"; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -34,18 +34,17 @@ public Command BuildPostCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - command.SetHandler(async (string mailFolderId, string messageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string messageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, messageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, messageIdOption, outputOption); return command; } /// @@ -76,16 +75,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/MailFolders/Item/Messages/Item/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs b/src/generated/Me/MailFolders/Item/Messages/Item/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs index 33b11de227f..8294ba2ca46 100644 --- a/src/generated/Me/MailFolders/Item/Messages/Item/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/Messages/Item/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Me.MailFolders.Item.Messages.Item.CalendarSharingMessage.Accept; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/MailFolders/Item/Messages/Item/Copy/CopyRequestBuilder.cs b/src/generated/Me/MailFolders/Item/Messages/Item/Copy/CopyRequestBuilder.cs index 38be4d41917..657bb8f3d15 100644 --- a/src/generated/Me/MailFolders/Item/Messages/Item/Copy/CopyRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/Messages/Item/Copy/CopyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copy"; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, messageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copy - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes message public class CopyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/MailFolders/Item/Messages/Item/CreateForward/CreateForwardRequestBuilder.cs b/src/generated/Me/MailFolders/Item/Messages/Item/CreateForward/CreateForwardRequestBuilder.cs index 195907cfe48..321052ec904 100644 --- a/src/generated/Me/MailFolders/Item/Messages/Item/CreateForward/CreateForwardRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/Messages/Item/CreateForward/CreateForwardRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action createForward"; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, messageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CreateForwardRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createForward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes message public class CreateForwardResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/MailFolders/Item/Messages/Item/CreateReply/CreateReplyRequestBuilder.cs b/src/generated/Me/MailFolders/Item/Messages/Item/CreateReply/CreateReplyRequestBuilder.cs index 50638f556db..9b8bb0d307b 100644 --- a/src/generated/Me/MailFolders/Item/Messages/Item/CreateReply/CreateReplyRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/Messages/Item/CreateReply/CreateReplyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action createReply"; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, messageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CreateReplyRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createReply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateReplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes message public class CreateReplyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/MailFolders/Item/Messages/Item/CreateReplyAll/CreateReplyAllRequestBuilder.cs b/src/generated/Me/MailFolders/Item/Messages/Item/CreateReplyAll/CreateReplyAllRequestBuilder.cs index aa2b06cff98..e0964c0412b 100644 --- a/src/generated/Me/MailFolders/Item/Messages/Item/CreateReplyAll/CreateReplyAllRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/Messages/Item/CreateReplyAll/CreateReplyAllRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action createReplyAll"; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, messageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CreateReplyAllRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createReplyAll - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateReplyAllRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes message public class CreateReplyAllResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/MailFolders/Item/Messages/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Me/MailFolders/Item/Messages/Item/Extensions/ExtensionsRequestBuilder.cs index 7cadc87492c..9777a0288dd 100644 --- a/src/generated/Me/MailFolders/Item/Messages/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/Messages/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of open extensions defined for the message. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, messageIdOption, bodyOption, outputOption); return command; } /// @@ -72,7 +70,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of open extensions defined for the message. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string mailFolderId, string messageId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string messageId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, messageIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, messageIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the message. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/MailFolders/Item/Messages/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Me/MailFolders/Item/Messages/Item/Extensions/Item/ExtensionRequestBuilder.cs index 1d8bc97c974..263d1577086 100644 --- a/src/generated/Me/MailFolders/Item/Messages/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/Messages/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of open extensions defined for the message. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string mailFolderId, string messageId, string extensionId) => { + command.SetHandler(async (string mailFolderId, string messageId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mailFolderIdOption, messageIdOption, extensionIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of open extensions defined for the message. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string mailFolderId, string messageId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string messageId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, messageIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, messageIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,7 +97,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of open extensions defined for the message. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string messageId, string extensionId, string body) => { + command.SetHandler(async (string mailFolderId, string messageId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mailFolderIdOption, messageIdOption, extensionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the message. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/MailFolders/Item/Messages/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Me/MailFolders/Item/Messages/Item/Forward/ForwardRequestBuilder.cs index 6840c70a786..52870ca763a 100644 --- a/src/generated/Me/MailFolders/Item/Messages/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/Messages/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action forward"; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string messageId, string body) => { + command.SetHandler(async (string mailFolderId, string messageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mailFolderIdOption, messageIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/MailFolders/Item/Messages/Item/MessageRequestBuilder.cs b/src/generated/Me/MailFolders/Item/Messages/Item/MessageRequestBuilder.cs index aca10108c2f..5ca0909a25b 100644 --- a/src/generated/Me/MailFolders/Item/Messages/Item/MessageRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/Messages/Item/MessageRequestBuilder.cs @@ -16,10 +16,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,6 +37,9 @@ public class MessageRequestBuilder { public Command BuildAttachmentsCommand() { var command = new Command("attachments"); var builder = new ApiSdk.Me.MailFolders.Item.Messages.Item.Attachments.AttachmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateUploadSessionCommand()); command.AddCommand(builder.BuildListCommand()); @@ -86,7 +89,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of messages in the mailFolder."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -94,11 +97,10 @@ public Command BuildDeleteCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - command.SetHandler(async (string mailFolderId, string messageId) => { + command.SetHandler(async (string mailFolderId, string messageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mailFolderIdOption, messageIdOption); return command; @@ -106,6 +108,9 @@ public Command BuildDeleteCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Me.MailFolders.Item.Messages.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -123,7 +128,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of messages in the mailFolder."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -141,20 +146,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string mailFolderId, string messageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string messageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, messageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, messageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildMoveCommand() { @@ -166,6 +170,9 @@ public Command BuildMoveCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Me.MailFolders.Item.Messages.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -177,7 +184,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of messages in the mailFolder."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -189,14 +196,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string messageId, string body) => { + command.SetHandler(async (string mailFolderId, string messageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mailFolderIdOption, messageIdOption, bodyOption); return command; @@ -222,6 +228,9 @@ public Command BuildSendCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Me.MailFolders.Item.Messages.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -293,42 +302,6 @@ public RequestInformation CreatePatchRequestInformation(Message body, Action - /// The collection of messages in the mailFolder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of messages in the mailFolder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of messages in the mailFolder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Message model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of messages in the mailFolder. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/MailFolders/Item/Messages/Item/Move/MoveRequestBuilder.cs b/src/generated/Me/MailFolders/Item/Messages/Item/Move/MoveRequestBuilder.cs index cbe390361bd..4ff0f98dc70 100644 --- a/src/generated/Me/MailFolders/Item/Messages/Item/Move/MoveRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/Messages/Item/Move/MoveRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action move"; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, messageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(MoveRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action move - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MoveRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes message public class MoveResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/MailFolders/Item/Messages/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/MailFolders/Item/Messages/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 5ee39e77fa9..bade8fe63fb 100644 --- a/src/generated/Me/MailFolders/Item/Messages/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/Messages/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of multi-value extended properties defined for the message. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string mailFolderId, string messageId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string mailFolderId, string messageId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mailFolderIdOption, messageIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of multi-value extended properties defined for the message. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string mailFolderId, string messageId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string messageId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, messageIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, messageIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,7 +97,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of multi-value extended properties defined for the message. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string messageId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string mailFolderId, string messageId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mailFolderIdOption, messageIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the message. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/MailFolders/Item/Messages/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/MailFolders/Item/Messages/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 142a49abc3e..25a9c546c61 100644 --- a/src/generated/Me/MailFolders/Item/Messages/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/Messages/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of multi-value extended properties defined for the message. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, messageIdOption, bodyOption, outputOption); return command; } /// @@ -72,7 +70,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of multi-value extended properties defined for the message. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string mailFolderId, string messageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string messageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, messageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, messageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the message. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/MailFolders/Item/Messages/Item/Reply/ReplyRequestBuilder.cs b/src/generated/Me/MailFolders/Item/Messages/Item/Reply/ReplyRequestBuilder.cs index d857b15de92..a8404f149ac 100644 --- a/src/generated/Me/MailFolders/Item/Messages/Item/Reply/ReplyRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/Messages/Item/Reply/ReplyRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action reply"; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string messageId, string body) => { + command.SetHandler(async (string mailFolderId, string messageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mailFolderIdOption, messageIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ReplyRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action reply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ReplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/MailFolders/Item/Messages/Item/ReplyAll/ReplyAllRequestBuilder.cs b/src/generated/Me/MailFolders/Item/Messages/Item/ReplyAll/ReplyAllRequestBuilder.cs index 0d01960634c..3598d60f44e 100644 --- a/src/generated/Me/MailFolders/Item/Messages/Item/ReplyAll/ReplyAllRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/Messages/Item/ReplyAll/ReplyAllRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action replyAll"; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string messageId, string body) => { + command.SetHandler(async (string mailFolderId, string messageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mailFolderIdOption, messageIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ReplyAllRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action replyAll - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ReplyAllRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/MailFolders/Item/Messages/Item/Send/SendRequestBuilder.cs b/src/generated/Me/MailFolders/Item/Messages/Item/Send/SendRequestBuilder.cs index 6ce2f98d87b..6310ea3481d 100644 --- a/src/generated/Me/MailFolders/Item/Messages/Item/Send/SendRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/Messages/Item/Send/SendRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action send"; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -33,11 +33,10 @@ public Command BuildPostCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - command.SetHandler(async (string mailFolderId, string messageId) => { + command.SetHandler(async (string mailFolderId, string messageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mailFolderIdOption, messageIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action send - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/MailFolders/Item/Messages/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/MailFolders/Item/Messages/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index ddbb04f1c6e..b2f29f299da 100644 --- a/src/generated/Me/MailFolders/Item/Messages/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/Messages/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of single-value extended properties defined for the message. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string mailFolderId, string messageId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string mailFolderId, string messageId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mailFolderIdOption, messageIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of single-value extended properties defined for the message. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string mailFolderId, string messageId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string messageId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, messageIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, messageIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,7 +97,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of single-value extended properties defined for the message. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string messageId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string mailFolderId, string messageId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mailFolderIdOption, messageIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the message. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/MailFolders/Item/Messages/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/MailFolders/Item/Messages/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 3afe0a9f06c..600e70e556a 100644 --- a/src/generated/Me/MailFolders/Item/Messages/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/Messages/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of single-value extended properties defined for the message. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, messageIdOption, bodyOption, outputOption); return command; } /// @@ -72,7 +70,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of single-value extended properties defined for the message. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string mailFolderId, string messageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string messageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, messageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, messageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the message. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/MailFolders/Item/Messages/Item/Value/ContentRequestBuilder.cs b/src/generated/Me/MailFolders/Item/Messages/Item/Value/ContentRequestBuilder.cs index 06bb4d044e1..df788ebb3da 100644 --- a/src/generated/Me/MailFolders/Item/Messages/Item/Value/ContentRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/Messages/Item/Value/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get media content for the navigation property messages from me"; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -33,24 +33,26 @@ public Command BuildGetCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string mailFolderId, string messageId, FileInfo output) => { + command.SetHandler(async (string mailFolderId, string messageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, mailFolderIdOption, messageIdOption, outputOption); + }, mailFolderIdOption, messageIdOption, fileOption, outputOption); return command; } /// @@ -60,7 +62,7 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "Update media content for the navigation property messages in me"; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -72,12 +74,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string messageId, FileInfo file) => { + command.SetHandler(async (string mailFolderId, string messageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mailFolderIdOption, messageIdOption, bodyOption); return command; @@ -128,29 +129,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property messages from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property messages in me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/MailFolders/Item/Messages/MessagesRequestBuilder.cs b/src/generated/Me/MailFolders/Item/Messages/MessagesRequestBuilder.cs index b0ef1c776ca..4a7d1544dd0 100644 --- a/src/generated/Me/MailFolders/Item/Messages/MessagesRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/Messages/MessagesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,26 +23,25 @@ public class MessagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MessageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAttachmentsCommand(), - builder.BuildCalendarSharingMessageCommand(), - builder.BuildContentCommand(), - builder.BuildCopyCommand(), - builder.BuildCreateForwardCommand(), - builder.BuildCreateReplyAllCommand(), - builder.BuildCreateReplyCommand(), - builder.BuildDeleteCommand(), - builder.BuildExtensionsCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildMoveCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildReplyAllCommand(), - builder.BuildReplyCommand(), - builder.BuildSendCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAttachmentsCommand()); + commands.Add(builder.BuildCalendarSharingMessageCommand()); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyCommand()); + commands.Add(builder.BuildCreateForwardCommand()); + commands.Add(builder.BuildCreateReplyAllCommand()); + commands.Add(builder.BuildCreateReplyCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildMoveCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildReplyAllCommand()); + commands.Add(builder.BuildReplyCommand()); + commands.Add(builder.BuildSendCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); return commands; } /// @@ -52,7 +51,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of messages in the mailFolder."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -60,21 +59,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, bodyOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of messages in the mailFolder."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string mailFolderId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -203,31 +200,6 @@ public RequestInformation CreatePostRequestInformation(Message body, Action - /// The collection of messages in the mailFolder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of messages in the mailFolder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Message model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of messages in the mailFolder. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/MailFolders/Item/Move/MoveRequestBuilder.cs b/src/generated/Me/MailFolders/Item/Move/MoveRequestBuilder.cs index 4eca12831f4..308f9661d1e 100644 --- a/src/generated/Me/MailFolders/Item/Move/MoveRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/Move/MoveRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action move"; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(MoveRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action move - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MoveRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes mailFolder public class MoveResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/MailFolders/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/MailFolders/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index e7b97cd5b1a..a1b3a8d44db 100644 --- a/src/generated/Me/MailFolders/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of multi-value extended properties defined for the mailFolder. Read-only. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string mailFolderId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string mailFolderId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mailFolderIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of multi-value extended properties defined for the mailFolder. Read-only. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string mailFolderId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of multi-value extended properties defined for the mailFolder. Read-only. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string mailFolderId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mailFolderIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the mailFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the mailFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the mailFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the mailFolder. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/MailFolders/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/MailFolders/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 4a1c82609b3..62f4588d581 100644 --- a/src/generated/Me/MailFolders/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of multi-value extended properties defined for the mailFolder. Read-only. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of multi-value extended properties defined for the mailFolder. Read-only. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string mailFolderId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the mailFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the mailFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the mailFolder. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/MailFolders/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/MailFolders/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 6681dffdb81..659383110ce 100644 --- a/src/generated/Me/MailFolders/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of single-value extended properties defined for the mailFolder. Read-only. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string mailFolderId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string mailFolderId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mailFolderIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of single-value extended properties defined for the mailFolder. Read-only. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string mailFolderId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of single-value extended properties defined for the mailFolder. Read-only. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string mailFolderId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, mailFolderIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the mailFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the mailFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the mailFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the mailFolder. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/MailFolders/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/MailFolders/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index ce09d097793..ff22146b46b 100644 --- a/src/generated/Me/MailFolders/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/MailFolders/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of single-value extended properties defined for the mailFolder. Read-only. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string mailFolderId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of single-value extended properties defined for the mailFolder. Read-only. Nullable."; // Create options for all the parameters - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string mailFolderId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string mailFolderId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, mailFolderIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, mailFolderIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the mailFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the mailFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the mailFolder. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/MailFolders/MailFoldersRequestBuilder.cs b/src/generated/Me/MailFolders/MailFoldersRequestBuilder.cs index 3e8f3197cb5..e97e7c9c8f5 100644 --- a/src/generated/Me/MailFolders/MailFoldersRequestBuilder.cs +++ b/src/generated/Me/MailFolders/MailFoldersRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class MailFoldersRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MailFolderRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildChildFoldersCommand(), - builder.BuildCopyCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildMessageRulesCommand(), - builder.BuildMessagesCommand(), - builder.BuildMoveCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildChildFoldersCommand()); + commands.Add(builder.BuildCopyCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildMessageRulesCommand()); + commands.Add(builder.BuildMessagesCommand()); + commands.Add(builder.BuildMoveCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -98,7 +96,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -107,15 +109,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -176,31 +173,6 @@ public RequestInformation CreatePostRequestInformation(MailFolder body, Action - /// The user's mail folders. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's mail folders. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MailFolder model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's mail folders. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/ManagedAppRegistrations/@Ref/@Ref.cs b/src/generated/Me/ManagedAppRegistrations/@Ref/@Ref.cs deleted file mode 100644 index 79d6218f02c..00000000000 --- a/src/generated/Me/ManagedAppRegistrations/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.ManagedAppRegistrations.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/ManagedAppRegistrations/@Ref/RefRequestBuilder.cs b/src/generated/Me/ManagedAppRegistrations/@Ref/RefRequestBuilder.cs deleted file mode 100644 index cf204127453..00000000000 --- a/src/generated/Me/ManagedAppRegistrations/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,194 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Me.ManagedAppRegistrations.@Ref { - /// Builds and executes requests for operations under \me\managedAppRegistrations\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Zero or more managed app registrations that belong to the user. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Zero or more managed app registrations that belong to the user."; - // Create options for all the parameters - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Zero or more managed app registrations that belong to the user. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Zero or more managed app registrations that belong to the user."; - // Create options for all the parameters - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/managedAppRegistrations/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Zero or more managed app registrations that belong to the user. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Zero or more managed app registrations that belong to the user. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Me.ManagedAppRegistrations.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Zero or more managed app registrations that belong to the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Zero or more managed app registrations that belong to the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Me.ManagedAppRegistrations.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Zero or more managed app registrations that belong to the user. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Me/ManagedAppRegistrations/@Ref/RefResponse.cs b/src/generated/Me/ManagedAppRegistrations/@Ref/RefResponse.cs deleted file mode 100644 index acd36cb757f..00000000000 --- a/src/generated/Me/ManagedAppRegistrations/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.ManagedAppRegistrations.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/ManagedAppRegistrations/GetUserIdsWithFlaggedAppRegistration/GetUserIdsWithFlaggedAppRegistrationRequestBuilder.cs b/src/generated/Me/ManagedAppRegistrations/GetUserIdsWithFlaggedAppRegistration/GetUserIdsWithFlaggedAppRegistrationRequestBuilder.cs index a11d02ffd5a..a44d379daf1 100644 --- a/src/generated/Me/ManagedAppRegistrations/GetUserIdsWithFlaggedAppRegistration/GetUserIdsWithFlaggedAppRegistrationRequestBuilder.cs +++ b/src/generated/Me/ManagedAppRegistrations/GetUserIdsWithFlaggedAppRegistration/GetUserIdsWithFlaggedAppRegistrationRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function getUserIdsWithFlaggedAppRegistration"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getUserIdsWithFlaggedAppRegistration - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/ManagedAppRegistrations/ManagedAppRegistrationsRequestBuilder.cs b/src/generated/Me/ManagedAppRegistrations/ManagedAppRegistrationsRequestBuilder.cs index f7f8f363267..056f8b5c036 100644 --- a/src/generated/Me/ManagedAppRegistrations/ManagedAppRegistrationsRequestBuilder.cs +++ b/src/generated/Me/ManagedAppRegistrations/ManagedAppRegistrationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Me.ManagedAppRegistrations.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -62,7 +62,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -73,20 +77,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Me.ManagedAppRegistrations.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Me.ManagedAppRegistrations.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -126,18 +125,6 @@ public RequestInformation CreateGetRequestInformation(Action return requestInfo; } /// - /// Zero or more managed app registrations that belong to the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \me\managedAppRegistrations\microsoft.graph.getUserIdsWithFlaggedAppRegistration() /// public GetUserIdsWithFlaggedAppRegistrationRequestBuilder GetUserIdsWithFlaggedAppRegistration() { diff --git a/src/generated/Me/ManagedAppRegistrations/Ref/Ref.cs b/src/generated/Me/ManagedAppRegistrations/Ref/Ref.cs new file mode 100644 index 00000000000..2eb60f87b89 --- /dev/null +++ b/src/generated/Me/ManagedAppRegistrations/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.ManagedAppRegistrations.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/ManagedAppRegistrations/Ref/RefRequestBuilder.cs b/src/generated/Me/ManagedAppRegistrations/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..5e0cd62b802 --- /dev/null +++ b/src/generated/Me/ManagedAppRegistrations/Ref/RefRequestBuilder.cs @@ -0,0 +1,167 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Me.ManagedAppRegistrations.Ref { + /// Builds and executes requests for operations under \me\managedAppRegistrations\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Zero or more managed app registrations that belong to the user. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Zero or more managed app registrations that belong to the user."; + // Create options for all the parameters + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Zero or more managed app registrations that belong to the user. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Zero or more managed app registrations that belong to the user."; + // Create options for all the parameters + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/me/managedAppRegistrations/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Zero or more managed app registrations that belong to the user. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Zero or more managed app registrations that belong to the user. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Me.ManagedAppRegistrations.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Zero or more managed app registrations that belong to the user. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Me/ManagedAppRegistrations/Ref/RefResponse.cs b/src/generated/Me/ManagedAppRegistrations/Ref/RefResponse.cs new file mode 100644 index 00000000000..8d001d317e4 --- /dev/null +++ b/src/generated/Me/ManagedAppRegistrations/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.ManagedAppRegistrations.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/ManagedDevices/Item/BypassActivationLock/BypassActivationLockRequestBuilder.cs b/src/generated/Me/ManagedDevices/Item/BypassActivationLock/BypassActivationLockRequestBuilder.cs index 124ed549d16..b9f9fe0883d 100644 --- a/src/generated/Me/ManagedDevices/Item/BypassActivationLock/BypassActivationLockRequestBuilder.cs +++ b/src/generated/Me/ManagedDevices/Item/BypassActivationLock/BypassActivationLockRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Bypass activation lock"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Bypass activation lock - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/ManagedDevices/Item/CleanWindowsDevice/CleanWindowsDeviceRequestBuilder.cs b/src/generated/Me/ManagedDevices/Item/CleanWindowsDevice/CleanWindowsDeviceRequestBuilder.cs index 62b0deaa18a..c3f16510b92 100644 --- a/src/generated/Me/ManagedDevices/Item/CleanWindowsDevice/CleanWindowsDeviceRequestBuilder.cs +++ b/src/generated/Me/ManagedDevices/Item/CleanWindowsDevice/CleanWindowsDeviceRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Clean Windows device"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceId, string body) => { + command.SetHandler(async (string managedDeviceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(CleanWindowsDeviceRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Clean Windows device - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CleanWindowsDeviceRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/ManagedDevices/Item/DeleteUserFromSharedAppleDevice/DeleteUserFromSharedAppleDeviceRequestBuilder.cs b/src/generated/Me/ManagedDevices/Item/DeleteUserFromSharedAppleDevice/DeleteUserFromSharedAppleDeviceRequestBuilder.cs index 239320a98c6..d7df9985dbd 100644 --- a/src/generated/Me/ManagedDevices/Item/DeleteUserFromSharedAppleDevice/DeleteUserFromSharedAppleDeviceRequestBuilder.cs +++ b/src/generated/Me/ManagedDevices/Item/DeleteUserFromSharedAppleDevice/DeleteUserFromSharedAppleDeviceRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Delete user from shared Apple device"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceId, string body) => { + command.SetHandler(async (string managedDeviceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(DeleteUserFromSharedApple requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete user from shared Apple device - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeleteUserFromSharedAppleDeviceRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/ManagedDevices/Item/DeviceCategory/DeviceCategoryRequestBuilder.cs b/src/generated/Me/ManagedDevices/Item/DeviceCategory/DeviceCategoryRequestBuilder.cs index 012eeb66bdd..83f697dbba3 100644 --- a/src/generated/Me/ManagedDevices/Item/DeviceCategory/DeviceCategoryRequestBuilder.cs +++ b/src/generated/Me/ManagedDevices/Item/DeviceCategory/DeviceCategoryRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Device category"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Device category"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedDeviceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Device category"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceId, string body) => { + command.SetHandler(async (string managedDeviceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Device category - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device category - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device category - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DeviceCategory model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Device category public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/ManagedDevices/Item/DeviceCompliancePolicyStates/DeviceCompliancePolicyStatesRequestBuilder.cs b/src/generated/Me/ManagedDevices/Item/DeviceCompliancePolicyStates/DeviceCompliancePolicyStatesRequestBuilder.cs index bfe85338304..f47609b4637 100644 --- a/src/generated/Me/ManagedDevices/Item/DeviceCompliancePolicyStates/DeviceCompliancePolicyStatesRequestBuilder.cs +++ b/src/generated/Me/ManagedDevices/Item/DeviceCompliancePolicyStates/DeviceCompliancePolicyStatesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DeviceCompliancePolicyStatesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceCompliancePolicyStateRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Device compliance policy states for this device."; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Device compliance policy states for this device."; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedDeviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(DeviceCompliancePolicySta requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Device compliance policy states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device compliance policy states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceCompliancePolicyState model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Device compliance policy states for this device. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/ManagedDevices/Item/DeviceCompliancePolicyStates/Item/DeviceCompliancePolicyStateRequestBuilder.cs b/src/generated/Me/ManagedDevices/Item/DeviceCompliancePolicyStates/Item/DeviceCompliancePolicyStateRequestBuilder.cs index 54ab724d50e..aca2dddd7ee 100644 --- a/src/generated/Me/ManagedDevices/Item/DeviceCompliancePolicyStates/Item/DeviceCompliancePolicyStateRequestBuilder.cs +++ b/src/generated/Me/ManagedDevices/Item/DeviceCompliancePolicyStates/Item/DeviceCompliancePolicyStateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Device compliance policy states for this device."; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - var deviceCompliancePolicyStateIdOption = new Option("--devicecompliancepolicystate-id", description: "key: id of deviceCompliancePolicyState") { + var deviceCompliancePolicyStateIdOption = new Option("--device-compliance-policy-state-id", description: "key: id of deviceCompliancePolicyState") { }; deviceCompliancePolicyStateIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyStateIdOption); - command.SetHandler(async (string managedDeviceId, string deviceCompliancePolicyStateId) => { + command.SetHandler(async (string managedDeviceId, string deviceCompliancePolicyStateId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption, deviceCompliancePolicyStateIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Device compliance policy states for this device."; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - var deviceCompliancePolicyStateIdOption = new Option("--devicecompliancepolicystate-id", description: "key: id of deviceCompliancePolicyState") { + var deviceCompliancePolicyStateIdOption = new Option("--device-compliance-policy-state-id", description: "key: id of deviceCompliancePolicyState") { }; deviceCompliancePolicyStateIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyStateIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedDeviceId, string deviceCompliancePolicyStateId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceId, string deviceCompliancePolicyStateId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceIdOption, deviceCompliancePolicyStateIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceIdOption, deviceCompliancePolicyStateIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Device compliance policy states for this device."; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - var deviceCompliancePolicyStateIdOption = new Option("--devicecompliancepolicystate-id", description: "key: id of deviceCompliancePolicyState") { + var deviceCompliancePolicyStateIdOption = new Option("--device-compliance-policy-state-id", description: "key: id of deviceCompliancePolicyState") { }; deviceCompliancePolicyStateIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyStateIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceId, string deviceCompliancePolicyStateId, string body) => { + command.SetHandler(async (string managedDeviceId, string deviceCompliancePolicyStateId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption, deviceCompliancePolicyStateIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceCompliancePolicySt requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Device compliance policy states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device compliance policy states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device compliance policy states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceCompliancePolicyState model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Device compliance policy states for this device. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/ManagedDevices/Item/DeviceConfigurationStates/DeviceConfigurationStatesRequestBuilder.cs b/src/generated/Me/ManagedDevices/Item/DeviceConfigurationStates/DeviceConfigurationStatesRequestBuilder.cs index ef8ab2daa2c..4ca02358a37 100644 --- a/src/generated/Me/ManagedDevices/Item/DeviceConfigurationStates/DeviceConfigurationStatesRequestBuilder.cs +++ b/src/generated/Me/ManagedDevices/Item/DeviceConfigurationStates/DeviceConfigurationStatesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DeviceConfigurationStatesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceConfigurationStateRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Device configuration states for this device."; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Device configuration states for this device."; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedDeviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(DeviceConfigurationState requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Device configuration states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device configuration states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceConfigurationState model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Device configuration states for this device. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/ManagedDevices/Item/DeviceConfigurationStates/Item/DeviceConfigurationStateRequestBuilder.cs b/src/generated/Me/ManagedDevices/Item/DeviceConfigurationStates/Item/DeviceConfigurationStateRequestBuilder.cs index 7655e46e6ef..fa9b4826a04 100644 --- a/src/generated/Me/ManagedDevices/Item/DeviceConfigurationStates/Item/DeviceConfigurationStateRequestBuilder.cs +++ b/src/generated/Me/ManagedDevices/Item/DeviceConfigurationStates/Item/DeviceConfigurationStateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Device configuration states for this device."; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - var deviceConfigurationStateIdOption = new Option("--deviceconfigurationstate-id", description: "key: id of deviceConfigurationState") { + var deviceConfigurationStateIdOption = new Option("--device-configuration-state-id", description: "key: id of deviceConfigurationState") { }; deviceConfigurationStateIdOption.IsRequired = true; command.AddOption(deviceConfigurationStateIdOption); - command.SetHandler(async (string managedDeviceId, string deviceConfigurationStateId) => { + command.SetHandler(async (string managedDeviceId, string deviceConfigurationStateId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption, deviceConfigurationStateIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Device configuration states for this device."; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - var deviceConfigurationStateIdOption = new Option("--deviceconfigurationstate-id", description: "key: id of deviceConfigurationState") { + var deviceConfigurationStateIdOption = new Option("--device-configuration-state-id", description: "key: id of deviceConfigurationState") { }; deviceConfigurationStateIdOption.IsRequired = true; command.AddOption(deviceConfigurationStateIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedDeviceId, string deviceConfigurationStateId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceId, string deviceConfigurationStateId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceIdOption, deviceConfigurationStateIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceIdOption, deviceConfigurationStateIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Device configuration states for this device."; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - var deviceConfigurationStateIdOption = new Option("--deviceconfigurationstate-id", description: "key: id of deviceConfigurationState") { + var deviceConfigurationStateIdOption = new Option("--device-configuration-state-id", description: "key: id of deviceConfigurationState") { }; deviceConfigurationStateIdOption.IsRequired = true; command.AddOption(deviceConfigurationStateIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceId, string deviceConfigurationStateId, string body) => { + command.SetHandler(async (string managedDeviceId, string deviceConfigurationStateId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption, deviceConfigurationStateIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceConfigurationState requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Device configuration states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device configuration states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device configuration states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceConfigurationState model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Device configuration states for this device. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/ManagedDevices/Item/DisableLostMode/DisableLostModeRequestBuilder.cs b/src/generated/Me/ManagedDevices/Item/DisableLostMode/DisableLostModeRequestBuilder.cs index ca40ce40f7f..4f4016ca4f3 100644 --- a/src/generated/Me/ManagedDevices/Item/DisableLostMode/DisableLostModeRequestBuilder.cs +++ b/src/generated/Me/ManagedDevices/Item/DisableLostMode/DisableLostModeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Disable lost mode"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Disable lost mode - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/ManagedDevices/Item/LocateDevice/LocateDeviceRequestBuilder.cs b/src/generated/Me/ManagedDevices/Item/LocateDevice/LocateDeviceRequestBuilder.cs index ae743b89070..1aca657a39b 100644 --- a/src/generated/Me/ManagedDevices/Item/LocateDevice/LocateDeviceRequestBuilder.cs +++ b/src/generated/Me/ManagedDevices/Item/LocateDevice/LocateDeviceRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Locate a device"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Locate a device - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/ManagedDevices/Item/LogoutSharedAppleDeviceActiveUser/LogoutSharedAppleDeviceActiveUserRequestBuilder.cs b/src/generated/Me/ManagedDevices/Item/LogoutSharedAppleDeviceActiveUser/LogoutSharedAppleDeviceActiveUserRequestBuilder.cs index 3e79393649f..a1b72e1a711 100644 --- a/src/generated/Me/ManagedDevices/Item/LogoutSharedAppleDeviceActiveUser/LogoutSharedAppleDeviceActiveUserRequestBuilder.cs +++ b/src/generated/Me/ManagedDevices/Item/LogoutSharedAppleDeviceActiveUser/LogoutSharedAppleDeviceActiveUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Logout shared Apple device active user"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Logout shared Apple device active user - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/ManagedDevices/Item/ManagedDeviceRequestBuilder.cs b/src/generated/Me/ManagedDevices/Item/ManagedDeviceRequestBuilder.cs index c841628284d..605f7fe5472 100644 --- a/src/generated/Me/ManagedDevices/Item/ManagedDeviceRequestBuilder.cs +++ b/src/generated/Me/ManagedDevices/Item/ManagedDeviceRequestBuilder.cs @@ -22,10 +22,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -59,15 +59,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The managed devices associated with the user."; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -89,6 +88,9 @@ public Command BuildDeviceCategoryCommand() { public Command BuildDeviceCompliancePolicyStatesCommand() { var command = new Command("device-compliance-policy-states"); var builder = new ApiSdk.Me.ManagedDevices.Item.DeviceCompliancePolicyStates.DeviceCompliancePolicyStatesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -96,6 +98,9 @@ public Command BuildDeviceCompliancePolicyStatesCommand() { public Command BuildDeviceConfigurationStatesCommand() { var command = new Command("device-configuration-states"); var builder = new ApiSdk.Me.ManagedDevices.Item.DeviceConfigurationStates.DeviceConfigurationStatesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -113,7 +118,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The managed devices associated with the user."; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -127,20 +132,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string managedDeviceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string managedDeviceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, managedDeviceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, managedDeviceIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLocateDeviceCommand() { @@ -162,7 +166,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The managed devices associated with the user."; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -170,14 +174,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceId, string body) => { + command.SetHandler(async (string managedDeviceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption, bodyOption); return command; @@ -321,42 +324,6 @@ public RequestInformation CreatePatchRequestInformation(ManagedDevice body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The managed devices associated with the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The managed devices associated with the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The managed devices associated with the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ManagedDevice model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The managed devices associated with the user. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/ManagedDevices/Item/RebootNow/RebootNowRequestBuilder.cs b/src/generated/Me/ManagedDevices/Item/RebootNow/RebootNowRequestBuilder.cs index 7fad98a27b6..4e20d16913e 100644 --- a/src/generated/Me/ManagedDevices/Item/RebootNow/RebootNowRequestBuilder.cs +++ b/src/generated/Me/ManagedDevices/Item/RebootNow/RebootNowRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Reboot device"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Reboot device - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/ManagedDevices/Item/RecoverPasscode/RecoverPasscodeRequestBuilder.cs b/src/generated/Me/ManagedDevices/Item/RecoverPasscode/RecoverPasscodeRequestBuilder.cs index 6d091b165c2..975fa67cb92 100644 --- a/src/generated/Me/ManagedDevices/Item/RecoverPasscode/RecoverPasscodeRequestBuilder.cs +++ b/src/generated/Me/ManagedDevices/Item/RecoverPasscode/RecoverPasscodeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Recover passcode"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Recover passcode - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/ManagedDevices/Item/RemoteLock/RemoteLockRequestBuilder.cs b/src/generated/Me/ManagedDevices/Item/RemoteLock/RemoteLockRequestBuilder.cs index d10cc90e134..e2e2f7aa153 100644 --- a/src/generated/Me/ManagedDevices/Item/RemoteLock/RemoteLockRequestBuilder.cs +++ b/src/generated/Me/ManagedDevices/Item/RemoteLock/RemoteLockRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Remote lock"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Remote lock - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/ManagedDevices/Item/RequestRemoteAssistance/RequestRemoteAssistanceRequestBuilder.cs b/src/generated/Me/ManagedDevices/Item/RequestRemoteAssistance/RequestRemoteAssistanceRequestBuilder.cs index 9172480f704..771d6c5f47d 100644 --- a/src/generated/Me/ManagedDevices/Item/RequestRemoteAssistance/RequestRemoteAssistanceRequestBuilder.cs +++ b/src/generated/Me/ManagedDevices/Item/RequestRemoteAssistance/RequestRemoteAssistanceRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Request remote assistance"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Request remote assistance - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/ManagedDevices/Item/ResetPasscode/ResetPasscodeRequestBuilder.cs b/src/generated/Me/ManagedDevices/Item/ResetPasscode/ResetPasscodeRequestBuilder.cs index 9ff8c11d58d..3d1b1f40a8b 100644 --- a/src/generated/Me/ManagedDevices/Item/ResetPasscode/ResetPasscodeRequestBuilder.cs +++ b/src/generated/Me/ManagedDevices/Item/ResetPasscode/ResetPasscodeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Reset passcode"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Reset passcode - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/ManagedDevices/Item/Retire/RetireRequestBuilder.cs b/src/generated/Me/ManagedDevices/Item/Retire/RetireRequestBuilder.cs index c778f02e91a..d89ab587e17 100644 --- a/src/generated/Me/ManagedDevices/Item/Retire/RetireRequestBuilder.cs +++ b/src/generated/Me/ManagedDevices/Item/Retire/RetireRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Retire a device"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Retire a device - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/ManagedDevices/Item/ShutDown/ShutDownRequestBuilder.cs b/src/generated/Me/ManagedDevices/Item/ShutDown/ShutDownRequestBuilder.cs index 9e712a2e0e7..458a5667030 100644 --- a/src/generated/Me/ManagedDevices/Item/ShutDown/ShutDownRequestBuilder.cs +++ b/src/generated/Me/ManagedDevices/Item/ShutDown/ShutDownRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Shut down device"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Shut down device - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/ManagedDevices/Item/SyncDevice/SyncDeviceRequestBuilder.cs b/src/generated/Me/ManagedDevices/Item/SyncDevice/SyncDeviceRequestBuilder.cs index f414889db2f..46a7402dfee 100644 --- a/src/generated/Me/ManagedDevices/Item/SyncDevice/SyncDeviceRequestBuilder.cs +++ b/src/generated/Me/ManagedDevices/Item/SyncDevice/SyncDeviceRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action syncDevice"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action syncDevice - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/ManagedDevices/Item/UpdateWindowsDeviceAccount/UpdateWindowsDeviceAccountRequestBuilder.cs b/src/generated/Me/ManagedDevices/Item/UpdateWindowsDeviceAccount/UpdateWindowsDeviceAccountRequestBuilder.cs index 5ff1524c7af..b159cf6b74e 100644 --- a/src/generated/Me/ManagedDevices/Item/UpdateWindowsDeviceAccount/UpdateWindowsDeviceAccountRequestBuilder.cs +++ b/src/generated/Me/ManagedDevices/Item/UpdateWindowsDeviceAccount/UpdateWindowsDeviceAccountRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action updateWindowsDeviceAccount"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceId, string body) => { + command.SetHandler(async (string managedDeviceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(UpdateWindowsDeviceAccoun requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action updateWindowsDeviceAccount - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UpdateWindowsDeviceAccountRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/ManagedDevices/Item/WindowsDefenderScan/WindowsDefenderScanRequestBuilder.cs b/src/generated/Me/ManagedDevices/Item/WindowsDefenderScan/WindowsDefenderScanRequestBuilder.cs index 9e4ea5e50be..e6eeb8f7dee 100644 --- a/src/generated/Me/ManagedDevices/Item/WindowsDefenderScan/WindowsDefenderScanRequestBuilder.cs +++ b/src/generated/Me/ManagedDevices/Item/WindowsDefenderScan/WindowsDefenderScanRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action windowsDefenderScan"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceId, string body) => { + command.SetHandler(async (string managedDeviceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(WindowsDefenderScanReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action windowsDefenderScan - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WindowsDefenderScanRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/ManagedDevices/Item/WindowsDefenderUpdateSignatures/WindowsDefenderUpdateSignaturesRequestBuilder.cs b/src/generated/Me/ManagedDevices/Item/WindowsDefenderUpdateSignatures/WindowsDefenderUpdateSignaturesRequestBuilder.cs index 12eaa44b8eb..a6148453dbb 100644 --- a/src/generated/Me/ManagedDevices/Item/WindowsDefenderUpdateSignatures/WindowsDefenderUpdateSignaturesRequestBuilder.cs +++ b/src/generated/Me/ManagedDevices/Item/WindowsDefenderUpdateSignatures/WindowsDefenderUpdateSignaturesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action windowsDefenderUpdateSignatures"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string managedDeviceId) => { + command.SetHandler(async (string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action windowsDefenderUpdateSignatures - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/ManagedDevices/Item/Wipe/WipeRequestBuilder.cs b/src/generated/Me/ManagedDevices/Item/Wipe/WipeRequestBuilder.cs index b5ab652dc0f..e657a1121b2 100644 --- a/src/generated/Me/ManagedDevices/Item/Wipe/WipeRequestBuilder.cs +++ b/src/generated/Me/ManagedDevices/Item/Wipe/WipeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Wipe a device"; // Create options for all the parameters - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string managedDeviceId, string body) => { + command.SetHandler(async (string managedDeviceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, managedDeviceIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(WipeRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Wipe a device - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WipeRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/ManagedDevices/ManagedDevicesRequestBuilder.cs b/src/generated/Me/ManagedDevices/ManagedDevicesRequestBuilder.cs index ab260bc0a88..916bd9dc4f1 100644 --- a/src/generated/Me/ManagedDevices/ManagedDevicesRequestBuilder.cs +++ b/src/generated/Me/ManagedDevices/ManagedDevicesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,32 +22,31 @@ public class ManagedDevicesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ManagedDeviceRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildBypassActivationLockCommand(), - builder.BuildCleanWindowsDeviceCommand(), - builder.BuildDeleteCommand(), - builder.BuildDeleteUserFromSharedAppleDeviceCommand(), - builder.BuildDeviceCategoryCommand(), - builder.BuildDeviceCompliancePolicyStatesCommand(), - builder.BuildDeviceConfigurationStatesCommand(), - builder.BuildDisableLostModeCommand(), - builder.BuildGetCommand(), - builder.BuildLocateDeviceCommand(), - builder.BuildLogoutSharedAppleDeviceActiveUserCommand(), - builder.BuildPatchCommand(), - builder.BuildRebootNowCommand(), - builder.BuildRecoverPasscodeCommand(), - builder.BuildRemoteLockCommand(), - builder.BuildRequestRemoteAssistanceCommand(), - builder.BuildResetPasscodeCommand(), - builder.BuildRetireCommand(), - builder.BuildShutDownCommand(), - builder.BuildSyncDeviceCommand(), - builder.BuildUpdateWindowsDeviceAccountCommand(), - builder.BuildWindowsDefenderScanCommand(), - builder.BuildWindowsDefenderUpdateSignaturesCommand(), - builder.BuildWipeCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildBypassActivationLockCommand()); + commands.Add(builder.BuildCleanWindowsDeviceCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDeleteUserFromSharedAppleDeviceCommand()); + commands.Add(builder.BuildDeviceCategoryCommand()); + commands.Add(builder.BuildDeviceCompliancePolicyStatesCommand()); + commands.Add(builder.BuildDeviceConfigurationStatesCommand()); + commands.Add(builder.BuildDisableLostModeCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildLocateDeviceCommand()); + commands.Add(builder.BuildLogoutSharedAppleDeviceActiveUserCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRebootNowCommand()); + commands.Add(builder.BuildRecoverPasscodeCommand()); + commands.Add(builder.BuildRemoteLockCommand()); + commands.Add(builder.BuildRequestRemoteAssistanceCommand()); + commands.Add(builder.BuildResetPasscodeCommand()); + commands.Add(builder.BuildRetireCommand()); + commands.Add(builder.BuildShutDownCommand()); + commands.Add(builder.BuildSyncDeviceCommand()); + commands.Add(builder.BuildUpdateWindowsDeviceAccountCommand()); + commands.Add(builder.BuildWindowsDefenderScanCommand()); + commands.Add(builder.BuildWindowsDefenderUpdateSignaturesCommand()); + commands.Add(builder.BuildWipeCommand()); return commands; } /// @@ -61,21 +60,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -194,31 +191,6 @@ public RequestInformation CreatePostRequestInformation(ManagedDevice body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The managed devices associated with the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The managed devices associated with the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ManagedDevice model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The managed devices associated with the user. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Manager/@Ref/@Ref.cs b/src/generated/Me/Manager/@Ref/@Ref.cs deleted file mode 100644 index 08682302b29..00000000000 --- a/src/generated/Me/Manager/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.Manager.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/Manager/@Ref/RefRequestBuilder.cs b/src/generated/Me/Manager/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 4ad545a03b6..00000000000 --- a/src/generated/Me/Manager/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,178 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Me.Manager.@Ref { - /// Builds and executes requests for operations under \me\manager\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand."; - // Create options for all the parameters - command.SetHandler(async () => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }); - return command; - } - /// - /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand."; - // Create options for all the parameters - command.SetHandler(async () => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); - return command; - } - /// - /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand."; - // Create options for all the parameters - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/manager/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Me.Manager.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Me.Manager.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Me/Manager/ManagerRequestBuilder.cs b/src/generated/Me/Manager/ManagerRequestBuilder.cs index 99849030070..65ca08b946b 100644 --- a/src/generated/Me/Manager/ManagerRequestBuilder.cs +++ b/src/generated/Me/Manager/ManagerRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,25 +37,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Me.Manager.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Me.Manager.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -95,18 +94,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Manager/Ref/Ref.cs b/src/generated/Me/Manager/Ref/Ref.cs new file mode 100644 index 00000000000..4531cf34757 --- /dev/null +++ b/src/generated/Me/Manager/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.Manager.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/Manager/Ref/RefRequestBuilder.cs b/src/generated/Me/Manager/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..3923eb81f8b --- /dev/null +++ b/src/generated/Me/Manager/Ref/RefRequestBuilder.cs @@ -0,0 +1,140 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Me.Manager.Ref { + /// Builds and executes requests for operations under \me\manager\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand."; + // Create options for all the parameters + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }); + return command; + } + /// + /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand."; + // Create options for all the parameters + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); + return command; + } + /// + /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand."; + // Create options for all the parameters + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/me/manager/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Me.Manager.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Me/MeRequestBuilder.cs b/src/generated/Me/MeRequestBuilder.cs index 3ffbd01755a..ab4e9a3b3f8 100644 --- a/src/generated/Me/MeRequestBuilder.cs +++ b/src/generated/Me/MeRequestBuilder.cs @@ -66,10 +66,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -87,6 +87,9 @@ public class MeRequestBuilder { public Command BuildActivitiesCommand() { var command = new Command("activities"); var builder = new ApiSdk.Me.Activities.ActivitiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -101,6 +104,9 @@ public Command BuildAgreementAcceptancesCommand() { public Command BuildAppRoleAssignmentsCommand() { var command = new Command("app-role-assignments"); var builder = new ApiSdk.Me.AppRoleAssignments.AppRoleAssignmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -140,6 +146,9 @@ public Command BuildCalendarCommand() { public Command BuildCalendarGroupsCommand() { var command = new Command("calendar-groups"); var builder = new ApiSdk.Me.CalendarGroups.CalendarGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -147,6 +156,9 @@ public Command BuildCalendarGroupsCommand() { public Command BuildCalendarsCommand() { var command = new Command("calendars"); var builder = new ApiSdk.Me.Calendars.CalendarsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -154,6 +166,9 @@ public Command BuildCalendarsCommand() { public Command BuildCalendarViewCommand() { var command = new Command("calendar-view"); var builder = new ApiSdk.Me.CalendarView.CalendarViewRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -167,6 +182,9 @@ public Command BuildChangePasswordCommand() { public Command BuildChatsCommand() { var command = new Command("chats"); var builder = new ApiSdk.Me.Chats.ChatsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -186,6 +204,9 @@ public Command BuildCheckMemberObjectsCommand() { public Command BuildContactFoldersCommand() { var command = new Command("contact-folders"); var builder = new ApiSdk.Me.ContactFolders.ContactFoldersRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -193,6 +214,9 @@ public Command BuildContactFoldersCommand() { public Command BuildContactsCommand() { var command = new Command("contacts"); var builder = new ApiSdk.Me.Contacts.ContactsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -207,6 +231,9 @@ public Command BuildCreatedObjectsCommand() { public Command BuildDeviceManagementTroubleshootingEventsCommand() { var command = new Command("device-management-troubleshooting-events"); var builder = new ApiSdk.Me.DeviceManagementTroubleshootingEvents.DeviceManagementTroubleshootingEventsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -229,6 +256,9 @@ public Command BuildDriveCommand() { public Command BuildDrivesCommand() { var command = new Command("drives"); var builder = new ApiSdk.Me.Drives.DrivesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -236,6 +266,9 @@ public Command BuildDrivesCommand() { public Command BuildEventsCommand() { var command = new Command("events"); var builder = new ApiSdk.Me.Events.EventsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -249,6 +282,9 @@ public Command BuildExportPersonalDataCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Me.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -283,20 +319,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } public Command BuildGetMailTipsCommand() { @@ -340,6 +375,9 @@ public Command BuildInsightsCommand() { public Command BuildJoinedTeamsCommand() { var command = new Command("joined-teams"); var builder = new ApiSdk.Me.JoinedTeams.JoinedTeamsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -347,6 +385,9 @@ public Command BuildJoinedTeamsCommand() { public Command BuildLicenseDetailsCommand() { var command = new Command("license-details"); var builder = new ApiSdk.Me.LicenseDetails.LicenseDetailsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -354,6 +395,9 @@ public Command BuildLicenseDetailsCommand() { public Command BuildMailFoldersCommand() { var command = new Command("mail-folders"); var builder = new ApiSdk.Me.MailFolders.MailFoldersRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -368,6 +412,9 @@ public Command BuildManagedAppRegistrationsCommand() { public Command BuildManagedDevicesCommand() { var command = new Command("managed-devices"); var builder = new ApiSdk.Me.ManagedDevices.ManagedDevicesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -389,6 +436,9 @@ public Command BuildMemberOfCommand() { public Command BuildMessagesCommand() { var command = new Command("messages"); var builder = new ApiSdk.Me.Messages.MessagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -417,6 +467,9 @@ public Command BuildOnenoteCommand() { public Command BuildOnlineMeetingsCommand() { var command = new Command("online-meetings"); var builder = new ApiSdk.Me.OnlineMeetings.OnlineMeetingsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateOrGetCommand()); command.AddCommand(builder.BuildListCommand()); @@ -456,14 +509,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -471,6 +523,9 @@ public Command BuildPatchCommand() { public Command BuildPeopleCommand() { var command = new Command("people"); var builder = new ApiSdk.Me.People.PeopleRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -487,6 +542,9 @@ public Command BuildPhotoCommand() { public Command BuildPhotosCommand() { var command = new Command("photos"); var builder = new ApiSdk.Me.Photos.PhotosRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -545,6 +603,9 @@ public Command BuildRevokeSignInSessionsCommand() { public Command BuildScopedRoleMemberOfCommand() { var command = new Command("scoped-role-member-of"); var builder = new ApiSdk.Me.ScopedRoleMemberOf.ScopedRoleMemberOfRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -655,18 +716,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. return requestInfo; } /// - /// Get me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \me\microsoft.graph.getManagedAppDiagnosticStatuses() /// public GetManagedAppDiagnosticStatusesRequestBuilder GetManagedAppDiagnosticStatuses() { @@ -679,19 +728,6 @@ public GetManagedAppPoliciesRequestBuilder GetManagedAppPolicies() { return new GetManagedAppPoliciesRequestBuilder(PathParameters, RequestAdapter); } /// - /// Update me - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.User model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \me\microsoft.graph.reminderView(StartDateTime='{StartDateTime}',EndDateTime='{EndDateTime}') /// Usage: EndDateTime={EndDateTime} /// Usage: StartDateTime={StartDateTime} diff --git a/src/generated/Me/MemberOf/@Ref/@Ref.cs b/src/generated/Me/MemberOf/@Ref/@Ref.cs deleted file mode 100644 index 0a2dcd11049..00000000000 --- a/src/generated/Me/MemberOf/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.MemberOf.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/MemberOf/@Ref/RefRequestBuilder.cs b/src/generated/Me/MemberOf/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 8959676fb66..00000000000 --- a/src/generated/Me/MemberOf/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,194 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Me.MemberOf.@Ref { - /// Builds and executes requests for operations under \me\memberOf\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/memberOf/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Me.MemberOf.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Me.MemberOf.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Me/MemberOf/@Ref/RefResponse.cs b/src/generated/Me/MemberOf/@Ref/RefResponse.cs deleted file mode 100644 index e8385ea48a5..00000000000 --- a/src/generated/Me/MemberOf/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.MemberOf.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/MemberOf/MemberOfRequestBuilder.cs b/src/generated/Me/MemberOf/MemberOfRequestBuilder.cs index b0c99cdd93f..c0926278623 100644 --- a/src/generated/Me/MemberOf/MemberOfRequestBuilder.cs +++ b/src/generated/Me/MemberOf/MemberOfRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Me.MemberOf.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -61,7 +61,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -72,20 +76,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Me.MemberOf.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Me.MemberOf.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -124,18 +123,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/MemberOf/Ref/Ref.cs b/src/generated/Me/MemberOf/Ref/Ref.cs new file mode 100644 index 00000000000..594977669db --- /dev/null +++ b/src/generated/Me/MemberOf/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.MemberOf.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/MemberOf/Ref/RefRequestBuilder.cs b/src/generated/Me/MemberOf/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..cc09e4696af --- /dev/null +++ b/src/generated/Me/MemberOf/Ref/RefRequestBuilder.cs @@ -0,0 +1,167 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Me.MemberOf.Ref { + /// Builds and executes requests for operations under \me\memberOf\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/me/memberOf/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Me.MemberOf.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Me/MemberOf/Ref/RefResponse.cs b/src/generated/Me/MemberOf/Ref/RefResponse.cs new file mode 100644 index 00000000000..877a96cda92 --- /dev/null +++ b/src/generated/Me/MemberOf/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.MemberOf.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/Messages/Delta/Delta.cs b/src/generated/Me/Messages/Delta/Delta.cs deleted file mode 100644 index c770129fead..00000000000 --- a/src/generated/Me/Messages/Delta/Delta.cs +++ /dev/null @@ -1,128 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.Messages.Delta { - public class Delta : OutlookItem, IParsable { - /// The fileAttachment and itemAttachment attachments for the message. - public List Attachments { get; set; } - /// The Bcc: recipients for the message. - public List BccRecipients { get; set; } - /// The body of the message. It can be in HTML or text format. Find out about safe HTML in a message body. - public ItemBody Body { get; set; } - /// The first 255 characters of the message body. It is in text format. If the message contains instances of mention, this property would contain a concatenation of these mentions as well. - public string BodyPreview { get; set; } - /// The Cc: recipients for the message. - public List CcRecipients { get; set; } - /// The ID of the conversation the email belongs to. - public string ConversationId { get; set; } - /// Indicates the position of the message within the conversation. - public byte[] ConversationIndex { get; set; } - /// The collection of open extensions defined for the message. Nullable. - public List Extensions { get; set; } - /// The flag value that indicates the status, start date, due date, or completion date for the message. - public FollowupFlag Flag { get; set; } - /// The owner of the mailbox from which the message is sent. In most cases, this value is the same as the sender property, except for sharing or delegation scenarios. The value must correspond to the actual mailbox used. Find out more about setting the from and sender properties of a message. - public Recipient From { get; set; } - /// Indicates whether the message has attachments. This property doesn't include inline attachments, so if a message contains only inline attachments, this property is false. To verify the existence of inline attachments, parse the body property to look for a src attribute, such as . - public bool? HasAttachments { get; set; } - public Importance? Importance { get; set; } - public InferenceClassificationType? InferenceClassification { get; set; } - public List InternetMessageHeaders { get; set; } - public string InternetMessageId { get; set; } - public bool? IsDeliveryReceiptRequested { get; set; } - public bool? IsDraft { get; set; } - public bool? IsRead { get; set; } - public bool? IsReadReceiptRequested { get; set; } - /// The collection of multi-value extended properties defined for the message. Nullable. - public List MultiValueExtendedProperties { get; set; } - public string ParentFolderId { get; set; } - public DateTimeOffset? ReceivedDateTime { get; set; } - public List ReplyTo { get; set; } - public Recipient Sender { get; set; } - public DateTimeOffset? SentDateTime { get; set; } - /// The collection of single-value extended properties defined for the message. Nullable. - public List SingleValueExtendedProperties { get; set; } - public string Subject { get; set; } - public List ToRecipients { get; set; } - public ItemBody UniqueBody { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"bccRecipients", (o,n) => { (o as Delta).BccRecipients = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"ccRecipients", (o,n) => { (o as Delta).CcRecipients = n.GetCollectionOfObjectValues().ToList(); } }, - {"conversationId", (o,n) => { (o as Delta).ConversationId = n.GetStringValue(); } }, - {"conversationIndex", (o,n) => { (o as Delta).ConversationIndex = n.GetByteArrayValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"flag", (o,n) => { (o as Delta).Flag = n.GetObjectValue(); } }, - {"from", (o,n) => { (o as Delta).From = n.GetObjectValue(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"inferenceClassification", (o,n) => { (o as Delta).InferenceClassification = n.GetEnumValue(); } }, - {"internetMessageHeaders", (o,n) => { (o as Delta).InternetMessageHeaders = n.GetCollectionOfObjectValues().ToList(); } }, - {"internetMessageId", (o,n) => { (o as Delta).InternetMessageId = n.GetStringValue(); } }, - {"isDeliveryReceiptRequested", (o,n) => { (o as Delta).IsDeliveryReceiptRequested = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isRead", (o,n) => { (o as Delta).IsRead = n.GetBoolValue(); } }, - {"isReadReceiptRequested", (o,n) => { (o as Delta).IsReadReceiptRequested = n.GetBoolValue(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"parentFolderId", (o,n) => { (o as Delta).ParentFolderId = n.GetStringValue(); } }, - {"receivedDateTime", (o,n) => { (o as Delta).ReceivedDateTime = n.GetDateTimeOffsetValue(); } }, - {"replyTo", (o,n) => { (o as Delta).ReplyTo = n.GetCollectionOfObjectValues().ToList(); } }, - {"sender", (o,n) => { (o as Delta).Sender = n.GetObjectValue(); } }, - {"sentDateTime", (o,n) => { (o as Delta).SentDateTime = n.GetDateTimeOffsetValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"toRecipients", (o,n) => { (o as Delta).ToRecipients = n.GetCollectionOfObjectValues().ToList(); } }, - {"uniqueBody", (o,n) => { (o as Delta).UniqueBody = n.GetObjectValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("bccRecipients", BccRecipients); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteCollectionOfObjectValues("ccRecipients", CcRecipients); - writer.WriteStringValue("conversationId", ConversationId); - writer.WriteByteArrayValue("conversationIndex", ConversationIndex); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteObjectValue("flag", Flag); - writer.WriteObjectValue("from", From); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteEnumValue("importance", Importance); - writer.WriteEnumValue("inferenceClassification", InferenceClassification); - writer.WriteCollectionOfObjectValues("internetMessageHeaders", InternetMessageHeaders); - writer.WriteStringValue("internetMessageId", InternetMessageId); - writer.WriteBoolValue("isDeliveryReceiptRequested", IsDeliveryReceiptRequested); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isRead", IsRead); - writer.WriteBoolValue("isReadReceiptRequested", IsReadReceiptRequested); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteStringValue("parentFolderId", ParentFolderId); - writer.WriteDateTimeOffsetValue("receivedDateTime", ReceivedDateTime); - writer.WriteCollectionOfObjectValues("replyTo", ReplyTo); - writer.WriteObjectValue("sender", Sender); - writer.WriteDateTimeOffsetValue("sentDateTime", SentDateTime); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteStringValue("subject", Subject); - writer.WriteCollectionOfObjectValues("toRecipients", ToRecipients); - writer.WriteObjectValue("uniqueBody", UniqueBody); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Me/Messages/Delta/DeltaRequestBuilder.cs b/src/generated/Me/Messages/Delta/DeltaRequestBuilder.cs index d94696a10d8..e7e2b2d87e3 100644 --- a/src/generated/Me/Messages/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/Messages/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +26,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +67,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Messages/Item/Attachments/AttachmentsRequestBuilder.cs b/src/generated/Me/Messages/Item/Attachments/AttachmentsRequestBuilder.cs index d22554612df..a13b26dc2f6 100644 --- a/src/generated/Me/Messages/Item/Attachments/AttachmentsRequestBuilder.cs +++ b/src/generated/Me/Messages/Item/Attachments/AttachmentsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class AttachmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttachmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, messageIdOption, bodyOption, outputOption); return command; } public Command BuildCreateUploadSessionCommand() { @@ -110,7 +108,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string messageId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string messageId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -120,15 +122,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, messageIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, messageIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -183,31 +180,6 @@ public RequestInformation CreatePostRequestInformation(Attachment body, Action - /// The fileAttachment and itemAttachment attachments for the message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The fileAttachment and itemAttachment attachments for the message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The fileAttachment and itemAttachment attachments for the message. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Messages/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Me/Messages/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index cdf2f0345c6..16e8345841e 100644 --- a/src/generated/Me/Messages/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Me/Messages/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, messageIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Messages/Item/Attachments/Item/AttachmentRequestBuilder.cs b/src/generated/Me/Messages/Item/Attachments/Item/AttachmentRequestBuilder.cs index fe7b48e548d..b69d842be92 100644 --- a/src/generated/Me/Messages/Item/Attachments/Item/AttachmentRequestBuilder.cs +++ b/src/generated/Me/Messages/Item/Attachments/Item/AttachmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; attachmentIdOption.IsRequired = true; command.AddOption(attachmentIdOption); - command.SetHandler(async (string messageId, string attachmentId) => { + command.SetHandler(async (string messageId, string attachmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, messageIdOption, attachmentIdOption); return command; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string messageId, string attachmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string messageId, string attachmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, messageIdOption, attachmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, messageIdOption, attachmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string messageId, string attachmentId, string body) => { + command.SetHandler(async (string messageId, string attachmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, messageIdOption, attachmentIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(Attachment body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The fileAttachment and itemAttachment attachments for the message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The fileAttachment and itemAttachment attachments for the message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The fileAttachment and itemAttachment attachments for the message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The fileAttachment and itemAttachment attachments for the message. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Messages/Item/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs b/src/generated/Me/Messages/Item/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs index 88662bc135e..d94edbbbd3e 100644 --- a/src/generated/Me/Messages/Item/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Me/Messages/Item/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildPostCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - command.SetHandler(async (string messageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string messageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, messageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, messageIdOption, outputOption); return command; } /// @@ -72,16 +71,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Messages/Item/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs b/src/generated/Me/Messages/Item/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs index 71b8e4f56a2..4ebe0039387 100644 --- a/src/generated/Me/Messages/Item/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs +++ b/src/generated/Me/Messages/Item/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Me.Messages.Item.CalendarSharingMessage.Accept; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Me/Messages/Item/Copy/CopyRequestBuilder.cs b/src/generated/Me/Messages/Item/Copy/CopyRequestBuilder.cs index 78ceb3fb2bc..a45a7e77a6a 100644 --- a/src/generated/Me/Messages/Item/Copy/CopyRequestBuilder.cs +++ b/src/generated/Me/Messages/Item/Copy/CopyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, messageIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CopyRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copy - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes message public class CopyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Messages/Item/CreateForward/CreateForwardRequestBuilder.cs b/src/generated/Me/Messages/Item/CreateForward/CreateForwardRequestBuilder.cs index 343686db6c2..854b27dac6d 100644 --- a/src/generated/Me/Messages/Item/CreateForward/CreateForwardRequestBuilder.cs +++ b/src/generated/Me/Messages/Item/CreateForward/CreateForwardRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, messageIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CreateForwardRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createForward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes message public class CreateForwardResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Messages/Item/CreateReply/CreateReplyRequestBuilder.cs b/src/generated/Me/Messages/Item/CreateReply/CreateReplyRequestBuilder.cs index e1d9a120440..c4a58a763ac 100644 --- a/src/generated/Me/Messages/Item/CreateReply/CreateReplyRequestBuilder.cs +++ b/src/generated/Me/Messages/Item/CreateReply/CreateReplyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, messageIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CreateReplyRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createReply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateReplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes message public class CreateReplyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Messages/Item/CreateReplyAll/CreateReplyAllRequestBuilder.cs b/src/generated/Me/Messages/Item/CreateReplyAll/CreateReplyAllRequestBuilder.cs index e0d2e39a43d..02747e16a47 100644 --- a/src/generated/Me/Messages/Item/CreateReplyAll/CreateReplyAllRequestBuilder.cs +++ b/src/generated/Me/Messages/Item/CreateReplyAll/CreateReplyAllRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, messageIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CreateReplyAllRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createReplyAll - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateReplyAllRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes message public class CreateReplyAllResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Messages/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Me/Messages/Item/Extensions/ExtensionsRequestBuilder.cs index 1dda3b40bc5..f468f9b5d3e 100644 --- a/src/generated/Me/Messages/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Me/Messages/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, messageIdOption, bodyOption, outputOption); return command; } /// @@ -103,7 +101,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string messageId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string messageId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -113,15 +115,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, messageIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, messageIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -176,31 +173,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the message. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Messages/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Me/Messages/Item/Extensions/Item/ExtensionRequestBuilder.cs index 2f8f4b00beb..4b49c2b6ea7 100644 --- a/src/generated/Me/Messages/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Me/Messages/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string messageId, string extensionId) => { + command.SetHandler(async (string messageId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, messageIdOption, extensionIdOption); return command; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string messageId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string messageId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, messageIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, messageIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string messageId, string extensionId, string body) => { + command.SetHandler(async (string messageId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, messageIdOption, extensionIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the message. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Messages/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Me/Messages/Item/Forward/ForwardRequestBuilder.cs index 5442380d638..d432d409c99 100644 --- a/src/generated/Me/Messages/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Me/Messages/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string messageId, string body) => { + command.SetHandler(async (string messageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, messageIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Messages/Item/MessageRequestBuilder.cs b/src/generated/Me/Messages/Item/MessageRequestBuilder.cs index 74d1d5343ff..67548d039ad 100644 --- a/src/generated/Me/Messages/Item/MessageRequestBuilder.cs +++ b/src/generated/Me/Messages/Item/MessageRequestBuilder.cs @@ -16,10 +16,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,6 +37,9 @@ public class MessageRequestBuilder { public Command BuildAttachmentsCommand() { var command = new Command("attachments"); var builder = new ApiSdk.Me.Messages.Item.Attachments.AttachmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateUploadSessionCommand()); command.AddCommand(builder.BuildListCommand()); @@ -90,11 +93,10 @@ public Command BuildDeleteCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - command.SetHandler(async (string messageId) => { + command.SetHandler(async (string messageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, messageIdOption); return command; @@ -102,6 +104,9 @@ public Command BuildDeleteCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Me.Messages.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -128,19 +133,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string messageId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string messageId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, messageIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, messageIdOption, selectOption, outputOption); return command; } public Command BuildMoveCommand() { @@ -152,6 +156,9 @@ public Command BuildMoveCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Me.Messages.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -171,14 +178,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string messageId, string body) => { + command.SetHandler(async (string messageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, messageIdOption, bodyOption); return command; @@ -204,6 +210,9 @@ public Command BuildSendCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Me.Messages.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -275,42 +284,6 @@ public RequestInformation CreatePatchRequestInformation(Message body, Action - /// The messages in a mailbox or folder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The messages in a mailbox or folder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The messages in a mailbox or folder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Message model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The messages in a mailbox or folder. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/Messages/Item/Move/MoveRequestBuilder.cs b/src/generated/Me/Messages/Item/Move/MoveRequestBuilder.cs index 9eb0b896c4c..a7d0bd688e0 100644 --- a/src/generated/Me/Messages/Item/Move/MoveRequestBuilder.cs +++ b/src/generated/Me/Messages/Item/Move/MoveRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, messageIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(MoveRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action move - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MoveRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes message public class MoveResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Messages/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/Messages/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 07df79a0685..43a2acf0b0f 100644 --- a/src/generated/Me/Messages/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/Messages/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string messageId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string messageId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, messageIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string messageId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string messageId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, messageIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, messageIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string messageId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string messageId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, messageIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the message. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Messages/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/Messages/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 661ed19b94c..4b74d37a18d 100644 --- a/src/generated/Me/Messages/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/Messages/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, messageIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string messageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string messageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, messageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, messageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the message. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Messages/Item/Reply/ReplyRequestBuilder.cs b/src/generated/Me/Messages/Item/Reply/ReplyRequestBuilder.cs index f91a2f0a714..4c59de9e720 100644 --- a/src/generated/Me/Messages/Item/Reply/ReplyRequestBuilder.cs +++ b/src/generated/Me/Messages/Item/Reply/ReplyRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string messageId, string body) => { + command.SetHandler(async (string messageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, messageIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ReplyRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action reply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ReplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Messages/Item/ReplyAll/ReplyAllRequestBuilder.cs b/src/generated/Me/Messages/Item/ReplyAll/ReplyAllRequestBuilder.cs index a1825cde6d1..31c238d5e17 100644 --- a/src/generated/Me/Messages/Item/ReplyAll/ReplyAllRequestBuilder.cs +++ b/src/generated/Me/Messages/Item/ReplyAll/ReplyAllRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string messageId, string body) => { + command.SetHandler(async (string messageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, messageIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ReplyAllRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action replyAll - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ReplyAllRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Messages/Item/Send/SendRequestBuilder.cs b/src/generated/Me/Messages/Item/Send/SendRequestBuilder.cs index b85992fec6f..f4b976bc3ba 100644 --- a/src/generated/Me/Messages/Item/Send/SendRequestBuilder.cs +++ b/src/generated/Me/Messages/Item/Send/SendRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,10 @@ public Command BuildPostCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - command.SetHandler(async (string messageId) => { + command.SetHandler(async (string messageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, messageIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action send - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Messages/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Me/Messages/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 814ca396389..71ba27f6410 100644 --- a/src/generated/Me/Messages/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Me/Messages/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string messageId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string messageId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, messageIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string messageId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string messageId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, messageIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, messageIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string messageId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string messageId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, messageIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the message. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Messages/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Me/Messages/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 4250dd3ac66..9936633eb7b 100644 --- a/src/generated/Me/Messages/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Me/Messages/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, messageIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string messageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string messageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, messageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, messageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the message. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Messages/Item/Value/ContentRequestBuilder.cs b/src/generated/Me/Messages/Item/Value/ContentRequestBuilder.cs index 9865a2b1be4..d8b68902c7a 100644 --- a/src/generated/Me/Messages/Item/Value/ContentRequestBuilder.cs +++ b/src/generated/Me/Messages/Item/Value/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string messageId, FileInfo output) => { + command.SetHandler(async (string messageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, messageIdOption, outputOption); + }, messageIdOption, fileOption, outputOption); return command; } /// @@ -64,12 +66,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string messageId, FileInfo file) => { + command.SetHandler(async (string messageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, messageIdOption, bodyOption); return command; @@ -120,29 +121,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property messages from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property messages in me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Messages/MessagesRequestBuilder.cs b/src/generated/Me/Messages/MessagesRequestBuilder.cs index 26671d95fa2..bf81109852a 100644 --- a/src/generated/Me/Messages/MessagesRequestBuilder.cs +++ b/src/generated/Me/Messages/MessagesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,26 +23,25 @@ public class MessagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MessageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAttachmentsCommand(), - builder.BuildCalendarSharingMessageCommand(), - builder.BuildContentCommand(), - builder.BuildCopyCommand(), - builder.BuildCreateForwardCommand(), - builder.BuildCreateReplyAllCommand(), - builder.BuildCreateReplyCommand(), - builder.BuildDeleteCommand(), - builder.BuildExtensionsCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildMoveCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildReplyAllCommand(), - builder.BuildReplyCommand(), - builder.BuildSendCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAttachmentsCommand()); + commands.Add(builder.BuildCalendarSharingMessageCommand()); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyCommand()); + commands.Add(builder.BuildCreateForwardCommand()); + commands.Add(builder.BuildCreateReplyAllCommand()); + commands.Add(builder.BuildCreateReplyCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildMoveCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildReplyAllCommand()); + commands.Add(builder.BuildReplyCommand()); + commands.Add(builder.BuildSendCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); return commands; } /// @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -110,7 +108,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -120,15 +122,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(Message body, Action - /// The messages in a mailbox or folder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The messages in a mailbox or folder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Message model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The messages in a mailbox or folder. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Oauth2PermissionGrants/@Ref/@Ref.cs b/src/generated/Me/Oauth2PermissionGrants/@Ref/@Ref.cs deleted file mode 100644 index 2da6191efa0..00000000000 --- a/src/generated/Me/Oauth2PermissionGrants/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.Oauth2PermissionGrants.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/Oauth2PermissionGrants/@Ref/RefRequestBuilder.cs b/src/generated/Me/Oauth2PermissionGrants/@Ref/RefRequestBuilder.cs deleted file mode 100644 index c63388c0930..00000000000 --- a/src/generated/Me/Oauth2PermissionGrants/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,194 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Me.Oauth2PermissionGrants.@Ref { - /// Builds and executes requests for operations under \me\oauth2PermissionGrants\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Get ref of oauth2PermissionGrants from me - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Get ref of oauth2PermissionGrants from me"; - // Create options for all the parameters - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Create new navigation property ref to oauth2PermissionGrants for me - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Create new navigation property ref to oauth2PermissionGrants for me"; - // Create options for all the parameters - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/oauth2PermissionGrants/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Get ref of oauth2PermissionGrants from me - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Create new navigation property ref to oauth2PermissionGrants for me - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Me.Oauth2PermissionGrants.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Get ref of oauth2PermissionGrants from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property ref to oauth2PermissionGrants for me - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Me.Oauth2PermissionGrants.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Get ref of oauth2PermissionGrants from me - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Me/Oauth2PermissionGrants/@Ref/RefResponse.cs b/src/generated/Me/Oauth2PermissionGrants/@Ref/RefResponse.cs deleted file mode 100644 index 98decceb2ac..00000000000 --- a/src/generated/Me/Oauth2PermissionGrants/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.Oauth2PermissionGrants.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/Oauth2PermissionGrants/Oauth2PermissionGrantsRequestBuilder.cs b/src/generated/Me/Oauth2PermissionGrants/Oauth2PermissionGrantsRequestBuilder.cs index 994bff7272f..6778b3802b6 100644 --- a/src/generated/Me/Oauth2PermissionGrants/Oauth2PermissionGrantsRequestBuilder.cs +++ b/src/generated/Me/Oauth2PermissionGrants/Oauth2PermissionGrantsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Me.Oauth2PermissionGrants.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -61,7 +61,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -72,20 +76,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Me.Oauth2PermissionGrants.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Me.Oauth2PermissionGrants.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -124,18 +123,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get oauth2PermissionGrants from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get oauth2PermissionGrants from me public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Oauth2PermissionGrants/Ref/Ref.cs b/src/generated/Me/Oauth2PermissionGrants/Ref/Ref.cs new file mode 100644 index 00000000000..bbfaf65dafa --- /dev/null +++ b/src/generated/Me/Oauth2PermissionGrants/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.Oauth2PermissionGrants.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/Oauth2PermissionGrants/Ref/RefRequestBuilder.cs b/src/generated/Me/Oauth2PermissionGrants/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..bb34bd43c37 --- /dev/null +++ b/src/generated/Me/Oauth2PermissionGrants/Ref/RefRequestBuilder.cs @@ -0,0 +1,167 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Me.Oauth2PermissionGrants.Ref { + /// Builds and executes requests for operations under \me\oauth2PermissionGrants\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Get ref of oauth2PermissionGrants from me + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Get ref of oauth2PermissionGrants from me"; + // Create options for all the parameters + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Create new navigation property ref to oauth2PermissionGrants for me + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Create new navigation property ref to oauth2PermissionGrants for me"; + // Create options for all the parameters + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/me/oauth2PermissionGrants/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Get ref of oauth2PermissionGrants from me + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Create new navigation property ref to oauth2PermissionGrants for me + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Me.Oauth2PermissionGrants.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Get ref of oauth2PermissionGrants from me + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Me/Oauth2PermissionGrants/Ref/RefResponse.cs b/src/generated/Me/Oauth2PermissionGrants/Ref/RefResponse.cs new file mode 100644 index 00000000000..5e99cdd7ae6 --- /dev/null +++ b/src/generated/Me/Oauth2PermissionGrants/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.Oauth2PermissionGrants.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/Onenote/Notebooks/GetNotebookFromWebUrl/GetNotebookFromWebUrlRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/GetNotebookFromWebUrl/GetNotebookFromWebUrlRequestBuilder.cs index 647c7986eac..34ea214902d 100644 --- a/src/generated/Me/Onenote/Notebooks/GetNotebookFromWebUrl/GetNotebookFromWebUrlRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/GetNotebookFromWebUrl/GetNotebookFromWebUrlRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -78,19 +77,6 @@ public RequestInformation CreatePostRequestInformation(GetNotebookFromWebUrlRequ requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getNotebookFromWebUrl - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GetNotebookFromWebUrlRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes CopyNotebookModel public class GetNotebookFromWebUrlResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Notebooks/GetRecentNotebooksWithIncludePersonalNotebooks/GetRecentNotebooksWithIncludePersonalNotebooksRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/GetRecentNotebooksWithIncludePersonalNotebooks/GetRecentNotebooksWithIncludePersonalNotebooksRequestBuilder.cs index 870da72c2f9..5ebef457a9d 100644 --- a/src/generated/Me/Onenote/Notebooks/GetRecentNotebooksWithIncludePersonalNotebooks/GetRecentNotebooksWithIncludePersonalNotebooksRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/GetRecentNotebooksWithIncludePersonalNotebooks/GetRecentNotebooksWithIncludePersonalNotebooksRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,22 +25,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function getRecentNotebooks"; // Create options for all the parameters - var includePersonalNotebooksOption = new Option("--includepersonalnotebooks", description: "Usage: includePersonalNotebooks={includePersonalNotebooks}") { + var includePersonalNotebooksOption = new Option("--include-personal-notebooks", description: "Usage: includePersonalNotebooks={includePersonalNotebooks}") { }; includePersonalNotebooksOption.IsRequired = true; command.AddOption(includePersonalNotebooksOption); - command.SetHandler(async (bool? includePersonalNotebooks) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (bool? includePersonalNotebooks, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, includePersonalNotebooksOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, includePersonalNotebooksOption, outputOption); return command; } /// @@ -73,16 +72,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getRecentNotebooks - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Onenote/Notebooks/Item/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/CopyNotebook/CopyNotebookRequestBuilder.cs index c05fcaaeb62..7d1a08bfbe4 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Notebooks/Item/NotebookRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/NotebookRequestBuilder.cs index f3568e9f497..88d4ab73367 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/NotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/NotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,11 +39,10 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - command.SetHandler(async (string notebookId) => { + command.SetHandler(async (string notebookId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption); return command; @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -100,14 +98,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string body) => { + command.SetHandler(async (string notebookId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, bodyOption); return command; @@ -115,6 +112,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Me.Onenote.Notebooks.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -122,6 +122,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Me.Onenote.Notebooks.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -193,42 +196,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 8913adaeb53..932810540c7 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index c3e7d1bb753..bb665ae25d4 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,15 +37,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string notebookId, string sectionGroupId) => { + command.SetHandler(async (string notebookId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, sectionGroupIdOption); return command; @@ -61,7 +60,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -75,20 +74,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -102,7 +100,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -110,14 +108,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string body) => { + command.SetHandler(async (string notebookId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, sectionGroupIdOption, bodyOption); return command; @@ -189,42 +186,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index c46b3b41598..96475aaa3e4 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string notebookId, string sectionGroupId) => { + command.SetHandler(async (string notebookId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, sectionGroupIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string body) => { + command.SetHandler(async (string notebookId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, sectionGroupIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index 92fa7975807..0c3359122ca 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string notebookId, string sectionGroupId) => { + command.SetHandler(async (string notebookId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, sectionGroupIdOption); return command; @@ -58,7 +57,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -72,20 +71,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -116,7 +114,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -124,14 +122,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string body) => { + command.SetHandler(async (string notebookId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, sectionGroupIdOption, bodyOption); return command; @@ -139,6 +136,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Me.Onenote.Notebooks.Item.SectionGroups.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -146,6 +146,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Me.Onenote.Notebooks.Item.SectionGroups.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -217,42 +220,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index 8032c5078fa..3b1329d0159 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string notebookId, string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string notebookId, string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string notebookId, string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs index 945e01ddfa7..9b4fc1628d8 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 577768fd5ad..a518b6645eb 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index bdafec81dcb..b15ba0f686c 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index 9c7b8c36154..657f732d81d 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,19 +47,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -75,11 +74,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -93,25 +92,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Me.Onenote.Notebooks.Item.SectionGroups.Item.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -144,11 +145,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -156,14 +157,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -235,42 +235,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index 2e2c633ddc0..3535eab964c 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,36 +29,38 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo output) => { + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); + }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, fileOption, outputOption); return command; } /// @@ -72,15 +74,15 @@ public Command BuildPutCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -88,12 +90,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file) => { + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -144,29 +145,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 634dc3c294d..88df0cb436c 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index 4d56ae551e4..b9da3b83446 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -49,23 +49,22 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -81,15 +80,15 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -103,20 +102,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -155,15 +153,15 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -171,14 +169,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -251,42 +248,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \me\onenote\notebooks\{notebook-id}\sectionGroups\{sectionGroup-id}\sections\{onenoteSection-id}\pages\{onenotePage-id}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index e799ad9a881..e3cfcb05027 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,15 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 939f90d1a58..d37a346454a 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 91111093e1a..dbfdac89802 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,23 +37,22 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -69,15 +68,15 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -91,20 +90,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -118,15 +116,15 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 799428636b4..ab9bf0ea078 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 24701cc2ee2..decbd29a767 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs index 77e3c4fa71b..0fa54b43b0d 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,23 +44,22 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -76,15 +75,15 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -125,15 +123,15 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index 6b7907f3e90..b6b66b0cd2c 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,30 +30,29 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs index d3e2acdb556..a977eaa1ffa 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,11 +44,11 @@ public Command BuildCreateCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -57,21 +56,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -85,11 +83,11 @@ public Command BuildListCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -128,7 +126,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -139,15 +141,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -202,31 +199,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index e62803b87ef..35fc3c75b4c 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index a8f318b7cd1..29b5156b6b9 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,19 +37,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -65,11 +64,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,11 +108,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index bd514bc6b82..a928b81d728 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string notebookId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/SectionsRequestBuilder.cs index 9e3aaeef1cc..391f3aaa1d7 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,7 +44,7 @@ public Command BuildCreateCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -81,7 +79,7 @@ public Command BuildListCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -194,31 +191,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/SectionGroupsRequestBuilder.cs index 0d11fc0b01b..77dc763b74e 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, bodyOption, outputOption); return command; } /// @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -122,15 +124,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -185,31 +182,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 32143f7bfd8..e03d2f22341 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index bc036964c5e..db6e3e47862 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index 58736fc9a90..5b76a7991e0 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,15 +47,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string notebookId, string onenoteSectionId) => { + command.SetHandler(async (string notebookId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, onenoteSectionIdOption); return command; @@ -71,7 +70,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -85,25 +84,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Me.Onenote.Notebooks.Item.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -123,7 +124,6 @@ public Command BuildParentSectionGroupCommand() { command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); command.AddCommand(builder.BuildPatchCommand()); command.AddCommand(builder.BuildSectionGroupsCommand()); command.AddCommand(builder.BuildSectionsCommand()); @@ -140,7 +140,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -148,14 +148,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string body) => { + command.SetHandler(async (string notebookId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -227,42 +226,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index 5c8c845b73f..5f06144befb 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,32 +29,34 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, FileInfo output) => { + command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); + }, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, fileOption, outputOption); return command; } /// @@ -68,11 +70,11 @@ public Command BuildPutCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -80,12 +82,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, FileInfo file) => { + command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -136,29 +137,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 93c8b4300af..70d187c6057 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index 1204b71e495..ff50a89805e 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -49,19 +49,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -77,11 +76,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -95,20 +94,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -147,11 +145,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -159,14 +157,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -239,42 +236,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \me\onenote\notebooks\{notebook-id}\sections\{onenoteSection-id}\pages\{onenotePage-id}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index 369683f7b9a..6c133de746d 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 0d2df0dbd8f..747c79ef8fd 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index aee77d5a157..9668931cf5a 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,19 +37,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -65,11 +64,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,11 +108,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 912c37d20fd..71ff64d0422 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index d0d6c91b52e..8a8ec811f7a 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs index ee954a93105..0666fb5d5c2 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,19 +44,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -72,11 +71,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -117,11 +115,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index 2ebe2a791fe..15685dad290 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,26 +30,25 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string onenoteSectionId, string onenotePageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/PagesRequestBuilder.cs index bab10f798b7..2e9d71bfd8d 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,7 +44,7 @@ public Command BuildCreateCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -81,7 +79,7 @@ public Command BuildListCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -194,31 +191,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 7880653ae7e..de0acbe715a 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 2ea4e696006..66204d5b369 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,15 +37,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string notebookId, string onenoteSectionId) => { + command.SetHandler(async (string notebookId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, onenoteSectionIdOption); return command; @@ -61,7 +60,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -75,20 +74,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -102,7 +100,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -110,14 +108,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string body) => { + command.SetHandler(async (string notebookId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -189,42 +186,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 45d27d57f1d..619a746c21b 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs index 29fe6bb28ac..32a03909a4f 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,15 +37,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string notebookId, string onenoteSectionId) => { + command.SetHandler(async (string notebookId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, onenoteSectionIdOption); return command; @@ -61,7 +60,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -75,20 +74,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -102,7 +100,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -110,14 +108,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string body) => { + command.SetHandler(async (string notebookId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -189,42 +186,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs deleted file mode 100644 index d1ae6b03d6a..00000000000 --- a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ /dev/null @@ -1,229 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Me.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup.ParentSectionGroup { - /// Builds and executes requests for operations under \me\onenote\notebooks\{notebook-id}\sections\{onenoteSection-id}\parentSectionGroup\parentSectionGroup - public class ParentSectionGroupRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var notebookIdOption = new Option("--notebook-id", description: "key: id of notebook") { - }; - notebookIdOption.IsRequired = true; - command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string notebookId, string onenoteSectionId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, notebookIdOption, onenoteSectionIdOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var notebookIdOption = new Option("--notebook-id", description: "key: id of notebook") { - }; - notebookIdOption.IsRequired = true; - command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildPatchCommand() { - var command = new Command("patch"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var notebookIdOption = new Option("--notebook-id", description: "key: id of notebook") { - }; - notebookIdOption.IsRequired = true; - command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePatchRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, notebookIdOption, onenoteSectionIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new ParentSectionGroupRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public ParentSectionGroupRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/onenote/notebooks/{notebook_id}/sections/{onenoteSection_id}/parentSectionGroup/parentSectionGroup{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePatchRequestInformation(SectionGroup body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PATCH, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// The section group that contains the section group. Read-only. - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 0947646a22e..dac2b3aa32c 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,15 +33,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string notebookId, string onenoteSectionId) => { + command.SetHandler(async (string notebookId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, onenoteSectionIdOption); return command; @@ -57,7 +56,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -71,20 +70,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -96,18 +94,6 @@ public Command BuildParentNotebookCommand() { command.AddCommand(builder.BuildPatchCommand()); return command; } - public Command BuildParentSectionGroupCommand() { - var command = new Command("parent-section-group"); - var builder = new ApiSdk.Me.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup.ParentSectionGroupRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildDeleteCommand()); - command.AddCommand(builder.BuildGetCommand()); - command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); - command.AddCommand(builder.BuildPatchCommand()); - command.AddCommand(builder.BuildSectionGroupsCommand()); - command.AddCommand(builder.BuildSectionsCommand()); - return command; - } /// /// The section group that contains the section. Read-only. /// @@ -119,7 +105,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -127,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string body) => { + command.SetHandler(async (string notebookId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -142,6 +127,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Me.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -149,6 +137,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Me.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -220,42 +211,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs index 9b575509316..af2a64640a5 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string notebookId, string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string notebookId, string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs index 6a22d57f2e8..4c3d82dd5fa 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 5ed2ad95c89..2e96122b7be 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 0aaba5f513d..d32e0740c5f 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs index 07944ab7cbf..538e9d4ebcd 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,19 +44,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string notebookId, string onenoteSectionId, string onenoteSectionId1) => { + command.SetHandler(async (string notebookId, string onenoteSectionId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option); return command; @@ -72,11 +71,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -117,11 +115,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string notebookId, string onenoteSectionId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs index 02ceb3e0f13..2a74ea73b40 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,7 +41,7 @@ public Command BuildCreateCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -78,7 +76,7 @@ public Command BuildListCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -117,7 +115,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Notebooks/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/Item/Sections/SectionsRequestBuilder.cs index f057c67e302..c6a41a790b5 100644 --- a/src/generated/Me/Onenote/Notebooks/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string notebookId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, bodyOption, outputOption); return command; } /// @@ -112,7 +110,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string notebookId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string notebookId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, notebookIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, notebookIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -186,31 +183,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Notebooks/NotebooksRequestBuilder.cs b/src/generated/Me/Onenote/Notebooks/NotebooksRequestBuilder.cs index ab3ae9b0058..50d3d0a34ba 100644 --- a/src/generated/Me/Onenote/Notebooks/NotebooksRequestBuilder.cs +++ b/src/generated/Me/Onenote/Notebooks/NotebooksRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -24,14 +24,13 @@ public class NotebooksRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new NotebookRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyNotebookCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyNotebookCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } public Command BuildGetNotebookFromWebUrlCommand() { @@ -110,7 +108,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -185,18 +182,6 @@ public RequestInformation CreatePostRequestInformation(Notebook body, Action - /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \me\onenote\notebooks\microsoft.graph.getRecentNotebooks(includePersonalNotebooks={includePersonalNotebooks}) /// Usage: includePersonalNotebooks={includePersonalNotebooks} /// @@ -204,19 +189,6 @@ public GetRecentNotebooksWithIncludePersonalNotebooksRequestBuilder GetRecentNot _ = includePersonalNotebooks ?? throw new ArgumentNullException(nameof(includePersonalNotebooks)); return new GetRecentNotebooksWithIncludePersonalNotebooksRequestBuilder(PathParameters, RequestAdapter, includePersonalNotebooks); } - /// - /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/OnenoteRequestBuilder.cs b/src/generated/Me/Onenote/OnenoteRequestBuilder.cs index f80670e8227..431713d13b7 100644 --- a/src/generated/Me/Onenote/OnenoteRequestBuilder.cs +++ b/src/generated/Me/Onenote/OnenoteRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -32,11 +32,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -58,25 +57,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } public Command BuildNotebooksCommand() { var command = new Command("notebooks"); var builder = new ApiSdk.Me.Onenote.Notebooks.NotebooksRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildGetNotebookFromWebUrlCommand()); command.AddCommand(builder.BuildListCommand()); @@ -85,6 +86,9 @@ public Command BuildNotebooksCommand() { public Command BuildOperationsCommand() { var command = new Command("operations"); var builder = new ApiSdk.Me.Onenote.Operations.OperationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -92,6 +96,9 @@ public Command BuildOperationsCommand() { public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Me.Onenote.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -107,14 +114,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -122,6 +128,9 @@ public Command BuildPatchCommand() { public Command BuildResourcesCommand() { var command = new Command("resources"); var builder = new ApiSdk.Me.Onenote.Resources.ResourcesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -129,6 +138,9 @@ public Command BuildResourcesCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Me.Onenote.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -136,6 +148,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Me.Onenote.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -207,42 +222,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Onenote model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Operations/Item/OnenoteOperationRequestBuilder.cs b/src/generated/Me/Onenote/Operations/Item/OnenoteOperationRequestBuilder.cs index 93e274c0d81..99ccb04e340 100644 --- a/src/generated/Me/Onenote/Operations/Item/OnenoteOperationRequestBuilder.cs +++ b/src/generated/Me/Onenote/Operations/Item/OnenoteOperationRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable."; // Create options for all the parameters - var onenoteOperationIdOption = new Option("--onenoteoperation-id", description: "key: id of onenoteOperation") { + var onenoteOperationIdOption = new Option("--onenote-operation-id", description: "key: id of onenoteOperation") { }; onenoteOperationIdOption.IsRequired = true; command.AddOption(onenoteOperationIdOption); - command.SetHandler(async (string onenoteOperationId) => { + command.SetHandler(async (string onenoteOperationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteOperationIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable."; // Create options for all the parameters - var onenoteOperationIdOption = new Option("--onenoteoperation-id", description: "key: id of onenoteOperation") { + var onenoteOperationIdOption = new Option("--onenote-operation-id", description: "key: id of onenoteOperation") { }; onenoteOperationIdOption.IsRequired = true; command.AddOption(onenoteOperationIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteOperationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteOperationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteOperationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteOperationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable."; // Create options for all the parameters - var onenoteOperationIdOption = new Option("--onenoteoperation-id", description: "key: id of onenoteOperation") { + var onenoteOperationIdOption = new Option("--onenote-operation-id", description: "key: id of onenoteOperation") { }; onenoteOperationIdOption.IsRequired = true; command.AddOption(onenoteOperationIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteOperationId, string body) => { + command.SetHandler(async (string onenoteOperationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteOperationIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteOperation body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteOperation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Operations/OperationsRequestBuilder.cs b/src/generated/Me/Onenote/Operations/OperationsRequestBuilder.cs index ac67a9d9223..00af45c32a9 100644 --- a/src/generated/Me/Onenote/Operations/OperationsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Operations/OperationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class OperationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteOperationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteOperation body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteOperation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/Content/ContentRequestBuilder.cs index 8460655425c..b41380397cf 100644 --- a/src/generated/Me/Onenote/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,28 +25,30 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get media content for the navigation property pages from me"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string onenotePageId, FileInfo output) => { + command.SetHandler(async (string onenotePageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, onenotePageIdOption, outputOption); + }, onenotePageIdOption, fileOption, outputOption); return command; } /// @@ -56,7 +58,7 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "Update media content for the navigation property pages in me"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -64,12 +66,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, FileInfo file) => { + command.SetHandler(async (string onenotePageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, bodyOption); return command; @@ -120,29 +121,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Onenote/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 551192ed1ce..30a764c44ed 100644 --- a/src/generated/Me/Onenote/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSection"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/OnenotePageRequestBuilder.cs index afba45dc68d..760bbe7d1aa 100644 --- a/src/generated/Me/Onenote/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/OnenotePageRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -45,15 +45,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The pages in all OneNote notebooks that are owned by the user or group. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string onenotePageId) => { + command.SetHandler(async (string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption); return command; @@ -65,7 +64,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The pages in all OneNote notebooks that are owned by the user or group. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -79,20 +78,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -132,7 +130,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The pages in all OneNote notebooks that are owned by the user or group. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -140,14 +138,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string body) => { + command.SetHandler(async (string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The pages in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The pages in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The pages in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \me\onenote\pages\{onenotePage-id}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Me/Onenote/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index 4a517c1b92b..68ddc83dd7a 100644 --- a/src/generated/Me/Onenote/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action onenotePatchContent"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string body) => { + command.SetHandler(async (string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 7d3cfd967db..d9824a521e4 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyNotebook"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index b6d1df5541d..e366d1c0a50 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,15 +35,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The notebook that contains the page. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string onenotePageId) => { + command.SetHandler(async (string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption); return command; @@ -55,7 +54,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The notebook that contains the page. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -92,7 +90,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The notebook that contains the page. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -100,14 +98,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string body) => { + command.SetHandler(async (string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, bodyOption); return command; @@ -115,6 +112,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Me.Onenote.Pages.Item.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -122,6 +122,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Me.Onenote.Pages.Item.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -193,42 +196,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 1683c3eb4fd..17aab9f5462 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyNotebook"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index eec2e14b9b5..99b30a2d1aa 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,19 +33,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The notebook that contains the section group. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption); return command; @@ -57,11 +56,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The notebook that contains the section group. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -75,20 +74,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -98,11 +96,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The notebook that contains the section group. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -110,14 +108,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -189,42 +186,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 0cd220a3e86..2360d163106 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section group that contains the section group. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section group that contains the section group. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section group that contains the section group. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index f9d8e13c397..d0a8027c1f6 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption); return command; @@ -54,11 +53,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -72,20 +71,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -112,11 +110,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -124,14 +122,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -139,6 +136,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Me.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -146,6 +146,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Me.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -217,42 +220,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index 394feb4ff86..e426a98b377 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs index a17b0a8a0ab..d070fe22e3b 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,11 +35,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -72,11 +70,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index af5de5a95af..f5a9d87d5e6 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToNotebook"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 6d91eeee9f3..db49f1087bb 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSectionGroup"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index 8dec355a7f4..45369d80597 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -43,23 +43,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -71,15 +70,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -93,25 +92,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Me.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -140,15 +141,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -156,14 +157,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -235,42 +235,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index 47d18c10c56..9cdeb9fe390 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,40 +25,42 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get media content for the navigation property pages from me"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, FileInfo output) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, outputOption); + }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, fileOption, outputOption); return command; } /// @@ -68,19 +70,19 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "Update media content for the navigation property pages in me"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -88,12 +90,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, FileInfo file) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); return command; @@ -144,29 +145,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 667da70bd04..4da09c47b66 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSection"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index 0e8ab990725..a7f6c753fd1 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -43,27 +43,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option); return command; @@ -75,19 +74,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -101,20 +100,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -130,19 +128,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -150,14 +148,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string body) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); return command; @@ -230,42 +227,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \me\onenote\pages\{onenotePage-id}\parentNotebook\sectionGroups\{sectionGroup-id}\sections\{onenoteSection-id}\pages\{onenotePage-id1}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index ce5a88cdf24..59bc58617c9 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action onenotePatchContent"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string body) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index 012b1803975..f5e47e13f3a 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,34 +26,33 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function preview"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs index 004b8be9d07..315a56dcf89 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -39,15 +38,15 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -55,21 +54,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -79,15 +77,15 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -126,7 +124,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -137,15 +139,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -200,31 +197,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 84fef1c5f2f..e9a21e47ecf 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyNotebook"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index de979f8b6e3..7623911f67b 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The notebook that contains the section. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The notebook that contains the section. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The notebook that contains the section. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 1745fa69c18..76f151417d6 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section group that contains the section. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section group that contains the section. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section group that contains the section. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs index 152e35912cb..1cea0a60d0b 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,11 +40,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -77,11 +75,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -194,31 +191,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index 7427e8830e0..c03fa856612 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -72,7 +70,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -122,15 +124,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -185,31 +182,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index bcb266c7395..9f7c21e1239 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToNotebook"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 44f5bafeef6..21283979824 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSectionGroup"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index 020417ca9ac..973722d1d29 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -43,19 +43,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -67,11 +66,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -85,25 +84,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Me.Onenote.Pages.Item.ParentNotebook.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -123,7 +124,6 @@ public Command BuildParentSectionGroupCommand() { command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); command.AddCommand(builder.BuildPatchCommand()); command.AddCommand(builder.BuildSectionGroupsCommand()); command.AddCommand(builder.BuildSectionsCommand()); @@ -136,11 +136,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -148,14 +148,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -227,42 +226,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index 88ab9fd6ba8..c13ff8b2898 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,36 +25,38 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get media content for the navigation property pages from me"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string onenotePageId1, FileInfo output) => { + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string onenotePageId1, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, outputOption); + }, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, fileOption, outputOption); return command; } /// @@ -64,15 +66,15 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "Update media content for the navigation property pages in me"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -80,12 +82,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string onenotePageId1, FileInfo file) => { + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string onenotePageId1, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); return command; @@ -136,29 +137,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 06e402a7647..5d803d7f386 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSection"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string onenotePageId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string onenotePageId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index c4c2f733394..5051dbeb9bb 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -43,23 +43,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string onenotePageId1) => { + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string onenotePageId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option); return command; @@ -71,15 +70,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -93,20 +92,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string onenotePageId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string onenotePageId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -122,15 +120,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -138,14 +136,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string onenotePageId1, string body) => { + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string onenotePageId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \me\onenote\pages\{onenotePage-id}\parentNotebook\sections\{onenoteSection-id}\pages\{onenotePage-id1}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index fcca37e8cc7..79a3feec237 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action onenotePatchContent"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string onenotePageId1, string body) => { + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string onenotePageId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index 443f841c4b5..60d756ca083 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function preview"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string onenotePageId1) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string onenotePageId1, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs index 734fadfd8d9..bd1d36cb38b 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -39,11 +38,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -51,21 +50,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -75,11 +73,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -129,15 +131,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index ff762bde072..600804abefb 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyNotebook"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 6d240d0eb75..b161e3a0d11 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,19 +33,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The notebook that contains the section. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -57,11 +56,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The notebook that contains the section. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -75,20 +74,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -98,11 +96,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The notebook that contains the section. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -110,14 +108,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -189,42 +186,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index d462942b7b0..15fa01f6509 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyNotebook"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs index 1f2d6aefea7..fab090a45a6 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,19 +33,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The notebook that contains the section group. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -57,11 +56,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The notebook that contains the section group. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -75,20 +74,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -98,11 +96,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The notebook that contains the section group. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -110,14 +108,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -189,42 +186,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs deleted file mode 100644 index f2ef63dbf95..00000000000 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ /dev/null @@ -1,229 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Me.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup.ParentSectionGroup { - /// Builds and executes requests for operations under \me\onenote\pages\{onenotePage-id}\parentNotebook\sections\{onenoteSection-id}\parentSectionGroup\parentSectionGroup - public class ParentSectionGroupRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { - }; - onenotePageIdOption.IsRequired = true; - command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, onenotePageIdOption, onenoteSectionIdOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { - }; - onenotePageIdOption.IsRequired = true; - command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildPatchCommand() { - var command = new Command("patch"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { - }; - onenotePageIdOption.IsRequired = true; - command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePatchRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, onenotePageIdOption, onenoteSectionIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new ParentSectionGroupRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public ParentSectionGroupRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/onenote/pages/{onenotePage_id}/parentNotebook/sections/{onenoteSection_id}/parentSectionGroup/parentSectionGroup{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePatchRequestInformation(SectionGroup body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PATCH, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// The section group that contains the section group. Read-only. - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index cb39eeefe95..39492633a92 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,19 +29,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section group that contains the section. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -53,11 +52,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section group that contains the section. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -71,20 +70,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -96,18 +94,6 @@ public Command BuildParentNotebookCommand() { command.AddCommand(builder.BuildPatchCommand()); return command; } - public Command BuildParentSectionGroupCommand() { - var command = new Command("parent-section-group"); - var builder = new ApiSdk.Me.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup.ParentSectionGroupRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildDeleteCommand()); - command.AddCommand(builder.BuildGetCommand()); - command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); - command.AddCommand(builder.BuildPatchCommand()); - command.AddCommand(builder.BuildSectionGroupsCommand()); - command.AddCommand(builder.BuildSectionsCommand()); - return command; - } /// /// The section group that contains the section. Read-only. /// @@ -115,11 +101,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section group that contains the section. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -127,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -142,6 +127,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Me.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -149,6 +137,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Me.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -220,42 +211,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs index fcc231d53d0..8c0323e46c7 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs index 94e510b9362..8a1ff4495d5 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,11 +35,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -72,11 +70,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 6143477b362..61af634118a 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToNotebook"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 42096cdc7ef..92efc52d61a 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSectionGroup"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs index 743654c4ce8..18a699f34df 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -40,23 +40,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string onenoteSectionId1) => { + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option); return command; @@ -68,15 +67,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -113,15 +111,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs index 2139b18f9d8..ed325316b02 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -38,11 +37,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -74,11 +72,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -117,7 +115,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs index 0024b179d28..88ee56a7ac0 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,7 +40,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -73,7 +71,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -112,7 +110,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -186,31 +183,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 9094900e39d..1f17a357480 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToNotebook"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index d7f079143d5..ab73cf07d99 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSectionGroup"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/Pages/Item/Content/ContentRequestBuilder.cs index 8d0f3c81251..c533fbc6763 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,32 +25,34 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get media content for the navigation property pages from me"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string onenotePageId, string onenotePageId1, FileInfo output) => { + command.SetHandler(async (string onenotePageId, string onenotePageId1, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, onenotePageIdOption, onenotePageId1Option, outputOption); + }, onenotePageIdOption, onenotePageId1Option, fileOption, outputOption); return command; } /// @@ -60,11 +62,11 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "Update media content for the navigation property pages in me"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -72,12 +74,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenotePageId1, FileInfo file) => { + command.SetHandler(async (string onenotePageId, string onenotePageId1, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, onenotePageId1Option, bodyOption); return command; @@ -128,29 +129,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 53283d6b32e..94734f11b9f 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSection"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenotePageId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenotePageId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenotePageId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenotePageId1Option, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePageRequestBuilder.cs index daad6bea9bd..b7ef0d8e8b2 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePageRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -43,19 +43,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - command.SetHandler(async (string onenotePageId, string onenotePageId1) => { + command.SetHandler(async (string onenotePageId, string onenotePageId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, onenotePageId1Option); return command; @@ -67,11 +66,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -85,20 +84,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string onenotePageId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenotePageId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenotePageId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenotePageId1Option, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -114,11 +112,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -126,14 +124,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenotePageId1, string body) => { + command.SetHandler(async (string onenotePageId, string onenotePageId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, onenotePageId1Option, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \me\onenote\pages\{onenotePage-id}\parentSection\pages\{onenotePage-id1}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index 9b5aa8872d6..f0a8545ea03 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,11 +25,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action onenotePatchContent"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenotePageId1, string body) => { + command.SetHandler(async (string onenotePageId, string onenotePageId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, onenotePageId1Option, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/Pages/Item/Preview/PreviewRequestBuilder.cs index 1fa34b6fce2..17c32331d3a 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function preview"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - command.SetHandler(async (string onenotePageId, string onenotePageId1) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenotePageId1, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenotePageId1Option); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenotePageId1Option, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/Pages/PagesRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/Pages/PagesRequestBuilder.cs index 7114300f9ce..6617424a9bc 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/Pages/PagesRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -39,7 +38,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -47,21 +46,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -71,7 +69,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -110,7 +108,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 021f86355bb..9fa97d8d231 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyNotebook"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/ParentNotebookRequestBuilder.cs index 48253567a7a..4872aa51765 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,15 +35,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The notebook that contains the section. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string onenotePageId) => { + command.SetHandler(async (string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption); return command; @@ -55,7 +54,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The notebook that contains the section. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -92,7 +90,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The notebook that contains the section. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -100,14 +98,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string body) => { + command.SetHandler(async (string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, bodyOption); return command; @@ -115,6 +112,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Me.Onenote.Pages.Item.ParentSection.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -122,6 +122,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Me.Onenote.Pages.Item.ParentSection.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -193,42 +196,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index b18eb35d8f2..e2c84a93d50 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyNotebook"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index dc1603f727e..0b894df7c02 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,19 +33,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The notebook that contains the section group. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption); return command; @@ -57,11 +56,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The notebook that contains the section group. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -75,20 +74,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -98,11 +96,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The notebook that contains the section group. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -110,14 +108,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -189,42 +186,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index db965302ff4..dba7485e2de 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section group that contains the section group. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section group that contains the section group. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section group that contains the section group. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index 31eb75dcee3..d2ecca292ac 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption); return command; @@ -54,11 +53,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -72,20 +71,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -112,11 +110,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -124,14 +122,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -139,6 +136,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Me.Onenote.Pages.Item.ParentSection.ParentNotebook.SectionGroups.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -146,6 +146,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Me.Onenote.Pages.Item.ParentSection.ParentNotebook.SectionGroups.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -217,42 +220,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index ae80f115f41..de95ccb843c 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs index cf358e2507f..f9dc88e246c 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,11 +35,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -72,11 +70,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index ec5f5fb0dc2..69ed1110819 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToNotebook"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index d8847ffde09..21a35888b9b 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSectionGroup"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index 42dd97cc2df..8a3a78522cf 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -40,23 +40,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -68,15 +67,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -113,15 +111,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs index 819f280610f..740c90c30db 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -38,11 +37,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -74,11 +72,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -117,7 +115,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index 5c753cdca42..5bf5299f0a4 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -72,7 +70,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -122,15 +124,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -185,31 +182,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index e24a0ae955e..2bbabfb6ffc 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToNotebook"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 1aab7db8c7b..cb3ca9602a0 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSectionGroup"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index 06a51d3e0cd..15642ff5381 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -40,19 +40,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -64,11 +63,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -82,20 +81,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -105,11 +103,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -117,14 +115,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -196,42 +193,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/SectionsRequestBuilder.cs index 4c908635967..6547ce067b3 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -38,7 +37,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +45,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -70,7 +68,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -109,7 +107,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -120,15 +122,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -183,31 +180,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index d09e742c1a7..7670777b86a 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyNotebook"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs index 784f2d04fda..b4401a64863 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,15 +35,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The notebook that contains the section group. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string onenotePageId) => { + command.SetHandler(async (string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption); return command; @@ -55,7 +54,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The notebook that contains the section group. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -92,7 +90,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The notebook that contains the section group. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -100,14 +98,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string body) => { + command.SetHandler(async (string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, bodyOption); return command; @@ -115,6 +112,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Me.Onenote.Pages.Item.ParentSection.ParentSectionGroup.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -122,6 +122,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Me.Onenote.Pages.Item.ParentSection.ParentSectionGroup.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -193,42 +196,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index b85ea754dc1..3dce02e0eb8 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index cdcf04b8d79..29d460ca1ce 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index f2318a56ea3..27320a0be48 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToNotebook"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 3cc20281e97..00fed1f0c3b 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSectionGroup"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index 9d089fbe43e..e66ce252174 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -40,19 +40,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -64,11 +63,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -82,20 +81,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -105,11 +103,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -117,14 +115,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -196,42 +193,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs index 8af67979a6a..b728df69770 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -38,7 +37,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +45,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -70,7 +68,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -109,7 +107,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -120,15 +122,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -183,31 +180,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs deleted file mode 100644 index c962c418dd9..00000000000 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ /dev/null @@ -1,217 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Me.Onenote.Pages.Item.ParentSection.ParentSectionGroup.ParentSectionGroup { - /// Builds and executes requests for operations under \me\onenote\pages\{onenotePage-id}\parentSection\parentSectionGroup\parentSectionGroup - public class ParentSectionGroupRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { - }; - onenotePageIdOption.IsRequired = true; - command.AddOption(onenotePageIdOption); - command.SetHandler(async (string onenotePageId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, onenotePageIdOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { - }; - onenotePageIdOption.IsRequired = true; - command.AddOption(onenotePageIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, selectOption, expandOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildPatchCommand() { - var command = new Command("patch"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { - }; - onenotePageIdOption.IsRequired = true; - command.AddOption(onenotePageIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePatchRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, onenotePageIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new ParentSectionGroupRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public ParentSectionGroupRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/onenote/pages/{onenotePage_id}/parentSection/parentSectionGroup/parentSectionGroup{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePatchRequestInformation(SectionGroup body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PATCH, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// The section group that contains the section group. Read-only. - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 30535e3cf73..7515a27761f 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section group that contains the section. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string onenotePageId) => { + command.SetHandler(async (string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption); return command; @@ -49,7 +48,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section group that contains the section. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -63,20 +62,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -90,18 +88,6 @@ public Command BuildParentNotebookCommand() { command.AddCommand(builder.BuildSectionsCommand()); return command; } - public Command BuildParentSectionGroupCommand() { - var command = new Command("parent-section-group"); - var builder = new ApiSdk.Me.Onenote.Pages.Item.ParentSection.ParentSectionGroup.ParentSectionGroupRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildDeleteCommand()); - command.AddCommand(builder.BuildGetCommand()); - command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); - command.AddCommand(builder.BuildPatchCommand()); - command.AddCommand(builder.BuildSectionGroupsCommand()); - command.AddCommand(builder.BuildSectionsCommand()); - return command; - } /// /// The section group that contains the section. Read-only. /// @@ -109,7 +95,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section group that contains the section. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -117,14 +103,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string body) => { + command.SetHandler(async (string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, bodyOption); return command; @@ -132,6 +117,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Me.Onenote.Pages.Item.ParentSection.ParentSectionGroup.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -139,6 +127,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Me.Onenote.Pages.Item.ParentSection.ParentSectionGroup.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -210,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs index 667493977b8..e6256e10aa2 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs index c3c07b4e9f1..4ae171df29c 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index c093e3d23a7..b3bd85dbf53 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToNotebook"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 6563479cb24..bc035fa7626 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSectionGroup"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs index 44bd1dddd6c..fcf4924ae82 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -40,19 +40,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -64,11 +63,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -82,20 +81,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -105,11 +103,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -117,14 +115,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -196,42 +193,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/SectionsRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/SectionsRequestBuilder.cs index c317cb307af..ee83141ac5b 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -38,7 +37,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +45,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -70,7 +68,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -109,7 +107,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -120,15 +122,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -183,31 +180,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs index 9be54574058..d3c4b68c2a0 100644 --- a/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -43,15 +43,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section that contains the page. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string onenotePageId) => { + command.SetHandler(async (string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section that contains the page. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -77,25 +76,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Me.Onenote.Pages.Item.ParentSection.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -117,7 +118,6 @@ public Command BuildParentSectionGroupCommand() { command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); command.AddCommand(builder.BuildPatchCommand()); command.AddCommand(builder.BuildSectionGroupsCommand()); command.AddCommand(builder.BuildSectionsCommand()); @@ -130,7 +130,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section that contains the page. Read-only."; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -138,14 +138,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenotePageId, string body) => { + command.SetHandler(async (string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenotePageIdOption, bodyOption); return command; @@ -217,42 +216,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Me/Onenote/Pages/Item/Preview/PreviewRequestBuilder.cs index 5cd453f65ab..77f002ab781 100644 --- a/src/generated/Me/Onenote/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function preview"; // Create options for all the parameters - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string onenotePageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenotePageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenotePageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenotePageIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Pages/PagesRequestBuilder.cs b/src/generated/Me/Onenote/Pages/PagesRequestBuilder.cs index e3d182192a9..2e6faa86276 100644 --- a/src/generated/Me/Onenote/Pages/PagesRequestBuilder.cs +++ b/src/generated/Me/Onenote/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -104,7 +102,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -115,15 +117,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -178,31 +175,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The pages in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The pages in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The pages in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Resources/Item/Content/ContentRequestBuilder.cs b/src/generated/Me/Onenote/Resources/Item/Content/ContentRequestBuilder.cs index 8ba24d0b4a5..c3db03a8e77 100644 --- a/src/generated/Me/Onenote/Resources/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Me/Onenote/Resources/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,28 +25,30 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get media content for the navigation property resources from me"; // Create options for all the parameters - var onenoteResourceIdOption = new Option("--onenoteresource-id", description: "key: id of onenoteResource") { + var onenoteResourceIdOption = new Option("--onenote-resource-id", description: "key: id of onenoteResource") { }; onenoteResourceIdOption.IsRequired = true; command.AddOption(onenoteResourceIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string onenoteResourceId, FileInfo output) => { + command.SetHandler(async (string onenoteResourceId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, onenoteResourceIdOption, outputOption); + }, onenoteResourceIdOption, fileOption, outputOption); return command; } /// @@ -56,7 +58,7 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "Update media content for the navigation property resources in me"; // Create options for all the parameters - var onenoteResourceIdOption = new Option("--onenoteresource-id", description: "key: id of onenoteResource") { + var onenoteResourceIdOption = new Option("--onenote-resource-id", description: "key: id of onenoteResource") { }; onenoteResourceIdOption.IsRequired = true; command.AddOption(onenoteResourceIdOption); @@ -64,12 +66,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteResourceId, FileInfo file) => { + command.SetHandler(async (string onenoteResourceId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteResourceIdOption, bodyOption); return command; @@ -120,29 +121,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property resources from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property resources in me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Onenote/Resources/Item/OnenoteResourceRequestBuilder.cs b/src/generated/Me/Onenote/Resources/Item/OnenoteResourceRequestBuilder.cs index 70a3faf8547..c1057f1dd06 100644 --- a/src/generated/Me/Onenote/Resources/Item/OnenoteResourceRequestBuilder.cs +++ b/src/generated/Me/Onenote/Resources/Item/OnenoteResourceRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable."; // Create options for all the parameters - var onenoteResourceIdOption = new Option("--onenoteresource-id", description: "key: id of onenoteResource") { + var onenoteResourceIdOption = new Option("--onenote-resource-id", description: "key: id of onenoteResource") { }; onenoteResourceIdOption.IsRequired = true; command.AddOption(onenoteResourceIdOption); - command.SetHandler(async (string onenoteResourceId) => { + command.SetHandler(async (string onenoteResourceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteResourceIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable."; // Create options for all the parameters - var onenoteResourceIdOption = new Option("--onenoteresource-id", description: "key: id of onenoteResource") { + var onenoteResourceIdOption = new Option("--onenote-resource-id", description: "key: id of onenoteResource") { }; onenoteResourceIdOption.IsRequired = true; command.AddOption(onenoteResourceIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteResourceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteResourceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteResourceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteResourceIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,7 +89,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable."; // Create options for all the parameters - var onenoteResourceIdOption = new Option("--onenoteresource-id", description: "key: id of onenoteResource") { + var onenoteResourceIdOption = new Option("--onenote-resource-id", description: "key: id of onenoteResource") { }; onenoteResourceIdOption.IsRequired = true; command.AddOption(onenoteResourceIdOption); @@ -99,14 +97,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteResourceId, string body) => { + command.SetHandler(async (string onenoteResourceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteResourceIdOption, bodyOption); return command; @@ -178,42 +175,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteResource body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Resources/ResourcesRequestBuilder.cs b/src/generated/Me/Onenote/Resources/ResourcesRequestBuilder.cs index bc41178ddea..ed1a5616160 100644 --- a/src/generated/Me/Onenote/Resources/ResourcesRequestBuilder.cs +++ b/src/generated/Me/Onenote/Resources/ResourcesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class ResourcesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteResourceRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteResource body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 5a9c46f61ac..291890ecf2a 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyNotebook"; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 212d28dda49..2751a6a3245 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,15 +35,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The notebook that contains the section group. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string sectionGroupId) => { + command.SetHandler(async (string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption); return command; @@ -55,7 +54,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The notebook that contains the section group. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -92,7 +90,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The notebook that contains the section group. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -100,14 +98,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string body) => { + command.SetHandler(async (string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, bodyOption); return command; @@ -115,6 +112,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Me.Onenote.SectionGroups.Item.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -122,6 +122,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Me.Onenote.SectionGroups.Item.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -193,42 +196,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index 023640b6b35..fa57974044a 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index cd5eb2e79b8..2d7fd7be1c6 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index b10278b31eb..5ed9c0e4ded 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToNotebook"; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 43e4360ffc4..b52739befb5 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSectionGroup"; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index 32fedcf1dca..52a63780859 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -43,19 +43,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -67,11 +66,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -85,25 +84,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Me.Onenote.SectionGroups.Item.ParentNotebook.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -132,11 +133,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -144,14 +145,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -223,42 +223,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index d2df795a1ed..2812c44a6f2 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,36 +25,38 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get media content for the navigation property pages from me"; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo output) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); + }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, fileOption, outputOption); return command; } /// @@ -64,15 +66,15 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "Update media content for the navigation property pages in me"; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -80,12 +82,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -136,29 +137,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 09eff71f6d1..81ef7a71996 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSection"; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index 18a89bc5745..23a908be0d0 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -45,23 +45,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -73,15 +72,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -95,20 +94,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -143,15 +141,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -159,14 +157,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -239,42 +236,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \me\onenote\sectionGroups\{sectionGroup-id}\parentNotebook\sections\{onenoteSection-id}\pages\{onenotePage-id}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index c43302cd3fa..4df81399886 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action onenotePatchContent"; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 5ff1c6039fe..50357f4e3c9 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyNotebook"; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 2a52cbc28c2..c4eb7685de1 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The notebook that contains the page. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The notebook that contains the page. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The notebook that contains the page. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 4e48827306b..364d2ea1da7 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToNotebook"; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index b7443e81e70..52952340d98 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSectionGroup"; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs index d2133103b8b..63f2c045fab 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -40,23 +40,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section that contains the page. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -68,15 +67,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section that contains the page. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -113,15 +111,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section that contains the page. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index cc9c53f6fd4..026afdf0089 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function preview"; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs index 0cc7002b478..e53e54a2265 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,11 +40,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -77,11 +75,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -194,31 +191,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 5aa307de614..eab9dca6e3f 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyNotebook"; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index b915d8f9e27..34d89c53fcc 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,19 +33,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The notebook that contains the section. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -57,11 +56,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The notebook that contains the section. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -75,20 +74,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -98,11 +96,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The notebook that contains the section. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -110,14 +108,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -189,42 +186,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 808935bae90..414fab33c4a 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section group that contains the section. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section group that contains the section. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section group that contains the section. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs index b75da2e2378..db3c8d083ca 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,7 +40,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -73,7 +71,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -112,7 +110,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -186,31 +183,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index bd05c1a38ef..aac1d760122 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section group that contains the section group. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string sectionGroupId) => { + command.SetHandler(async (string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section group that contains the section group. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section group that contains the section group. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string body) => { + command.SetHandler(async (string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/SectionGroupRequestBuilder.cs index 7359dc28004..cff3de6f45a 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string sectionGroupId) => { + command.SetHandler(async (string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption); return command; @@ -50,7 +49,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -64,20 +63,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -106,7 +104,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -114,14 +112,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string body) => { + command.SetHandler(async (string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, bodyOption); return command; @@ -129,6 +126,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Me.Onenote.SectionGroups.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -136,6 +136,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Me.Onenote.SectionGroups.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -207,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index b431f60248f..e9d6729f1c4 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs index 94661c7787c..3a4e3faa561 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 000dfdfbb09..a8a44e7750e 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToNotebook"; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index c845afa0851..85d530afa2a 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSectionGroup"; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index badec27895f..a2a025301ca 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -43,19 +43,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -67,11 +66,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -85,25 +84,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Me.Onenote.SectionGroups.Item.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,11 +135,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -146,14 +147,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -225,42 +225,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index d40ab3d819c..2605c287469 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,36 +25,38 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get media content for the navigation property pages from me"; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo output) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); + }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, fileOption, outputOption); return command; } /// @@ -64,15 +66,15 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "Update media content for the navigation property pages in me"; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -80,12 +82,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -136,29 +137,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 49bce3a226e..7336c116171 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSection"; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index a1b4c6d6cf6..ea0164ed8f5 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -45,23 +45,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -73,15 +72,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -95,20 +94,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -145,15 +143,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -161,14 +159,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -241,42 +238,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \me\onenote\sectionGroups\{sectionGroup-id}\sections\{onenoteSection-id}\pages\{onenotePage-id}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index 94cc0a883e9..f25b4ba1224 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action onenotePatchContent"; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index f1811dd9619..0276855f3a9 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyNotebook"; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index de88927fc76..b00b29786d3 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,23 +35,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The notebook that contains the page. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -63,15 +62,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The notebook that contains the page. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -85,20 +84,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -108,15 +106,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The notebook that contains the page. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -124,14 +122,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -139,6 +136,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Me.Onenote.SectionGroups.Item.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -146,6 +146,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Me.Onenote.SectionGroups.Item.Sections.Item.Pages.Item.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -217,42 +220,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index 906cc58c2d7..ab037d6fe09 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,27 +26,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string sectionGroupId1) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupId1Option); return command; @@ -58,19 +57,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -107,19 +105,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string sectionGroupId1, string body) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupId1Option, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index 52d8e89cc7d..5afd60cd996 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,15 +35,15 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -76,15 +74,15 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 55084f2981b..fd3dbf51182 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToNotebook"; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 12566a65f6c..703baf7a16a 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSectionGroup"; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index 5d2428d096f..0d75dcc789d 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -40,27 +40,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option); return command; @@ -72,19 +71,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -121,19 +119,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs index 7d18e0a03fe..fc1a22601eb 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -38,15 +37,15 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -78,15 +76,15 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -125,7 +123,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 0eaaf7e4953..bba94931d48 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToNotebook"; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 76213169e7c..0e4c89e6ce6 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSectionGroup"; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs index 3d05a0d537c..3d10d1a721d 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -40,23 +40,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section that contains the page. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -68,15 +67,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section that contains the page. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -113,15 +111,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section that contains the page. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index 233e112f55d..5db1b5b2cd7 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function preview"; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenotePageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs index a8aeafba33d..6a706b3fccd 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,11 +40,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -77,11 +75,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -194,31 +191,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index c60b8d4fe48..5f059c05215 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyNotebook"; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index f3f1ad4bda3..eb1eda1a139 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,19 +35,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The notebook that contains the section. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -59,11 +58,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The notebook that contains the section. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -100,11 +98,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The notebook that contains the section. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -127,6 +124,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Me.Onenote.SectionGroups.Item.Sections.Item.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,6 +134,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Me.Onenote.SectionGroups.Item.Sections.Item.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -205,42 +208,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index 12d5c10e478..74b10d6ecba 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string sectionGroupId1) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, sectionGroupId1Option); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string sectionGroupId1, string body) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, sectionGroupId1Option, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index 7f340d46a77..fd5378303c0 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,11 +35,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -72,11 +70,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 7aaf3e0fc86..85b8d7f24d5 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToNotebook"; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index a800c95b350..86a469b2769 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSectionGroup"; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index bb357e12d46..391a688f260 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -40,23 +40,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenoteSectionId1) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option); return command; @@ -68,15 +67,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -113,15 +111,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs index 09a8feb8fce..02d26f1ebe6 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -38,11 +37,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -74,11 +72,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -117,7 +115,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 36280ae810b..2ec0c5826df 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section group that contains the section. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section group that contains the section. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section group that contains the section. Read-only."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/SectionGroups/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/Item/Sections/SectionsRequestBuilder.cs index 108d5a664d9..30ad1f2f8fa 100644 --- a/src/generated/Me/Onenote/SectionGroups/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,7 +40,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -73,7 +71,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -112,7 +110,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -186,31 +183,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Me/Onenote/SectionGroups/SectionGroupsRequestBuilder.cs index 88b7ea57a0c..18312a22b6c 100644 --- a/src/generated/Me/Onenote/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Me/Onenote/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -103,7 +101,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -114,15 +116,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -177,31 +174,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 07c417c1150..1b6b4114d39 100644 --- a/src/generated/Me/Onenote/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToNotebook"; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index d8f0b0f1532..1740b7b7e74 100644 --- a/src/generated/Me/Onenote/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSectionGroup"; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/OnenoteSectionRequestBuilder.cs index a20c3c974f9..f1b2a9b18ae 100644 --- a/src/generated/Me/Onenote/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -43,15 +43,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string onenoteSectionId) => { + command.SetHandler(async (string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -77,25 +76,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Me.Onenote.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -117,7 +118,6 @@ public Command BuildParentSectionGroupCommand() { command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); command.AddCommand(builder.BuildPatchCommand()); command.AddCommand(builder.BuildSectionGroupsCommand()); command.AddCommand(builder.BuildSectionsCommand()); @@ -130,7 +130,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -138,14 +138,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string body) => { + command.SetHandler(async (string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, bodyOption); return command; @@ -217,42 +216,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index cbeb42b7e71..1b26e324767 100644 --- a/src/generated/Me/Onenote/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,32 +25,34 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get media content for the navigation property pages from me"; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, FileInfo output) => { + command.SetHandler(async (string onenoteSectionId, string onenotePageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, onenoteSectionIdOption, onenotePageIdOption, outputOption); + }, onenoteSectionIdOption, onenotePageIdOption, fileOption, outputOption); return command; } /// @@ -60,11 +62,11 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "Update media content for the navigation property pages in me"; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -72,12 +74,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, FileInfo file) => { + command.SetHandler(async (string onenoteSectionId, string onenotePageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -128,29 +129,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Onenote/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 4e0f06c550d..5aee433565d 100644 --- a/src/generated/Me/Onenote/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSection"; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index f10ff4c4bc8..ecf46f2185b 100644 --- a/src/generated/Me/Onenote/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -45,19 +45,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -69,11 +68,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -87,20 +86,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -137,11 +135,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -149,14 +147,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -229,42 +226,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \me\onenote\sections\{onenoteSection-id}\pages\{onenotePage-id}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Me/Onenote/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index d62a32d6740..cc43cda0a61 100644 --- a/src/generated/Me/Onenote/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,11 +25,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action onenotePatchContent"; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 52813401f58..aadf8f73560 100644 --- a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyNotebook"; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 723c183fc88..d29e0e08571 100644 --- a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,19 +35,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The notebook that contains the page. Read-only."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -59,11 +58,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The notebook that contains the page. Read-only."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -100,11 +98,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The notebook that contains the page. Read-only."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -127,6 +124,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Me.Onenote.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,6 +134,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Me.Onenote.Sections.Item.Pages.Item.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -205,42 +208,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index d3330b7e2bd..885b5311f98 100644 --- a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyNotebook"; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 04c572c3aca..86a70951cc9 100644 --- a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The notebook that contains the section group. Read-only."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The notebook that contains the section group. Read-only."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The notebook that contains the section group. Read-only."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 633ffec2414..f1f18fa5613 100644 --- a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section group that contains the section group. Read-only."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section group that contains the section group. Read-only."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section group that contains the section group. Read-only."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index dd38a8ccfc7..8722ff5e0f5 100644 --- a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -58,15 +57,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -80,20 +79,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -120,15 +118,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -136,14 +134,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -151,6 +148,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Me.Onenote.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -158,6 +158,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Me.Onenote.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -229,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index 1173dd8255f..5b14fade493 100644 --- a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,27 +26,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -58,19 +57,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -107,19 +105,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs index 5126bcf0d6c..b63d74b401f 100644 --- a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,15 +35,15 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -76,15 +74,15 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 620c83c75f7..f08a4eb4d76 100644 --- a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToNotebook"; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index d5dabe8ab68..1370af403db 100644 --- a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSectionGroup"; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index 72ff02c80ca..4a5e42ca487 100644 --- a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -40,27 +40,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1) => { + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option); return command; @@ -72,19 +71,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -121,19 +119,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs index 8b539da2289..e36e35e8c74 100644 --- a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -38,15 +37,15 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -78,15 +76,15 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -125,7 +123,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index 311d4736828..84689d1f601 100644 --- a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -40,11 +39,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -76,11 +74,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -130,15 +132,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -193,31 +190,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 9ebb7e7df42..2c734f00691 100644 --- a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToNotebook"; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 8c69df99fe8..9ee9af9e5b0 100644 --- a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSectionGroup"; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index 2d024527f55..b2aa55857f0 100644 --- a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -40,23 +40,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string onenoteSectionId1) => { + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option); return command; @@ -68,15 +67,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -113,15 +111,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs index 3573e7cdece..2bbd461888b 100644 --- a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -38,11 +37,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -74,11 +72,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -117,7 +115,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 132688645b4..298469242dd 100644 --- a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToNotebook"; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index bd8ecd37f95..f88b58bbf7b 100644 --- a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSectionGroup"; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs index c57e124c41f..df10036fc13 100644 --- a/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -40,19 +40,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section that contains the page. Read-only."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -64,11 +63,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section that contains the page. Read-only."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -82,20 +81,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -105,11 +103,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section that contains the page. Read-only."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -117,14 +115,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -196,42 +193,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index aedcd3e0ba8..9101835de56 100644 --- a/src/generated/Me/Onenote/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function preview"; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string onenoteSectionId, string onenotePageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenotePageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenotePageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenotePageIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/Pages/PagesRequestBuilder.cs index 67304a45ab4..3401e2d7f18 100644 --- a/src/generated/Me/Onenote/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,7 +40,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -73,7 +71,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of pages in the section. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -112,7 +110,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -186,31 +183,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index e0fcaf2fb95..5fbe9481686 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyNotebook"; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index cc337db68a6..05159af723d 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,15 +35,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The notebook that contains the section. Read-only."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string onenoteSectionId) => { + command.SetHandler(async (string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption); return command; @@ -55,7 +54,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The notebook that contains the section. Read-only."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -92,7 +90,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The notebook that contains the section. Read-only."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -100,14 +98,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string body) => { + command.SetHandler(async (string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, bodyOption); return command; @@ -115,6 +112,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Me.Onenote.Sections.Item.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -122,6 +122,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Me.Onenote.Sections.Item.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -193,42 +196,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 2dd2c633a38..55cb34b10eb 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyNotebook"; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 730bbc8fc62..0da9d725046 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,19 +33,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The notebook that contains the section group. Read-only."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -57,11 +56,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The notebook that contains the section group. Read-only."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -75,20 +74,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -98,11 +96,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The notebook that contains the section group. Read-only."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -110,14 +108,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -189,42 +186,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 96b1cecada5..cfdb4cd8ad2 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section group that contains the section group. Read-only."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section group that contains the section group. Read-only."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section group that contains the section group. Read-only."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index 7d941e05e54..5541c92c9ef 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -54,11 +53,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -72,20 +71,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -112,11 +110,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -124,14 +122,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -139,6 +136,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Me.Onenote.Sections.Item.ParentNotebook.SectionGroups.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -146,6 +146,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Me.Onenote.Sections.Item.ParentNotebook.SectionGroups.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -217,42 +220,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index c73246f8b2d..2c4382aa236 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs index f7ee1ef6d4e..8542421f6d4 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,11 +35,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -72,11 +70,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index ab5f749660b..a4a7d8ca068 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToNotebook"; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 771aa3ea836..97c8c1b75f1 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSectionGroup"; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index 35a9eb14d79..6cade366c2f 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -40,23 +40,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string onenoteSectionId1) => { + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option); return command; @@ -68,15 +67,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -113,15 +111,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs index 34f5d4cf8c7..c8e7df3f716 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -38,11 +37,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -74,11 +72,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -117,7 +115,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index 67131f930a5..597bf89c8ae 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -72,7 +70,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -122,15 +124,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -185,31 +182,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 667d2e9ef3c..33805561b12 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToNotebook"; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 1b55d41b7b6..0d3c898f391 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSectionGroup"; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index ee49e49fdcc..c667a19a04a 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -40,19 +40,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1) => { + command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, onenoteSectionId1Option); return command; @@ -64,11 +63,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -82,20 +81,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -105,11 +103,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -117,14 +115,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -196,42 +193,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs index bd239ad56e4..87fd79abfdd 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -38,7 +37,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -46,21 +45,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -70,7 +68,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -109,7 +107,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -120,15 +122,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -183,31 +180,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 912c0110a42..7ac7bae9bbe 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyNotebook"; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs index 07f971bd7a1..238603b246b 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,15 +35,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The notebook that contains the section group. Read-only."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string onenoteSectionId) => { + command.SetHandler(async (string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption); return command; @@ -55,7 +54,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The notebook that contains the section group. Read-only."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -92,7 +90,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The notebook that contains the section group. Read-only."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -100,14 +98,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string body) => { + command.SetHandler(async (string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, bodyOption); return command; @@ -115,6 +112,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Me.Onenote.Sections.Item.ParentSectionGroup.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -122,6 +122,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Me.Onenote.Sections.Item.ParentSectionGroup.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -193,42 +196,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index 2ad756f212f..b4f952509ed 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index 2b811f2c148..051792b76e6 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The section groups in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index e726839beef..9fc61185332 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToNotebook"; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 6cb236d6025..72c36356d6f 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSectionGroup"; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index a65125802b9..7fbdca8badd 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -40,19 +40,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1) => { + command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, onenoteSectionId1Option); return command; @@ -64,11 +63,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -82,20 +81,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -105,11 +103,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -117,14 +115,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -196,42 +193,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs index 459671008c7..27487740a76 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -38,7 +37,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -46,21 +45,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -70,7 +68,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The sections in the notebook. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -109,7 +107,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -120,15 +122,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -183,31 +180,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs deleted file mode 100644 index bddb1f5deec..00000000000 --- a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ /dev/null @@ -1,217 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Me.Onenote.Sections.Item.ParentSectionGroup.ParentSectionGroup { - /// Builds and executes requests for operations under \me\onenote\sections\{onenoteSection-id}\parentSectionGroup\parentSectionGroup - public class ParentSectionGroupRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string onenoteSectionId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, onenoteSectionIdOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, selectOption, expandOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildPatchCommand() { - var command = new Command("patch"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePatchRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, onenoteSectionIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new ParentSectionGroupRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public ParentSectionGroupRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/onenote/sections/{onenoteSection_id}/parentSectionGroup/parentSectionGroup{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePatchRequestInformation(SectionGroup body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PATCH, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// The section group that contains the section group. Read-only. - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index f22a4f81273..7bf45a2b3a4 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section group that contains the section. Read-only."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string onenoteSectionId) => { + command.SetHandler(async (string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption); return command; @@ -49,7 +48,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section group that contains the section. Read-only."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -63,20 +62,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -90,18 +88,6 @@ public Command BuildParentNotebookCommand() { command.AddCommand(builder.BuildSectionsCommand()); return command; } - public Command BuildParentSectionGroupCommand() { - var command = new Command("parent-section-group"); - var builder = new ApiSdk.Me.Onenote.Sections.Item.ParentSectionGroup.ParentSectionGroupRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildDeleteCommand()); - command.AddCommand(builder.BuildGetCommand()); - command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); - command.AddCommand(builder.BuildPatchCommand()); - command.AddCommand(builder.BuildSectionGroupsCommand()); - command.AddCommand(builder.BuildSectionsCommand()); - return command; - } /// /// The section group that contains the section. Read-only. /// @@ -109,7 +95,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section group that contains the section. Read-only."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -117,14 +103,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string body) => { + command.SetHandler(async (string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, bodyOption); return command; @@ -132,6 +117,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Me.Onenote.Sections.Item.ParentSectionGroup.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -139,6 +127,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Me.Onenote.Sections.Item.ParentSectionGroup.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -210,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs index fa2a9387d24..33c1615b045 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs index 098cddf2133..a4306052e30 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The section groups in the section. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 17871ce2537..5a1500527ea 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToNotebook"; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 0767b5bd90e..5e8af155a67 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToSectionGroup"; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs index da351bd01fe..70da48c5229 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -40,19 +40,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1) => { + command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, onenoteSectionId1Option); return command; @@ -64,11 +63,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -82,20 +81,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -105,11 +103,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -117,14 +115,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string onenoteSectionId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -196,42 +193,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs index fb257ada473..9dcdfdb561a 100644 --- a/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -38,7 +37,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -46,21 +45,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -70,7 +68,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The sections in the section group. Read-only. Nullable."; // Create options for all the parameters - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -109,7 +107,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -120,15 +122,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -183,31 +180,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Onenote/Sections/SectionsRequestBuilder.cs b/src/generated/Me/Onenote/Sections/SectionsRequestBuilder.cs index 17c185d4c31..2e78f3fde50 100644 --- a/src/generated/Me/Onenote/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Me/Onenote/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -104,7 +102,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -115,15 +117,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -178,31 +175,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/OnlineMeetings/CreateOrGet/CreateOrGetRequestBuilder.cs b/src/generated/Me/OnlineMeetings/CreateOrGet/CreateOrGetRequestBuilder.cs index c75497b4486..2e6919ec708 100644 --- a/src/generated/Me/OnlineMeetings/CreateOrGet/CreateOrGetRequestBuilder.cs +++ b/src/generated/Me/OnlineMeetings/CreateOrGet/CreateOrGetRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -78,19 +77,6 @@ public RequestInformation CreatePostRequestInformation(CreateOrGetRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createOrGet - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateOrGetRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onlineMeeting public class CreateOrGetResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/OnlineMeetings/Item/AttendanceReports/AttendanceReportsRequestBuilder.cs b/src/generated/Me/OnlineMeetings/Item/AttendanceReports/AttendanceReportsRequestBuilder.cs index c6437d26610..29b64f82f75 100644 --- a/src/generated/Me/OnlineMeetings/Item/AttendanceReports/AttendanceReportsRequestBuilder.cs +++ b/src/generated/Me/OnlineMeetings/Item/AttendanceReports/AttendanceReportsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class AttendanceReportsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MeetingAttendanceReportRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAttendanceRecordsCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAttendanceRecordsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -37,7 +36,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The attendance reports of an online meeting. Read-only."; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onlineMeetingId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onlineMeetingId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onlineMeetingIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onlineMeetingIdOption, bodyOption, outputOption); return command; } /// @@ -69,7 +67,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The attendance reports of an online meeting. Read-only."; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onlineMeetingId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onlineMeetingId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onlineMeetingIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onlineMeetingIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(MeetingAttendanceReport b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The attendance reports of an online meeting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The attendance reports of an online meeting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MeetingAttendanceReport model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The attendance reports of an online meeting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/OnlineMeetings/Item/AttendanceReports/Item/AttendanceRecords/AttendanceRecordsRequestBuilder.cs b/src/generated/Me/OnlineMeetings/Item/AttendanceReports/Item/AttendanceRecords/AttendanceRecordsRequestBuilder.cs index 9560b4296a3..4b25ac1796e 100644 --- a/src/generated/Me/OnlineMeetings/Item/AttendanceReports/Item/AttendanceRecords/AttendanceRecordsRequestBuilder.cs +++ b/src/generated/Me/OnlineMeetings/Item/AttendanceReports/Item/AttendanceRecords/AttendanceRecordsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AttendanceRecordsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttendanceRecordRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,11 +35,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "List of attendance records of an attendance report. Read-only."; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - var meetingAttendanceReportIdOption = new Option("--meetingattendancereport-id", description: "key: id of meetingAttendanceReport") { + var meetingAttendanceReportIdOption = new Option("--meeting-attendance-report-id", description: "key: id of meetingAttendanceReport") { }; meetingAttendanceReportIdOption.IsRequired = true; command.AddOption(meetingAttendanceReportIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onlineMeetingIdOption, meetingAttendanceReportIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onlineMeetingIdOption, meetingAttendanceReportIdOption, bodyOption, outputOption); return command; } /// @@ -72,11 +70,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "List of attendance records of an attendance report. Read-only."; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - var meetingAttendanceReportIdOption = new Option("--meetingattendancereport-id", description: "key: id of meetingAttendanceReport") { + var meetingAttendanceReportIdOption = new Option("--meeting-attendance-report-id", description: "key: id of meetingAttendanceReport") { }; meetingAttendanceReportIdOption.IsRequired = true; command.AddOption(meetingAttendanceReportIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onlineMeetingIdOption, meetingAttendanceReportIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onlineMeetingIdOption, meetingAttendanceReportIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(AttendanceRecord body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of attendance records of an attendance report. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of attendance records of an attendance report. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AttendanceRecord model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// List of attendance records of an attendance report. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/OnlineMeetings/Item/AttendanceReports/Item/AttendanceRecords/Item/AttendanceRecordRequestBuilder.cs b/src/generated/Me/OnlineMeetings/Item/AttendanceReports/Item/AttendanceRecords/Item/AttendanceRecordRequestBuilder.cs index ef5a514ac27..1499043ccec 100644 --- a/src/generated/Me/OnlineMeetings/Item/AttendanceReports/Item/AttendanceRecords/Item/AttendanceRecordRequestBuilder.cs +++ b/src/generated/Me/OnlineMeetings/Item/AttendanceReports/Item/AttendanceRecords/Item/AttendanceRecordRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "List of attendance records of an attendance report. Read-only."; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - var meetingAttendanceReportIdOption = new Option("--meetingattendancereport-id", description: "key: id of meetingAttendanceReport") { + var meetingAttendanceReportIdOption = new Option("--meeting-attendance-report-id", description: "key: id of meetingAttendanceReport") { }; meetingAttendanceReportIdOption.IsRequired = true; command.AddOption(meetingAttendanceReportIdOption); - var attendanceRecordIdOption = new Option("--attendancerecord-id", description: "key: id of attendanceRecord") { + var attendanceRecordIdOption = new Option("--attendance-record-id", description: "key: id of attendanceRecord") { }; attendanceRecordIdOption.IsRequired = true; command.AddOption(attendanceRecordIdOption); - command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, string attendanceRecordId) => { + command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, string attendanceRecordId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onlineMeetingIdOption, meetingAttendanceReportIdOption, attendanceRecordIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "List of attendance records of an attendance report. Read-only."; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - var meetingAttendanceReportIdOption = new Option("--meetingattendancereport-id", description: "key: id of meetingAttendanceReport") { + var meetingAttendanceReportIdOption = new Option("--meeting-attendance-report-id", description: "key: id of meetingAttendanceReport") { }; meetingAttendanceReportIdOption.IsRequired = true; command.AddOption(meetingAttendanceReportIdOption); - var attendanceRecordIdOption = new Option("--attendancerecord-id", description: "key: id of attendanceRecord") { + var attendanceRecordIdOption = new Option("--attendance-record-id", description: "key: id of attendanceRecord") { }; attendanceRecordIdOption.IsRequired = true; command.AddOption(attendanceRecordIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, string attendanceRecordId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, string attendanceRecordId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onlineMeetingIdOption, meetingAttendanceReportIdOption, attendanceRecordIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onlineMeetingIdOption, meetingAttendanceReportIdOption, attendanceRecordIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "List of attendance records of an attendance report. Read-only."; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - var meetingAttendanceReportIdOption = new Option("--meetingattendancereport-id", description: "key: id of meetingAttendanceReport") { + var meetingAttendanceReportIdOption = new Option("--meeting-attendance-report-id", description: "key: id of meetingAttendanceReport") { }; meetingAttendanceReportIdOption.IsRequired = true; command.AddOption(meetingAttendanceReportIdOption); - var attendanceRecordIdOption = new Option("--attendancerecord-id", description: "key: id of attendanceRecord") { + var attendanceRecordIdOption = new Option("--attendance-record-id", description: "key: id of attendanceRecord") { }; attendanceRecordIdOption.IsRequired = true; command.AddOption(attendanceRecordIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, string attendanceRecordId, string body) => { + command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, string attendanceRecordId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onlineMeetingIdOption, meetingAttendanceReportIdOption, attendanceRecordIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(AttendanceRecord body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of attendance records of an attendance report. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of attendance records of an attendance report. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of attendance records of an attendance report. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AttendanceRecord model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// List of attendance records of an attendance report. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/OnlineMeetings/Item/AttendanceReports/Item/MeetingAttendanceReportRequestBuilder.cs b/src/generated/Me/OnlineMeetings/Item/AttendanceReports/Item/MeetingAttendanceReportRequestBuilder.cs index 7d2e9dca205..be56b9867b0 100644 --- a/src/generated/Me/OnlineMeetings/Item/AttendanceReports/Item/MeetingAttendanceReportRequestBuilder.cs +++ b/src/generated/Me/OnlineMeetings/Item/AttendanceReports/Item/MeetingAttendanceReportRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,6 +23,9 @@ public class MeetingAttendanceReportRequestBuilder { public Command BuildAttendanceRecordsCommand() { var command = new Command("attendance-records"); var builder = new ApiSdk.Me.OnlineMeetings.Item.AttendanceReports.Item.AttendanceRecords.AttendanceRecordsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -34,19 +37,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The attendance reports of an online meeting. Read-only."; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - var meetingAttendanceReportIdOption = new Option("--meetingattendancereport-id", description: "key: id of meetingAttendanceReport") { + var meetingAttendanceReportIdOption = new Option("--meeting-attendance-report-id", description: "key: id of meetingAttendanceReport") { }; meetingAttendanceReportIdOption.IsRequired = true; command.AddOption(meetingAttendanceReportIdOption); - command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId) => { + command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onlineMeetingIdOption, meetingAttendanceReportIdOption); return command; @@ -58,11 +60,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The attendance reports of an online meeting. Read-only."; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - var meetingAttendanceReportIdOption = new Option("--meetingattendancereport-id", description: "key: id of meetingAttendanceReport") { + var meetingAttendanceReportIdOption = new Option("--meeting-attendance-report-id", description: "key: id of meetingAttendanceReport") { }; meetingAttendanceReportIdOption.IsRequired = true; command.AddOption(meetingAttendanceReportIdOption); @@ -76,20 +78,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onlineMeetingIdOption, meetingAttendanceReportIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onlineMeetingIdOption, meetingAttendanceReportIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,11 +100,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The attendance reports of an online meeting. Read-only."; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - var meetingAttendanceReportIdOption = new Option("--meetingattendancereport-id", description: "key: id of meetingAttendanceReport") { + var meetingAttendanceReportIdOption = new Option("--meeting-attendance-report-id", description: "key: id of meetingAttendanceReport") { }; meetingAttendanceReportIdOption.IsRequired = true; command.AddOption(meetingAttendanceReportIdOption); @@ -111,14 +112,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, string body) => { + command.SetHandler(async (string onlineMeetingId, string meetingAttendanceReportId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onlineMeetingIdOption, meetingAttendanceReportIdOption, bodyOption); return command; @@ -190,42 +190,6 @@ public RequestInformation CreatePatchRequestInformation(MeetingAttendanceReport requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The attendance reports of an online meeting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The attendance reports of an online meeting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The attendance reports of an online meeting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MeetingAttendanceReport model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The attendance reports of an online meeting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/OnlineMeetings/Item/AttendeeReport/AttendeeReportRequestBuilder.cs b/src/generated/Me/OnlineMeetings/Item/AttendeeReport/AttendeeReportRequestBuilder.cs index aae8fa2ab1e..e8859d216fc 100644 --- a/src/generated/Me/OnlineMeetings/Item/AttendeeReport/AttendeeReportRequestBuilder.cs +++ b/src/generated/Me/OnlineMeetings/Item/AttendeeReport/AttendeeReportRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,28 +25,30 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get media content for the navigation property onlineMeetings from me"; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string onlineMeetingId, FileInfo output) => { + command.SetHandler(async (string onlineMeetingId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, onlineMeetingIdOption, outputOption); + }, onlineMeetingIdOption, fileOption, outputOption); return command; } /// @@ -56,7 +58,7 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "Update media content for the navigation property onlineMeetings in me"; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); @@ -64,12 +66,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onlineMeetingId, FileInfo file) => { + command.SetHandler(async (string onlineMeetingId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onlineMeetingIdOption, bodyOption); return command; @@ -120,29 +121,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property onlineMeetings from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property onlineMeetings in me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/OnlineMeetings/Item/OnlineMeetingRequestBuilder.cs b/src/generated/Me/OnlineMeetings/Item/OnlineMeetingRequestBuilder.cs index 13251580427..e9dded17cfd 100644 --- a/src/generated/Me/OnlineMeetings/Item/OnlineMeetingRequestBuilder.cs +++ b/src/generated/Me/OnlineMeetings/Item/OnlineMeetingRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -24,6 +24,9 @@ public class OnlineMeetingRequestBuilder { public Command BuildAttendanceReportsCommand() { var command = new Command("attendance-reports"); var builder = new ApiSdk.Me.OnlineMeetings.Item.AttendanceReports.AttendanceReportsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -42,15 +45,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property onlineMeetings for me"; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - command.SetHandler(async (string onlineMeetingId) => { + command.SetHandler(async (string onlineMeetingId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onlineMeetingIdOption); return command; @@ -62,7 +64,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get onlineMeetings from me"; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); @@ -76,20 +78,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string onlineMeetingId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string onlineMeetingId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, onlineMeetingIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, onlineMeetingIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,7 +100,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property onlineMeetings in me"; // Create options for all the parameters - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); @@ -107,14 +108,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string onlineMeetingId, string body) => { + command.SetHandler(async (string onlineMeetingId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, onlineMeetingIdOption, bodyOption); return command; @@ -186,42 +186,6 @@ public RequestInformation CreatePatchRequestInformation(OnlineMeeting body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property onlineMeetings for me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get onlineMeetings from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property onlineMeetings in me - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnlineMeeting model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get onlineMeetings from me public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/OnlineMeetings/OnlineMeetingsRequestBuilder.cs b/src/generated/Me/OnlineMeetings/OnlineMeetingsRequestBuilder.cs index 14f774669e1..f938e575109 100644 --- a/src/generated/Me/OnlineMeetings/OnlineMeetingsRequestBuilder.cs +++ b/src/generated/Me/OnlineMeetings/OnlineMeetingsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,13 +23,12 @@ public class OnlineMeetingsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnlineMeetingRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAttendanceReportsCommand(), - builder.BuildAttendeeReportCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAttendanceReportsCommand()); + commands.Add(builder.BuildAttendeeReportCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -43,21 +42,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } public Command BuildCreateOrGetCommand() { @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(OnlineMeeting body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get onlineMeetings from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to onlineMeetings for me - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnlineMeeting model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get onlineMeetings from me public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Outlook/MasterCategories/Item/OutlookCategoryRequestBuilder.cs b/src/generated/Me/Outlook/MasterCategories/Item/OutlookCategoryRequestBuilder.cs index fe23a445a32..e900024b4d0 100644 --- a/src/generated/Me/Outlook/MasterCategories/Item/OutlookCategoryRequestBuilder.cs +++ b/src/generated/Me/Outlook/MasterCategories/Item/OutlookCategoryRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "A list of categories defined for the user."; // Create options for all the parameters - var outlookCategoryIdOption = new Option("--outlookcategory-id", description: "key: id of outlookCategory") { + var outlookCategoryIdOption = new Option("--outlook-category-id", description: "key: id of outlookCategory") { }; outlookCategoryIdOption.IsRequired = true; command.AddOption(outlookCategoryIdOption); - command.SetHandler(async (string outlookCategoryId) => { + command.SetHandler(async (string outlookCategoryId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, outlookCategoryIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "A list of categories defined for the user."; // Create options for all the parameters - var outlookCategoryIdOption = new Option("--outlookcategory-id", description: "key: id of outlookCategory") { + var outlookCategoryIdOption = new Option("--outlook-category-id", description: "key: id of outlookCategory") { }; outlookCategoryIdOption.IsRequired = true; command.AddOption(outlookCategoryIdOption); @@ -55,19 +54,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string outlookCategoryId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string outlookCategoryId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, outlookCategoryIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outlookCategoryIdOption, selectOption, outputOption); return command; } /// @@ -77,7 +75,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "A list of categories defined for the user."; // Create options for all the parameters - var outlookCategoryIdOption = new Option("--outlookcategory-id", description: "key: id of outlookCategory") { + var outlookCategoryIdOption = new Option("--outlook-category-id", description: "key: id of outlookCategory") { }; outlookCategoryIdOption.IsRequired = true; command.AddOption(outlookCategoryIdOption); @@ -85,14 +83,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string outlookCategoryId, string body) => { + command.SetHandler(async (string outlookCategoryId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, outlookCategoryIdOption, bodyOption); return command; @@ -164,42 +161,6 @@ public RequestInformation CreatePatchRequestInformation(OutlookCategory body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A list of categories defined for the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A list of categories defined for the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A list of categories defined for the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OutlookCategory model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A list of categories defined for the user. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/Outlook/MasterCategories/MasterCategoriesRequestBuilder.cs b/src/generated/Me/Outlook/MasterCategories/MasterCategoriesRequestBuilder.cs index 45e4085ddea..1a409e2dc33 100644 --- a/src/generated/Me/Outlook/MasterCategories/MasterCategoriesRequestBuilder.cs +++ b/src/generated/Me/Outlook/MasterCategories/MasterCategoriesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MasterCategoriesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OutlookCategoryRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -90,7 +88,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -99,15 +101,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -162,31 +159,6 @@ public RequestInformation CreatePostRequestInformation(OutlookCategory body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A list of categories defined for the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A list of categories defined for the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OutlookCategory model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A list of categories defined for the user. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Outlook/OutlookRequestBuilder.cs b/src/generated/Me/Outlook/OutlookRequestBuilder.cs index f60a2aacbec..322ef864991 100644 --- a/src/generated/Me/Outlook/OutlookRequestBuilder.cs +++ b/src/generated/Me/Outlook/OutlookRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Selective Outlook services available to the user. Read-only. Nullable."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -51,24 +50,26 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, outputOption); return command; } public Command BuildMasterCategoriesCommand() { var command = new Command("master-categories"); var builder = new ApiSdk.Me.Outlook.MasterCategories.MasterCategoriesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -84,14 +85,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -164,42 +164,6 @@ public RequestInformation CreatePatchRequestInformation(OutlookUser body, Action return requestInfo; } /// - /// Selective Outlook services available to the user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Selective Outlook services available to the user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Selective Outlook services available to the user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OutlookUser model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \me\outlook\microsoft.graph.supportedLanguages() /// public SupportedLanguagesRequestBuilder SupportedLanguages() { diff --git a/src/generated/Me/Outlook/SupportedLanguages/SupportedLanguages.cs b/src/generated/Me/Outlook/SupportedLanguages/SupportedLanguages.cs deleted file mode 100644 index 6ff6c0f3349..00000000000 --- a/src/generated/Me/Outlook/SupportedLanguages/SupportedLanguages.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.Outlook.SupportedLanguages { - public class SupportedLanguages : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// A name representing the user's locale in natural language, for example, 'English (United States)'. - public string DisplayName { get; set; } - /// A locale representation for the user, which includes the user's preferred language and country/region. For example, 'en-us'. The language component follows 2-letter codes as defined in ISO 639-1, and the country component follows 2-letter codes as defined in ISO 3166-1 alpha-2. - public string Locale { get; set; } - /// - /// Instantiates a new supportedLanguages and sets the default values. - /// - public SupportedLanguages() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"displayName", (o,n) => { (o as SupportedLanguages).DisplayName = n.GetStringValue(); } }, - {"locale", (o,n) => { (o as SupportedLanguages).Locale = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("displayName", DisplayName); - writer.WriteStringValue("locale", Locale); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/Outlook/SupportedLanguages/SupportedLanguagesRequestBuilder.cs b/src/generated/Me/Outlook/SupportedLanguages/SupportedLanguagesRequestBuilder.cs index bae15b92d32..c64d7a55b70 100644 --- a/src/generated/Me/Outlook/SupportedLanguages/SupportedLanguagesRequestBuilder.cs +++ b/src/generated/Me/Outlook/SupportedLanguages/SupportedLanguagesRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +26,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function supportedLanguages"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +67,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function supportedLanguages - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Outlook/SupportedTimeZones/SupportedTimeZones.cs b/src/generated/Me/Outlook/SupportedTimeZones/SupportedTimeZones.cs deleted file mode 100644 index cb523da4bd2..00000000000 --- a/src/generated/Me/Outlook/SupportedTimeZones/SupportedTimeZones.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.Outlook.SupportedTimeZones { - public class SupportedTimeZones : IParsable { - /// An identifier for the time zone. - public string @Alias { get; set; } - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// A display string that represents the time zone. - public string DisplayName { get; set; } - /// - /// Instantiates a new supportedTimeZones and sets the default values. - /// - public SupportedTimeZones() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"alias", (o,n) => { (o as SupportedTimeZones).@Alias = n.GetStringValue(); } }, - {"displayName", (o,n) => { (o as SupportedTimeZones).DisplayName = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("alias", @Alias); - writer.WriteStringValue("displayName", DisplayName); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/Outlook/SupportedTimeZones/SupportedTimeZonesRequestBuilder.cs b/src/generated/Me/Outlook/SupportedTimeZones/SupportedTimeZonesRequestBuilder.cs index 2d96f930e84..42bcb721ee9 100644 --- a/src/generated/Me/Outlook/SupportedTimeZones/SupportedTimeZonesRequestBuilder.cs +++ b/src/generated/Me/Outlook/SupportedTimeZones/SupportedTimeZonesRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +26,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function supportedTimeZones"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +67,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function supportedTimeZones - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Outlook/SupportedTimeZonesWithTimeZoneStandard/SupportedTimeZonesWithTimeZoneStandard.cs b/src/generated/Me/Outlook/SupportedTimeZonesWithTimeZoneStandard/SupportedTimeZonesWithTimeZoneStandard.cs deleted file mode 100644 index 70b45aa5998..00000000000 --- a/src/generated/Me/Outlook/SupportedTimeZonesWithTimeZoneStandard/SupportedTimeZonesWithTimeZoneStandard.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.Outlook.SupportedTimeZonesWithTimeZoneStandard { - public class SupportedTimeZonesWithTimeZoneStandard : IParsable { - /// An identifier for the time zone. - public string @Alias { get; set; } - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// A display string that represents the time zone. - public string DisplayName { get; set; } - /// - /// Instantiates a new supportedTimeZonesWithTimeZoneStandard and sets the default values. - /// - public SupportedTimeZonesWithTimeZoneStandard() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"alias", (o,n) => { (o as SupportedTimeZonesWithTimeZoneStandard).@Alias = n.GetStringValue(); } }, - {"displayName", (o,n) => { (o as SupportedTimeZonesWithTimeZoneStandard).DisplayName = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("alias", @Alias); - writer.WriteStringValue("displayName", DisplayName); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/Outlook/SupportedTimeZonesWithTimeZoneStandard/SupportedTimeZonesWithTimeZoneStandardRequestBuilder.cs b/src/generated/Me/Outlook/SupportedTimeZonesWithTimeZoneStandard/SupportedTimeZonesWithTimeZoneStandardRequestBuilder.cs index dc6caac67f6..e3dd1f468c3 100644 --- a/src/generated/Me/Outlook/SupportedTimeZonesWithTimeZoneStandard/SupportedTimeZonesWithTimeZoneStandardRequestBuilder.cs +++ b/src/generated/Me/Outlook/SupportedTimeZonesWithTimeZoneStandard/SupportedTimeZonesWithTimeZoneStandardRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,22 +26,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function supportedTimeZones"; // Create options for all the parameters - var TimeZoneStandardOption = new Option("--timezonestandard", description: "Usage: TimeZoneStandard={TimeZoneStandard}") { + var TimeZoneStandardOption = new Option("--time-zone-standard", description: "Usage: TimeZoneStandard={TimeZoneStandard}") { }; TimeZoneStandardOption.IsRequired = true; command.AddOption(TimeZoneStandardOption); - command.SetHandler(async (object TimeZoneStandard) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (object TimeZoneStandard, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, TimeZoneStandardOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, TimeZoneStandardOption, outputOption); return command; } /// @@ -73,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function supportedTimeZones - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/OwnedDevices/@Ref/@Ref.cs b/src/generated/Me/OwnedDevices/@Ref/@Ref.cs deleted file mode 100644 index 78fd3241ea1..00000000000 --- a/src/generated/Me/OwnedDevices/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.OwnedDevices.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/OwnedDevices/@Ref/RefRequestBuilder.cs b/src/generated/Me/OwnedDevices/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 49ec7ccb777..00000000000 --- a/src/generated/Me/OwnedDevices/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,194 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Me.OwnedDevices.@Ref { - /// Builds and executes requests for operations under \me\ownedDevices\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Devices that are owned by the user. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Devices that are owned by the user. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/ownedDevices/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Me.OwnedDevices.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Me.OwnedDevices.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Me/OwnedDevices/@Ref/RefResponse.cs b/src/generated/Me/OwnedDevices/@Ref/RefResponse.cs deleted file mode 100644 index aa63b84ab59..00000000000 --- a/src/generated/Me/OwnedDevices/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.OwnedDevices.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/OwnedDevices/OwnedDevicesRequestBuilder.cs b/src/generated/Me/OwnedDevices/OwnedDevicesRequestBuilder.cs index 66612304b5a..d269ad6031b 100644 --- a/src/generated/Me/OwnedDevices/OwnedDevicesRequestBuilder.cs +++ b/src/generated/Me/OwnedDevices/OwnedDevicesRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Me.OwnedDevices.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -61,7 +61,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -72,20 +76,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Me.OwnedDevices.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Me.OwnedDevices.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -124,18 +123,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/OwnedDevices/Ref/Ref.cs b/src/generated/Me/OwnedDevices/Ref/Ref.cs new file mode 100644 index 00000000000..62128dea139 --- /dev/null +++ b/src/generated/Me/OwnedDevices/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.OwnedDevices.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/OwnedDevices/Ref/RefRequestBuilder.cs b/src/generated/Me/OwnedDevices/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..d183e0077c9 --- /dev/null +++ b/src/generated/Me/OwnedDevices/Ref/RefRequestBuilder.cs @@ -0,0 +1,167 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Me.OwnedDevices.Ref { + /// Builds and executes requests for operations under \me\ownedDevices\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Devices that are owned by the user. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Devices that are owned by the user. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/me/ownedDevices/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Me.OwnedDevices.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Me/OwnedDevices/Ref/RefResponse.cs b/src/generated/Me/OwnedDevices/Ref/RefResponse.cs new file mode 100644 index 00000000000..465104f6af4 --- /dev/null +++ b/src/generated/Me/OwnedDevices/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.OwnedDevices.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/OwnedObjects/@Ref/@Ref.cs b/src/generated/Me/OwnedObjects/@Ref/@Ref.cs deleted file mode 100644 index 2ed0279fd3b..00000000000 --- a/src/generated/Me/OwnedObjects/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.OwnedObjects.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/OwnedObjects/@Ref/RefRequestBuilder.cs b/src/generated/Me/OwnedObjects/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 3f08dbac37c..00000000000 --- a/src/generated/Me/OwnedObjects/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,194 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Me.OwnedObjects.@Ref { - /// Builds and executes requests for operations under \me\ownedObjects\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Directory objects that are owned by the user. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Directory objects that are owned by the user. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/ownedObjects/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Me.OwnedObjects.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Me.OwnedObjects.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Me/OwnedObjects/@Ref/RefResponse.cs b/src/generated/Me/OwnedObjects/@Ref/RefResponse.cs deleted file mode 100644 index 04b8387e63b..00000000000 --- a/src/generated/Me/OwnedObjects/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.OwnedObjects.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/OwnedObjects/OwnedObjectsRequestBuilder.cs b/src/generated/Me/OwnedObjects/OwnedObjectsRequestBuilder.cs index 9e9d6c7d1ac..345163a4f64 100644 --- a/src/generated/Me/OwnedObjects/OwnedObjectsRequestBuilder.cs +++ b/src/generated/Me/OwnedObjects/OwnedObjectsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Me.OwnedObjects.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -61,7 +61,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -72,20 +76,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Me.OwnedObjects.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Me.OwnedObjects.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -124,18 +123,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/OwnedObjects/Ref/Ref.cs b/src/generated/Me/OwnedObjects/Ref/Ref.cs new file mode 100644 index 00000000000..c2150e2ac37 --- /dev/null +++ b/src/generated/Me/OwnedObjects/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.OwnedObjects.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/OwnedObjects/Ref/RefRequestBuilder.cs b/src/generated/Me/OwnedObjects/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..23b02e11f96 --- /dev/null +++ b/src/generated/Me/OwnedObjects/Ref/RefRequestBuilder.cs @@ -0,0 +1,167 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Me.OwnedObjects.Ref { + /// Builds and executes requests for operations under \me\ownedObjects\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Directory objects that are owned by the user. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Directory objects that are owned by the user. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/me/ownedObjects/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Me.OwnedObjects.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Me/OwnedObjects/Ref/RefResponse.cs b/src/generated/Me/OwnedObjects/Ref/RefResponse.cs new file mode 100644 index 00000000000..089b4275166 --- /dev/null +++ b/src/generated/Me/OwnedObjects/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.OwnedObjects.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/People/Item/PersonRequestBuilder.cs b/src/generated/Me/People/Item/PersonRequestBuilder.cs index d2fa7ae75f4..1c41a9dc514 100644 --- a/src/generated/Me/People/Item/PersonRequestBuilder.cs +++ b/src/generated/Me/People/Item/PersonRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,10 @@ public Command BuildDeleteCommand() { }; personIdOption.IsRequired = true; command.AddOption(personIdOption); - command.SetHandler(async (string personId) => { + command.SetHandler(async (string personId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, personIdOption); return command; @@ -55,19 +54,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string personId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string personId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, personIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, personIdOption, selectOption, outputOption); return command; } /// @@ -85,14 +83,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string personId, string body) => { + command.SetHandler(async (string personId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, personIdOption, bodyOption); return command; @@ -164,42 +161,6 @@ public RequestInformation CreatePatchRequestInformation(Person body, Action - /// Read-only. The most relevant people to the user. The collection is ordered by their relevance to the user, which is determined by the user's communication, collaboration and business relationships. A person is an aggregation of information from across mail, contacts and social networks. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. The most relevant people to the user. The collection is ordered by their relevance to the user, which is determined by the user's communication, collaboration and business relationships. A person is an aggregation of information from across mail, contacts and social networks. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. The most relevant people to the user. The collection is ordered by their relevance to the user, which is determined by the user's communication, collaboration and business relationships. A person is an aggregation of information from across mail, contacts and social networks. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Person model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. The most relevant people to the user. The collection is ordered by their relevance to the user, which is determined by the user's communication, collaboration and business relationships. A person is an aggregation of information from across mail, contacts and social networks. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/People/PeopleRequestBuilder.cs b/src/generated/Me/People/PeopleRequestBuilder.cs index 0e626d83a42..5e57348fa04 100644 --- a/src/generated/Me/People/PeopleRequestBuilder.cs +++ b/src/generated/Me/People/PeopleRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class PeopleRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PersonRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -94,7 +92,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -104,15 +106,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -167,31 +164,6 @@ public RequestInformation CreatePostRequestInformation(Person body, Action - /// Read-only. The most relevant people to the user. The collection is ordered by their relevance to the user, which is determined by the user's communication, collaboration and business relationships. A person is an aggregation of information from across mail, contacts and social networks. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. The most relevant people to the user. The collection is ordered by their relevance to the user, which is determined by the user's communication, collaboration and business relationships. A person is an aggregation of information from across mail, contacts and social networks. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Person model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. The most relevant people to the user. The collection is ordered by their relevance to the user, which is determined by the user's communication, collaboration and business relationships. A person is an aggregation of information from across mail, contacts and social networks. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Photo/PhotoRequestBuilder.cs b/src/generated/Me/Photo/PhotoRequestBuilder.cs index 9f31e63977f..0334b64d069 100644 --- a/src/generated/Me/Photo/PhotoRequestBuilder.cs +++ b/src/generated/Me/Photo/PhotoRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The user's profile photo. Read-only."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -55,19 +54,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, outputOption); return command; } /// @@ -81,14 +79,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -160,42 +157,6 @@ public RequestInformation CreatePatchRequestInformation(ProfilePhoto body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user's profile photo. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's profile photo. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's profile photo. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ProfilePhoto model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's profile photo. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/Photo/Value/ContentRequestBuilder.cs b/src/generated/Me/Photo/Value/ContentRequestBuilder.cs index 3530d8e8189..b11a6341afd 100644 --- a/src/generated/Me/Photo/Value/ContentRequestBuilder.cs +++ b/src/generated/Me/Photo/Value/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,24 +25,26 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The user's profile photo. Read-only."; // Create options for all the parameters - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (FileInfo output) => { + command.SetHandler(async (FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, outputOption); + }, fileOption, outputOption); return command; } /// @@ -56,12 +58,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (FileInfo file) => { + command.SetHandler(async (FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -112,29 +113,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// The user's profile photo. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's profile photo. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Photos/Item/ProfilePhotoRequestBuilder.cs b/src/generated/Me/Photos/Item/ProfilePhotoRequestBuilder.cs index 8cf5d29b422..0be93d0c7eb 100644 --- a/src/generated/Me/Photos/Item/ProfilePhotoRequestBuilder.cs +++ b/src/generated/Me/Photos/Item/ProfilePhotoRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var profilePhotoIdOption = new Option("--profilephoto-id", description: "key: id of profilePhoto") { + var profilePhotoIdOption = new Option("--profile-photo-id", description: "key: id of profilePhoto") { }; profilePhotoIdOption.IsRequired = true; command.AddOption(profilePhotoIdOption); - command.SetHandler(async (string profilePhotoId) => { + command.SetHandler(async (string profilePhotoId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, profilePhotoIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var profilePhotoIdOption = new Option("--profilephoto-id", description: "key: id of profilePhoto") { + var profilePhotoIdOption = new Option("--profile-photo-id", description: "key: id of profilePhoto") { }; profilePhotoIdOption.IsRequired = true; command.AddOption(profilePhotoIdOption); @@ -63,19 +62,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string profilePhotoId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string profilePhotoId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, profilePhotoIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, profilePhotoIdOption, selectOption, outputOption); return command; } /// @@ -85,7 +83,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var profilePhotoIdOption = new Option("--profilephoto-id", description: "key: id of profilePhoto") { + var profilePhotoIdOption = new Option("--profile-photo-id", description: "key: id of profilePhoto") { }; profilePhotoIdOption.IsRequired = true; command.AddOption(profilePhotoIdOption); @@ -93,14 +91,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string profilePhotoId, string body) => { + command.SetHandler(async (string profilePhotoId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, profilePhotoIdOption, bodyOption); return command; @@ -172,42 +169,6 @@ public RequestInformation CreatePatchRequestInformation(ProfilePhoto body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ProfilePhoto model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Me/Photos/Item/Value/ContentRequestBuilder.cs b/src/generated/Me/Photos/Item/Value/ContentRequestBuilder.cs index 6eed30c39b3..6066f9e05d9 100644 --- a/src/generated/Me/Photos/Item/Value/ContentRequestBuilder.cs +++ b/src/generated/Me/Photos/Item/Value/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,28 +25,30 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get media content for the navigation property photos from me"; // Create options for all the parameters - var profilePhotoIdOption = new Option("--profilephoto-id", description: "key: id of profilePhoto") { + var profilePhotoIdOption = new Option("--profile-photo-id", description: "key: id of profilePhoto") { }; profilePhotoIdOption.IsRequired = true; command.AddOption(profilePhotoIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string profilePhotoId, FileInfo output) => { + command.SetHandler(async (string profilePhotoId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, profilePhotoIdOption, outputOption); + }, profilePhotoIdOption, fileOption, outputOption); return command; } /// @@ -56,7 +58,7 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "Update media content for the navigation property photos in me"; // Create options for all the parameters - var profilePhotoIdOption = new Option("--profilephoto-id", description: "key: id of profilePhoto") { + var profilePhotoIdOption = new Option("--profile-photo-id", description: "key: id of profilePhoto") { }; profilePhotoIdOption.IsRequired = true; command.AddOption(profilePhotoIdOption); @@ -64,12 +66,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string profilePhotoId, FileInfo file) => { + command.SetHandler(async (string profilePhotoId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, profilePhotoIdOption, bodyOption); return command; @@ -120,29 +121,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property photos from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property photos in me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Photos/PhotosRequestBuilder.cs b/src/generated/Me/Photos/PhotosRequestBuilder.cs index c3604f81c26..1ac82ebc3be 100644 --- a/src/generated/Me/Photos/PhotosRequestBuilder.cs +++ b/src/generated/Me/Photos/PhotosRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class PhotosRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ProfilePhotoRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -91,7 +89,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -100,15 +102,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -163,31 +160,6 @@ public RequestInformation CreatePostRequestInformation(ProfilePhoto body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ProfilePhoto model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Planner/PlannerRequestBuilder.cs b/src/generated/Me/Planner/PlannerRequestBuilder.cs index dfd792d1d6a..a051e3de881 100644 --- a/src/generated/Me/Planner/PlannerRequestBuilder.cs +++ b/src/generated/Me/Planner/PlannerRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,11 +28,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Selective Planner services available to the user. Read-only. Nullable."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -54,20 +53,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -81,14 +79,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -96,6 +93,9 @@ public Command BuildPatchCommand() { public Command BuildPlansCommand() { var command = new Command("plans"); var builder = new ApiSdk.Me.Planner.Plans.PlansRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -103,6 +103,9 @@ public Command BuildPlansCommand() { public Command BuildTasksCommand() { var command = new Command("tasks"); var builder = new ApiSdk.Me.Planner.Tasks.TasksRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -174,42 +177,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerUser body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Selective Planner services available to the user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Selective Planner services available to the user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Selective Planner services available to the user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerUser model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Selective Planner services available to the user. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Planner/Plans/Item/Buckets/BucketsRequestBuilder.cs b/src/generated/Me/Planner/Plans/Item/Buckets/BucketsRequestBuilder.cs index 283a3838f6b..de92f6d7c54 100644 --- a/src/generated/Me/Planner/Plans/Item/Buckets/BucketsRequestBuilder.cs +++ b/src/generated/Me/Planner/Plans/Item/Buckets/BucketsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class BucketsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PlannerBucketRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildTasksCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildTasksCommand()); return commands; } /// @@ -37,7 +36,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Collection of buckets in the plan. Read-only. Nullable."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, bodyOption, outputOption); return command; } /// @@ -69,7 +67,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Collection of buckets in the plan. Read-only. Nullable."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(PlannerBucket body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of buckets in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of buckets in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PlannerBucket model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of buckets in the plan. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Planner/Plans/Item/Buckets/Item/PlannerBucketRequestBuilder.cs b/src/generated/Me/Planner/Plans/Item/Buckets/Item/PlannerBucketRequestBuilder.cs index 559948f8152..64112438527 100644 --- a/src/generated/Me/Planner/Plans/Item/Buckets/Item/PlannerBucketRequestBuilder.cs +++ b/src/generated/Me/Planner/Plans/Item/Buckets/Item/PlannerBucketRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,19 +27,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Collection of buckets in the plan. Read-only. Nullable."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId) => { + command.SetHandler(async (string plannerPlanId, string plannerBucketId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerBucketIdOption); return command; @@ -51,11 +50,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Collection of buckets in the plan. Read-only. Nullable."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, plannerBucketIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, plannerBucketIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -92,11 +90,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Collection of buckets in the plan. Read-only. Nullable."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); @@ -104,14 +102,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string body) => { + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerBucketIdOption, bodyOption); return command; @@ -119,6 +116,9 @@ public Command BuildPatchCommand() { public Command BuildTasksCommand() { var command = new Command("tasks"); var builder = new ApiSdk.Me.Planner.Plans.Item.Buckets.Item.Tasks.TasksRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -190,42 +190,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerBucket body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of buckets in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of buckets in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of buckets in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerBucket model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of buckets in the plan. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Planner/Plans/Item/Buckets/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs b/src/generated/Me/Planner/Plans/Item/Buckets/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs index 4c9ed7095ca..f9be47940fd 100644 --- a/src/generated/Me/Planner/Plans/Item/Buckets/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Me/Planner/Plans/Item/Buckets/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId) => { + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string body) => { + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerAssignedToTaskBoa requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerAssignedToTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Planner/Plans/Item/Buckets/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs b/src/generated/Me/Planner/Plans/Item/Buckets/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs index 204af67804c..0f0a4c3ce92 100644 --- a/src/generated/Me/Planner/Plans/Item/Buckets/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Me/Planner/Plans/Item/Buckets/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId) => { + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string body) => { + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerBucketTaskBoardTa requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerBucketTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Planner/Plans/Item/Buckets/Item/Tasks/Item/Details/DetailsRequestBuilder.cs b/src/generated/Me/Planner/Plans/Item/Buckets/Item/Tasks/Item/Details/DetailsRequestBuilder.cs index e807b63fb12..adc82c9a551 100644 --- a/src/generated/Me/Planner/Plans/Item/Buckets/Item/Tasks/Item/Details/DetailsRequestBuilder.cs +++ b/src/generated/Me/Planner/Plans/Item/Buckets/Item/Tasks/Item/Details/DetailsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Additional details about the task."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId) => { + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Additional details about the task."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Additional details about the task."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string body) => { + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerTaskDetails body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerTaskDetails model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Additional details about the task. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Planner/Plans/Item/Buckets/Item/Tasks/Item/PlannerTaskRequestBuilder.cs b/src/generated/Me/Planner/Plans/Item/Buckets/Item/Tasks/Item/PlannerTaskRequestBuilder.cs index 8e3debfc5e8..1d03907740b 100644 --- a/src/generated/Me/Planner/Plans/Item/Buckets/Item/Tasks/Item/PlannerTaskRequestBuilder.cs +++ b/src/generated/Me/Planner/Plans/Item/Buckets/Item/Tasks/Item/PlannerTaskRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -46,23 +46,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. The collection of tasks in the bucket."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId) => { + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption); return command; @@ -82,15 +81,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. The collection of tasks in the bucket."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -104,20 +103,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -127,15 +125,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. The collection of tasks in the bucket."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -143,14 +141,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string body) => { + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, bodyOption); return command; @@ -230,42 +227,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerTask body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. The collection of tasks in the bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. The collection of tasks in the bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. The collection of tasks in the bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. The collection of tasks in the bucket. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Planner/Plans/Item/Buckets/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs b/src/generated/Me/Planner/Plans/Item/Buckets/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs index e5e862bdaa1..ea4942d8548 100644 --- a/src/generated/Me/Planner/Plans/Item/Buckets/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Me/Planner/Plans/Item/Buckets/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId) => { + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string body) => { + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerProgressTaskBoard requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerProgressTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Planner/Plans/Item/Buckets/Item/Tasks/TasksRequestBuilder.cs b/src/generated/Me/Planner/Plans/Item/Buckets/Item/Tasks/TasksRequestBuilder.cs index 1c1316b9716..a22660f7c06 100644 --- a/src/generated/Me/Planner/Plans/Item/Buckets/Item/Tasks/TasksRequestBuilder.cs +++ b/src/generated/Me/Planner/Plans/Item/Buckets/Item/Tasks/TasksRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class TasksRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PlannerTaskRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAssignedToTaskBoardFormatCommand(), - builder.BuildBucketTaskBoardFormatCommand(), - builder.BuildDeleteCommand(), - builder.BuildDetailsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildProgressTaskBoardFormatCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAssignedToTaskBoardFormatCommand()); + commands.Add(builder.BuildBucketTaskBoardFormatCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDetailsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildProgressTaskBoardFormatCommand()); return commands; } /// @@ -40,11 +39,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Read-only. Nullable. The collection of tasks in the bucket."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, plannerBucketIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, plannerBucketIdOption, bodyOption, outputOption); return command; } /// @@ -76,11 +74,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Read-only. Nullable. The collection of tasks in the bucket."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string plannerBucketId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -130,15 +132,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, plannerBucketIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, plannerBucketIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -193,31 +190,6 @@ public RequestInformation CreatePostRequestInformation(PlannerTask body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. The collection of tasks in the bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. The collection of tasks in the bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PlannerTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. The collection of tasks in the bucket. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Planner/Plans/Item/Details/DetailsRequestBuilder.cs b/src/generated/Me/Planner/Plans/Item/Details/DetailsRequestBuilder.cs index 6f75d167668..1120ad39c2f 100644 --- a/src/generated/Me/Planner/Plans/Item/Details/DetailsRequestBuilder.cs +++ b/src/generated/Me/Planner/Plans/Item/Details/DetailsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Additional details about the plan. Read-only. Nullable."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - command.SetHandler(async (string plannerPlanId) => { + command.SetHandler(async (string plannerPlanId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Additional details about the plan. Read-only. Nullable."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Additional details about the plan. Read-only. Nullable."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string body) => { + command.SetHandler(async (string plannerPlanId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerPlanDetails body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Additional details about the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Additional details about the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Additional details about the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerPlanDetails model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Additional details about the plan. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Planner/Plans/Item/PlannerPlanRequestBuilder.cs b/src/generated/Me/Planner/Plans/Item/PlannerPlanRequestBuilder.cs index f2c31766aa2..36584f0bf95 100644 --- a/src/generated/Me/Planner/Plans/Item/PlannerPlanRequestBuilder.cs +++ b/src/generated/Me/Planner/Plans/Item/PlannerPlanRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,6 +25,9 @@ public class PlannerPlanRequestBuilder { public Command BuildBucketsCommand() { var command = new Command("buckets"); var builder = new ApiSdk.Me.Planner.Plans.Item.Buckets.BucketsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -36,15 +39,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Returns the plannerTasks assigned to the user."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - command.SetHandler(async (string plannerPlanId) => { + command.SetHandler(async (string plannerPlanId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption); return command; @@ -64,7 +66,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Returns the plannerTasks assigned to the user."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -78,20 +80,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -101,7 +102,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Returns the plannerTasks assigned to the user."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -109,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string body) => { + command.SetHandler(async (string plannerPlanId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, bodyOption); return command; @@ -124,6 +124,9 @@ public Command BuildPatchCommand() { public Command BuildTasksCommand() { var command = new Command("tasks"); var builder = new ApiSdk.Me.Planner.Plans.Item.Tasks.TasksRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -195,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerPlan body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Returns the plannerTasks assigned to the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns the plannerTasks assigned to the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns the plannerTasks assigned to the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerPlan model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Returns the plannerTasks assigned to the user. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Planner/Plans/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs b/src/generated/Me/Planner/Plans/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs index 5bd5b93ccff..25a4c683dfa 100644 --- a/src/generated/Me/Planner/Plans/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Me/Planner/Plans/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId) => { + command.SetHandler(async (string plannerPlanId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerTaskIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId, string body) => { + command.SetHandler(async (string plannerPlanId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerTaskIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerAssignedToTaskBoa requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerAssignedToTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Planner/Plans/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs b/src/generated/Me/Planner/Plans/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs index def6a13991f..0af918737a3 100644 --- a/src/generated/Me/Planner/Plans/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Me/Planner/Plans/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId) => { + command.SetHandler(async (string plannerPlanId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerTaskIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId, string body) => { + command.SetHandler(async (string plannerPlanId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerTaskIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerBucketTaskBoardTa requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerBucketTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Planner/Plans/Item/Tasks/Item/Details/DetailsRequestBuilder.cs b/src/generated/Me/Planner/Plans/Item/Tasks/Item/Details/DetailsRequestBuilder.cs index 10d500a2775..db616cb6afe 100644 --- a/src/generated/Me/Planner/Plans/Item/Tasks/Item/Details/DetailsRequestBuilder.cs +++ b/src/generated/Me/Planner/Plans/Item/Tasks/Item/Details/DetailsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Additional details about the task."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId) => { + command.SetHandler(async (string plannerPlanId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerTaskIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Additional details about the task."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Additional details about the task."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId, string body) => { + command.SetHandler(async (string plannerPlanId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerTaskIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerTaskDetails body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerTaskDetails model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Additional details about the task. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Planner/Plans/Item/Tasks/Item/PlannerTaskRequestBuilder.cs b/src/generated/Me/Planner/Plans/Item/Tasks/Item/PlannerTaskRequestBuilder.cs index 752ce27938c..88b6ee38527 100644 --- a/src/generated/Me/Planner/Plans/Item/Tasks/Item/PlannerTaskRequestBuilder.cs +++ b/src/generated/Me/Planner/Plans/Item/Tasks/Item/PlannerTaskRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -46,19 +46,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Collection of tasks in the plan. Read-only. Nullable."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId) => { + command.SetHandler(async (string plannerPlanId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerTaskIdOption); return command; @@ -78,11 +77,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Collection of tasks in the plan. Read-only. Nullable."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -96,20 +95,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,11 +117,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Collection of tasks in the plan. Read-only. Nullable."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -131,14 +129,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId, string body) => { + command.SetHandler(async (string plannerPlanId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerTaskIdOption, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerTask body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of tasks in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of tasks in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of tasks in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of tasks in the plan. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Planner/Plans/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs b/src/generated/Me/Planner/Plans/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs index ec50e9ca7ef..de7e06d30ad 100644 --- a/src/generated/Me/Planner/Plans/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Me/Planner/Plans/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId) => { + command.SetHandler(async (string plannerPlanId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerTaskIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId, string body) => { + command.SetHandler(async (string plannerPlanId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerTaskIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerProgressTaskBoard requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerProgressTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Planner/Plans/Item/Tasks/TasksRequestBuilder.cs b/src/generated/Me/Planner/Plans/Item/Tasks/TasksRequestBuilder.cs index 93ded6193fa..1f573eba75a 100644 --- a/src/generated/Me/Planner/Plans/Item/Tasks/TasksRequestBuilder.cs +++ b/src/generated/Me/Planner/Plans/Item/Tasks/TasksRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class TasksRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PlannerTaskRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAssignedToTaskBoardFormatCommand(), - builder.BuildBucketTaskBoardFormatCommand(), - builder.BuildDeleteCommand(), - builder.BuildDetailsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildProgressTaskBoardFormatCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAssignedToTaskBoardFormatCommand()); + commands.Add(builder.BuildBucketTaskBoardFormatCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDetailsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildProgressTaskBoardFormatCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Collection of tasks in the plan. Read-only. Nullable."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, bodyOption, outputOption); return command; } /// @@ -72,7 +70,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Collection of tasks in the plan. Read-only. Nullable."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -122,15 +124,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -185,31 +182,6 @@ public RequestInformation CreatePostRequestInformation(PlannerTask body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of tasks in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of tasks in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PlannerTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of tasks in the plan. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Planner/Plans/PlansRequestBuilder.cs b/src/generated/Me/Planner/Plans/PlansRequestBuilder.cs index fa46177e98c..157c11b4456 100644 --- a/src/generated/Me/Planner/Plans/PlansRequestBuilder.cs +++ b/src/generated/Me/Planner/Plans/PlansRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class PlansRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PlannerPlanRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildBucketsCommand(), - builder.BuildDeleteCommand(), - builder.BuildDetailsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildTasksCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildBucketsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDetailsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildTasksCommand()); return commands; } /// @@ -43,21 +42,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -102,7 +100,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -113,15 +115,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -176,31 +173,6 @@ public RequestInformation CreatePostRequestInformation(PlannerPlan body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Returns the plannerTasks assigned to the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns the plannerTasks assigned to the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PlannerPlan model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Returns the plannerTasks assigned to the user. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Planner/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs b/src/generated/Me/Planner/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs index 4b96d797524..a08051251a1 100644 --- a/src/generated/Me/Planner/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Me/Planner/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo."; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerTaskId) => { + command.SetHandler(async (string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerTaskIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo."; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo."; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerTaskId, string body) => { + command.SetHandler(async (string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerTaskIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerAssignedToTaskBoa requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerAssignedToTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Planner/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs b/src/generated/Me/Planner/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs index ddccc97d8c5..ac9477258e7 100644 --- a/src/generated/Me/Planner/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Me/Planner/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket."; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerTaskId) => { + command.SetHandler(async (string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerTaskIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket."; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket."; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerTaskId, string body) => { + command.SetHandler(async (string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerTaskIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerBucketTaskBoardTa requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerBucketTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Planner/Tasks/Item/Details/DetailsRequestBuilder.cs b/src/generated/Me/Planner/Tasks/Item/Details/DetailsRequestBuilder.cs index 962ad6f23c1..f7ce7f8c336 100644 --- a/src/generated/Me/Planner/Tasks/Item/Details/DetailsRequestBuilder.cs +++ b/src/generated/Me/Planner/Tasks/Item/Details/DetailsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Additional details about the task."; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerTaskId) => { + command.SetHandler(async (string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerTaskIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Additional details about the task."; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Additional details about the task."; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerTaskId, string body) => { + command.SetHandler(async (string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerTaskIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerTaskDetails body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerTaskDetails model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Additional details about the task. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Planner/Tasks/Item/PlannerTaskRequestBuilder.cs b/src/generated/Me/Planner/Tasks/Item/PlannerTaskRequestBuilder.cs index 5ba6181c67e..c378c1cb572 100644 --- a/src/generated/Me/Planner/Tasks/Item/PlannerTaskRequestBuilder.cs +++ b/src/generated/Me/Planner/Tasks/Item/PlannerTaskRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -46,15 +46,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Returns the plannerTasks assigned to the user."; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerTaskId) => { + command.SetHandler(async (string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerTaskIdOption); return command; @@ -74,7 +73,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Returns the plannerTasks assigned to the user."; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -88,20 +87,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,7 +109,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Returns the plannerTasks assigned to the user."; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -119,14 +117,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerTaskId, string body) => { + command.SetHandler(async (string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerTaskIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerTask body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Returns the plannerTasks assigned to the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns the plannerTasks assigned to the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns the plannerTasks assigned to the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Returns the plannerTasks assigned to the user. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Planner/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs b/src/generated/Me/Planner/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs index 3828b52fd1f..022a52cb3d5 100644 --- a/src/generated/Me/Planner/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Me/Planner/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress."; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerTaskId) => { + command.SetHandler(async (string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerTaskIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress."; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress."; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerTaskId, string body) => { + command.SetHandler(async (string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerTaskIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerProgressTaskBoard requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerProgressTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Planner/Tasks/TasksRequestBuilder.cs b/src/generated/Me/Planner/Tasks/TasksRequestBuilder.cs index 7540755af29..2df7a01d976 100644 --- a/src/generated/Me/Planner/Tasks/TasksRequestBuilder.cs +++ b/src/generated/Me/Planner/Tasks/TasksRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class TasksRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PlannerTaskRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAssignedToTaskBoardFormatCommand(), - builder.BuildBucketTaskBoardFormatCommand(), - builder.BuildDeleteCommand(), - builder.BuildDetailsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildProgressTaskBoardFormatCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAssignedToTaskBoardFormatCommand()); + commands.Add(builder.BuildBucketTaskBoardFormatCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDetailsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildProgressTaskBoardFormatCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -103,7 +101,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -114,15 +116,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -177,31 +174,6 @@ public RequestInformation CreatePostRequestInformation(PlannerTask body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Returns the plannerTasks assigned to the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns the plannerTasks assigned to the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PlannerTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Returns the plannerTasks assigned to the user. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Presence/ClearPresence/ClearPresenceRequestBuilder.cs b/src/generated/Me/Presence/ClearPresence/ClearPresenceRequestBuilder.cs index 4d8421f4ff3..4d5bf12425d 100644 --- a/src/generated/Me/Presence/ClearPresence/ClearPresenceRequestBuilder.cs +++ b/src/generated/Me/Presence/ClearPresence/ClearPresenceRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,14 +29,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -72,18 +71,5 @@ public RequestInformation CreatePostRequestInformation(ClearPresenceRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action clearPresence - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ClearPresenceRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Presence/PresenceRequestBuilder.cs b/src/generated/Me/Presence/PresenceRequestBuilder.cs index 212e5b1b607..6c8fa4b7762 100644 --- a/src/generated/Me/Presence/PresenceRequestBuilder.cs +++ b/src/generated/Me/Presence/PresenceRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property presence for me"; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -87,14 +85,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -172,42 +169,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property presence for me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get presence from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property presence in me - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Presence model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get presence from me public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Presence/SetPresence/SetPresenceRequestBody.cs b/src/generated/Me/Presence/SetPresence/SetPresenceRequestBody.cs index 6bb3675905b..9c934119c36 100644 --- a/src/generated/Me/Presence/SetPresence/SetPresenceRequestBody.cs +++ b/src/generated/Me/Presence/SetPresence/SetPresenceRequestBody.cs @@ -9,7 +9,7 @@ public class SetPresenceRequestBody : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string Availability { get; set; } - public string ExpirationDuration { get; set; } + public TimeSpan? ExpirationDuration { get; set; } public string SessionId { get; set; } /// /// Instantiates a new setPresenceRequestBody and sets the default values. @@ -24,7 +24,7 @@ public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"activity", (o,n) => { (o as SetPresenceRequestBody).Activity = n.GetStringValue(); } }, {"availability", (o,n) => { (o as SetPresenceRequestBody).Availability = n.GetStringValue(); } }, - {"expirationDuration", (o,n) => { (o as SetPresenceRequestBody).ExpirationDuration = n.GetStringValue(); } }, + {"expirationDuration", (o,n) => { (o as SetPresenceRequestBody).ExpirationDuration = n.GetTimeSpanValue(); } }, {"sessionId", (o,n) => { (o as SetPresenceRequestBody).SessionId = n.GetStringValue(); } }, }; } @@ -36,7 +36,7 @@ public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("activity", Activity); writer.WriteStringValue("availability", Availability); - writer.WriteStringValue("expirationDuration", ExpirationDuration); + writer.WriteTimeSpanValue("expirationDuration", ExpirationDuration); writer.WriteStringValue("sessionId", SessionId); writer.WriteAdditionalData(AdditionalData); } diff --git a/src/generated/Me/Presence/SetPresence/SetPresenceRequestBuilder.cs b/src/generated/Me/Presence/SetPresence/SetPresenceRequestBuilder.cs index 4c7d49cdd63..f6c4c9eee9e 100644 --- a/src/generated/Me/Presence/SetPresence/SetPresenceRequestBuilder.cs +++ b/src/generated/Me/Presence/SetPresence/SetPresenceRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,14 +29,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -72,18 +71,5 @@ public RequestInformation CreatePostRequestInformation(SetPresenceRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setPresence - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetPresenceRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/RegisteredDevices/@Ref/@Ref.cs b/src/generated/Me/RegisteredDevices/@Ref/@Ref.cs deleted file mode 100644 index ec231ea269e..00000000000 --- a/src/generated/Me/RegisteredDevices/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.RegisteredDevices.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/RegisteredDevices/@Ref/RefRequestBuilder.cs b/src/generated/Me/RegisteredDevices/@Ref/RefRequestBuilder.cs deleted file mode 100644 index c4c11335f58..00000000000 --- a/src/generated/Me/RegisteredDevices/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,194 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Me.RegisteredDevices.@Ref { - /// Builds and executes requests for operations under \me\registeredDevices\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Devices that are registered for the user. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Devices that are registered for the user. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/registeredDevices/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Me.RegisteredDevices.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Me.RegisteredDevices.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Me/RegisteredDevices/@Ref/RefResponse.cs b/src/generated/Me/RegisteredDevices/@Ref/RefResponse.cs deleted file mode 100644 index ded724850e0..00000000000 --- a/src/generated/Me/RegisteredDevices/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.RegisteredDevices.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/RegisteredDevices/Ref/Ref.cs b/src/generated/Me/RegisteredDevices/Ref/Ref.cs new file mode 100644 index 00000000000..4b92543376c --- /dev/null +++ b/src/generated/Me/RegisteredDevices/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.RegisteredDevices.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/RegisteredDevices/Ref/RefRequestBuilder.cs b/src/generated/Me/RegisteredDevices/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..e6bc2b8ef58 --- /dev/null +++ b/src/generated/Me/RegisteredDevices/Ref/RefRequestBuilder.cs @@ -0,0 +1,167 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Me.RegisteredDevices.Ref { + /// Builds and executes requests for operations under \me\registeredDevices\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Devices that are registered for the user. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Devices that are registered for the user. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/me/registeredDevices/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Me.RegisteredDevices.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Me/RegisteredDevices/Ref/RefResponse.cs b/src/generated/Me/RegisteredDevices/Ref/RefResponse.cs new file mode 100644 index 00000000000..da7c41a0395 --- /dev/null +++ b/src/generated/Me/RegisteredDevices/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.RegisteredDevices.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/RegisteredDevices/RegisteredDevicesRequestBuilder.cs b/src/generated/Me/RegisteredDevices/RegisteredDevicesRequestBuilder.cs index ddecbebf9d3..d03e197ba51 100644 --- a/src/generated/Me/RegisteredDevices/RegisteredDevicesRequestBuilder.cs +++ b/src/generated/Me/RegisteredDevices/RegisteredDevicesRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Me.RegisteredDevices.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -61,7 +61,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -72,20 +76,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Me.RegisteredDevices.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Me.RegisteredDevices.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -124,18 +123,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/ReminderViewWithStartDateTimeWithEndDateTime/ReminderViewWithStartDateTimeWithEndDateTime.cs b/src/generated/Me/ReminderViewWithStartDateTimeWithEndDateTime/ReminderViewWithStartDateTimeWithEndDateTime.cs deleted file mode 100644 index 70ce2c51777..00000000000 --- a/src/generated/Me/ReminderViewWithStartDateTimeWithEndDateTime/ReminderViewWithStartDateTimeWithEndDateTime.cs +++ /dev/null @@ -1,65 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.ReminderViewWithStartDateTimeWithEndDateTime { - public class ReminderViewWithStartDateTimeWithEndDateTime : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Identifies the version of the reminder. Every time the reminder is changed, changeKey changes as well. This allows Exchange to apply changes to the correct version of the object. - public string ChangeKey { get; set; } - /// The date, time and time zone that the event ends. - public DateTimeTimeZone EventEndTime { get; set; } - /// The unique ID of the event. Read only. - public string EventId { get; set; } - /// The location of the event. - public Location EventLocation { get; set; } - /// The date, time, and time zone that the event starts. - public DateTimeTimeZone EventStartTime { get; set; } - /// The text of the event's subject line. - public string EventSubject { get; set; } - /// The URL to open the event in Outlook on the web.The event will open in the browser if you are logged in to your mailbox via Outlook on the web. You will be prompted to login if you are not already logged in with the browser.This URL cannot be accessed from within an iFrame. - public string EventWebLink { get; set; } - /// The date, time, and time zone that the reminder is set to occur. - public DateTimeTimeZone ReminderFireTime { get; set; } - /// - /// Instantiates a new reminderViewWithStartDateTimeWithEndDateTime and sets the default values. - /// - public ReminderViewWithStartDateTimeWithEndDateTime() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"changeKey", (o,n) => { (o as ReminderViewWithStartDateTimeWithEndDateTime).ChangeKey = n.GetStringValue(); } }, - {"eventEndTime", (o,n) => { (o as ReminderViewWithStartDateTimeWithEndDateTime).EventEndTime = n.GetObjectValue(); } }, - {"eventId", (o,n) => { (o as ReminderViewWithStartDateTimeWithEndDateTime).EventId = n.GetStringValue(); } }, - {"eventLocation", (o,n) => { (o as ReminderViewWithStartDateTimeWithEndDateTime).EventLocation = n.GetObjectValue(); } }, - {"eventStartTime", (o,n) => { (o as ReminderViewWithStartDateTimeWithEndDateTime).EventStartTime = n.GetObjectValue(); } }, - {"eventSubject", (o,n) => { (o as ReminderViewWithStartDateTimeWithEndDateTime).EventSubject = n.GetStringValue(); } }, - {"eventWebLink", (o,n) => { (o as ReminderViewWithStartDateTimeWithEndDateTime).EventWebLink = n.GetStringValue(); } }, - {"reminderFireTime", (o,n) => { (o as ReminderViewWithStartDateTimeWithEndDateTime).ReminderFireTime = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("changeKey", ChangeKey); - writer.WriteObjectValue("eventEndTime", EventEndTime); - writer.WriteStringValue("eventId", EventId); - writer.WriteObjectValue("eventLocation", EventLocation); - writer.WriteObjectValue("eventStartTime", EventStartTime); - writer.WriteStringValue("eventSubject", EventSubject); - writer.WriteStringValue("eventWebLink", EventWebLink); - writer.WriteObjectValue("reminderFireTime", ReminderFireTime); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/ReminderViewWithStartDateTimeWithEndDateTime/ReminderViewWithStartDateTimeWithEndDateTimeRequestBuilder.cs b/src/generated/Me/ReminderViewWithStartDateTimeWithEndDateTime/ReminderViewWithStartDateTimeWithEndDateTimeRequestBuilder.cs index a223ad2d800..b7de9354ebe 100644 --- a/src/generated/Me/ReminderViewWithStartDateTimeWithEndDateTime/ReminderViewWithStartDateTimeWithEndDateTimeRequestBuilder.cs +++ b/src/generated/Me/ReminderViewWithStartDateTimeWithEndDateTime/ReminderViewWithStartDateTimeWithEndDateTimeRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function reminderView"; // Create options for all the parameters - var StartDateTimeOption = new Option("--startdatetime", description: "Usage: StartDateTime={StartDateTime}") { + var StartDateTimeOption = new Option("--start-date-time", description: "Usage: StartDateTime={StartDateTime}") { }; StartDateTimeOption.IsRequired = true; command.AddOption(StartDateTimeOption); - var EndDateTimeOption = new Option("--enddatetime", description: "Usage: EndDateTime={EndDateTime}") { + var EndDateTimeOption = new Option("--end-date-time", description: "Usage: EndDateTime={EndDateTime}") { }; EndDateTimeOption.IsRequired = true; command.AddOption(EndDateTimeOption); - command.SetHandler(async (string StartDateTime, string EndDateTime) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string StartDateTime, string EndDateTime, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, StartDateTimeOption, EndDateTimeOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, StartDateTimeOption, EndDateTimeOption, outputOption); return command; } /// @@ -79,16 +79,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function reminderView - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/RemoveAllDevicesFromManagement/RemoveAllDevicesFromManagementRequestBuilder.cs b/src/generated/Me/RemoveAllDevicesFromManagement/RemoveAllDevicesFromManagementRequestBuilder.cs index 5406462e6bd..28cc0c064b8 100644 --- a/src/generated/Me/RemoveAllDevicesFromManagement/RemoveAllDevicesFromManagementRequestBuilder.cs +++ b/src/generated/Me/RemoveAllDevicesFromManagement/RemoveAllDevicesFromManagementRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,11 +25,10 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Retire all devices from management for this user"; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -62,16 +61,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Retire all devices from management for this user - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/ReprocessLicenseAssignment/ReprocessLicenseAssignmentRequestBuilder.cs b/src/generated/Me/ReprocessLicenseAssignment/ReprocessLicenseAssignmentRequestBuilder.cs index f7f78d4e191..fd58267e322 100644 --- a/src/generated/Me/ReprocessLicenseAssignment/ReprocessLicenseAssignmentRequestBuilder.cs +++ b/src/generated/Me/ReprocessLicenseAssignment/ReprocessLicenseAssignmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,18 +26,17 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action reprocessLicenseAssignment"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -68,17 +67,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action reprocessLicenseAssignment - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes user public class ReprocessLicenseAssignmentResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/Restore/RestoreRequestBuilder.cs b/src/generated/Me/Restore/RestoreRequestBuilder.cs index 767ee0f5738..6e7d433a6e8 100644 --- a/src/generated/Me/Restore/RestoreRequestBuilder.cs +++ b/src/generated/Me/Restore/RestoreRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,18 +26,17 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action restore"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -68,17 +67,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action restore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes directoryObject public class RestoreResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Me/RevokeSignInSessions/RevokeSignInSessionsRequestBuilder.cs b/src/generated/Me/RevokeSignInSessions/RevokeSignInSessionsRequestBuilder.cs index b2fda84fbc1..0516f8f4d18 100644 --- a/src/generated/Me/RevokeSignInSessions/RevokeSignInSessionsRequestBuilder.cs +++ b/src/generated/Me/RevokeSignInSessions/RevokeSignInSessionsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action revokeSignInSessions"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteBoolValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action revokeSignInSessions - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/ScopedRoleMemberOf/Item/ScopedRoleMembershipRequestBuilder.cs b/src/generated/Me/ScopedRoleMemberOf/Item/ScopedRoleMembershipRequestBuilder.cs index 06036375b6b..622e99e67f2 100644 --- a/src/generated/Me/ScopedRoleMemberOf/Item/ScopedRoleMembershipRequestBuilder.cs +++ b/src/generated/Me/ScopedRoleMemberOf/Item/ScopedRoleMembershipRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The scoped-role administrative unit memberships for this user. Read-only. Nullable."; // Create options for all the parameters - var scopedRoleMembershipIdOption = new Option("--scopedrolemembership-id", description: "key: id of scopedRoleMembership") { + var scopedRoleMembershipIdOption = new Option("--scoped-role-membership-id", description: "key: id of scopedRoleMembership") { }; scopedRoleMembershipIdOption.IsRequired = true; command.AddOption(scopedRoleMembershipIdOption); - command.SetHandler(async (string scopedRoleMembershipId) => { + command.SetHandler(async (string scopedRoleMembershipId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, scopedRoleMembershipIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The scoped-role administrative unit memberships for this user. Read-only. Nullable."; // Create options for all the parameters - var scopedRoleMembershipIdOption = new Option("--scopedrolemembership-id", description: "key: id of scopedRoleMembership") { + var scopedRoleMembershipIdOption = new Option("--scoped-role-membership-id", description: "key: id of scopedRoleMembership") { }; scopedRoleMembershipIdOption.IsRequired = true; command.AddOption(scopedRoleMembershipIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string scopedRoleMembershipId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string scopedRoleMembershipId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, scopedRoleMembershipIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, scopedRoleMembershipIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The scoped-role administrative unit memberships for this user. Read-only. Nullable."; // Create options for all the parameters - var scopedRoleMembershipIdOption = new Option("--scopedrolemembership-id", description: "key: id of scopedRoleMembership") { + var scopedRoleMembershipIdOption = new Option("--scoped-role-membership-id", description: "key: id of scopedRoleMembership") { }; scopedRoleMembershipIdOption.IsRequired = true; command.AddOption(scopedRoleMembershipIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string scopedRoleMembershipId, string body) => { + command.SetHandler(async (string scopedRoleMembershipId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, scopedRoleMembershipIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ScopedRoleMembership bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The scoped-role administrative unit memberships for this user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The scoped-role administrative unit memberships for this user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The scoped-role administrative unit memberships for this user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ScopedRoleMembership model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The scoped-role administrative unit memberships for this user. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/ScopedRoleMemberOf/ScopedRoleMemberOfRequestBuilder.cs b/src/generated/Me/ScopedRoleMemberOf/ScopedRoleMemberOfRequestBuilder.cs index e6b2456bce7..785a9b2ca39 100644 --- a/src/generated/Me/ScopedRoleMemberOf/ScopedRoleMemberOfRequestBuilder.cs +++ b/src/generated/Me/ScopedRoleMemberOf/ScopedRoleMemberOfRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ScopedRoleMemberOfRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ScopedRoleMembershipRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(ScopedRoleMembership body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The scoped-role administrative unit memberships for this user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The scoped-role administrative unit memberships for this user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ScopedRoleMembership model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The scoped-role administrative unit memberships for this user. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/SendMail/SendMailRequestBuilder.cs b/src/generated/Me/SendMail/SendMailRequestBuilder.cs index f9bf2fcea12..cb74d861e45 100644 --- a/src/generated/Me/SendMail/SendMailRequestBuilder.cs +++ b/src/generated/Me/SendMail/SendMailRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,14 +29,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -72,18 +71,5 @@ public RequestInformation CreatePostRequestInformation(SendMailRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action sendMail - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SendMailRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Settings/SettingsRequestBuilder.cs b/src/generated/Me/Settings/SettingsRequestBuilder.cs index 01dd70e62b1..b8a1e316ed3 100644 --- a/src/generated/Me/Settings/SettingsRequestBuilder.cs +++ b/src/generated/Me/Settings/SettingsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,11 +27,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -53,20 +52,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -80,14 +78,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -167,42 +164,6 @@ public RequestInformation CreatePatchRequestInformation(UserSettings body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(UserSettings model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Settings/ShiftPreferences/ShiftPreferencesRequestBuilder.cs b/src/generated/Me/Settings/ShiftPreferences/ShiftPreferencesRequestBuilder.cs index 7968616eca2..09783b7bd16 100644 --- a/src/generated/Me/Settings/ShiftPreferences/ShiftPreferencesRequestBuilder.cs +++ b/src/generated/Me/Settings/ShiftPreferences/ShiftPreferencesRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The shift preferences for the user."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -52,20 +51,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -79,14 +77,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -158,42 +155,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The shift preferences for the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The shift preferences for the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The shift preferences for the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.ShiftPreferences model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The shift preferences for the user. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Teamwork/InstalledApps/InstalledAppsRequestBuilder.cs b/src/generated/Me/Teamwork/InstalledApps/InstalledAppsRequestBuilder.cs index 49c254fd19a..1f2afec128c 100644 --- a/src/generated/Me/Teamwork/InstalledApps/InstalledAppsRequestBuilder.cs +++ b/src/generated/Me/Teamwork/InstalledApps/InstalledAppsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class InstalledAppsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new UserScopeTeamsAppInstallationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildChatCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildChatCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(UserScopeTeamsAppInstalla requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The apps installed in the personal scope of this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The apps installed in the personal scope of this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UserScopeTeamsAppInstallation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The apps installed in the personal scope of this user. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Teamwork/InstalledApps/Item/Chat/@Ref/@Ref.cs b/src/generated/Me/Teamwork/InstalledApps/Item/Chat/@Ref/@Ref.cs deleted file mode 100644 index ffc1b586457..00000000000 --- a/src/generated/Me/Teamwork/InstalledApps/Item/Chat/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.Teamwork.InstalledApps.Item.Chat.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/Teamwork/InstalledApps/Item/Chat/@Ref/RefRequestBuilder.cs b/src/generated/Me/Teamwork/InstalledApps/Item/Chat/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 1163c1d742d..00000000000 --- a/src/generated/Me/Teamwork/InstalledApps/Item/Chat/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Me.Teamwork.InstalledApps.Item.Chat.@Ref { - /// Builds and executes requests for operations under \me\teamwork\installedApps\{userScopeTeamsAppInstallation-id}\chat\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The chat between the user and Teams app. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The chat between the user and Teams app."; - // Create options for all the parameters - var userScopeTeamsAppInstallationIdOption = new Option("--userscopeteamsappinstallation-id", description: "key: id of userScopeTeamsAppInstallation") { - }; - userScopeTeamsAppInstallationIdOption.IsRequired = true; - command.AddOption(userScopeTeamsAppInstallationIdOption); - command.SetHandler(async (string userScopeTeamsAppInstallationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userScopeTeamsAppInstallationIdOption); - return command; - } - /// - /// The chat between the user and Teams app. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The chat between the user and Teams app."; - // Create options for all the parameters - var userScopeTeamsAppInstallationIdOption = new Option("--userscopeteamsappinstallation-id", description: "key: id of userScopeTeamsAppInstallation") { - }; - userScopeTeamsAppInstallationIdOption.IsRequired = true; - command.AddOption(userScopeTeamsAppInstallationIdOption); - command.SetHandler(async (string userScopeTeamsAppInstallationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userScopeTeamsAppInstallationIdOption); - return command; - } - /// - /// The chat between the user and Teams app. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The chat between the user and Teams app."; - // Create options for all the parameters - var userScopeTeamsAppInstallationIdOption = new Option("--userscopeteamsappinstallation-id", description: "key: id of userScopeTeamsAppInstallation") { - }; - userScopeTeamsAppInstallationIdOption.IsRequired = true; - command.AddOption(userScopeTeamsAppInstallationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string userScopeTeamsAppInstallationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userScopeTeamsAppInstallationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/teamwork/installedApps/{userScopeTeamsAppInstallation_id}/chat/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The chat between the user and Teams app. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The chat between the user and Teams app. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The chat between the user and Teams app. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Me.Teamwork.InstalledApps.Item.Chat.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The chat between the user and Teams app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The chat between the user and Teams app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The chat between the user and Teams app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Me.Teamwork.InstalledApps.Item.Chat.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Me/Teamwork/InstalledApps/Item/Chat/ChatRequestBuilder.cs b/src/generated/Me/Teamwork/InstalledApps/Item/Chat/ChatRequestBuilder.cs index e2f4459fc53..0da8276b19b 100644 --- a/src/generated/Me/Teamwork/InstalledApps/Item/Chat/ChatRequestBuilder.cs +++ b/src/generated/Me/Teamwork/InstalledApps/Item/Chat/ChatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The chat between the user and Teams app."; // Create options for all the parameters - var userScopeTeamsAppInstallationIdOption = new Option("--userscopeteamsappinstallation-id", description: "key: id of userScopeTeamsAppInstallation") { + var userScopeTeamsAppInstallationIdOption = new Option("--user-scope-teams-app-installation-id", description: "key: id of userScopeTeamsAppInstallation") { }; userScopeTeamsAppInstallationIdOption.IsRequired = true; command.AddOption(userScopeTeamsAppInstallationIdOption); @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userScopeTeamsAppInstallationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userScopeTeamsAppInstallationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userScopeTeamsAppInstallationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userScopeTeamsAppInstallationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Me.Teamwork.InstalledApps.Item.Chat.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Me.Teamwork.InstalledApps.Item.Chat.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The chat between the user and Teams app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The chat between the user and Teams app. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Teamwork/InstalledApps/Item/Chat/Ref/Ref.cs b/src/generated/Me/Teamwork/InstalledApps/Item/Chat/Ref/Ref.cs new file mode 100644 index 00000000000..a2fa511e42e --- /dev/null +++ b/src/generated/Me/Teamwork/InstalledApps/Item/Chat/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.Teamwork.InstalledApps.Item.Chat.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/Teamwork/InstalledApps/Item/Chat/Ref/RefRequestBuilder.cs b/src/generated/Me/Teamwork/InstalledApps/Item/Chat/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..72407a9aa06 --- /dev/null +++ b/src/generated/Me/Teamwork/InstalledApps/Item/Chat/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Me.Teamwork.InstalledApps.Item.Chat.Ref { + /// Builds and executes requests for operations under \me\teamwork\installedApps\{userScopeTeamsAppInstallation-id}\chat\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The chat between the user and Teams app. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The chat between the user and Teams app."; + // Create options for all the parameters + var userScopeTeamsAppInstallationIdOption = new Option("--user-scope-teams-app-installation-id", description: "key: id of userScopeTeamsAppInstallation") { + }; + userScopeTeamsAppInstallationIdOption.IsRequired = true; + command.AddOption(userScopeTeamsAppInstallationIdOption); + command.SetHandler(async (string userScopeTeamsAppInstallationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, userScopeTeamsAppInstallationIdOption); + return command; + } + /// + /// The chat between the user and Teams app. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The chat between the user and Teams app."; + // Create options for all the parameters + var userScopeTeamsAppInstallationIdOption = new Option("--user-scope-teams-app-installation-id", description: "key: id of userScopeTeamsAppInstallation") { + }; + userScopeTeamsAppInstallationIdOption.IsRequired = true; + command.AddOption(userScopeTeamsAppInstallationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userScopeTeamsAppInstallationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userScopeTeamsAppInstallationIdOption, outputOption); + return command; + } + /// + /// The chat between the user and Teams app. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The chat between the user and Teams app."; + // Create options for all the parameters + var userScopeTeamsAppInstallationIdOption = new Option("--user-scope-teams-app-installation-id", description: "key: id of userScopeTeamsAppInstallation") { + }; + userScopeTeamsAppInstallationIdOption.IsRequired = true; + command.AddOption(userScopeTeamsAppInstallationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string userScopeTeamsAppInstallationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, userScopeTeamsAppInstallationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/me/teamwork/installedApps/{userScopeTeamsAppInstallation_id}/chat/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The chat between the user and Teams app. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The chat between the user and Teams app. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The chat between the user and Teams app. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Me.Teamwork.InstalledApps.Item.Chat.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Me/Teamwork/InstalledApps/Item/UserScopeTeamsAppInstallationRequestBuilder.cs b/src/generated/Me/Teamwork/InstalledApps/Item/UserScopeTeamsAppInstallationRequestBuilder.cs index 94e76a49a0c..d3e19dca6f5 100644 --- a/src/generated/Me/Teamwork/InstalledApps/Item/UserScopeTeamsAppInstallationRequestBuilder.cs +++ b/src/generated/Me/Teamwork/InstalledApps/Item/UserScopeTeamsAppInstallationRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The apps installed in the personal scope of this user."; // Create options for all the parameters - var userScopeTeamsAppInstallationIdOption = new Option("--userscopeteamsappinstallation-id", description: "key: id of userScopeTeamsAppInstallation") { + var userScopeTeamsAppInstallationIdOption = new Option("--user-scope-teams-app-installation-id", description: "key: id of userScopeTeamsAppInstallation") { }; userScopeTeamsAppInstallationIdOption.IsRequired = true; command.AddOption(userScopeTeamsAppInstallationIdOption); - command.SetHandler(async (string userScopeTeamsAppInstallationId) => { + command.SetHandler(async (string userScopeTeamsAppInstallationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userScopeTeamsAppInstallationIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The apps installed in the personal scope of this user."; // Create options for all the parameters - var userScopeTeamsAppInstallationIdOption = new Option("--userscopeteamsappinstallation-id", description: "key: id of userScopeTeamsAppInstallation") { + var userScopeTeamsAppInstallationIdOption = new Option("--user-scope-teams-app-installation-id", description: "key: id of userScopeTeamsAppInstallation") { }; userScopeTeamsAppInstallationIdOption.IsRequired = true; command.AddOption(userScopeTeamsAppInstallationIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userScopeTeamsAppInstallationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userScopeTeamsAppInstallationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userScopeTeamsAppInstallationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userScopeTeamsAppInstallationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,7 +89,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The apps installed in the personal scope of this user."; // Create options for all the parameters - var userScopeTeamsAppInstallationIdOption = new Option("--userscopeteamsappinstallation-id", description: "key: id of userScopeTeamsAppInstallation") { + var userScopeTeamsAppInstallationIdOption = new Option("--user-scope-teams-app-installation-id", description: "key: id of userScopeTeamsAppInstallation") { }; userScopeTeamsAppInstallationIdOption.IsRequired = true; command.AddOption(userScopeTeamsAppInstallationIdOption); @@ -99,14 +97,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userScopeTeamsAppInstallationId, string body) => { + command.SetHandler(async (string userScopeTeamsAppInstallationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userScopeTeamsAppInstallationIdOption, bodyOption); return command; @@ -178,42 +175,6 @@ public RequestInformation CreatePatchRequestInformation(UserScopeTeamsAppInstall requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The apps installed in the personal scope of this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The apps installed in the personal scope of this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The apps installed in the personal scope of this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(UserScopeTeamsAppInstallation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The apps installed in the personal scope of this user. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Teamwork/SendActivityNotification/SendActivityNotificationRequestBuilder.cs b/src/generated/Me/Teamwork/SendActivityNotification/SendActivityNotificationRequestBuilder.cs index 2bba96ee00b..0a2957243ad 100644 --- a/src/generated/Me/Teamwork/SendActivityNotification/SendActivityNotificationRequestBuilder.cs +++ b/src/generated/Me/Teamwork/SendActivityNotification/SendActivityNotificationRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,14 +29,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -72,18 +71,5 @@ public RequestInformation CreatePostRequestInformation(SendActivityNotificationR requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action sendActivityNotification - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SendActivityNotificationRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Teamwork/TeamworkRequestBuilder.cs b/src/generated/Me/Teamwork/TeamworkRequestBuilder.cs index 20434778db0..ec8fc2dd9fc 100644 --- a/src/generated/Me/Teamwork/TeamworkRequestBuilder.cs +++ b/src/generated/Me/Teamwork/TeamworkRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,11 +28,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "A container for Microsoft Teams features available for the user. Read-only. Nullable."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -54,25 +53,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } public Command BuildInstalledAppsCommand() { var command = new Command("installed-apps"); var builder = new ApiSdk.Me.Teamwork.InstalledApps.InstalledAppsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -88,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -173,42 +173,6 @@ public RequestInformation CreatePatchRequestInformation(UserTeamwork body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A container for Microsoft Teams features available for the user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A container for Microsoft Teams features available for the user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A container for Microsoft Teams features available for the user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(UserTeamwork model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A container for Microsoft Teams features available for the user. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Todo/Lists/Delta/DeltaRequestBuilder.cs b/src/generated/Me/Todo/Lists/Delta/DeltaRequestBuilder.cs index 3c098cbe63c..1895145f7ee 100644 --- a/src/generated/Me/Todo/Lists/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/Todo/Lists/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Todo/Lists/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Me/Todo/Lists/Item/Extensions/ExtensionsRequestBuilder.cs index 47beeb71dc1..5734764d4cf 100644 --- a/src/generated/Me/Todo/Lists/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Me/Todo/Lists/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of open extensions defined for the task list. Nullable."; // Create options for all the parameters - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string todoTaskListId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string todoTaskListId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, todoTaskListIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, todoTaskListIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of open extensions defined for the task list. Nullable."; // Create options for all the parameters - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string todoTaskListId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string todoTaskListId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, todoTaskListIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, todoTaskListIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the task list. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the task list. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the task list. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Todo/Lists/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Me/Todo/Lists/Item/Extensions/Item/ExtensionRequestBuilder.cs index 462dc7dc62e..710e7b9b65b 100644 --- a/src/generated/Me/Todo/Lists/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Me/Todo/Lists/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of open extensions defined for the task list. Nullable."; // Create options for all the parameters - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string todoTaskListId, string extensionId) => { + command.SetHandler(async (string todoTaskListId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, todoTaskListIdOption, extensionIdOption); return command; @@ -50,7 +49,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of open extensions defined for the task list. Nullable."; // Create options for all the parameters - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string todoTaskListId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string todoTaskListId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, todoTaskListIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, todoTaskListIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,7 +89,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of open extensions defined for the task list. Nullable."; // Create options for all the parameters - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string todoTaskListId, string extensionId, string body) => { + command.SetHandler(async (string todoTaskListId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, todoTaskListIdOption, extensionIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the task list. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the task list. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the task list. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the task list. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Todo/Lists/Item/Tasks/Delta/DeltaRequestBuilder.cs b/src/generated/Me/Todo/Lists/Item/Tasks/Delta/DeltaRequestBuilder.cs index 9b2193cd876..4f0a022699e 100644 --- a/src/generated/Me/Todo/Lists/Item/Tasks/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Me/Todo/Lists/Item/Tasks/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,22 +25,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - command.SetHandler(async (string todoTaskListId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string todoTaskListId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, todoTaskListIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, todoTaskListIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/Todo/Lists/Item/Tasks/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Me/Todo/Lists/Item/Tasks/Item/Extensions/ExtensionsRequestBuilder.cs index 88d2b3f4c10..7e489b8f9b8 100644 --- a/src/generated/Me/Todo/Lists/Item/Tasks/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Me/Todo/Lists/Item/Tasks/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,11 +35,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of open extensions defined for the task. Nullable."; // Create options for all the parameters - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - var todoTaskIdOption = new Option("--todotask-id", description: "key: id of todoTask") { + var todoTaskIdOption = new Option("--todo-task-id", description: "key: id of todoTask") { }; todoTaskIdOption.IsRequired = true; command.AddOption(todoTaskIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string todoTaskListId, string todoTaskId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string todoTaskListId, string todoTaskId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, todoTaskListIdOption, todoTaskIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, todoTaskListIdOption, todoTaskIdOption, bodyOption, outputOption); return command; } /// @@ -72,11 +70,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of open extensions defined for the task. Nullable."; // Create options for all the parameters - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - var todoTaskIdOption = new Option("--todotask-id", description: "key: id of todoTask") { + var todoTaskIdOption = new Option("--todo-task-id", description: "key: id of todoTask") { }; todoTaskIdOption.IsRequired = true; command.AddOption(todoTaskIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string todoTaskListId, string todoTaskId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string todoTaskListId, string todoTaskId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, todoTaskListIdOption, todoTaskIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, todoTaskListIdOption, todoTaskIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the task. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the task. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the task. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Todo/Lists/Item/Tasks/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Me/Todo/Lists/Item/Tasks/Item/Extensions/Item/ExtensionRequestBuilder.cs index 62891ed9c31..497d3208f8e 100644 --- a/src/generated/Me/Todo/Lists/Item/Tasks/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Me/Todo/Lists/Item/Tasks/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of open extensions defined for the task. Nullable."; // Create options for all the parameters - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - var todoTaskIdOption = new Option("--todotask-id", description: "key: id of todoTask") { + var todoTaskIdOption = new Option("--todo-task-id", description: "key: id of todoTask") { }; todoTaskIdOption.IsRequired = true; command.AddOption(todoTaskIdOption); @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string todoTaskListId, string todoTaskId, string extensionId) => { + command.SetHandler(async (string todoTaskListId, string todoTaskId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, todoTaskListIdOption, todoTaskIdOption, extensionIdOption); return command; @@ -54,11 +53,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of open extensions defined for the task. Nullable."; // Create options for all the parameters - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - var todoTaskIdOption = new Option("--todotask-id", description: "key: id of todoTask") { + var todoTaskIdOption = new Option("--todo-task-id", description: "key: id of todoTask") { }; todoTaskIdOption.IsRequired = true; command.AddOption(todoTaskIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string todoTaskListId, string todoTaskId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string todoTaskListId, string todoTaskId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, todoTaskListIdOption, todoTaskIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, todoTaskListIdOption, todoTaskIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,11 +97,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of open extensions defined for the task. Nullable."; // Create options for all the parameters - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - var todoTaskIdOption = new Option("--todotask-id", description: "key: id of todoTask") { + var todoTaskIdOption = new Option("--todo-task-id", description: "key: id of todoTask") { }; todoTaskIdOption.IsRequired = true; command.AddOption(todoTaskIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string todoTaskListId, string todoTaskId, string extensionId, string body) => { + command.SetHandler(async (string todoTaskListId, string todoTaskId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, todoTaskListIdOption, todoTaskIdOption, extensionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the task. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the task. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the task. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the task. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Todo/Lists/Item/Tasks/Item/LinkedResources/Item/LinkedResourceRequestBuilder.cs b/src/generated/Me/Todo/Lists/Item/Tasks/Item/LinkedResources/Item/LinkedResourceRequestBuilder.cs index d904ab9e396..f67505d6687 100644 --- a/src/generated/Me/Todo/Lists/Item/Tasks/Item/LinkedResources/Item/LinkedResourceRequestBuilder.cs +++ b/src/generated/Me/Todo/Lists/Item/Tasks/Item/LinkedResources/Item/LinkedResourceRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "A collection of resources linked to the task."; // Create options for all the parameters - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - var todoTaskIdOption = new Option("--todotask-id", description: "key: id of todoTask") { + var todoTaskIdOption = new Option("--todo-task-id", description: "key: id of todoTask") { }; todoTaskIdOption.IsRequired = true; command.AddOption(todoTaskIdOption); - var linkedResourceIdOption = new Option("--linkedresource-id", description: "key: id of linkedResource") { + var linkedResourceIdOption = new Option("--linked-resource-id", description: "key: id of linkedResource") { }; linkedResourceIdOption.IsRequired = true; command.AddOption(linkedResourceIdOption); - command.SetHandler(async (string todoTaskListId, string todoTaskId, string linkedResourceId) => { + command.SetHandler(async (string todoTaskListId, string todoTaskId, string linkedResourceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, todoTaskListIdOption, todoTaskIdOption, linkedResourceIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "A collection of resources linked to the task."; // Create options for all the parameters - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - var todoTaskIdOption = new Option("--todotask-id", description: "key: id of todoTask") { + var todoTaskIdOption = new Option("--todo-task-id", description: "key: id of todoTask") { }; todoTaskIdOption.IsRequired = true; command.AddOption(todoTaskIdOption); - var linkedResourceIdOption = new Option("--linkedresource-id", description: "key: id of linkedResource") { + var linkedResourceIdOption = new Option("--linked-resource-id", description: "key: id of linkedResource") { }; linkedResourceIdOption.IsRequired = true; command.AddOption(linkedResourceIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string todoTaskListId, string todoTaskId, string linkedResourceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string todoTaskListId, string todoTaskId, string linkedResourceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, todoTaskListIdOption, todoTaskIdOption, linkedResourceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, todoTaskListIdOption, todoTaskIdOption, linkedResourceIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "A collection of resources linked to the task."; // Create options for all the parameters - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - var todoTaskIdOption = new Option("--todotask-id", description: "key: id of todoTask") { + var todoTaskIdOption = new Option("--todo-task-id", description: "key: id of todoTask") { }; todoTaskIdOption.IsRequired = true; command.AddOption(todoTaskIdOption); - var linkedResourceIdOption = new Option("--linkedresource-id", description: "key: id of linkedResource") { + var linkedResourceIdOption = new Option("--linked-resource-id", description: "key: id of linkedResource") { }; linkedResourceIdOption.IsRequired = true; command.AddOption(linkedResourceIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string todoTaskListId, string todoTaskId, string linkedResourceId, string body) => { + command.SetHandler(async (string todoTaskListId, string todoTaskId, string linkedResourceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, todoTaskListIdOption, todoTaskIdOption, linkedResourceIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(LinkedResource body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of resources linked to the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of resources linked to the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of resources linked to the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(LinkedResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of resources linked to the task. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Todo/Lists/Item/Tasks/Item/LinkedResources/LinkedResourcesRequestBuilder.cs b/src/generated/Me/Todo/Lists/Item/Tasks/Item/LinkedResources/LinkedResourcesRequestBuilder.cs index 03c6e38c68c..220c787fd87 100644 --- a/src/generated/Me/Todo/Lists/Item/Tasks/Item/LinkedResources/LinkedResourcesRequestBuilder.cs +++ b/src/generated/Me/Todo/Lists/Item/Tasks/Item/LinkedResources/LinkedResourcesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class LinkedResourcesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new LinkedResourceRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,11 +35,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "A collection of resources linked to the task."; // Create options for all the parameters - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - var todoTaskIdOption = new Option("--todotask-id", description: "key: id of todoTask") { + var todoTaskIdOption = new Option("--todo-task-id", description: "key: id of todoTask") { }; todoTaskIdOption.IsRequired = true; command.AddOption(todoTaskIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string todoTaskListId, string todoTaskId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string todoTaskListId, string todoTaskId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, todoTaskListIdOption, todoTaskIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, todoTaskListIdOption, todoTaskIdOption, bodyOption, outputOption); return command; } /// @@ -72,11 +70,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "A collection of resources linked to the task."; // Create options for all the parameters - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - var todoTaskIdOption = new Option("--todotask-id", description: "key: id of todoTask") { + var todoTaskIdOption = new Option("--todo-task-id", description: "key: id of todoTask") { }; todoTaskIdOption.IsRequired = true; command.AddOption(todoTaskIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string todoTaskListId, string todoTaskId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string todoTaskListId, string todoTaskId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, todoTaskListIdOption, todoTaskIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, todoTaskListIdOption, todoTaskIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(LinkedResource body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of resources linked to the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of resources linked to the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(LinkedResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of resources linked to the task. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Todo/Lists/Item/Tasks/Item/TodoTaskRequestBuilder.cs b/src/generated/Me/Todo/Lists/Item/Tasks/Item/TodoTaskRequestBuilder.cs index 667394a7dc5..ee2be402421 100644 --- a/src/generated/Me/Todo/Lists/Item/Tasks/Item/TodoTaskRequestBuilder.cs +++ b/src/generated/Me/Todo/Lists/Item/Tasks/Item/TodoTaskRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,19 +28,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The tasks in this task list. Read-only. Nullable."; // Create options for all the parameters - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - var todoTaskIdOption = new Option("--todotask-id", description: "key: id of todoTask") { + var todoTaskIdOption = new Option("--todo-task-id", description: "key: id of todoTask") { }; todoTaskIdOption.IsRequired = true; command.AddOption(todoTaskIdOption); - command.SetHandler(async (string todoTaskListId, string todoTaskId) => { + command.SetHandler(async (string todoTaskListId, string todoTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, todoTaskListIdOption, todoTaskIdOption); return command; @@ -48,6 +47,9 @@ public Command BuildDeleteCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Me.Todo.Lists.Item.Tasks.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -59,11 +61,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The tasks in this task list. Read-only. Nullable."; // Create options for all the parameters - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - var todoTaskIdOption = new Option("--todotask-id", description: "key: id of todoTask") { + var todoTaskIdOption = new Option("--todo-task-id", description: "key: id of todoTask") { }; todoTaskIdOption.IsRequired = true; command.AddOption(todoTaskIdOption); @@ -77,25 +79,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string todoTaskListId, string todoTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string todoTaskListId, string todoTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, todoTaskListIdOption, todoTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, todoTaskListIdOption, todoTaskIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLinkedResourcesCommand() { var command = new Command("linked-resources"); var builder = new ApiSdk.Me.Todo.Lists.Item.Tasks.Item.LinkedResources.LinkedResourcesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -107,11 +111,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The tasks in this task list. Read-only. Nullable."; // Create options for all the parameters - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - var todoTaskIdOption = new Option("--todotask-id", description: "key: id of todoTask") { + var todoTaskIdOption = new Option("--todo-task-id", description: "key: id of todoTask") { }; todoTaskIdOption.IsRequired = true; command.AddOption(todoTaskIdOption); @@ -119,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string todoTaskListId, string todoTaskId, string body) => { + command.SetHandler(async (string todoTaskListId, string todoTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, todoTaskListIdOption, todoTaskIdOption, bodyOption); return command; @@ -198,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(TodoTask body, Action - /// The tasks in this task list. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The tasks in this task list. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The tasks in this task list. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(TodoTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The tasks in this task list. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Todo/Lists/Item/Tasks/TasksRequestBuilder.cs b/src/generated/Me/Todo/Lists/Item/Tasks/TasksRequestBuilder.cs index b32b60bf0d3..47243fa327d 100644 --- a/src/generated/Me/Todo/Lists/Item/Tasks/TasksRequestBuilder.cs +++ b/src/generated/Me/Todo/Lists/Item/Tasks/TasksRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,13 +23,12 @@ public class TasksRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TodoTaskRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildExtensionsCommand(), - builder.BuildGetCommand(), - builder.BuildLinkedResourcesCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildLinkedResourcesCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -39,7 +38,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The tasks in this task list. Read-only. Nullable."; // Create options for all the parameters - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); @@ -47,21 +46,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string todoTaskListId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string todoTaskListId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, todoTaskListIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, todoTaskListIdOption, bodyOption, outputOption); return command; } /// @@ -71,7 +69,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The tasks in this task list. Read-only. Nullable."; // Create options for all the parameters - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); @@ -110,7 +108,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string todoTaskListId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string todoTaskListId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, todoTaskListIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, todoTaskListIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -190,31 +187,6 @@ public RequestInformation CreatePostRequestInformation(TodoTask body, Action - /// The tasks in this task list. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The tasks in this task list. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TodoTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The tasks in this task list. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Todo/Lists/Item/TodoTaskListRequestBuilder.cs b/src/generated/Me/Todo/Lists/Item/TodoTaskListRequestBuilder.cs index 59cae0f3854..173716a7649 100644 --- a/src/generated/Me/Todo/Lists/Item/TodoTaskListRequestBuilder.cs +++ b/src/generated/Me/Todo/Lists/Item/TodoTaskListRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,15 +28,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The task lists in the users mailbox."; // Create options for all the parameters - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - command.SetHandler(async (string todoTaskListId) => { + command.SetHandler(async (string todoTaskListId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, todoTaskListIdOption); return command; @@ -44,6 +43,9 @@ public Command BuildDeleteCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Me.Todo.Lists.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -55,7 +57,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The task lists in the users mailbox."; // Create options for all the parameters - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); @@ -69,20 +71,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string todoTaskListId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string todoTaskListId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, todoTaskListIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, todoTaskListIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -92,7 +93,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The task lists in the users mailbox."; // Create options for all the parameters - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); @@ -100,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string todoTaskListId, string body) => { + command.SetHandler(async (string todoTaskListId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, todoTaskListIdOption, bodyOption); return command; @@ -115,6 +115,9 @@ public Command BuildPatchCommand() { public Command BuildTasksCommand() { var command = new Command("tasks"); var builder = new ApiSdk.Me.Todo.Lists.Item.Tasks.TasksRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -186,42 +189,6 @@ public RequestInformation CreatePatchRequestInformation(TodoTaskList body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The task lists in the users mailbox. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The task lists in the users mailbox. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The task lists in the users mailbox. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(TodoTaskList model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The task lists in the users mailbox. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/Todo/Lists/ListsRequestBuilder.cs b/src/generated/Me/Todo/Lists/ListsRequestBuilder.cs index 04087f879ab..b377d31facd 100644 --- a/src/generated/Me/Todo/Lists/ListsRequestBuilder.cs +++ b/src/generated/Me/Todo/Lists/ListsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,13 +23,12 @@ public class ListsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TodoTaskListRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildExtensionsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildTasksCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildTasksCommand()); return commands; } /// @@ -43,21 +42,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -102,7 +100,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -113,15 +115,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(TodoTaskList body, Action public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// The task lists in the users mailbox. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The task lists in the users mailbox. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TodoTaskList model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The task lists in the users mailbox. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/Todo/TodoRequestBuilder.cs b/src/generated/Me/Todo/TodoRequestBuilder.cs index b821110bc6c..9aa34d7ed45 100644 --- a/src/generated/Me/Todo/TodoRequestBuilder.cs +++ b/src/generated/Me/Todo/TodoRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,11 +27,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the To Do services available to a user."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -53,25 +52,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } public Command BuildListsCommand() { var command = new Command("lists"); var builder = new ApiSdk.Me.Todo.Lists.ListsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -87,14 +88,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -166,42 +166,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the To Do services available to a user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the To Do services available to a user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the To Do services available to a user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Todo model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the To Do services available to a user. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Me/TransitiveMemberOf/@Ref/@Ref.cs b/src/generated/Me/TransitiveMemberOf/@Ref/@Ref.cs deleted file mode 100644 index 443c309ed61..00000000000 --- a/src/generated/Me/TransitiveMemberOf/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.TransitiveMemberOf.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/TransitiveMemberOf/@Ref/RefRequestBuilder.cs b/src/generated/Me/TransitiveMemberOf/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 9057d7dfa30..00000000000 --- a/src/generated/Me/TransitiveMemberOf/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,194 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Me.TransitiveMemberOf.@Ref { - /// Builds and executes requests for operations under \me\transitiveMemberOf\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Get ref of transitiveMemberOf from me - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Get ref of transitiveMemberOf from me"; - // Create options for all the parameters - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Create new navigation property ref to transitiveMemberOf for me - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Create new navigation property ref to transitiveMemberOf for me"; - // Create options for all the parameters - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/me/transitiveMemberOf/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Get ref of transitiveMemberOf from me - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Create new navigation property ref to transitiveMemberOf for me - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Me.TransitiveMemberOf.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Get ref of transitiveMemberOf from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property ref to transitiveMemberOf for me - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Me.TransitiveMemberOf.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Get ref of transitiveMemberOf from me - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Me/TransitiveMemberOf/@Ref/RefResponse.cs b/src/generated/Me/TransitiveMemberOf/@Ref/RefResponse.cs deleted file mode 100644 index 87098f4a510..00000000000 --- a/src/generated/Me/TransitiveMemberOf/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.TransitiveMemberOf.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/TransitiveMemberOf/Ref/Ref.cs b/src/generated/Me/TransitiveMemberOf/Ref/Ref.cs new file mode 100644 index 00000000000..08ec6ab1fe1 --- /dev/null +++ b/src/generated/Me/TransitiveMemberOf/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.TransitiveMemberOf.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/TransitiveMemberOf/Ref/RefRequestBuilder.cs b/src/generated/Me/TransitiveMemberOf/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..da30a309b49 --- /dev/null +++ b/src/generated/Me/TransitiveMemberOf/Ref/RefRequestBuilder.cs @@ -0,0 +1,167 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Me.TransitiveMemberOf.Ref { + /// Builds and executes requests for operations under \me\transitiveMemberOf\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Get ref of transitiveMemberOf from me + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Get ref of transitiveMemberOf from me"; + // Create options for all the parameters + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Create new navigation property ref to transitiveMemberOf for me + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Create new navigation property ref to transitiveMemberOf for me"; + // Create options for all the parameters + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/me/transitiveMemberOf/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Get ref of transitiveMemberOf from me + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Create new navigation property ref to transitiveMemberOf for me + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Me.TransitiveMemberOf.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Get ref of transitiveMemberOf from me + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Me/TransitiveMemberOf/Ref/RefResponse.cs b/src/generated/Me/TransitiveMemberOf/Ref/RefResponse.cs new file mode 100644 index 00000000000..406f1185a0b --- /dev/null +++ b/src/generated/Me/TransitiveMemberOf/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Me.TransitiveMemberOf.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Me/TransitiveMemberOf/TransitiveMemberOfRequestBuilder.cs b/src/generated/Me/TransitiveMemberOf/TransitiveMemberOfRequestBuilder.cs index 17edacaa720..fc6f183e8ab 100644 --- a/src/generated/Me/TransitiveMemberOf/TransitiveMemberOfRequestBuilder.cs +++ b/src/generated/Me/TransitiveMemberOf/TransitiveMemberOfRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Me.TransitiveMemberOf.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -61,7 +61,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -72,20 +76,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Me.TransitiveMemberOf.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Me.TransitiveMemberOf.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -124,18 +123,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get transitiveMemberOf from me - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get transitiveMemberOf from me public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Me/TranslateExchangeIds/TranslateExchangeIds.cs b/src/generated/Me/TranslateExchangeIds/TranslateExchangeIds.cs deleted file mode 100644 index 983a6f5f23e..00000000000 --- a/src/generated/Me/TranslateExchangeIds/TranslateExchangeIds.cs +++ /dev/null @@ -1,45 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Me.TranslateExchangeIds { - public class TranslateExchangeIds : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// An error object indicating the reason for the conversion failure. This value is not present if the conversion succeeded. - public GenericError ErrorDetails { get; set; } - /// The identifier that was converted. This value is the original, un-converted identifier. - public string SourceId { get; set; } - /// The converted identifier. This value is not present if the conversion failed. - public string TargetId { get; set; } - /// - /// Instantiates a new translateExchangeIds and sets the default values. - /// - public TranslateExchangeIds() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"errorDetails", (o,n) => { (o as TranslateExchangeIds).ErrorDetails = n.GetObjectValue(); } }, - {"sourceId", (o,n) => { (o as TranslateExchangeIds).SourceId = n.GetStringValue(); } }, - {"targetId", (o,n) => { (o as TranslateExchangeIds).TargetId = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("errorDetails", ErrorDetails); - writer.WriteStringValue("sourceId", SourceId); - writer.WriteStringValue("targetId", TargetId); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Me/TranslateExchangeIds/TranslateExchangeIdsRequestBuilder.cs b/src/generated/Me/TranslateExchangeIds/TranslateExchangeIdsRequestBuilder.cs index 12f56ba2c99..1de6d3dc095 100644 --- a/src/generated/Me/TranslateExchangeIds/TranslateExchangeIdsRequestBuilder.cs +++ b/src/generated/Me/TranslateExchangeIds/TranslateExchangeIdsRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(TranslateExchangeIdsReque requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action translateExchangeIds - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(TranslateExchangeIdsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Me/WipeManagedAppRegistrationsByDeviceTag/WipeManagedAppRegistrationsByDeviceTagRequestBuilder.cs b/src/generated/Me/WipeManagedAppRegistrationsByDeviceTag/WipeManagedAppRegistrationsByDeviceTagRequestBuilder.cs index 0f28a32ff16..c0336e3c575 100644 --- a/src/generated/Me/WipeManagedAppRegistrationsByDeviceTag/WipeManagedAppRegistrationsByDeviceTagRequestBuilder.cs +++ b/src/generated/Me/WipeManagedAppRegistrationsByDeviceTag/WipeManagedAppRegistrationsByDeviceTagRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,14 +29,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -72,18 +71,5 @@ public RequestInformation CreatePostRequestInformation(WipeManagedAppRegistratio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Issues a wipe operation on an app registration with specified device tag. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WipeManagedAppRegistrationsByDeviceTagRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Models/Microsoft/Graph/@Event.cs b/src/generated/Models/Microsoft/Graph/@Event.cs deleted file mode 100644 index bf52dfbe4d1..00000000000 --- a/src/generated/Models/Microsoft/Graph/@Event.cs +++ /dev/null @@ -1,164 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Models.Microsoft.Graph { - public class @Event : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as @Event).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as @Event).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as @Event).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as @Event).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as @Event).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as @Event).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as @Event).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as @Event).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as @Event).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as @Event).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as @Event).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as @Event).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as @Event).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as @Event).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as @Event).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as @Event).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as @Event).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as @Event).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as @Event).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as @Event).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as @Event).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as @Event).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as @Event).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as @Event).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as @Event).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as @Event).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as @Event).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as @Event).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as @Event).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as @Event).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as @Event).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as @Event).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as @Event).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as @Event).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as @Event).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as @Event).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as @Event).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as @Event).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as @Event).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as @Event).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as @Event).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as @Event).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Models/Microsoft/Graph/AdministrativeUnit.cs b/src/generated/Models/Microsoft/Graph/AdministrativeUnit.cs index a90e3faadda..7457f111a34 100644 --- a/src/generated/Models/Microsoft/Graph/AdministrativeUnit.cs +++ b/src/generated/Models/Microsoft/Graph/AdministrativeUnit.cs @@ -5,15 +5,15 @@ using System.Linq; namespace ApiSdk.Models.Microsoft.Graph { public class AdministrativeUnit : DirectoryObject, IParsable { - /// An optional description for the administrative unit. Supports $filter (eq, ne, in, startsWith). + /// An optional description for the administrative unit. Supports $filter (eq, ne, in, startsWith), $search. public string Description { get; set; } /// Display name for the administrative unit. Supports $filter (eq, ne, not, ge, le, in, startsWith, and eq on null values), $search, and $orderBy. public string DisplayName { get; set; } /// The collection of open extensions defined for this administrative unit. Nullable. public List Extensions { get; set; } - /// Users and groups that are members of this administrative unit. HTTP Methods: GET (list members), POST (add members), DELETE (remove members). + /// Users and groups that are members of this administrative unit. Supports $expand. public List Members { get; set; } - /// Scoped-role members of this administrative unit. HTTP Methods: GET (list scopedRoleMemberships), POST (add scopedRoleMembership), DELETE (remove scopedRoleMembership). + /// Scoped-role members of this administrative unit. public List ScopedRoleMembers { get; set; } /// Controls whether the administrative unit and its members are hidden or public. Can be set to HiddenMembership or Public. If not set, default behavior is Public. When set to HiddenMembership, only members of the administrative unit can list other members of the administrative unit. public string Visibility { get; set; } diff --git a/src/generated/Models/Microsoft/Graph/Agreement.cs b/src/generated/Models/Microsoft/Graph/Agreement.cs index f63927fa606..b5c9b8a9ecd 100644 --- a/src/generated/Models/Microsoft/Graph/Agreement.cs +++ b/src/generated/Models/Microsoft/Graph/Agreement.cs @@ -20,7 +20,7 @@ public class Agreement : Entity, IParsable { /// Expiration schedule and frequency of agreement for all users. public TermsExpiration TermsExpiration { get; set; } /// The duration after which the user must re-accept the terms of use. The value is represented in ISO 8601 format for durations. - public string UserReacceptRequiredFrequency { get; set; } + public TimeSpan? UserReacceptRequiredFrequency { get; set; } /// /// The deserialization information for the current model /// @@ -33,7 +33,7 @@ public class Agreement : Entity, IParsable { {"isPerDeviceAcceptanceRequired", (o,n) => { (o as Agreement).IsPerDeviceAcceptanceRequired = n.GetBoolValue(); } }, {"isViewingBeforeAcceptanceRequired", (o,n) => { (o as Agreement).IsViewingBeforeAcceptanceRequired = n.GetBoolValue(); } }, {"termsExpiration", (o,n) => { (o as Agreement).TermsExpiration = n.GetObjectValue(); } }, - {"userReacceptRequiredFrequency", (o,n) => { (o as Agreement).UserReacceptRequiredFrequency = n.GetStringValue(); } }, + {"userReacceptRequiredFrequency", (o,n) => { (o as Agreement).UserReacceptRequiredFrequency = n.GetTimeSpanValue(); } }, }; } /// @@ -50,7 +50,7 @@ public class Agreement : Entity, IParsable { writer.WriteBoolValue("isPerDeviceAcceptanceRequired", IsPerDeviceAcceptanceRequired); writer.WriteBoolValue("isViewingBeforeAcceptanceRequired", IsViewingBeforeAcceptanceRequired); writer.WriteObjectValue("termsExpiration", TermsExpiration); - writer.WriteStringValue("userReacceptRequiredFrequency", UserReacceptRequiredFrequency); + writer.WriteTimeSpanValue("userReacceptRequiredFrequency", UserReacceptRequiredFrequency); } } } diff --git a/src/generated/Models/Microsoft/Graph/BookingAppointment.cs b/src/generated/Models/Microsoft/Graph/BookingAppointment.cs index bdb9e5a069e..eaeae6f3984 100644 --- a/src/generated/Models/Microsoft/Graph/BookingAppointment.cs +++ b/src/generated/Models/Microsoft/Graph/BookingAppointment.cs @@ -12,7 +12,7 @@ public class BookingAppointment : Entity, IParsable { /// The time zone of the customer. For a list of possible values, see dateTimeTimeZone. public string CustomerTimeZone { get; set; } /// The length of the appointment, denoted in ISO8601 format. - public string Duration { get; set; } + public TimeSpan? Duration { get; set; } public DateTimeTimeZone EndDateTime { get; set; } /// The current number of customers in the appointment. public int? FilledAttendeesCount { get; set; } @@ -25,9 +25,9 @@ public class BookingAppointment : Entity, IParsable { /// True indicates that the bookingCustomer for this appointment does not wish to receive a confirmation for this appointment. public bool? OptOutOfCustomerEmail { get; set; } /// The amount of time to reserve after the appointment ends, for cleaning up, as an example. The value is expressed in ISO8601 format. - public string PostBuffer { get; set; } + public TimeSpan? PostBuffer { get; set; } /// The amount of time to reserve before the appointment begins, for preparation, as an example. The value is expressed in ISO8601 format. - public string PreBuffer { get; set; } + public TimeSpan? PreBuffer { get; set; } /// The regular price for an appointment for the specified bookingService. public double? Price { get; set; } /// A setting to provide flexibility for the pricing structure of services. Possible values are: undefined, fixedPrice, startingAt, hourly, free, priceVaries, callUs, notSet, unknownFutureValue. @@ -57,15 +57,15 @@ public class BookingAppointment : Entity, IParsable { {"additionalInformation", (o,n) => { (o as BookingAppointment).AdditionalInformation = n.GetStringValue(); } }, {"customers", (o,n) => { (o as BookingAppointment).Customers = n.GetCollectionOfObjectValues().ToList(); } }, {"customerTimeZone", (o,n) => { (o as BookingAppointment).CustomerTimeZone = n.GetStringValue(); } }, - {"duration", (o,n) => { (o as BookingAppointment).Duration = n.GetStringValue(); } }, + {"duration", (o,n) => { (o as BookingAppointment).Duration = n.GetTimeSpanValue(); } }, {"endDateTime", (o,n) => { (o as BookingAppointment).EndDateTime = n.GetObjectValue(); } }, {"filledAttendeesCount", (o,n) => { (o as BookingAppointment).FilledAttendeesCount = n.GetIntValue(); } }, {"isLocationOnline", (o,n) => { (o as BookingAppointment).IsLocationOnline = n.GetBoolValue(); } }, {"joinWebUrl", (o,n) => { (o as BookingAppointment).JoinWebUrl = n.GetStringValue(); } }, {"maximumAttendeesCount", (o,n) => { (o as BookingAppointment).MaximumAttendeesCount = n.GetIntValue(); } }, {"optOutOfCustomerEmail", (o,n) => { (o as BookingAppointment).OptOutOfCustomerEmail = n.GetBoolValue(); } }, - {"postBuffer", (o,n) => { (o as BookingAppointment).PostBuffer = n.GetStringValue(); } }, - {"preBuffer", (o,n) => { (o as BookingAppointment).PreBuffer = n.GetStringValue(); } }, + {"postBuffer", (o,n) => { (o as BookingAppointment).PostBuffer = n.GetTimeSpanValue(); } }, + {"preBuffer", (o,n) => { (o as BookingAppointment).PreBuffer = n.GetTimeSpanValue(); } }, {"price", (o,n) => { (o as BookingAppointment).Price = n.GetDoubleValue(); } }, {"priceType", (o,n) => { (o as BookingAppointment).PriceType = n.GetEnumValue(); } }, {"reminders", (o,n) => { (o as BookingAppointment).Reminders = n.GetCollectionOfObjectValues().ToList(); } }, @@ -89,15 +89,15 @@ public class BookingAppointment : Entity, IParsable { writer.WriteStringValue("additionalInformation", AdditionalInformation); writer.WriteCollectionOfObjectValues("customers", Customers); writer.WriteStringValue("customerTimeZone", CustomerTimeZone); - writer.WriteStringValue("duration", Duration); + writer.WriteTimeSpanValue("duration", Duration); writer.WriteObjectValue("endDateTime", EndDateTime); writer.WriteIntValue("filledAttendeesCount", FilledAttendeesCount); writer.WriteBoolValue("isLocationOnline", IsLocationOnline); writer.WriteStringValue("joinWebUrl", JoinWebUrl); writer.WriteIntValue("maximumAttendeesCount", MaximumAttendeesCount); writer.WriteBoolValue("optOutOfCustomerEmail", OptOutOfCustomerEmail); - writer.WriteStringValue("postBuffer", PostBuffer); - writer.WriteStringValue("preBuffer", PreBuffer); + writer.WriteTimeSpanValue("postBuffer", PostBuffer); + writer.WriteTimeSpanValue("preBuffer", PreBuffer); writer.WriteDoubleValue("price", Price); writer.WriteEnumValue("priceType", PriceType); writer.WriteCollectionOfObjectValues("reminders", Reminders); diff --git a/src/generated/Models/Microsoft/Graph/BookingReminder.cs b/src/generated/Models/Microsoft/Graph/BookingReminder.cs index 82494d08a90..5d70f8cd80b 100644 --- a/src/generated/Models/Microsoft/Graph/BookingReminder.cs +++ b/src/generated/Models/Microsoft/Graph/BookingReminder.cs @@ -10,7 +10,7 @@ public class BookingReminder : IParsable { /// The message in the reminder. public string Message { get; set; } /// The amount of time before the start of an appointment that the reminder should be sent. It's denoted in ISO 8601 format. - public string Offset { get; set; } + public TimeSpan? Offset { get; set; } /// The persons who should receive the reminder. Possible values are: allAttendees, staff, customer and unknownFutureValue. public BookingReminderRecipients? Recipients { get; set; } /// @@ -25,7 +25,7 @@ public BookingReminder() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"message", (o,n) => { (o as BookingReminder).Message = n.GetStringValue(); } }, - {"offset", (o,n) => { (o as BookingReminder).Offset = n.GetStringValue(); } }, + {"offset", (o,n) => { (o as BookingReminder).Offset = n.GetTimeSpanValue(); } }, {"recipients", (o,n) => { (o as BookingReminder).Recipients = n.GetEnumValue(); } }, }; } @@ -36,7 +36,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("message", Message); - writer.WriteStringValue("offset", Offset); + writer.WriteTimeSpanValue("offset", Offset); writer.WriteEnumValue("recipients", Recipients); writer.WriteAdditionalData(AdditionalData); } diff --git a/src/generated/Models/Microsoft/Graph/BookingSchedulingPolicy.cs b/src/generated/Models/Microsoft/Graph/BookingSchedulingPolicy.cs index fbc08bab36a..304402737d9 100644 --- a/src/generated/Models/Microsoft/Graph/BookingSchedulingPolicy.cs +++ b/src/generated/Models/Microsoft/Graph/BookingSchedulingPolicy.cs @@ -10,13 +10,13 @@ public class BookingSchedulingPolicy : IParsable { /// True if to allow customers to choose a specific person for the booking. public bool? AllowStaffSelection { get; set; } /// Maximum number of days in advance that a booking can be made. It follows the ISO 8601 format. - public string MaximumAdvance { get; set; } + public TimeSpan? MaximumAdvance { get; set; } /// The minimum amount of time before which bookings and cancellations must be made. It follows the ISO 8601 format. - public string MinimumLeadTime { get; set; } + public TimeSpan? MinimumLeadTime { get; set; } /// True to notify the business via email when a booking is created or changed. Use the email address specified in the email property of the bookingBusiness entity for the business. public bool? SendConfirmationsToOwner { get; set; } /// Duration of each time slot, denoted in ISO 8601 format. - public string TimeSlotInterval { get; set; } + public TimeSpan? TimeSlotInterval { get; set; } /// /// Instantiates a new bookingSchedulingPolicy and sets the default values. /// @@ -29,10 +29,10 @@ public BookingSchedulingPolicy() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"allowStaffSelection", (o,n) => { (o as BookingSchedulingPolicy).AllowStaffSelection = n.GetBoolValue(); } }, - {"maximumAdvance", (o,n) => { (o as BookingSchedulingPolicy).MaximumAdvance = n.GetStringValue(); } }, - {"minimumLeadTime", (o,n) => { (o as BookingSchedulingPolicy).MinimumLeadTime = n.GetStringValue(); } }, + {"maximumAdvance", (o,n) => { (o as BookingSchedulingPolicy).MaximumAdvance = n.GetTimeSpanValue(); } }, + {"minimumLeadTime", (o,n) => { (o as BookingSchedulingPolicy).MinimumLeadTime = n.GetTimeSpanValue(); } }, {"sendConfirmationsToOwner", (o,n) => { (o as BookingSchedulingPolicy).SendConfirmationsToOwner = n.GetBoolValue(); } }, - {"timeSlotInterval", (o,n) => { (o as BookingSchedulingPolicy).TimeSlotInterval = n.GetStringValue(); } }, + {"timeSlotInterval", (o,n) => { (o as BookingSchedulingPolicy).TimeSlotInterval = n.GetTimeSpanValue(); } }, }; } /// @@ -42,10 +42,10 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteBoolValue("allowStaffSelection", AllowStaffSelection); - writer.WriteStringValue("maximumAdvance", MaximumAdvance); - writer.WriteStringValue("minimumLeadTime", MinimumLeadTime); + writer.WriteTimeSpanValue("maximumAdvance", MaximumAdvance); + writer.WriteTimeSpanValue("minimumLeadTime", MinimumLeadTime); writer.WriteBoolValue("sendConfirmationsToOwner", SendConfirmationsToOwner); - writer.WriteStringValue("timeSlotInterval", TimeSlotInterval); + writer.WriteTimeSpanValue("timeSlotInterval", TimeSlotInterval); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Models/Microsoft/Graph/BookingService.cs b/src/generated/Models/Microsoft/Graph/BookingService.cs index 37821590374..8ac3ae947a6 100644 --- a/src/generated/Models/Microsoft/Graph/BookingService.cs +++ b/src/generated/Models/Microsoft/Graph/BookingService.cs @@ -10,7 +10,7 @@ public class BookingService : Entity, IParsable { /// Contains the set of custom questions associated with a particular service. public List CustomQuestions { get; set; } /// The default length of the service, represented in numbers of days, hours, minutes, and seconds. For example, P11D23H59M59.999999999999S. - public string DefaultDuration { get; set; } + public TimeSpan? DefaultDuration { get; set; } /// The default physical location for the service. public Location DefaultLocation { get; set; } /// The default monetary price for the service. @@ -32,9 +32,9 @@ public class BookingService : Entity, IParsable { /// Additional information about this service. public string Notes { get; set; } /// The time to buffer after an appointment for this service ends, and before the next customer appointment can be booked. - public string PostBuffer { get; set; } + public TimeSpan? PostBuffer { get; set; } /// The time to buffer before an appointment for this service can start. - public string PreBuffer { get; set; } + public TimeSpan? PreBuffer { get; set; } /// The set of policies that determine how appointments for this type of service should be created and managed. public BookingSchedulingPolicy SchedulingPolicy { get; set; } /// True indicates SMS notifications can be sent to the customers for the appointment of the service. Default value is false. @@ -50,7 +50,7 @@ public class BookingService : Entity, IParsable { return new Dictionary>(base.GetFieldDeserializers()) { {"additionalInformation", (o,n) => { (o as BookingService).AdditionalInformation = n.GetStringValue(); } }, {"customQuestions", (o,n) => { (o as BookingService).CustomQuestions = n.GetCollectionOfObjectValues().ToList(); } }, - {"defaultDuration", (o,n) => { (o as BookingService).DefaultDuration = n.GetStringValue(); } }, + {"defaultDuration", (o,n) => { (o as BookingService).DefaultDuration = n.GetTimeSpanValue(); } }, {"defaultLocation", (o,n) => { (o as BookingService).DefaultLocation = n.GetObjectValue(); } }, {"defaultPrice", (o,n) => { (o as BookingService).DefaultPrice = n.GetDoubleValue(); } }, {"defaultPriceType", (o,n) => { (o as BookingService).DefaultPriceType = n.GetEnumValue(); } }, @@ -61,8 +61,8 @@ public class BookingService : Entity, IParsable { {"isLocationOnline", (o,n) => { (o as BookingService).IsLocationOnline = n.GetBoolValue(); } }, {"maximumAttendeesCount", (o,n) => { (o as BookingService).MaximumAttendeesCount = n.GetIntValue(); } }, {"notes", (o,n) => { (o as BookingService).Notes = n.GetStringValue(); } }, - {"postBuffer", (o,n) => { (o as BookingService).PostBuffer = n.GetStringValue(); } }, - {"preBuffer", (o,n) => { (o as BookingService).PreBuffer = n.GetStringValue(); } }, + {"postBuffer", (o,n) => { (o as BookingService).PostBuffer = n.GetTimeSpanValue(); } }, + {"preBuffer", (o,n) => { (o as BookingService).PreBuffer = n.GetTimeSpanValue(); } }, {"schedulingPolicy", (o,n) => { (o as BookingService).SchedulingPolicy = n.GetObjectValue(); } }, {"smsNotificationsEnabled", (o,n) => { (o as BookingService).SmsNotificationsEnabled = n.GetBoolValue(); } }, {"staffMemberIds", (o,n) => { (o as BookingService).StaffMemberIds = n.GetCollectionOfPrimitiveValues().ToList(); } }, @@ -78,7 +78,7 @@ public class BookingService : Entity, IParsable { base.Serialize(writer); writer.WriteStringValue("additionalInformation", AdditionalInformation); writer.WriteCollectionOfObjectValues("customQuestions", CustomQuestions); - writer.WriteStringValue("defaultDuration", DefaultDuration); + writer.WriteTimeSpanValue("defaultDuration", DefaultDuration); writer.WriteObjectValue("defaultLocation", DefaultLocation); writer.WriteDoubleValue("defaultPrice", DefaultPrice); writer.WriteEnumValue("defaultPriceType", DefaultPriceType); @@ -89,8 +89,8 @@ public class BookingService : Entity, IParsable { writer.WriteBoolValue("isLocationOnline", IsLocationOnline); writer.WriteIntValue("maximumAttendeesCount", MaximumAttendeesCount); writer.WriteStringValue("notes", Notes); - writer.WriteStringValue("postBuffer", PostBuffer); - writer.WriteStringValue("preBuffer", PreBuffer); + writer.WriteTimeSpanValue("postBuffer", PostBuffer); + writer.WriteTimeSpanValue("preBuffer", PreBuffer); writer.WriteObjectValue("schedulingPolicy", SchedulingPolicy); writer.WriteBoolValue("smsNotificationsEnabled", SmsNotificationsEnabled); writer.WriteCollectionOfPrimitiveValues("staffMemberIds", StaffMemberIds); diff --git a/src/generated/Models/Microsoft/Graph/BookingWorkTimeSlot.cs b/src/generated/Models/Microsoft/Graph/BookingWorkTimeSlot.cs index 95c0fc3a85f..72ffad3a0ae 100644 --- a/src/generated/Models/Microsoft/Graph/BookingWorkTimeSlot.cs +++ b/src/generated/Models/Microsoft/Graph/BookingWorkTimeSlot.cs @@ -1,3 +1,4 @@ +using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; using System; using System.Collections.Generic; @@ -8,9 +9,9 @@ public class BookingWorkTimeSlot : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } /// The time of the day when work stops. For example, 17:00:00.0000000. - public string EndTime { get; set; } + public Time? EndTime { get; set; } /// The time of the day when work starts. For example, 08:00:00.0000000. - public string StartTime { get; set; } + public Time? StartTime { get; set; } /// /// Instantiates a new bookingWorkTimeSlot and sets the default values. /// @@ -22,8 +23,8 @@ public BookingWorkTimeSlot() { /// public IDictionary> GetFieldDeserializers() { return new Dictionary> { - {"endTime", (o,n) => { (o as BookingWorkTimeSlot).EndTime = n.GetStringValue(); } }, - {"startTime", (o,n) => { (o as BookingWorkTimeSlot).StartTime = n.GetStringValue(); } }, + {"endTime", (o,n) => { (o as BookingWorkTimeSlot).EndTime = n.GetTimeValue(); } }, + {"startTime", (o,n) => { (o as BookingWorkTimeSlot).StartTime = n.GetTimeValue(); } }, }; } /// @@ -32,8 +33,8 @@ public IDictionary> GetFieldDeserializers() { /// public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("endTime", EndTime); - writer.WriteStringValue("startTime", StartTime); + writer.WriteTimeValue("endTime", EndTime); + writer.WriteTimeValue("startTime", StartTime); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Models/Microsoft/Graph/Calendar.cs b/src/generated/Models/Microsoft/Graph/Calendar.cs index 555310d1f0d..e637bc85b6f 100644 --- a/src/generated/Models/Microsoft/Graph/Calendar.cs +++ b/src/generated/Models/Microsoft/Graph/Calendar.cs @@ -10,7 +10,7 @@ public class Calendar : Entity, IParsable { /// The permissions of the users with whom the calendar is shared. public List CalendarPermissions { get; set; } /// The calendar view for the calendar. Navigation property. Read-only. - public List<@Event> CalendarView { get; set; } + public List CalendarView { get; set; } /// true if the user can write to the calendar, false otherwise. This property is true for the user who created the calendar. This property is also true for a user who has been shared a calendar and granted write access, through an Outlook client or the corresponding calendarPermission resource. Read-only. public bool? CanEdit { get; set; } /// true if the user has the permission to share the calendar, false otherwise. Only the user who created the calendar can share it. Read-only. @@ -24,7 +24,7 @@ public class Calendar : Entity, IParsable { /// The default online meeting provider for meetings sent from this calendar. Possible values are: unknown, skypeForBusiness, skypeForConsumer, teamsForBusiness. public OnlineMeetingProviderType? DefaultOnlineMeetingProvider { get; set; } /// The events in the calendar. Navigation property. Read-only. - public List<@Event> Events { get; set; } + public List Events { get; set; } /// The calendar color, expressed in a hex color code of three hexadecimal values, each ranging from 00 to FF and representing the red, green, or blue components of the color in the RGB color space. If the user has never explicitly set a color for the calendar, this property is empty. public string HexColor { get; set; } /// true if this is the default calendar where new events are created by default, false otherwise. @@ -48,14 +48,14 @@ public class Calendar : Entity, IParsable { return new Dictionary>(base.GetFieldDeserializers()) { {"allowedOnlineMeetingProviders", (o,n) => { (o as Calendar).AllowedOnlineMeetingProviders = n.GetCollectionOfEnumValues().ToList(); } }, {"calendarPermissions", (o,n) => { (o as Calendar).CalendarPermissions = n.GetCollectionOfObjectValues().ToList(); } }, - {"calendarView", (o,n) => { (o as Calendar).CalendarView = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"calendarView", (o,n) => { (o as Calendar).CalendarView = n.GetCollectionOfObjectValues().ToList(); } }, {"canEdit", (o,n) => { (o as Calendar).CanEdit = n.GetBoolValue(); } }, {"canShare", (o,n) => { (o as Calendar).CanShare = n.GetBoolValue(); } }, {"canViewPrivateItems", (o,n) => { (o as Calendar).CanViewPrivateItems = n.GetBoolValue(); } }, {"changeKey", (o,n) => { (o as Calendar).ChangeKey = n.GetStringValue(); } }, {"color", (o,n) => { (o as Calendar).Color = n.GetEnumValue(); } }, {"defaultOnlineMeetingProvider", (o,n) => { (o as Calendar).DefaultOnlineMeetingProvider = n.GetEnumValue(); } }, - {"events", (o,n) => { (o as Calendar).Events = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"events", (o,n) => { (o as Calendar).Events = n.GetCollectionOfObjectValues().ToList(); } }, {"hexColor", (o,n) => { (o as Calendar).HexColor = n.GetStringValue(); } }, {"isDefaultCalendar", (o,n) => { (o as Calendar).IsDefaultCalendar = n.GetBoolValue(); } }, {"isRemovable", (o,n) => { (o as Calendar).IsRemovable = n.GetBoolValue(); } }, @@ -75,14 +75,14 @@ public class Calendar : Entity, IParsable { base.Serialize(writer); writer.WriteCollectionOfEnumValues("allowedOnlineMeetingProviders", AllowedOnlineMeetingProviders); writer.WriteCollectionOfObjectValues("calendarPermissions", CalendarPermissions); - writer.WriteCollectionOfObjectValues<@Event>("calendarView", CalendarView); + writer.WriteCollectionOfObjectValues("calendarView", CalendarView); writer.WriteBoolValue("canEdit", CanEdit); writer.WriteBoolValue("canShare", CanShare); writer.WriteBoolValue("canViewPrivateItems", CanViewPrivateItems); writer.WriteStringValue("changeKey", ChangeKey); writer.WriteEnumValue("color", Color); writer.WriteEnumValue("defaultOnlineMeetingProvider", DefaultOnlineMeetingProvider); - writer.WriteCollectionOfObjectValues<@Event>("events", Events); + writer.WriteCollectionOfObjectValues("events", Events); writer.WriteStringValue("hexColor", HexColor); writer.WriteBoolValue("isDefaultCalendar", IsDefaultCalendar); writer.WriteBoolValue("isRemovable", IsRemovable); diff --git a/src/generated/Models/Microsoft/Graph/CallRecords/Endpoint.cs b/src/generated/Models/Microsoft/Graph/CallRecords/Endpoint.cs new file mode 100644 index 00000000000..bc954823644 --- /dev/null +++ b/src/generated/Models/Microsoft/Graph/CallRecords/Endpoint.cs @@ -0,0 +1,36 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Models.Microsoft.Graph.CallRecords { + public class Endpoint : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// User-agent reported by this endpoint. + public UserAgent UserAgent { get; set; } + /// + /// Instantiates a new endpoint and sets the default values. + /// + public Endpoint() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"userAgent", (o,n) => { (o as Endpoint).UserAgent = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("userAgent", UserAgent); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Models/Microsoft/Graph/CallRecords/MediaStream.cs b/src/generated/Models/Microsoft/Graph/CallRecords/MediaStream.cs new file mode 100644 index 00000000000..d68c60287b0 --- /dev/null +++ b/src/generated/Models/Microsoft/Graph/CallRecords/MediaStream.cs @@ -0,0 +1,132 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Models.Microsoft.Graph.CallRecords { + public class MediaStream : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Average Network Mean Opinion Score degradation for stream. Represents how much the network loss and jitter has impacted the quality of received audio. + public float? AverageAudioDegradation { get; set; } + /// Average jitter for the stream computed as specified in [RFC 3550][], denoted in [ISO 8601][] format. For example, 1 second is denoted as 'PT1S', where 'P' is the duration designator, 'T' is the time designator, and 'S' is the second designator. + public TimeSpan? AverageAudioNetworkJitter { get; set; } + /// Average estimated bandwidth available between two endpoints in bits per second. + public long? AverageBandwidthEstimate { get; set; } + /// Average jitter for the stream computed as specified in [RFC 3550][], denoted in [ISO 8601][] format. For example, 1 second is denoted as 'PT1S', where 'P' is the duration designator, 'T' is the time designator, and 'S' is the second designator. + public TimeSpan? AverageJitter { get; set; } + /// Average packet loss rate for stream. + public float? AveragePacketLossRate { get; set; } + /// Ratio of the number of audio frames with samples generated by packet loss concealment to the total number of audio frames. + public float? AverageRatioOfConcealedSamples { get; set; } + /// Average frames per second received for all video streams computed over the duration of the session. + public float? AverageReceivedFrameRate { get; set; } + /// Average network propagation round-trip time computed as specified in [RFC 3550][], denoted in [ISO 8601][] format. For example, 1 second is denoted as 'PT1S', where 'P' is the duration designator, 'T' is the time designator, and 'S' is the second designator. + public TimeSpan? AverageRoundTripTime { get; set; } + /// Average percentage of video frames lost as displayed to the user. + public float? AverageVideoFrameLossPercentage { get; set; } + /// Average frames per second received for a video stream, computed over the duration of the session. + public float? AverageVideoFrameRate { get; set; } + /// Average fraction of packets lost, as specified in [RFC 3550][], computed over the duration of the session. + public float? AverageVideoPacketLossRate { get; set; } + /// UTC time when the stream ended. The DateTimeOffset type represents date and time information using ISO 8601 format and is always in UTC time. For example, midnight UTC on Jan 1, 2014 is 2014-01-01T00:00:00Z + public DateTimeOffset? EndDateTime { get; set; } + /// Fraction of the call where frame rate is less than 7.5 frames per second. + public float? LowFrameRateRatio { get; set; } + /// Fraction of the call that the client is running less than 70% expected video processing capability. + public float? LowVideoProcessingCapabilityRatio { get; set; } + /// Maximum of audio network jitter computed over each of the 20 second windows during the session, denoted in [ISO 8601][] format. For example, 1 second is denoted as 'PT1S', where 'P' is the duration designator, 'T' is the time designator, and 'S' is the second designator. + public TimeSpan? MaxAudioNetworkJitter { get; set; } + /// Maximum jitter for the stream computed as specified in RFC 3550, denoted in [ISO 8601][] format. For example, 1 second is denoted as 'PT1S', where 'P' is the duration designator, 'T' is the time designator, and 'S' is the second designator. + public TimeSpan? MaxJitter { get; set; } + /// Maximum packet loss rate for the stream. + public float? MaxPacketLossRate { get; set; } + /// Maximum ratio of packets concealed by the healer. + public float? MaxRatioOfConcealedSamples { get; set; } + /// Maximum network propagation round-trip time computed as specified in [RFC 3550][], denoted in [ISO 8601][] format. For example, 1 second is denoted as 'PT1S', where 'P' is the duration designator, 'T' is the time designator, and 'S' is the second designator. + public TimeSpan? MaxRoundTripTime { get; set; } + /// Packet count for the stream. + public long? PacketUtilization { get; set; } + /// Packet loss rate after FEC has been applied aggregated across all video streams and codecs. + public float? PostForwardErrorCorrectionPacketLossRate { get; set; } + /// UTC time when the stream started. The DateTimeOffset type represents date and time information using ISO 8601 format and is always in UTC time. For example, midnight UTC on Jan 1, 2014 is 2014-01-01T00:00:00Z + public DateTimeOffset? StartDateTime { get; set; } + /// Indicates the direction of the media stream. Possible values are: callerToCallee, calleeToCaller. + public MediaStreamDirection? StreamDirection { get; set; } + /// Unique identifier for the stream. + public string StreamId { get; set; } + /// True if the media stream bypassed the Mediation Server and went straight between client and PSTN Gateway/PBX, false otherwise. + public bool? WasMediaBypassed { get; set; } + /// + /// Instantiates a new mediaStream and sets the default values. + /// + public MediaStream() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"averageAudioDegradation", (o,n) => { (o as MediaStream).AverageAudioDegradation = n.GetFloatValue(); } }, + {"averageAudioNetworkJitter", (o,n) => { (o as MediaStream).AverageAudioNetworkJitter = n.GetTimeSpanValue(); } }, + {"averageBandwidthEstimate", (o,n) => { (o as MediaStream).AverageBandwidthEstimate = n.GetLongValue(); } }, + {"averageJitter", (o,n) => { (o as MediaStream).AverageJitter = n.GetTimeSpanValue(); } }, + {"averagePacketLossRate", (o,n) => { (o as MediaStream).AveragePacketLossRate = n.GetFloatValue(); } }, + {"averageRatioOfConcealedSamples", (o,n) => { (o as MediaStream).AverageRatioOfConcealedSamples = n.GetFloatValue(); } }, + {"averageReceivedFrameRate", (o,n) => { (o as MediaStream).AverageReceivedFrameRate = n.GetFloatValue(); } }, + {"averageRoundTripTime", (o,n) => { (o as MediaStream).AverageRoundTripTime = n.GetTimeSpanValue(); } }, + {"averageVideoFrameLossPercentage", (o,n) => { (o as MediaStream).AverageVideoFrameLossPercentage = n.GetFloatValue(); } }, + {"averageVideoFrameRate", (o,n) => { (o as MediaStream).AverageVideoFrameRate = n.GetFloatValue(); } }, + {"averageVideoPacketLossRate", (o,n) => { (o as MediaStream).AverageVideoPacketLossRate = n.GetFloatValue(); } }, + {"endDateTime", (o,n) => { (o as MediaStream).EndDateTime = n.GetDateTimeOffsetValue(); } }, + {"lowFrameRateRatio", (o,n) => { (o as MediaStream).LowFrameRateRatio = n.GetFloatValue(); } }, + {"lowVideoProcessingCapabilityRatio", (o,n) => { (o as MediaStream).LowVideoProcessingCapabilityRatio = n.GetFloatValue(); } }, + {"maxAudioNetworkJitter", (o,n) => { (o as MediaStream).MaxAudioNetworkJitter = n.GetTimeSpanValue(); } }, + {"maxJitter", (o,n) => { (o as MediaStream).MaxJitter = n.GetTimeSpanValue(); } }, + {"maxPacketLossRate", (o,n) => { (o as MediaStream).MaxPacketLossRate = n.GetFloatValue(); } }, + {"maxRatioOfConcealedSamples", (o,n) => { (o as MediaStream).MaxRatioOfConcealedSamples = n.GetFloatValue(); } }, + {"maxRoundTripTime", (o,n) => { (o as MediaStream).MaxRoundTripTime = n.GetTimeSpanValue(); } }, + {"packetUtilization", (o,n) => { (o as MediaStream).PacketUtilization = n.GetLongValue(); } }, + {"postForwardErrorCorrectionPacketLossRate", (o,n) => { (o as MediaStream).PostForwardErrorCorrectionPacketLossRate = n.GetFloatValue(); } }, + {"startDateTime", (o,n) => { (o as MediaStream).StartDateTime = n.GetDateTimeOffsetValue(); } }, + {"streamDirection", (o,n) => { (o as MediaStream).StreamDirection = n.GetEnumValue(); } }, + {"streamId", (o,n) => { (o as MediaStream).StreamId = n.GetStringValue(); } }, + {"wasMediaBypassed", (o,n) => { (o as MediaStream).WasMediaBypassed = n.GetBoolValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteFloatValue("averageAudioDegradation", AverageAudioDegradation); + writer.WriteTimeSpanValue("averageAudioNetworkJitter", AverageAudioNetworkJitter); + writer.WriteLongValue("averageBandwidthEstimate", AverageBandwidthEstimate); + writer.WriteTimeSpanValue("averageJitter", AverageJitter); + writer.WriteFloatValue("averagePacketLossRate", AveragePacketLossRate); + writer.WriteFloatValue("averageRatioOfConcealedSamples", AverageRatioOfConcealedSamples); + writer.WriteFloatValue("averageReceivedFrameRate", AverageReceivedFrameRate); + writer.WriteTimeSpanValue("averageRoundTripTime", AverageRoundTripTime); + writer.WriteFloatValue("averageVideoFrameLossPercentage", AverageVideoFrameLossPercentage); + writer.WriteFloatValue("averageVideoFrameRate", AverageVideoFrameRate); + writer.WriteFloatValue("averageVideoPacketLossRate", AverageVideoPacketLossRate); + writer.WriteDateTimeOffsetValue("endDateTime", EndDateTime); + writer.WriteFloatValue("lowFrameRateRatio", LowFrameRateRatio); + writer.WriteFloatValue("lowVideoProcessingCapabilityRatio", LowVideoProcessingCapabilityRatio); + writer.WriteTimeSpanValue("maxAudioNetworkJitter", MaxAudioNetworkJitter); + writer.WriteTimeSpanValue("maxJitter", MaxJitter); + writer.WriteFloatValue("maxPacketLossRate", MaxPacketLossRate); + writer.WriteFloatValue("maxRatioOfConcealedSamples", MaxRatioOfConcealedSamples); + writer.WriteTimeSpanValue("maxRoundTripTime", MaxRoundTripTime); + writer.WriteLongValue("packetUtilization", PacketUtilization); + writer.WriteFloatValue("postForwardErrorCorrectionPacketLossRate", PostForwardErrorCorrectionPacketLossRate); + writer.WriteDateTimeOffsetValue("startDateTime", StartDateTime); + writer.WriteEnumValue("streamDirection", StreamDirection); + writer.WriteStringValue("streamId", StreamId); + writer.WriteBoolValue("wasMediaBypassed", WasMediaBypassed); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Models/Microsoft/Graph/CallRecords/MediaStreamDirection.cs b/src/generated/Models/Microsoft/Graph/CallRecords/MediaStreamDirection.cs new file mode 100644 index 00000000000..629365f6349 --- /dev/null +++ b/src/generated/Models/Microsoft/Graph/CallRecords/MediaStreamDirection.cs @@ -0,0 +1,6 @@ +namespace ApiSdk.Models.Microsoft.Graph.CallRecords { + public enum MediaStreamDirection { + CallerToCallee, + CalleeToCaller, + } +} diff --git a/src/generated/Models/Microsoft/Graph/CallRecords/Modality.cs b/src/generated/Models/Microsoft/Graph/CallRecords/Modality.cs new file mode 100644 index 00000000000..f040d211281 --- /dev/null +++ b/src/generated/Models/Microsoft/Graph/CallRecords/Modality.cs @@ -0,0 +1,10 @@ +namespace ApiSdk.Models.Microsoft.Graph.CallRecords { + public enum Modality { + Audio, + Video, + VideoBasedScreenSharing, + Data, + ScreenSharing, + UnknownFutureValue, + } +} diff --git a/src/generated/Models/Microsoft/Graph/CallRecords/UserAgent.cs b/src/generated/Models/Microsoft/Graph/CallRecords/UserAgent.cs new file mode 100644 index 00000000000..fe82254bfa0 --- /dev/null +++ b/src/generated/Models/Microsoft/Graph/CallRecords/UserAgent.cs @@ -0,0 +1,40 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Models.Microsoft.Graph.CallRecords { + public class UserAgent : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Identifies the version of application software used by this endpoint. + public string ApplicationVersion { get; set; } + /// User-agent header value reported by this endpoint. + public string HeaderValue { get; set; } + /// + /// Instantiates a new userAgent and sets the default values. + /// + public UserAgent() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"applicationVersion", (o,n) => { (o as UserAgent).ApplicationVersion = n.GetStringValue(); } }, + {"headerValue", (o,n) => { (o as UserAgent).HeaderValue = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("applicationVersion", ApplicationVersion); + writer.WriteStringValue("headerValue", HeaderValue); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Models/Microsoft/Graph/ColumnDefinition.cs b/src/generated/Models/Microsoft/Graph/ColumnDefinition.cs index e69827a9562..655ca434186 100644 --- a/src/generated/Models/Microsoft/Graph/ColumnDefinition.cs +++ b/src/generated/Models/Microsoft/Graph/ColumnDefinition.cs @@ -5,8 +5,6 @@ using System.Linq; namespace ApiSdk.Models.Microsoft.Graph { public class ColumnDefinition : Entity, IParsable { - /// Specifies whether the column values can be modified. - public bool? @ReadOnly { get; set; } /// This column stores boolean values. public BooleanColumn Boolean { get; set; } /// This column's data is calculated based on other columns. @@ -53,6 +51,8 @@ public class ColumnDefinition : Entity, IParsable { public PersonOrGroupColumn PersonOrGroup { get; set; } /// If true, changes to this column will be propagated to lists that implement the column. public bool? PropagateChanges { get; set; } + /// Specifies whether the column values can be modified. + public bool? ReadOnly { get; set; } /// Specifies whether the column value isn't optional. public bool? Required { get; set; } /// The source column for content type column. @@ -72,7 +72,6 @@ public class ColumnDefinition : Entity, IParsable { /// public new IDictionary> GetFieldDeserializers() { return new Dictionary>(base.GetFieldDeserializers()) { - {"readOnly", (o,n) => { (o as ColumnDefinition).@ReadOnly = n.GetBoolValue(); } }, {"boolean", (o,n) => { (o as ColumnDefinition).Boolean = n.GetObjectValue(); } }, {"calculated", (o,n) => { (o as ColumnDefinition).Calculated = n.GetObjectValue(); } }, {"choice", (o,n) => { (o as ColumnDefinition).Choice = n.GetObjectValue(); } }, @@ -96,6 +95,7 @@ public class ColumnDefinition : Entity, IParsable { {"number", (o,n) => { (o as ColumnDefinition).Number = n.GetObjectValue(); } }, {"personOrGroup", (o,n) => { (o as ColumnDefinition).PersonOrGroup = n.GetObjectValue(); } }, {"propagateChanges", (o,n) => { (o as ColumnDefinition).PropagateChanges = n.GetBoolValue(); } }, + {"readOnly", (o,n) => { (o as ColumnDefinition).ReadOnly = n.GetBoolValue(); } }, {"required", (o,n) => { (o as ColumnDefinition).Required = n.GetBoolValue(); } }, {"sourceColumn", (o,n) => { (o as ColumnDefinition).SourceColumn = n.GetObjectValue(); } }, {"term", (o,n) => { (o as ColumnDefinition).Term = n.GetObjectValue(); } }, @@ -112,7 +112,6 @@ public class ColumnDefinition : Entity, IParsable { public new void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); base.Serialize(writer); - writer.WriteBoolValue("readOnly", @ReadOnly); writer.WriteObjectValue("boolean", Boolean); writer.WriteObjectValue("calculated", Calculated); writer.WriteObjectValue("choice", Choice); @@ -136,6 +135,7 @@ public class ColumnDefinition : Entity, IParsable { writer.WriteObjectValue("number", Number); writer.WriteObjectValue("personOrGroup", PersonOrGroup); writer.WriteBoolValue("propagateChanges", PropagateChanges); + writer.WriteBoolValue("readOnly", ReadOnly); writer.WriteBoolValue("required", Required); writer.WriteObjectValue("sourceColumn", SourceColumn); writer.WriteObjectValue("term", Term); diff --git a/src/generated/Models/Microsoft/Graph/ConditionalAccessGrantControls.cs b/src/generated/Models/Microsoft/Graph/ConditionalAccessGrantControls.cs index f8e99b05fb5..c6904eb7130 100644 --- a/src/generated/Models/Microsoft/Graph/ConditionalAccessGrantControls.cs +++ b/src/generated/Models/Microsoft/Graph/ConditionalAccessGrantControls.cs @@ -5,14 +5,14 @@ using System.Linq; namespace ApiSdk.Models.Microsoft.Graph { public class ConditionalAccessGrantControls : IParsable { - /// Defines the relationship of the grant controls. Possible values: AND, OR. - public string @Operator { get; set; } /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } /// List of values of built-in controls required by the policy. Possible values: block, mfa, compliantDevice, domainJoinedDevice, approvedApplication, compliantApplication, passwordChange, unknownFutureValue. public List BuiltInControls { get; set; } /// List of custom controls IDs required by the policy. To learn more about custom control, see Custom controls (preview). public List CustomAuthenticationFactors { get; set; } + /// Defines the relationship of the grant controls. Possible values: AND, OR. + public string Operator { get; set; } /// List of terms of use IDs required by the policy. public List TermsOfUse { get; set; } /// @@ -26,9 +26,9 @@ public ConditionalAccessGrantControls() { /// public IDictionary> GetFieldDeserializers() { return new Dictionary> { - {"operator", (o,n) => { (o as ConditionalAccessGrantControls).@Operator = n.GetStringValue(); } }, {"builtInControls", (o,n) => { (o as ConditionalAccessGrantControls).BuiltInControls = n.GetCollectionOfEnumValues().ToList(); } }, {"customAuthenticationFactors", (o,n) => { (o as ConditionalAccessGrantControls).CustomAuthenticationFactors = n.GetCollectionOfPrimitiveValues().ToList(); } }, + {"operator", (o,n) => { (o as ConditionalAccessGrantControls).Operator = n.GetStringValue(); } }, {"termsOfUse", (o,n) => { (o as ConditionalAccessGrantControls).TermsOfUse = n.GetCollectionOfPrimitiveValues().ToList(); } }, }; } @@ -38,9 +38,9 @@ public IDictionary> GetFieldDeserializers() { /// public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("operator", @Operator); writer.WriteCollectionOfEnumValues("builtInControls", BuiltInControls); writer.WriteCollectionOfPrimitiveValues("customAuthenticationFactors", CustomAuthenticationFactors); + writer.WriteStringValue("operator", Operator); writer.WriteCollectionOfPrimitiveValues("termsOfUse", TermsOfUse); writer.WriteAdditionalData(AdditionalData); } diff --git a/src/generated/Models/Microsoft/Graph/ContentType.cs b/src/generated/Models/Microsoft/Graph/ContentType.cs index 5c7c0e26e6b..9151a893e8f 100644 --- a/src/generated/Models/Microsoft/Graph/ContentType.cs +++ b/src/generated/Models/Microsoft/Graph/ContentType.cs @@ -5,14 +5,10 @@ using System.Linq; namespace ApiSdk.Models.Microsoft.Graph { public class ContentType : Entity, IParsable { - /// Parent contentType from which this content type is derived. - public ContentType @Base { get; set; } - /// If true, the content type cannot be modified unless this value is first set to false. - public bool? @ReadOnly { get; set; } - /// If true, the content type cannot be modified by users or through push-down operations. Only site collection administrators can seal or unseal content types. - public bool? @Sealed { get; set; } /// List of canonical URLs for hub sites with which this content type is associated to. This will contain all hubsites where this content type is queued to be enforced or is already enforced. Enforcing a content type means that the content type will be applied to the lists in the enforced sites. public List AssociatedHubsUrls { get; set; } + /// Parent contentType from which this content type is derived. + public ContentType Base { get; set; } /// The collection of content types that are ancestors of this content type. public List BaseTypes { get; set; } /// The collection of columns that are required by this content type @@ -43,15 +39,17 @@ public class ContentType : Entity, IParsable { public string ParentId { get; set; } /// If true, any changes made to the content type will be pushed to inherited content types and lists that implement the content type. public bool? PropagateChanges { get; set; } + /// If true, the content type cannot be modified unless this value is first set to false. + public bool? ReadOnly { get; set; } + /// If true, the content type cannot be modified by users or through push-down operations. Only site collection administrators can seal or unseal content types. + public bool? Sealed { get; set; } /// /// The deserialization information for the current model /// public new IDictionary> GetFieldDeserializers() { return new Dictionary>(base.GetFieldDeserializers()) { - {"base", (o,n) => { (o as ContentType).@Base = n.GetObjectValue(); } }, - {"readOnly", (o,n) => { (o as ContentType).@ReadOnly = n.GetBoolValue(); } }, - {"sealed", (o,n) => { (o as ContentType).@Sealed = n.GetBoolValue(); } }, {"associatedHubsUrls", (o,n) => { (o as ContentType).AssociatedHubsUrls = n.GetCollectionOfPrimitiveValues().ToList(); } }, + {"base", (o,n) => { (o as ContentType).Base = n.GetObjectValue(); } }, {"baseTypes", (o,n) => { (o as ContentType).BaseTypes = n.GetCollectionOfObjectValues().ToList(); } }, {"columnLinks", (o,n) => { (o as ContentType).ColumnLinks = n.GetCollectionOfObjectValues().ToList(); } }, {"columnPositions", (o,n) => { (o as ContentType).ColumnPositions = n.GetCollectionOfObjectValues().ToList(); } }, @@ -67,6 +65,8 @@ public class ContentType : Entity, IParsable { {"order", (o,n) => { (o as ContentType).Order = n.GetObjectValue(); } }, {"parentId", (o,n) => { (o as ContentType).ParentId = n.GetStringValue(); } }, {"propagateChanges", (o,n) => { (o as ContentType).PropagateChanges = n.GetBoolValue(); } }, + {"readOnly", (o,n) => { (o as ContentType).ReadOnly = n.GetBoolValue(); } }, + {"sealed", (o,n) => { (o as ContentType).Sealed = n.GetBoolValue(); } }, }; } /// @@ -76,10 +76,8 @@ public class ContentType : Entity, IParsable { public new void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); base.Serialize(writer); - writer.WriteObjectValue("base", @Base); - writer.WriteBoolValue("readOnly", @ReadOnly); - writer.WriteBoolValue("sealed", @Sealed); writer.WriteCollectionOfPrimitiveValues("associatedHubsUrls", AssociatedHubsUrls); + writer.WriteObjectValue("base", Base); writer.WriteCollectionOfObjectValues("baseTypes", BaseTypes); writer.WriteCollectionOfObjectValues("columnLinks", ColumnLinks); writer.WriteCollectionOfObjectValues("columnPositions", ColumnPositions); @@ -95,6 +93,8 @@ public class ContentType : Entity, IParsable { writer.WriteObjectValue("order", Order); writer.WriteStringValue("parentId", ParentId); writer.WriteBoolValue("propagateChanges", PropagateChanges); + writer.WriteBoolValue("readOnly", ReadOnly); + writer.WriteBoolValue("sealed", Sealed); } } } diff --git a/src/generated/Models/Microsoft/Graph/ContentTypeOrder.cs b/src/generated/Models/Microsoft/Graph/ContentTypeOrder.cs index 4bc9252c4e9..208fcb9b834 100644 --- a/src/generated/Models/Microsoft/Graph/ContentTypeOrder.cs +++ b/src/generated/Models/Microsoft/Graph/ContentTypeOrder.cs @@ -5,10 +5,10 @@ using System.Linq; namespace ApiSdk.Models.Microsoft.Graph { public class ContentTypeOrder : IParsable { - /// Whether this is the default Content Type - public bool? @Default { get; set; } /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } + /// Whether this is the default Content Type + public bool? Default { get; set; } /// Specifies the position in which the Content Type appears in the selection UI. public int? Position { get; set; } /// @@ -22,7 +22,7 @@ public ContentTypeOrder() { /// public IDictionary> GetFieldDeserializers() { return new Dictionary> { - {"default", (o,n) => { (o as ContentTypeOrder).@Default = n.GetBoolValue(); } }, + {"default", (o,n) => { (o as ContentTypeOrder).Default = n.GetBoolValue(); } }, {"position", (o,n) => { (o as ContentTypeOrder).Position = n.GetIntValue(); } }, }; } @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { /// public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteBoolValue("default", @Default); + writer.WriteBoolValue("default", Default); writer.WriteIntValue("position", Position); writer.WriteAdditionalData(AdditionalData); } diff --git a/src/generated/Models/Microsoft/Graph/ConvertIdResult.cs b/src/generated/Models/Microsoft/Graph/ConvertIdResult.cs new file mode 100644 index 00000000000..420b779208f --- /dev/null +++ b/src/generated/Models/Microsoft/Graph/ConvertIdResult.cs @@ -0,0 +1,44 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Models.Microsoft.Graph { + public class ConvertIdResult : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// An error object indicating the reason for the conversion failure. This value is not present if the conversion succeeded. + public GenericError ErrorDetails { get; set; } + /// The identifier that was converted. This value is the original, un-converted identifier. + public string SourceId { get; set; } + /// The converted identifier. This value is not present if the conversion failed. + public string TargetId { get; set; } + /// + /// Instantiates a new ConvertIdResult and sets the default values. + /// + public ConvertIdResult() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"errorDetails", (o,n) => { (o as ConvertIdResult).ErrorDetails = n.GetObjectValue(); } }, + {"sourceId", (o,n) => { (o as ConvertIdResult).SourceId = n.GetStringValue(); } }, + {"targetId", (o,n) => { (o as ConvertIdResult).TargetId = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("errorDetails", ErrorDetails); + writer.WriteStringValue("sourceId", SourceId); + writer.WriteStringValue("targetId", TargetId); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Models/Microsoft/Graph/DirectoryRole.cs b/src/generated/Models/Microsoft/Graph/DirectoryRole.cs index bed4e7efc90..32186d9f3d4 100644 --- a/src/generated/Models/Microsoft/Graph/DirectoryRole.cs +++ b/src/generated/Models/Microsoft/Graph/DirectoryRole.cs @@ -5,13 +5,13 @@ using System.Linq; namespace ApiSdk.Models.Microsoft.Graph { public class DirectoryRole : DirectoryObject, IParsable { - /// The description for the directory role. Read-only. + /// The description for the directory role. Read-only. Supports $filter (eq), $search, $select. public string Description { get; set; } - /// The display name for the directory role. Read-only. + /// The display name for the directory role. Read-only. Supports $filter (eq), $search, $select. public string DisplayName { get; set; } - /// Users that are members of this directory role. HTTP Methods: GET, POST, DELETE. Read-only. Nullable. + /// Users that are members of this directory role. HTTP Methods: GET, POST, DELETE. Read-only. Nullable. Supports $expand. public List Members { get; set; } - /// The id of the directoryRoleTemplate that this role is based on. The property must be specified when activating a directory role in a tenant with a POST operation. After the directory role has been activated, the property is read only. + /// The id of the directoryRoleTemplate that this role is based on. The property must be specified when activating a directory role in a tenant with a POST operation. After the directory role has been activated, the property is read only. Supports $filter (eq), $select. public string RoleTemplateId { get; set; } /// Members of this directory role that are scoped to administrative units. Read-only. Nullable. public List ScopedMembers { get; set; } diff --git a/src/generated/Models/Microsoft/Graph/DriveRecipient.cs b/src/generated/Models/Microsoft/Graph/DriveRecipient.cs index a80c5cbf122..70891a65c51 100644 --- a/src/generated/Models/Microsoft/Graph/DriveRecipient.cs +++ b/src/generated/Models/Microsoft/Graph/DriveRecipient.cs @@ -5,10 +5,10 @@ using System.Linq; namespace ApiSdk.Models.Microsoft.Graph { public class DriveRecipient : IParsable { - /// The alias of the domain object, for cases where an email address is unavailable (e.g. security groups). - public string @Alias { get; set; } /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } + /// The alias of the domain object, for cases where an email address is unavailable (e.g. security groups). + public string Alias { get; set; } /// The email address for the recipient, if the recipient has an associated email address. public string Email { get; set; } /// The unique identifier for the recipient in the directory. @@ -24,7 +24,7 @@ public DriveRecipient() { /// public IDictionary> GetFieldDeserializers() { return new Dictionary> { - {"alias", (o,n) => { (o as DriveRecipient).@Alias = n.GetStringValue(); } }, + {"alias", (o,n) => { (o as DriveRecipient).Alias = n.GetStringValue(); } }, {"email", (o,n) => { (o as DriveRecipient).Email = n.GetStringValue(); } }, {"objectId", (o,n) => { (o as DriveRecipient).ObjectId = n.GetStringValue(); } }, }; @@ -35,7 +35,7 @@ public IDictionary> GetFieldDeserializers() { /// public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("alias", @Alias); + writer.WriteStringValue("alias", Alias); writer.WriteStringValue("email", Email); writer.WriteStringValue("objectId", ObjectId); writer.WriteAdditionalData(AdditionalData); diff --git a/src/generated/Models/Microsoft/Graph/Education.cs b/src/generated/Models/Microsoft/Graph/Education.cs deleted file mode 100644 index b68b2e4ae54..00000000000 --- a/src/generated/Models/Microsoft/Graph/Education.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Models.Microsoft.Graph { - public class Education : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public List Classes { get; set; } - public EducationUser Me { get; set; } - public List Schools { get; set; } - public List Users { get; set; } - /// - /// Instantiates a new education and sets the default values. - /// - public Education() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"classes", (o,n) => { (o as Education).Classes = n.GetCollectionOfObjectValues().ToList(); } }, - {"me", (o,n) => { (o as Education).Me = n.GetObjectValue(); } }, - {"schools", (o,n) => { (o as Education).Schools = n.GetCollectionOfObjectValues().ToList(); } }, - {"users", (o,n) => { (o as Education).Users = n.GetCollectionOfObjectValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteCollectionOfObjectValues("classes", Classes); - writer.WriteObjectValue("me", Me); - writer.WriteCollectionOfObjectValues("schools", Schools); - writer.WriteCollectionOfObjectValues("users", Users); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Models/Microsoft/Graph/EducationAssignmentDefaults.cs b/src/generated/Models/Microsoft/Graph/EducationAssignmentDefaults.cs index 183c6a691c9..145a14c86f6 100644 --- a/src/generated/Models/Microsoft/Graph/EducationAssignmentDefaults.cs +++ b/src/generated/Models/Microsoft/Graph/EducationAssignmentDefaults.cs @@ -1,3 +1,4 @@ +using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; using System; using System.Collections.Generic; @@ -10,7 +11,7 @@ public class EducationAssignmentDefaults : Entity, IParsable { /// Optional field to control adding assignments to students' and teachers' calendars when the assignment is published. The possible values are: none, studentsAndPublisher, studentsAndTeamOwners, unknownFutureValue, and studentsOnly. Note that you must use the Prefer: include-unknown-enum-members request header to get the following value(s) in this evolvable enum: studentsOnly. The default value is none. public EducationAddToCalendarOptions? AddToCalendarAction { get; set; } /// Class-level default value for due time field. Default value is 23:59:00. - public string DueTime { get; set; } + public Time? DueTime { get; set; } /// Default Teams channel to which notifications will be sent. Default value is null. public string NotificationChannelUrl { get; set; } /// @@ -20,7 +21,7 @@ public class EducationAssignmentDefaults : Entity, IParsable { return new Dictionary>(base.GetFieldDeserializers()) { {"addedStudentAction", (o,n) => { (o as EducationAssignmentDefaults).AddedStudentAction = n.GetEnumValue(); } }, {"addToCalendarAction", (o,n) => { (o as EducationAssignmentDefaults).AddToCalendarAction = n.GetEnumValue(); } }, - {"dueTime", (o,n) => { (o as EducationAssignmentDefaults).DueTime = n.GetStringValue(); } }, + {"dueTime", (o,n) => { (o as EducationAssignmentDefaults).DueTime = n.GetTimeValue(); } }, {"notificationChannelUrl", (o,n) => { (o as EducationAssignmentDefaults).NotificationChannelUrl = n.GetStringValue(); } }, }; } @@ -33,7 +34,7 @@ public class EducationAssignmentDefaults : Entity, IParsable { base.Serialize(writer); writer.WriteEnumValue("addedStudentAction", AddedStudentAction); writer.WriteEnumValue("addToCalendarAction", AddToCalendarAction); - writer.WriteStringValue("dueTime", DueTime); + writer.WriteTimeValue("dueTime", DueTime); writer.WriteStringValue("notificationChannelUrl", NotificationChannelUrl); } } diff --git a/src/generated/Models/Microsoft/Graph/EducationStudent.cs b/src/generated/Models/Microsoft/Graph/EducationStudent.cs index 80f068f4d05..9526118e057 100644 --- a/src/generated/Models/Microsoft/Graph/EducationStudent.cs +++ b/src/generated/Models/Microsoft/Graph/EducationStudent.cs @@ -1,3 +1,4 @@ +using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; using System; using System.Collections.Generic; @@ -8,7 +9,7 @@ public class EducationStudent : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } /// Birth date of the student. - public string BirthDate { get; set; } + public Date? BirthDate { get; set; } /// ID of the student in the source system. public string ExternalId { get; set; } /// Possible values are: female, male, other. @@ -30,7 +31,7 @@ public EducationStudent() { /// public IDictionary> GetFieldDeserializers() { return new Dictionary> { - {"birthDate", (o,n) => { (o as EducationStudent).BirthDate = n.GetStringValue(); } }, + {"birthDate", (o,n) => { (o as EducationStudent).BirthDate = n.GetDateValue(); } }, {"externalId", (o,n) => { (o as EducationStudent).ExternalId = n.GetStringValue(); } }, {"gender", (o,n) => { (o as EducationStudent).Gender = n.GetEnumValue(); } }, {"grade", (o,n) => { (o as EducationStudent).Grade = n.GetStringValue(); } }, @@ -44,7 +45,7 @@ public IDictionary> GetFieldDeserializers() { /// public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("birthDate", BirthDate); + writer.WriteDateValue("birthDate", BirthDate); writer.WriteStringValue("externalId", ExternalId); writer.WriteEnumValue("gender", Gender); writer.WriteStringValue("grade", Grade); diff --git a/src/generated/Models/Microsoft/Graph/EducationTerm.cs b/src/generated/Models/Microsoft/Graph/EducationTerm.cs index bd7683e0bc9..c989e52dc79 100644 --- a/src/generated/Models/Microsoft/Graph/EducationTerm.cs +++ b/src/generated/Models/Microsoft/Graph/EducationTerm.cs @@ -1,3 +1,4 @@ +using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; using System; using System.Collections.Generic; @@ -10,11 +11,11 @@ public class EducationTerm : IParsable { /// Display name of the term. public string DisplayName { get; set; } /// End of the term. - public string EndDate { get; set; } + public Date? EndDate { get; set; } /// ID of term in the syncing system. public string ExternalId { get; set; } /// Start of the term. - public string StartDate { get; set; } + public Date? StartDate { get; set; } /// /// Instantiates a new educationTerm and sets the default values. /// @@ -27,9 +28,9 @@ public EducationTerm() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"displayName", (o,n) => { (o as EducationTerm).DisplayName = n.GetStringValue(); } }, - {"endDate", (o,n) => { (o as EducationTerm).EndDate = n.GetStringValue(); } }, + {"endDate", (o,n) => { (o as EducationTerm).EndDate = n.GetDateValue(); } }, {"externalId", (o,n) => { (o as EducationTerm).ExternalId = n.GetStringValue(); } }, - {"startDate", (o,n) => { (o as EducationTerm).StartDate = n.GetStringValue(); } }, + {"startDate", (o,n) => { (o as EducationTerm).StartDate = n.GetDateValue(); } }, }; } /// @@ -39,9 +40,9 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("displayName", DisplayName); - writer.WriteStringValue("endDate", EndDate); + writer.WriteDateValue("endDate", EndDate); writer.WriteStringValue("externalId", ExternalId); - writer.WriteStringValue("startDate", StartDate); + writer.WriteDateValue("startDate", StartDate); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Models/Microsoft/Graph/EntitlementManagementSettings.cs b/src/generated/Models/Microsoft/Graph/EntitlementManagementSettings.cs index 9a13009d4dc..a44b9b8421c 100644 --- a/src/generated/Models/Microsoft/Graph/EntitlementManagementSettings.cs +++ b/src/generated/Models/Microsoft/Graph/EntitlementManagementSettings.cs @@ -6,7 +6,7 @@ namespace ApiSdk.Models.Microsoft.Graph { public class EntitlementManagementSettings : Entity, IParsable { /// If externalUserLifecycleAction is blockSignInAndDelete, the duration, typically a number of days, after an external user is blocked from sign in before their account is deleted. - public string DurationUntilExternalUserDeletedAfterBlocked { get; set; } + public TimeSpan? DurationUntilExternalUserDeletedAfterBlocked { get; set; } /// One of None, BlockSignIn, or BlockSignInAndDelete. public AccessPackageExternalUserLifecycleAction? ExternalUserLifecycleAction { get; set; } /// @@ -14,7 +14,7 @@ public class EntitlementManagementSettings : Entity, IParsable { /// public new IDictionary> GetFieldDeserializers() { return new Dictionary>(base.GetFieldDeserializers()) { - {"durationUntilExternalUserDeletedAfterBlocked", (o,n) => { (o as EntitlementManagementSettings).DurationUntilExternalUserDeletedAfterBlocked = n.GetStringValue(); } }, + {"durationUntilExternalUserDeletedAfterBlocked", (o,n) => { (o as EntitlementManagementSettings).DurationUntilExternalUserDeletedAfterBlocked = n.GetTimeSpanValue(); } }, {"externalUserLifecycleAction", (o,n) => { (o as EntitlementManagementSettings).ExternalUserLifecycleAction = n.GetEnumValue(); } }, }; } @@ -25,7 +25,7 @@ public class EntitlementManagementSettings : Entity, IParsable { public new void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); base.Serialize(writer); - writer.WriteStringValue("durationUntilExternalUserDeletedAfterBlocked", DurationUntilExternalUserDeletedAfterBlocked); + writer.WriteTimeSpanValue("durationUntilExternalUserDeletedAfterBlocked", DurationUntilExternalUserDeletedAfterBlocked); writer.WriteEnumValue("externalUserLifecycleAction", ExternalUserLifecycleAction); } } diff --git a/src/generated/Models/Microsoft/Graph/Event.cs b/src/generated/Models/Microsoft/Graph/Event.cs new file mode 100644 index 00000000000..1a846ec6a81 --- /dev/null +++ b/src/generated/Models/Microsoft/Graph/Event.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Models.Microsoft.Graph { + public class Event : OutlookItem, IParsable { + /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. + public bool? AllowNewTimeProposals { get; set; } + /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. + public List Attachments { get; set; } + /// The collection of attendees for the event. + public List Attendees { get; set; } + /// The body of the message associated with the event. It can be in HTML or text format. + public ItemBody Body { get; set; } + /// The preview of the message associated with the event. It is in text format. + public string BodyPreview { get; set; } + /// The calendar that contains the event. Navigation property. Read-only. + public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } + /// The date, time, and time zone that the event ends. By default, the end time is in UTC. + public DateTimeTimeZone End { get; set; } + /// The collection of open extensions defined for the event. Nullable. + public List Extensions { get; set; } + /// Set to true if the event has attachments. + public bool? HasAttachments { get; set; } + /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. + public bool? HideAttendees { get; set; } + /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. + public string ICalUId { get; set; } + public Importance? Importance { get; set; } + /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. + public List Instances { get; set; } + public bool? IsAllDay { get; set; } + public bool? IsCancelled { get; set; } + public bool? IsDraft { get; set; } + public bool? IsOnlineMeeting { get; set; } + public bool? IsOrganizer { get; set; } + public bool? IsReminderOn { get; set; } + public Location Location { get; set; } + public List Locations { get; set; } + /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. + public List MultiValueExtendedProperties { get; set; } + public OnlineMeetingInfo OnlineMeeting { get; set; } + public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } + public string OnlineMeetingUrl { get; set; } + public Recipient Organizer { get; set; } + public string OriginalEndTimeZone { get; set; } + public DateTimeOffset? OriginalStart { get; set; } + public string OriginalStartTimeZone { get; set; } + public PatternedRecurrence Recurrence { get; set; } + public int? ReminderMinutesBeforeStart { get; set; } + public bool? ResponseRequested { get; set; } + public ResponseStatus ResponseStatus { get; set; } + public Sensitivity? Sensitivity { get; set; } + public string SeriesMasterId { get; set; } + public FreeBusyStatus? ShowAs { get; set; } + /// The collection of single-value extended properties defined for the event. Read-only. Nullable. + public List SingleValueExtendedProperties { get; set; } + public DateTimeTimeZone Start { get; set; } + public string Subject { get; set; } + public string TransactionId { get; set; } + public EventType? Type { get; set; } + public string WebLink { get; set; } + /// + /// The deserialization information for the current model + /// + public new IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"allowNewTimeProposals", (o,n) => { (o as Event).AllowNewTimeProposals = n.GetBoolValue(); } }, + {"attachments", (o,n) => { (o as Event).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, + {"attendees", (o,n) => { (o as Event).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, + {"body", (o,n) => { (o as Event).Body = n.GetObjectValue(); } }, + {"bodyPreview", (o,n) => { (o as Event).BodyPreview = n.GetStringValue(); } }, + {"calendar", (o,n) => { (o as Event).Calendar = n.GetObjectValue(); } }, + {"end", (o,n) => { (o as Event).End = n.GetObjectValue(); } }, + {"extensions", (o,n) => { (o as Event).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, + {"hasAttachments", (o,n) => { (o as Event).HasAttachments = n.GetBoolValue(); } }, + {"hideAttendees", (o,n) => { (o as Event).HideAttendees = n.GetBoolValue(); } }, + {"iCalUId", (o,n) => { (o as Event).ICalUId = n.GetStringValue(); } }, + {"importance", (o,n) => { (o as Event).Importance = n.GetEnumValue(); } }, + {"instances", (o,n) => { (o as Event).Instances = n.GetCollectionOfObjectValues().ToList(); } }, + {"isAllDay", (o,n) => { (o as Event).IsAllDay = n.GetBoolValue(); } }, + {"isCancelled", (o,n) => { (o as Event).IsCancelled = n.GetBoolValue(); } }, + {"isDraft", (o,n) => { (o as Event).IsDraft = n.GetBoolValue(); } }, + {"isOnlineMeeting", (o,n) => { (o as Event).IsOnlineMeeting = n.GetBoolValue(); } }, + {"isOrganizer", (o,n) => { (o as Event).IsOrganizer = n.GetBoolValue(); } }, + {"isReminderOn", (o,n) => { (o as Event).IsReminderOn = n.GetBoolValue(); } }, + {"location", (o,n) => { (o as Event).Location = n.GetObjectValue(); } }, + {"locations", (o,n) => { (o as Event).Locations = n.GetCollectionOfObjectValues().ToList(); } }, + {"multiValueExtendedProperties", (o,n) => { (o as Event).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, + {"onlineMeeting", (o,n) => { (o as Event).OnlineMeeting = n.GetObjectValue(); } }, + {"onlineMeetingProvider", (o,n) => { (o as Event).OnlineMeetingProvider = n.GetEnumValue(); } }, + {"onlineMeetingUrl", (o,n) => { (o as Event).OnlineMeetingUrl = n.GetStringValue(); } }, + {"organizer", (o,n) => { (o as Event).Organizer = n.GetObjectValue(); } }, + {"originalEndTimeZone", (o,n) => { (o as Event).OriginalEndTimeZone = n.GetStringValue(); } }, + {"originalStart", (o,n) => { (o as Event).OriginalStart = n.GetDateTimeOffsetValue(); } }, + {"originalStartTimeZone", (o,n) => { (o as Event).OriginalStartTimeZone = n.GetStringValue(); } }, + {"recurrence", (o,n) => { (o as Event).Recurrence = n.GetObjectValue(); } }, + {"reminderMinutesBeforeStart", (o,n) => { (o as Event).ReminderMinutesBeforeStart = n.GetIntValue(); } }, + {"responseRequested", (o,n) => { (o as Event).ResponseRequested = n.GetBoolValue(); } }, + {"responseStatus", (o,n) => { (o as Event).ResponseStatus = n.GetObjectValue(); } }, + {"sensitivity", (o,n) => { (o as Event).Sensitivity = n.GetEnumValue(); } }, + {"seriesMasterId", (o,n) => { (o as Event).SeriesMasterId = n.GetStringValue(); } }, + {"showAs", (o,n) => { (o as Event).ShowAs = n.GetEnumValue(); } }, + {"singleValueExtendedProperties", (o,n) => { (o as Event).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, + {"start", (o,n) => { (o as Event).Start = n.GetObjectValue(); } }, + {"subject", (o,n) => { (o as Event).Subject = n.GetStringValue(); } }, + {"transactionId", (o,n) => { (o as Event).TransactionId = n.GetStringValue(); } }, + {"type", (o,n) => { (o as Event).Type = n.GetEnumValue(); } }, + {"webLink", (o,n) => { (o as Event).WebLink = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public new void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); + writer.WriteCollectionOfObjectValues("attachments", Attachments); + writer.WriteCollectionOfObjectValues("attendees", Attendees); + writer.WriteObjectValue("body", Body); + writer.WriteStringValue("bodyPreview", BodyPreview); + writer.WriteObjectValue("calendar", Calendar); + writer.WriteObjectValue("end", End); + writer.WriteCollectionOfObjectValues("extensions", Extensions); + writer.WriteBoolValue("hasAttachments", HasAttachments); + writer.WriteBoolValue("hideAttendees", HideAttendees); + writer.WriteStringValue("iCalUId", ICalUId); + writer.WriteEnumValue("importance", Importance); + writer.WriteCollectionOfObjectValues("instances", Instances); + writer.WriteBoolValue("isAllDay", IsAllDay); + writer.WriteBoolValue("isCancelled", IsCancelled); + writer.WriteBoolValue("isDraft", IsDraft); + writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); + writer.WriteBoolValue("isOrganizer", IsOrganizer); + writer.WriteBoolValue("isReminderOn", IsReminderOn); + writer.WriteObjectValue("location", Location); + writer.WriteCollectionOfObjectValues("locations", Locations); + writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); + writer.WriteObjectValue("onlineMeeting", OnlineMeeting); + writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); + writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); + writer.WriteObjectValue("organizer", Organizer); + writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); + writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); + writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); + writer.WriteObjectValue("recurrence", Recurrence); + writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); + writer.WriteBoolValue("responseRequested", ResponseRequested); + writer.WriteObjectValue("responseStatus", ResponseStatus); + writer.WriteEnumValue("sensitivity", Sensitivity); + writer.WriteStringValue("seriesMasterId", SeriesMasterId); + writer.WriteEnumValue("showAs", ShowAs); + writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); + writer.WriteObjectValue("start", Start); + writer.WriteStringValue("subject", Subject); + writer.WriteStringValue("transactionId", TransactionId); + writer.WriteEnumValue("type", Type); + writer.WriteStringValue("webLink", WebLink); + } + } +} diff --git a/src/generated/Models/Microsoft/Graph/ExpirationPattern.cs b/src/generated/Models/Microsoft/Graph/ExpirationPattern.cs index cc89f579f35..5d118059c14 100644 --- a/src/generated/Models/Microsoft/Graph/ExpirationPattern.cs +++ b/src/generated/Models/Microsoft/Graph/ExpirationPattern.cs @@ -8,7 +8,7 @@ public class ExpirationPattern : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } /// The requestor's desired duration of access represented in ISO 8601 format for durations. For example, PT3H refers to three hours. If specified in a request, endDateTime should not be present and the type property should be set to afterDuration. - public string Duration { get; set; } + public TimeSpan? Duration { get; set; } /// Timestamp of date and time information using ISO 8601 format and is always in UTC time. For example, midnight UTC on Jan 1, 2014 is 2014-01-01T00:00:00Z. public DateTimeOffset? EndDateTime { get; set; } /// The requestor's desired expiration pattern type. @@ -24,7 +24,7 @@ public ExpirationPattern() { /// public IDictionary> GetFieldDeserializers() { return new Dictionary> { - {"duration", (o,n) => { (o as ExpirationPattern).Duration = n.GetStringValue(); } }, + {"duration", (o,n) => { (o as ExpirationPattern).Duration = n.GetTimeSpanValue(); } }, {"endDateTime", (o,n) => { (o as ExpirationPattern).EndDateTime = n.GetDateTimeOffsetValue(); } }, {"type", (o,n) => { (o as ExpirationPattern).Type = n.GetEnumValue(); } }, }; @@ -35,7 +35,7 @@ public IDictionary> GetFieldDeserializers() { /// public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("duration", Duration); + writer.WriteTimeSpanValue("duration", Duration); writer.WriteDateTimeOffsetValue("endDateTime", EndDateTime); writer.WriteEnumValue("type", Type); writer.WriteAdditionalData(AdditionalData); diff --git a/src/generated/Models/Microsoft/Graph/ExternalConnectors/ExternalGroup.cs b/src/generated/Models/Microsoft/Graph/ExternalConnectors/ExternalGroup.cs index 6665cab397f..35afe94992c 100644 --- a/src/generated/Models/Microsoft/Graph/ExternalConnectors/ExternalGroup.cs +++ b/src/generated/Models/Microsoft/Graph/ExternalConnectors/ExternalGroup.cs @@ -10,7 +10,7 @@ public class ExternalGroup : Entity, IParsable { /// The friendly name of the external group. Optional. public string DisplayName { get; set; } /// A member added to an externalGroup. You can add Azure Active Directory users, Azure Active Directory groups, or other externalGroups as members. - public List Members { get; set; } + public List Members { get; set; } /// /// The deserialization information for the current model /// @@ -18,7 +18,7 @@ public class ExternalGroup : Entity, IParsable { return new Dictionary>(base.GetFieldDeserializers()) { {"description", (o,n) => { (o as ExternalGroup).Description = n.GetStringValue(); } }, {"displayName", (o,n) => { (o as ExternalGroup).DisplayName = n.GetStringValue(); } }, - {"members", (o,n) => { (o as ExternalGroup).Members = n.GetCollectionOfObjectValues().ToList(); } }, + {"members", (o,n) => { (o as ExternalGroup).Members = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -30,7 +30,7 @@ public class ExternalGroup : Entity, IParsable { base.Serialize(writer); writer.WriteStringValue("description", Description); writer.WriteStringValue("displayName", DisplayName); - writer.WriteCollectionOfObjectValues("members", Members); + writer.WriteCollectionOfObjectValues("members", Members); } } } diff --git a/src/generated/Models/Microsoft/Graph/ExternalConnectors/Identity.cs b/src/generated/Models/Microsoft/Graph/ExternalConnectors/Identity.cs new file mode 100644 index 00000000000..38cc7f41c6b --- /dev/null +++ b/src/generated/Models/Microsoft/Graph/ExternalConnectors/Identity.cs @@ -0,0 +1,28 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Models.Microsoft.Graph.ExternalConnectors { + public class Identity : Entity, IParsable { + /// The type of identity. Possible values are: user or group for Azure AD identities and externalgroup for groups in an external system. + public IdentityType? Type { get; set; } + /// + /// The deserialization information for the current model + /// + public new IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"type", (o,n) => { (o as Identity).Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public new void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/src/generated/Models/Microsoft/Graph/ExternalConnectors/IdentityType.cs b/src/generated/Models/Microsoft/Graph/ExternalConnectors/IdentityType.cs new file mode 100644 index 00000000000..04407df2b3d --- /dev/null +++ b/src/generated/Models/Microsoft/Graph/ExternalConnectors/IdentityType.cs @@ -0,0 +1,8 @@ +namespace ApiSdk.Models.Microsoft.Graph.ExternalConnectors { + public enum IdentityType { + User, + Group, + ExternalGroup, + UnknownFutureValue, + } +} diff --git a/src/generated/Models/Microsoft/Graph/Group.cs b/src/generated/Models/Microsoft/Graph/Group.cs index 93909d2cc6e..f4e49439895 100644 --- a/src/generated/Models/Microsoft/Graph/Group.cs +++ b/src/generated/Models/Microsoft/Graph/Group.cs @@ -20,7 +20,7 @@ public class Group : DirectoryObject, IParsable { /// The group's calendar. Read-only. public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } /// The calendar view for the calendar. Read-only. - public List<@Event> CalendarView { get; set; } + public List CalendarView { get; set; } /// Describes a classification for the group (such as low, medium or high business impact). Valid values for this property are defined by creating a ClassificationList setting value, based on the template definition.Returned by default. Supports $filter (eq, ne, not, ge, le, startsWith). public string Classification { get; set; } /// The group's conversations. @@ -38,7 +38,7 @@ public class Group : DirectoryObject, IParsable { /// The group's drives. Read-only. public List Drives { get; set; } /// The group's events. - public List<@Event> Events { get; set; } + public List Events { get; set; } /// Timestamp of when the group is set to expire. The value cannot be modified and is automatically populated when the group is created. The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time. For example, midnight UTC on Jan 1, 2014 is 2014-01-01T00:00:00Z. Returned by default. Supports $filter (eq, ne, not, ge, le, in). Read-only. public DateTimeOffset? ExpirationDateTime { get; set; } /// The collection of open extensions defined for the group. Read-only. Nullable. @@ -68,7 +68,7 @@ public class Group : DirectoryObject, IParsable { public string MailNickname { get; set; } /// Groups and administrative units that this group is a member of. HTTP Methods: GET (supported for all groups). Read-only. Nullable. Supports $expand. public List MemberOf { get; set; } - /// Users, contacts, and groups that are members of this group. HTTP Methods: GET (supported for all groups), POST (supported for security groups and mail-enabled security groups), DELETE (supported only for security groups) Read-only. Nullable. Supports $expand. + /// Members of this group, who can be users, devices, other groups, or service principals. Supports the List members, Add member, and Remove member operations. Nullable. Supports $expand including nested $select. For example, /groups?$filter=startsWith(displayName,'Role')&$select=id,displayName&$expand=members($select=id,userPrincipalName,displayName). public List Members { get; set; } /// The rule that determines members for this group if the group is a dynamic group (groupTypes contains DynamicMembership). For more information about the syntax of the membership rule, see Membership Rules syntax. Returned by default. Supports $filter (eq, ne, not, ge, le, startsWith). public string MembershipRule { get; set; } @@ -92,7 +92,7 @@ public class Group : DirectoryObject, IParsable { public string OnPremisesSecurityIdentifier { get; set; } /// true if this group is synced from an on-premises directory; false if this group was originally synced from an on-premises directory but is no longer synced; null if this object has never been synced from an on-premises directory (default). Returned by default. Read-only. Supports $filter (eq, ne, not, in, and eq on null values). public bool? OnPremisesSyncEnabled { get; set; } - /// The owners of the group. The owners are a set of non-admin users who are allowed to modify this object. Nullable. If this property is not specified when creating a Microsoft 365 group, the calling user is automatically assigned as the group owner. Supports $expand. + /// The owners of the group who can be users or service principals. Nullable. If this property is not specified when creating a Microsoft 365 group, the calling user is automatically assigned as the group owner. Supports $expand including nested $select. For example, /groups?$filter=startsWith(displayName,'Role')&$select=id,displayName&$expand=owners($select=id,userPrincipalName,displayName). public List Owners { get; set; } /// The permissions that have been granted for a group to a specific application. Supports $expand. public List PermissionGrants { get; set; } @@ -143,7 +143,7 @@ public class Group : DirectoryObject, IParsable { {"assignedLicenses", (o,n) => { (o as Group).AssignedLicenses = n.GetCollectionOfObjectValues().ToList(); } }, {"autoSubscribeNewMembers", (o,n) => { (o as Group).AutoSubscribeNewMembers = n.GetBoolValue(); } }, {"calendar", (o,n) => { (o as Group).Calendar = n.GetObjectValue(); } }, - {"calendarView", (o,n) => { (o as Group).CalendarView = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"calendarView", (o,n) => { (o as Group).CalendarView = n.GetCollectionOfObjectValues().ToList(); } }, {"classification", (o,n) => { (o as Group).Classification = n.GetStringValue(); } }, {"conversations", (o,n) => { (o as Group).Conversations = n.GetCollectionOfObjectValues().ToList(); } }, {"createdDateTime", (o,n) => { (o as Group).CreatedDateTime = n.GetDateTimeOffsetValue(); } }, @@ -152,7 +152,7 @@ public class Group : DirectoryObject, IParsable { {"displayName", (o,n) => { (o as Group).DisplayName = n.GetStringValue(); } }, {"drive", (o,n) => { (o as Group).Drive = n.GetObjectValue(); } }, {"drives", (o,n) => { (o as Group).Drives = n.GetCollectionOfObjectValues().ToList(); } }, - {"events", (o,n) => { (o as Group).Events = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"events", (o,n) => { (o as Group).Events = n.GetCollectionOfObjectValues().ToList(); } }, {"expirationDateTime", (o,n) => { (o as Group).ExpirationDateTime = n.GetDateTimeOffsetValue(); } }, {"extensions", (o,n) => { (o as Group).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, {"groupLifecyclePolicies", (o,n) => { (o as Group).GroupLifecyclePolicies = n.GetCollectionOfObjectValues().ToList(); } }, @@ -217,7 +217,7 @@ public class Group : DirectoryObject, IParsable { writer.WriteCollectionOfObjectValues("assignedLicenses", AssignedLicenses); writer.WriteBoolValue("autoSubscribeNewMembers", AutoSubscribeNewMembers); writer.WriteObjectValue("calendar", Calendar); - writer.WriteCollectionOfObjectValues<@Event>("calendarView", CalendarView); + writer.WriteCollectionOfObjectValues("calendarView", CalendarView); writer.WriteStringValue("classification", Classification); writer.WriteCollectionOfObjectValues("conversations", Conversations); writer.WriteDateTimeOffsetValue("createdDateTime", CreatedDateTime); @@ -226,7 +226,7 @@ public class Group : DirectoryObject, IParsable { writer.WriteStringValue("displayName", DisplayName); writer.WriteObjectValue("drive", Drive); writer.WriteCollectionOfObjectValues("drives", Drives); - writer.WriteCollectionOfObjectValues<@Event>("events", Events); + writer.WriteCollectionOfObjectValues("events", Events); writer.WriteDateTimeOffsetValue("expirationDateTime", ExpirationDateTime); writer.WriteCollectionOfObjectValues("extensions", Extensions); writer.WriteCollectionOfObjectValues("groupLifecyclePolicies", GroupLifecyclePolicies); diff --git a/src/generated/Models/Microsoft/Graph/Identity.cs b/src/generated/Models/Microsoft/Graph/Identity.cs index 9f8930aac1d..7108da2b8de 100644 --- a/src/generated/Models/Microsoft/Graph/Identity.cs +++ b/src/generated/Models/Microsoft/Graph/Identity.cs @@ -7,9 +7,9 @@ namespace ApiSdk.Models.Microsoft.Graph { public class Identity : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } - /// The identity's display name. Note that this may not always be available or up to date. For example, if a user changes their display name, the API may show the new value in a future response, but the items associated with the user won't show up as having changed when using delta. + /// The display name of the identity. This property is read-only. public string DisplayName { get; set; } - /// Unique identifier for the identity. + /// The identifier of the identity. This property is read-only. public string Id { get; set; } /// /// Instantiates a new identity and sets the default values. diff --git a/src/generated/Models/Microsoft/Graph/IdentityProtection.cs b/src/generated/Models/Microsoft/Graph/IdentityProtection.cs deleted file mode 100644 index 3b93bd6490e..00000000000 --- a/src/generated/Models/Microsoft/Graph/IdentityProtection.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Models.Microsoft.Graph { - public class IdentityProtection : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public List RiskDetections { get; set; } - public List RiskyUsers { get; set; } - /// - /// Instantiates a new identityProtection and sets the default values. - /// - public IdentityProtection() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"riskDetections", (o,n) => { (o as IdentityProtection).RiskDetections = n.GetCollectionOfObjectValues().ToList(); } }, - {"riskyUsers", (o,n) => { (o as IdentityProtection).RiskyUsers = n.GetCollectionOfObjectValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteCollectionOfObjectValues("riskDetections", RiskDetections); - writer.WriteCollectionOfObjectValues("riskyUsers", RiskyUsers); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Models/Microsoft/Graph/IdentityProtectionRoot.cs b/src/generated/Models/Microsoft/Graph/IdentityProtectionRoot.cs index a398b1ceae2..728199048a6 100644 --- a/src/generated/Models/Microsoft/Graph/IdentityProtectionRoot.cs +++ b/src/generated/Models/Microsoft/Graph/IdentityProtectionRoot.cs @@ -7,7 +7,9 @@ namespace ApiSdk.Models.Microsoft.Graph { public class IdentityProtectionRoot : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } + /// Risk detection in Azure AD Identity Protection and the associated information about the detection. public List RiskDetections { get; set; } + /// Users that are flagged as at-risk by Azure AD Identity Protection. public List RiskyUsers { get; set; } /// /// Instantiates a new IdentityProtectionRoot and sets the default values. diff --git a/src/generated/Models/Microsoft/Graph/MailTips.cs b/src/generated/Models/Microsoft/Graph/MailTips.cs new file mode 100644 index 00000000000..d7a4b4c3d6e --- /dev/null +++ b/src/generated/Models/Microsoft/Graph/MailTips.cs @@ -0,0 +1,80 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Models.Microsoft.Graph { + public class MailTips : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Mail tips for automatic reply if it has been set up by the recipient. + public AutomaticRepliesMailTips AutomaticReplies { get; set; } + /// A custom mail tip that can be set on the recipient's mailbox. + public string CustomMailTip { get; set; } + /// Whether the recipient's mailbox is restricted, for example, accepting messages from only a predefined list of senders, rejecting messages from a predefined list of senders, or accepting messages from only authenticated senders. + public bool? DeliveryRestricted { get; set; } + /// The email address of the recipient to get mailtips for. + public EmailAddress EmailAddress { get; set; } + /// Errors that occur during the getMailTips action. + public MailTipsError Error { get; set; } + /// The number of external members if the recipient is a distribution list. + public int? ExternalMemberCount { get; set; } + /// Whether sending messages to the recipient requires approval. For example, if the recipient is a large distribution list and a moderator has been set up to approve messages sent to that distribution list, or if sending messages to a recipient requires approval of the recipient's manager. + public bool? IsModerated { get; set; } + /// The mailbox full status of the recipient. + public bool? MailboxFull { get; set; } + /// The maximum message size that has been configured for the recipient's organization or mailbox. + public int? MaxMessageSize { get; set; } + /// The scope of the recipient. Possible values are: none, internal, external, externalPartner, externalNonParther. For example, an administrator can set another organization to be its 'partner'. The scope is useful if an administrator wants certain mailtips to be accessible to certain scopes. It's also useful to senders to inform them that their message may leave the organization, helping them make the correct decisions about wording, tone and content. + public RecipientScopeType? RecipientScope { get; set; } + /// Recipients suggested based on previous contexts where they appear in the same message. + public List RecipientSuggestions { get; set; } + /// The number of members if the recipient is a distribution list. + public int? TotalMemberCount { get; set; } + /// + /// Instantiates a new MailTips and sets the default values. + /// + public MailTips() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"automaticReplies", (o,n) => { (o as MailTips).AutomaticReplies = n.GetObjectValue(); } }, + {"customMailTip", (o,n) => { (o as MailTips).CustomMailTip = n.GetStringValue(); } }, + {"deliveryRestricted", (o,n) => { (o as MailTips).DeliveryRestricted = n.GetBoolValue(); } }, + {"emailAddress", (o,n) => { (o as MailTips).EmailAddress = n.GetObjectValue(); } }, + {"error", (o,n) => { (o as MailTips).Error = n.GetObjectValue(); } }, + {"externalMemberCount", (o,n) => { (o as MailTips).ExternalMemberCount = n.GetIntValue(); } }, + {"isModerated", (o,n) => { (o as MailTips).IsModerated = n.GetBoolValue(); } }, + {"mailboxFull", (o,n) => { (o as MailTips).MailboxFull = n.GetBoolValue(); } }, + {"maxMessageSize", (o,n) => { (o as MailTips).MaxMessageSize = n.GetIntValue(); } }, + {"recipientScope", (o,n) => { (o as MailTips).RecipientScope = n.GetEnumValue(); } }, + {"recipientSuggestions", (o,n) => { (o as MailTips).RecipientSuggestions = n.GetCollectionOfObjectValues().ToList(); } }, + {"totalMemberCount", (o,n) => { (o as MailTips).TotalMemberCount = n.GetIntValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("automaticReplies", AutomaticReplies); + writer.WriteStringValue("customMailTip", CustomMailTip); + writer.WriteBoolValue("deliveryRestricted", DeliveryRestricted); + writer.WriteObjectValue("emailAddress", EmailAddress); + writer.WriteObjectValue("error", Error); + writer.WriteIntValue("externalMemberCount", ExternalMemberCount); + writer.WriteBoolValue("isModerated", IsModerated); + writer.WriteBoolValue("mailboxFull", MailboxFull); + writer.WriteIntValue("maxMessageSize", MaxMessageSize); + writer.WriteEnumValue("recipientScope", RecipientScope); + writer.WriteCollectionOfObjectValues("recipientSuggestions", RecipientSuggestions); + writer.WriteIntValue("totalMemberCount", TotalMemberCount); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Models/Microsoft/Graph/ManagedAppProtection.cs b/src/generated/Models/Microsoft/Graph/ManagedAppProtection.cs index 6ef422f6897..debdca69937 100644 --- a/src/generated/Models/Microsoft/Graph/ManagedAppProtection.cs +++ b/src/generated/Models/Microsoft/Graph/ManagedAppProtection.cs @@ -42,13 +42,13 @@ public class ManagedAppProtection : ManagedAppPolicy, IParsable { /// Indicates whether organizational credentials are required for app use. public bool? OrganizationalCredentialsRequired { get; set; } /// TimePeriod before the all-level pin must be reset if PinRequired is set to True. - public string PeriodBeforePinReset { get; set; } + public TimeSpan? PeriodBeforePinReset { get; set; } /// The period after which access is checked when the device is not connected to the internet. - public string PeriodOfflineBeforeAccessCheck { get; set; } + public TimeSpan? PeriodOfflineBeforeAccessCheck { get; set; } /// The amount of time an app is allowed to remain disconnected from the internet before all managed data it is wiped. - public string PeriodOfflineBeforeWipeIsEnforced { get; set; } + public TimeSpan? PeriodOfflineBeforeWipeIsEnforced { get; set; } /// The period after which access is checked when the device is connected to the internet. - public string PeriodOnlineBeforeAccessCheck { get; set; } + public TimeSpan? PeriodOnlineBeforeAccessCheck { get; set; } /// Character set which may be used for an app-level pin if PinRequired is set to True. Possible values are: numeric, alphanumericAndSymbol. public ManagedAppPinCharacterSet? PinCharacterSet { get; set; } /// Indicates whether an app-level pin is required. @@ -82,10 +82,10 @@ public class ManagedAppProtection : ManagedAppPolicy, IParsable { {"minimumWarningAppVersion", (o,n) => { (o as ManagedAppProtection).MinimumWarningAppVersion = n.GetStringValue(); } }, {"minimumWarningOsVersion", (o,n) => { (o as ManagedAppProtection).MinimumWarningOsVersion = n.GetStringValue(); } }, {"organizationalCredentialsRequired", (o,n) => { (o as ManagedAppProtection).OrganizationalCredentialsRequired = n.GetBoolValue(); } }, - {"periodBeforePinReset", (o,n) => { (o as ManagedAppProtection).PeriodBeforePinReset = n.GetStringValue(); } }, - {"periodOfflineBeforeAccessCheck", (o,n) => { (o as ManagedAppProtection).PeriodOfflineBeforeAccessCheck = n.GetStringValue(); } }, - {"periodOfflineBeforeWipeIsEnforced", (o,n) => { (o as ManagedAppProtection).PeriodOfflineBeforeWipeIsEnforced = n.GetStringValue(); } }, - {"periodOnlineBeforeAccessCheck", (o,n) => { (o as ManagedAppProtection).PeriodOnlineBeforeAccessCheck = n.GetStringValue(); } }, + {"periodBeforePinReset", (o,n) => { (o as ManagedAppProtection).PeriodBeforePinReset = n.GetTimeSpanValue(); } }, + {"periodOfflineBeforeAccessCheck", (o,n) => { (o as ManagedAppProtection).PeriodOfflineBeforeAccessCheck = n.GetTimeSpanValue(); } }, + {"periodOfflineBeforeWipeIsEnforced", (o,n) => { (o as ManagedAppProtection).PeriodOfflineBeforeWipeIsEnforced = n.GetTimeSpanValue(); } }, + {"periodOnlineBeforeAccessCheck", (o,n) => { (o as ManagedAppProtection).PeriodOnlineBeforeAccessCheck = n.GetTimeSpanValue(); } }, {"pinCharacterSet", (o,n) => { (o as ManagedAppProtection).PinCharacterSet = n.GetEnumValue(); } }, {"pinRequired", (o,n) => { (o as ManagedAppProtection).PinRequired = n.GetBoolValue(); } }, {"printBlocked", (o,n) => { (o as ManagedAppProtection).PrintBlocked = n.GetBoolValue(); } }, @@ -118,10 +118,10 @@ public class ManagedAppProtection : ManagedAppPolicy, IParsable { writer.WriteStringValue("minimumWarningAppVersion", MinimumWarningAppVersion); writer.WriteStringValue("minimumWarningOsVersion", MinimumWarningOsVersion); writer.WriteBoolValue("organizationalCredentialsRequired", OrganizationalCredentialsRequired); - writer.WriteStringValue("periodBeforePinReset", PeriodBeforePinReset); - writer.WriteStringValue("periodOfflineBeforeAccessCheck", PeriodOfflineBeforeAccessCheck); - writer.WriteStringValue("periodOfflineBeforeWipeIsEnforced", PeriodOfflineBeforeWipeIsEnforced); - writer.WriteStringValue("periodOnlineBeforeAccessCheck", PeriodOnlineBeforeAccessCheck); + writer.WriteTimeSpanValue("periodBeforePinReset", PeriodBeforePinReset); + writer.WriteTimeSpanValue("periodOfflineBeforeAccessCheck", PeriodOfflineBeforeAccessCheck); + writer.WriteTimeSpanValue("periodOfflineBeforeWipeIsEnforced", PeriodOfflineBeforeWipeIsEnforced); + writer.WriteTimeSpanValue("periodOnlineBeforeAccessCheck", PeriodOnlineBeforeAccessCheck); writer.WriteEnumValue("pinCharacterSet", PinCharacterSet); writer.WriteBoolValue("pinRequired", PinRequired); writer.WriteBoolValue("printBlocked", PrintBlocked); diff --git a/src/generated/Models/Microsoft/Graph/PersonType.cs b/src/generated/Models/Microsoft/Graph/PersonType.cs index 7fbbc6493aa..9a123ec3c2c 100644 --- a/src/generated/Models/Microsoft/Graph/PersonType.cs +++ b/src/generated/Models/Microsoft/Graph/PersonType.cs @@ -5,10 +5,10 @@ using System.Linq; namespace ApiSdk.Models.Microsoft.Graph { public class PersonType : IParsable { - /// The type of data source, such as Person. - public string @Class { get; set; } /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } + /// The type of data source, such as Person. + public string Class { get; set; } /// The secondary type of data source, such as OrganizationUser. public string Subclass { get; set; } /// @@ -22,7 +22,7 @@ public PersonType() { /// public IDictionary> GetFieldDeserializers() { return new Dictionary> { - {"class", (o,n) => { (o as PersonType).@Class = n.GetStringValue(); } }, + {"class", (o,n) => { (o as PersonType).Class = n.GetStringValue(); } }, {"subclass", (o,n) => { (o as PersonType).Subclass = n.GetStringValue(); } }, }; } @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { /// public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("class", @Class); + writer.WriteStringValue("class", Class); writer.WriteStringValue("subclass", Subclass); writer.WriteAdditionalData(AdditionalData); } diff --git a/src/generated/Models/Microsoft/Graph/PrintTaskTrigger.cs b/src/generated/Models/Microsoft/Graph/PrintTaskTrigger.cs index feb33137ed3..42fd7fc7e59 100644 --- a/src/generated/Models/Microsoft/Graph/PrintTaskTrigger.cs +++ b/src/generated/Models/Microsoft/Graph/PrintTaskTrigger.cs @@ -5,16 +5,16 @@ using System.Linq; namespace ApiSdk.Models.Microsoft.Graph { public class PrintTaskTrigger : Entity, IParsable { - /// The Universal Print event that will cause a new printTask to be triggered. Valid values are described in the following table. - public PrintEvent? @Event { get; set; } public PrintTaskDefinition Definition { get; set; } + /// The Universal Print event that will cause a new printTask to be triggered. Valid values are described in the following table. + public PrintEvent? Event { get; set; } /// /// The deserialization information for the current model /// public new IDictionary> GetFieldDeserializers() { return new Dictionary>(base.GetFieldDeserializers()) { - {"event", (o,n) => { (o as PrintTaskTrigger).@Event = n.GetEnumValue(); } }, {"definition", (o,n) => { (o as PrintTaskTrigger).Definition = n.GetObjectValue(); } }, + {"event", (o,n) => { (o as PrintTaskTrigger).Event = n.GetEnumValue(); } }, }; } /// @@ -24,8 +24,8 @@ public class PrintTaskTrigger : Entity, IParsable { public new void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); base.Serialize(writer); - writer.WriteEnumValue("event", @Event); writer.WriteObjectValue("definition", Definition); + writer.WriteEnumValue("event", Event); } } } diff --git a/src/generated/Models/Microsoft/Graph/PrintUsage.cs b/src/generated/Models/Microsoft/Graph/PrintUsage.cs index 1ee22e1b6bc..7531b94d977 100644 --- a/src/generated/Models/Microsoft/Graph/PrintUsage.cs +++ b/src/generated/Models/Microsoft/Graph/PrintUsage.cs @@ -1,3 +1,4 @@ +using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; using System; using System.Collections.Generic; @@ -8,7 +9,7 @@ public class PrintUsage : Entity, IParsable { public long? CompletedBlackAndWhiteJobCount { get; set; } public long? CompletedColorJobCount { get; set; } public long? IncompleteJobCount { get; set; } - public string UsageDate { get; set; } + public Date? UsageDate { get; set; } /// /// The deserialization information for the current model /// @@ -17,7 +18,7 @@ public class PrintUsage : Entity, IParsable { {"completedBlackAndWhiteJobCount", (o,n) => { (o as PrintUsage).CompletedBlackAndWhiteJobCount = n.GetLongValue(); } }, {"completedColorJobCount", (o,n) => { (o as PrintUsage).CompletedColorJobCount = n.GetLongValue(); } }, {"incompleteJobCount", (o,n) => { (o as PrintUsage).IncompleteJobCount = n.GetLongValue(); } }, - {"usageDate", (o,n) => { (o as PrintUsage).UsageDate = n.GetStringValue(); } }, + {"usageDate", (o,n) => { (o as PrintUsage).UsageDate = n.GetDateValue(); } }, }; } /// @@ -30,7 +31,7 @@ public class PrintUsage : Entity, IParsable { writer.WriteLongValue("completedBlackAndWhiteJobCount", CompletedBlackAndWhiteJobCount); writer.WriteLongValue("completedColorJobCount", CompletedColorJobCount); writer.WriteLongValue("incompleteJobCount", IncompleteJobCount); - writer.WriteStringValue("usageDate", UsageDate); + writer.WriteDateValue("usageDate", UsageDate); } } } diff --git a/src/generated/Models/Microsoft/Graph/RecurrenceRange.cs b/src/generated/Models/Microsoft/Graph/RecurrenceRange.cs index 2f685a1157a..fdbf68d47a8 100644 --- a/src/generated/Models/Microsoft/Graph/RecurrenceRange.cs +++ b/src/generated/Models/Microsoft/Graph/RecurrenceRange.cs @@ -1,3 +1,4 @@ +using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; using System; using System.Collections.Generic; @@ -8,13 +9,13 @@ public class RecurrenceRange : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } /// The date to stop applying the recurrence pattern. Depending on the recurrence pattern of the event, the last occurrence of the meeting may not be this date. Required if type is endDate. - public string EndDate { get; set; } + public Date? EndDate { get; set; } /// The number of times to repeat the event. Required and must be positive if type is numbered. public int? NumberOfOccurrences { get; set; } /// Time zone for the startDate and endDate properties. Optional. If not specified, the time zone of the event is used. public string RecurrenceTimeZone { get; set; } /// The date to start applying the recurrence pattern. The first occurrence of the meeting may be this date or later, depending on the recurrence pattern of the event. Must be the same value as the start property of the recurring event. Required. - public string StartDate { get; set; } + public Date? StartDate { get; set; } /// The recurrence range. Possible values are: endDate, noEnd, numbered. Required. public RecurrenceRangeType? Type { get; set; } /// @@ -28,10 +29,10 @@ public RecurrenceRange() { /// public IDictionary> GetFieldDeserializers() { return new Dictionary> { - {"endDate", (o,n) => { (o as RecurrenceRange).EndDate = n.GetStringValue(); } }, + {"endDate", (o,n) => { (o as RecurrenceRange).EndDate = n.GetDateValue(); } }, {"numberOfOccurrences", (o,n) => { (o as RecurrenceRange).NumberOfOccurrences = n.GetIntValue(); } }, {"recurrenceTimeZone", (o,n) => { (o as RecurrenceRange).RecurrenceTimeZone = n.GetStringValue(); } }, - {"startDate", (o,n) => { (o as RecurrenceRange).StartDate = n.GetStringValue(); } }, + {"startDate", (o,n) => { (o as RecurrenceRange).StartDate = n.GetDateValue(); } }, {"type", (o,n) => { (o as RecurrenceRange).Type = n.GetEnumValue(); } }, }; } @@ -41,10 +42,10 @@ public IDictionary> GetFieldDeserializers() { /// public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("endDate", EndDate); + writer.WriteDateValue("endDate", EndDate); writer.WriteIntValue("numberOfOccurrences", NumberOfOccurrences); writer.WriteStringValue("recurrenceTimeZone", RecurrenceTimeZone); - writer.WriteStringValue("startDate", StartDate); + writer.WriteDateValue("startDate", StartDate); writer.WriteEnumValue("type", Type); writer.WriteAdditionalData(AdditionalData); } diff --git a/src/generated/Models/Microsoft/Graph/Reminder.cs b/src/generated/Models/Microsoft/Graph/Reminder.cs new file mode 100644 index 00000000000..be6884ae6e2 --- /dev/null +++ b/src/generated/Models/Microsoft/Graph/Reminder.cs @@ -0,0 +1,64 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Models.Microsoft.Graph { + public class Reminder : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Identifies the version of the reminder. Every time the reminder is changed, changeKey changes as well. This allows Exchange to apply changes to the correct version of the object. + public string ChangeKey { get; set; } + /// The date, time and time zone that the event ends. + public DateTimeTimeZone EventEndTime { get; set; } + /// The unique ID of the event. Read only. + public string EventId { get; set; } + /// The location of the event. + public Location EventLocation { get; set; } + /// The date, time, and time zone that the event starts. + public DateTimeTimeZone EventStartTime { get; set; } + /// The text of the event's subject line. + public string EventSubject { get; set; } + /// The URL to open the event in Outlook on the web.The event will open in the browser if you are logged in to your mailbox via Outlook on the web. You will be prompted to login if you are not already logged in with the browser.This URL cannot be accessed from within an iFrame. + public string EventWebLink { get; set; } + /// The date, time, and time zone that the reminder is set to occur. + public DateTimeTimeZone ReminderFireTime { get; set; } + /// + /// Instantiates a new Reminder and sets the default values. + /// + public Reminder() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"changeKey", (o,n) => { (o as Reminder).ChangeKey = n.GetStringValue(); } }, + {"eventEndTime", (o,n) => { (o as Reminder).EventEndTime = n.GetObjectValue(); } }, + {"eventId", (o,n) => { (o as Reminder).EventId = n.GetStringValue(); } }, + {"eventLocation", (o,n) => { (o as Reminder).EventLocation = n.GetObjectValue(); } }, + {"eventStartTime", (o,n) => { (o as Reminder).EventStartTime = n.GetObjectValue(); } }, + {"eventSubject", (o,n) => { (o as Reminder).EventSubject = n.GetStringValue(); } }, + {"eventWebLink", (o,n) => { (o as Reminder).EventWebLink = n.GetStringValue(); } }, + {"reminderFireTime", (o,n) => { (o as Reminder).ReminderFireTime = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("changeKey", ChangeKey); + writer.WriteObjectValue("eventEndTime", EventEndTime); + writer.WriteStringValue("eventId", EventId); + writer.WriteObjectValue("eventLocation", EventLocation); + writer.WriteObjectValue("eventStartTime", EventStartTime); + writer.WriteStringValue("eventSubject", EventSubject); + writer.WriteStringValue("eventWebLink", EventWebLink); + writer.WriteObjectValue("reminderFireTime", ReminderFireTime); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Models/Microsoft/Graph/SearchResponse.cs b/src/generated/Models/Microsoft/Graph/SearchResponse.cs new file mode 100644 index 00000000000..5c8e60fcc51 --- /dev/null +++ b/src/generated/Models/Microsoft/Graph/SearchResponse.cs @@ -0,0 +1,40 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Models.Microsoft.Graph { + public class SearchResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// A collection of search results. + public List HitsContainers { get; set; } + /// Contains the search terms sent in the initial search query. + public List SearchTerms { get; set; } + /// + /// Instantiates a new SearchResponse and sets the default values. + /// + public SearchResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"hitsContainers", (o,n) => { (o as SearchResponse).HitsContainers = n.GetCollectionOfObjectValues().ToList(); } }, + {"searchTerms", (o,n) => { (o as SearchResponse).SearchTerms = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("hitsContainers", HitsContainers); + writer.WriteCollectionOfPrimitiveValues("searchTerms", SearchTerms); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Models/Microsoft/Graph/ServiceAnnouncementAttachment.cs b/src/generated/Models/Microsoft/Graph/ServiceAnnouncementAttachment.cs index 64c1c7b9d4f..39dd6f7f396 100644 --- a/src/generated/Models/Microsoft/Graph/ServiceAnnouncementAttachment.cs +++ b/src/generated/Models/Microsoft/Graph/ServiceAnnouncementAttachment.cs @@ -5,6 +5,7 @@ using System.Linq; namespace ApiSdk.Models.Microsoft.Graph { public class ServiceAnnouncementAttachment : Entity, IParsable { + /// The attachment content. public byte[] Content { get; set; } public string ContentType { get; set; } public DateTimeOffset? LastModifiedDateTime { get; set; } diff --git a/src/generated/Models/Microsoft/Graph/ServiceHealth.cs b/src/generated/Models/Microsoft/Graph/ServiceHealth.cs index 085fed761c1..5f46519e423 100644 --- a/src/generated/Models/Microsoft/Graph/ServiceHealth.cs +++ b/src/generated/Models/Microsoft/Graph/ServiceHealth.cs @@ -5,11 +5,11 @@ using System.Linq; namespace ApiSdk.Models.Microsoft.Graph { public class ServiceHealth : Entity, IParsable { - /// A collection of issues happened on the service, with detailed information for each issue. + /// A collection of issues that happened on the service, with detailed information for each issue. public List Issues { get; set; } /// The service name. Use the list healthOverviews operation to get exact string names for services subscribed by the tenant. public string Service { get; set; } - /// Show the overral service health status. Possible values are: serviceOperational, investigating, restoringService, verifyingService, serviceRestored, postIncidentReviewPublished, serviceDegradation, serviceInterruption, extendedRecovery, falsePositive, investigationSuspended, resolved, mitigatedExternal, mitigated, resolvedExternal, confirmed, reported, unknownFutureValue. + /// Show the overall service health status. Possible values are: serviceOperational, investigating, restoringService, verifyingService, serviceRestored, postIncidentReviewPublished, serviceDegradation, serviceInterruption, extendedRecovery, falsePositive, investigationSuspended, resolved, mitigatedExternal, mitigated, resolvedExternal, confirmed, reported, unknownFutureValue. For more details, see serviceHealthStatus values. public ServiceHealthStatus? Status { get; set; } /// /// The deserialization information for the current model diff --git a/src/generated/Models/Microsoft/Graph/ServiceHealthIssue.cs b/src/generated/Models/Microsoft/Graph/ServiceHealthIssue.cs index 9755ec3f99e..dfb517931ca 100644 --- a/src/generated/Models/Microsoft/Graph/ServiceHealthIssue.cs +++ b/src/generated/Models/Microsoft/Graph/ServiceHealthIssue.cs @@ -21,7 +21,7 @@ public class ServiceHealthIssue : ServiceAnnouncementBase, IParsable { public List Posts { get; set; } /// Indicates the service affected by the issue. public string Service { get; set; } - /// The status of the service issue. Possible values are: serviceOperational, investigating, restoringService, verifyingService, serviceRestored, postIncidentReviewPublished, serviceDegradation, serviceInterruption, extendedRecovery, falsePositive, investigationSuspended, resolved, mitigatedExternal, mitigated, resolvedExternal, confirmed, reported, unknownFutureValue. + /// The status of the service issue. Possible values are: serviceOperational, investigating, restoringService, verifyingService, serviceRestored, postIncidentReviewPublished, serviceDegradation, serviceInterruption, extendedRecovery, falsePositive, investigationSuspended, resolved, mitigatedExternal, mitigated, resolvedExternal, confirmed, reported, unknownFutureValue. For more details, see serviceHealthStatus values. public ServiceHealthStatus? Status { get; set; } /// /// The deserialization information for the current model diff --git a/src/generated/Models/Microsoft/Graph/ServiceUpdateMessage.cs b/src/generated/Models/Microsoft/Graph/ServiceUpdateMessage.cs index 7494be01e26..adecf1e82fa 100644 --- a/src/generated/Models/Microsoft/Graph/ServiceUpdateMessage.cs +++ b/src/generated/Models/Microsoft/Graph/ServiceUpdateMessage.cs @@ -7,11 +7,14 @@ namespace ApiSdk.Models.Microsoft.Graph { public class ServiceUpdateMessage : ServiceAnnouncementBase, IParsable { /// The expected deadline of the action for the message. public DateTimeOffset? ActionRequiredByDateTime { get; set; } + /// A collection of serviceAnnouncementAttachments. public List Attachments { get; set; } + /// The zip file of all attachments for a message. public byte[] AttachmentsArchive { get; set; } public ItemBody Body { get; set; } /// The service message category. Possible values are: preventOrFixIssue, planForChange, stayInformed, unknownFutureValue. public ServiceUpdateCategory? Category { get; set; } + /// Indicates whether the message has any attachment. public bool? HasAttachments { get; set; } /// Indicates whether the message describes a major update for the service. public bool? IsMajorChange { get; set; } @@ -19,9 +22,9 @@ public class ServiceUpdateMessage : ServiceAnnouncementBase, IParsable { public List Services { get; set; } /// The severity of the service message. Possible values are: normal, high, critical, unknownFutureValue. public ServiceUpdateSeverity? Severity { get; set; } - /// A collection of tags for the service message. + /// A collection of tags for the service message. Tags are provided by the service team/support team who post the message to tell whether this message contains privacy data, or whether this message is for a service new feature update, and so on. public List Tags { get; set; } - /// Represents user view points data of the service message. This data includes message status such as whether the user has archived, read, or marked the message as favorite. This property is null when accessed with application permissions. + /// Represents user viewpoints data of the service message. This data includes message status such as whether the user has archived, read, or marked the message as favorite. This property is null when accessed with application permissions. public ServiceUpdateMessageViewpoint ViewPoint { get; set; } /// /// The deserialization information for the current model diff --git a/src/generated/Models/Microsoft/Graph/Solutions.cs b/src/generated/Models/Microsoft/Graph/Solutions.cs deleted file mode 100644 index 703af8ad9bb..00000000000 --- a/src/generated/Models/Microsoft/Graph/Solutions.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Models.Microsoft.Graph { - public class Solutions : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public List BookingBusinesses { get; set; } - public List BookingCurrencies { get; set; } - /// - /// Instantiates a new solutions and sets the default values. - /// - public Solutions() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"bookingBusinesses", (o,n) => { (o as Solutions).BookingBusinesses = n.GetCollectionOfObjectValues().ToList(); } }, - {"bookingCurrencies", (o,n) => { (o as Solutions).BookingCurrencies = n.GetCollectionOfObjectValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteCollectionOfObjectValues("bookingBusinesses", BookingBusinesses); - writer.WriteCollectionOfObjectValues("bookingCurrencies", BookingCurrencies); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Models/Microsoft/Graph/TeleconferenceDeviceMediaQuality.cs b/src/generated/Models/Microsoft/Graph/TeleconferenceDeviceMediaQuality.cs index 92e9d0de7c2..c1256da24c0 100644 --- a/src/generated/Models/Microsoft/Graph/TeleconferenceDeviceMediaQuality.cs +++ b/src/generated/Models/Microsoft/Graph/TeleconferenceDeviceMediaQuality.cs @@ -8,17 +8,17 @@ public class TeleconferenceDeviceMediaQuality : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } /// The average inbound stream network jitter. - public string AverageInboundJitter { get; set; } + public TimeSpan? AverageInboundJitter { get; set; } /// The average inbound stream packet loss rate in percentage (0-100). For example, 0.01 means 0.01%. public double? AverageInboundPacketLossRateInPercentage { get; set; } /// The average inbound stream network round trip delay. - public string AverageInboundRoundTripDelay { get; set; } + public TimeSpan? AverageInboundRoundTripDelay { get; set; } /// The average outbound stream network jitter. - public string AverageOutboundJitter { get; set; } + public TimeSpan? AverageOutboundJitter { get; set; } /// The average outbound stream packet loss rate in percentage (0-100). For example, 0.01 means 0.01%. public double? AverageOutboundPacketLossRateInPercentage { get; set; } /// The average outbound stream network round trip delay. - public string AverageOutboundRoundTripDelay { get; set; } + public TimeSpan? AverageOutboundRoundTripDelay { get; set; } /// The channel index of media. Indexing begins with 1. If a media session contains 3 video modalities, channel indexes will be 1, 2, and 3. public int? ChannelIndex { get; set; } /// The total number of the inbound packets. @@ -28,19 +28,19 @@ public class TeleconferenceDeviceMediaQuality : IParsable { /// The local media port. public int? LocalPort { get; set; } /// The maximum inbound stream network jitter. - public string MaximumInboundJitter { get; set; } + public TimeSpan? MaximumInboundJitter { get; set; } /// The maximum inbound stream packet loss rate in percentage (0-100). For example, 0.01 means 0.01%. public double? MaximumInboundPacketLossRateInPercentage { get; set; } /// The maximum inbound stream network round trip delay. - public string MaximumInboundRoundTripDelay { get; set; } + public TimeSpan? MaximumInboundRoundTripDelay { get; set; } /// The maximum outbound stream network jitter. - public string MaximumOutboundJitter { get; set; } + public TimeSpan? MaximumOutboundJitter { get; set; } /// The maximum outbound stream packet loss rate in percentage (0-100). For example, 0.01 means 0.01%. public double? MaximumOutboundPacketLossRateInPercentage { get; set; } /// The maximum outbound stream network round trip delay. - public string MaximumOutboundRoundTripDelay { get; set; } + public TimeSpan? MaximumOutboundRoundTripDelay { get; set; } /// The total modality duration. If the media enabled and disabled multiple times, MediaDuration will the summation of all of the durations. - public string MediaDuration { get; set; } + public TimeSpan? MediaDuration { get; set; } /// The network link speed in bytes public long? NetworkLinkSpeedInBytes { get; set; } /// The total number of the outbound packets. @@ -60,23 +60,23 @@ public TeleconferenceDeviceMediaQuality() { /// public IDictionary> GetFieldDeserializers() { return new Dictionary> { - {"averageInboundJitter", (o,n) => { (o as TeleconferenceDeviceMediaQuality).AverageInboundJitter = n.GetStringValue(); } }, + {"averageInboundJitter", (o,n) => { (o as TeleconferenceDeviceMediaQuality).AverageInboundJitter = n.GetTimeSpanValue(); } }, {"averageInboundPacketLossRateInPercentage", (o,n) => { (o as TeleconferenceDeviceMediaQuality).AverageInboundPacketLossRateInPercentage = n.GetDoubleValue(); } }, - {"averageInboundRoundTripDelay", (o,n) => { (o as TeleconferenceDeviceMediaQuality).AverageInboundRoundTripDelay = n.GetStringValue(); } }, - {"averageOutboundJitter", (o,n) => { (o as TeleconferenceDeviceMediaQuality).AverageOutboundJitter = n.GetStringValue(); } }, + {"averageInboundRoundTripDelay", (o,n) => { (o as TeleconferenceDeviceMediaQuality).AverageInboundRoundTripDelay = n.GetTimeSpanValue(); } }, + {"averageOutboundJitter", (o,n) => { (o as TeleconferenceDeviceMediaQuality).AverageOutboundJitter = n.GetTimeSpanValue(); } }, {"averageOutboundPacketLossRateInPercentage", (o,n) => { (o as TeleconferenceDeviceMediaQuality).AverageOutboundPacketLossRateInPercentage = n.GetDoubleValue(); } }, - {"averageOutboundRoundTripDelay", (o,n) => { (o as TeleconferenceDeviceMediaQuality).AverageOutboundRoundTripDelay = n.GetStringValue(); } }, + {"averageOutboundRoundTripDelay", (o,n) => { (o as TeleconferenceDeviceMediaQuality).AverageOutboundRoundTripDelay = n.GetTimeSpanValue(); } }, {"channelIndex", (o,n) => { (o as TeleconferenceDeviceMediaQuality).ChannelIndex = n.GetIntValue(); } }, {"inboundPackets", (o,n) => { (o as TeleconferenceDeviceMediaQuality).InboundPackets = n.GetLongValue(); } }, {"localIPAddress", (o,n) => { (o as TeleconferenceDeviceMediaQuality).LocalIPAddress = n.GetStringValue(); } }, {"localPort", (o,n) => { (o as TeleconferenceDeviceMediaQuality).LocalPort = n.GetIntValue(); } }, - {"maximumInboundJitter", (o,n) => { (o as TeleconferenceDeviceMediaQuality).MaximumInboundJitter = n.GetStringValue(); } }, + {"maximumInboundJitter", (o,n) => { (o as TeleconferenceDeviceMediaQuality).MaximumInboundJitter = n.GetTimeSpanValue(); } }, {"maximumInboundPacketLossRateInPercentage", (o,n) => { (o as TeleconferenceDeviceMediaQuality).MaximumInboundPacketLossRateInPercentage = n.GetDoubleValue(); } }, - {"maximumInboundRoundTripDelay", (o,n) => { (o as TeleconferenceDeviceMediaQuality).MaximumInboundRoundTripDelay = n.GetStringValue(); } }, - {"maximumOutboundJitter", (o,n) => { (o as TeleconferenceDeviceMediaQuality).MaximumOutboundJitter = n.GetStringValue(); } }, + {"maximumInboundRoundTripDelay", (o,n) => { (o as TeleconferenceDeviceMediaQuality).MaximumInboundRoundTripDelay = n.GetTimeSpanValue(); } }, + {"maximumOutboundJitter", (o,n) => { (o as TeleconferenceDeviceMediaQuality).MaximumOutboundJitter = n.GetTimeSpanValue(); } }, {"maximumOutboundPacketLossRateInPercentage", (o,n) => { (o as TeleconferenceDeviceMediaQuality).MaximumOutboundPacketLossRateInPercentage = n.GetDoubleValue(); } }, - {"maximumOutboundRoundTripDelay", (o,n) => { (o as TeleconferenceDeviceMediaQuality).MaximumOutboundRoundTripDelay = n.GetStringValue(); } }, - {"mediaDuration", (o,n) => { (o as TeleconferenceDeviceMediaQuality).MediaDuration = n.GetStringValue(); } }, + {"maximumOutboundRoundTripDelay", (o,n) => { (o as TeleconferenceDeviceMediaQuality).MaximumOutboundRoundTripDelay = n.GetTimeSpanValue(); } }, + {"mediaDuration", (o,n) => { (o as TeleconferenceDeviceMediaQuality).MediaDuration = n.GetTimeSpanValue(); } }, {"networkLinkSpeedInBytes", (o,n) => { (o as TeleconferenceDeviceMediaQuality).NetworkLinkSpeedInBytes = n.GetLongValue(); } }, {"outboundPackets", (o,n) => { (o as TeleconferenceDeviceMediaQuality).OutboundPackets = n.GetLongValue(); } }, {"remoteIPAddress", (o,n) => { (o as TeleconferenceDeviceMediaQuality).RemoteIPAddress = n.GetStringValue(); } }, @@ -89,23 +89,23 @@ public IDictionary> GetFieldDeserializers() { /// public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("averageInboundJitter", AverageInboundJitter); + writer.WriteTimeSpanValue("averageInboundJitter", AverageInboundJitter); writer.WriteDoubleValue("averageInboundPacketLossRateInPercentage", AverageInboundPacketLossRateInPercentage); - writer.WriteStringValue("averageInboundRoundTripDelay", AverageInboundRoundTripDelay); - writer.WriteStringValue("averageOutboundJitter", AverageOutboundJitter); + writer.WriteTimeSpanValue("averageInboundRoundTripDelay", AverageInboundRoundTripDelay); + writer.WriteTimeSpanValue("averageOutboundJitter", AverageOutboundJitter); writer.WriteDoubleValue("averageOutboundPacketLossRateInPercentage", AverageOutboundPacketLossRateInPercentage); - writer.WriteStringValue("averageOutboundRoundTripDelay", AverageOutboundRoundTripDelay); + writer.WriteTimeSpanValue("averageOutboundRoundTripDelay", AverageOutboundRoundTripDelay); writer.WriteIntValue("channelIndex", ChannelIndex); writer.WriteLongValue("inboundPackets", InboundPackets); writer.WriteStringValue("localIPAddress", LocalIPAddress); writer.WriteIntValue("localPort", LocalPort); - writer.WriteStringValue("maximumInboundJitter", MaximumInboundJitter); + writer.WriteTimeSpanValue("maximumInboundJitter", MaximumInboundJitter); writer.WriteDoubleValue("maximumInboundPacketLossRateInPercentage", MaximumInboundPacketLossRateInPercentage); - writer.WriteStringValue("maximumInboundRoundTripDelay", MaximumInboundRoundTripDelay); - writer.WriteStringValue("maximumOutboundJitter", MaximumOutboundJitter); + writer.WriteTimeSpanValue("maximumInboundRoundTripDelay", MaximumInboundRoundTripDelay); + writer.WriteTimeSpanValue("maximumOutboundJitter", MaximumOutboundJitter); writer.WriteDoubleValue("maximumOutboundPacketLossRateInPercentage", MaximumOutboundPacketLossRateInPercentage); - writer.WriteStringValue("maximumOutboundRoundTripDelay", MaximumOutboundRoundTripDelay); - writer.WriteStringValue("mediaDuration", MediaDuration); + writer.WriteTimeSpanValue("maximumOutboundRoundTripDelay", MaximumOutboundRoundTripDelay); + writer.WriteTimeSpanValue("mediaDuration", MediaDuration); writer.WriteLongValue("networkLinkSpeedInBytes", NetworkLinkSpeedInBytes); writer.WriteLongValue("outboundPackets", OutboundPackets); writer.WriteStringValue("remoteIPAddress", RemoteIPAddress); diff --git a/src/generated/Models/Microsoft/Graph/TermStore/Group.cs b/src/generated/Models/Microsoft/Graph/TermStore/Group.cs index d1d0d7989cc..1fbc923de3f 100644 --- a/src/generated/Models/Microsoft/Graph/TermStore/Group.cs +++ b/src/generated/Models/Microsoft/Graph/TermStore/Group.cs @@ -13,9 +13,10 @@ public class Group : Entity, IParsable { public string DisplayName { get; set; } /// Id of the parent site of this group. public string ParentSiteId { get; set; } + /// Returns type of group. Possible values are 'global', 'system' and 'siteCollection'. public TermGroupScope? Scope { get; set; } /// All sets under the group in a term [store]. - public List Sets { get; set; } + public List Sets { get; set; } /// /// The deserialization information for the current model /// @@ -26,7 +27,7 @@ public class Group : Entity, IParsable { {"displayName", (o,n) => { (o as Group).DisplayName = n.GetStringValue(); } }, {"parentSiteId", (o,n) => { (o as Group).ParentSiteId = n.GetStringValue(); } }, {"scope", (o,n) => { (o as Group).Scope = n.GetEnumValue(); } }, - {"sets", (o,n) => { (o as Group).Sets = n.GetCollectionOfObjectValues().ToList(); } }, + {"sets", (o,n) => { (o as Group).Sets = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -41,7 +42,7 @@ public class Group : Entity, IParsable { writer.WriteStringValue("displayName", DisplayName); writer.WriteStringValue("parentSiteId", ParentSiteId); writer.WriteEnumValue("scope", Scope); - writer.WriteCollectionOfObjectValues("sets", Sets); + writer.WriteCollectionOfObjectValues("sets", Sets); } } } diff --git a/src/generated/Models/Microsoft/Graph/TermStore/Set.cs b/src/generated/Models/Microsoft/Graph/TermStore/Set.cs index 08ce1eb16c4..062dba66ee1 100644 --- a/src/generated/Models/Microsoft/Graph/TermStore/Set.cs +++ b/src/generated/Models/Microsoft/Graph/TermStore/Set.cs @@ -13,7 +13,7 @@ public class Set : Entity, IParsable { public string Description { get; set; } /// Name of the set for each languageTag. public List LocalizedNames { get; set; } - public ApiSdk.Models.Microsoft.Graph.Group ParentGroup { get; set; } + public ApiSdk.Models.Microsoft.Graph.TermStore.Group ParentGroup { get; set; } /// Custom properties for the set. public List Properties { get; set; } /// Indicates which terms have been pinned or reused directly under the set. @@ -29,7 +29,7 @@ public class Set : Entity, IParsable { {"createdDateTime", (o,n) => { (o as Set).CreatedDateTime = n.GetDateTimeOffsetValue(); } }, {"description", (o,n) => { (o as Set).Description = n.GetStringValue(); } }, {"localizedNames", (o,n) => { (o as Set).LocalizedNames = n.GetCollectionOfObjectValues().ToList(); } }, - {"parentGroup", (o,n) => { (o as Set).ParentGroup = n.GetObjectValue(); } }, + {"parentGroup", (o,n) => { (o as Set).ParentGroup = n.GetObjectValue(); } }, {"properties", (o,n) => { (o as Set).Properties = n.GetCollectionOfObjectValues().ToList(); } }, {"relations", (o,n) => { (o as Set).Relations = n.GetCollectionOfObjectValues().ToList(); } }, {"terms", (o,n) => { (o as Set).Terms = n.GetCollectionOfObjectValues().ToList(); } }, @@ -46,7 +46,7 @@ public class Set : Entity, IParsable { writer.WriteDateTimeOffsetValue("createdDateTime", CreatedDateTime); writer.WriteStringValue("description", Description); writer.WriteCollectionOfObjectValues("localizedNames", LocalizedNames); - writer.WriteObjectValue("parentGroup", ParentGroup); + writer.WriteObjectValue("parentGroup", ParentGroup); writer.WriteCollectionOfObjectValues("properties", Properties); writer.WriteCollectionOfObjectValues("relations", Relations); writer.WriteCollectionOfObjectValues("terms", Terms); diff --git a/src/generated/Models/Microsoft/Graph/TermStore/Store.cs b/src/generated/Models/Microsoft/Graph/TermStore/Store.cs index 62d878f7180..e41198d9abc 100644 --- a/src/generated/Models/Microsoft/Graph/TermStore/Store.cs +++ b/src/generated/Models/Microsoft/Graph/TermStore/Store.cs @@ -8,7 +8,7 @@ public class Store : Entity, IParsable { /// Default language of the term store. public string DefaultLanguageTag { get; set; } /// Collection of all groups available in the term store. - public List Groups { get; set; } + public List Groups { get; set; } /// List of languages for the term store. public List LanguageTags { get; set; } /// Collection of all sets available in the term store. @@ -19,7 +19,7 @@ public class Store : Entity, IParsable { public new IDictionary> GetFieldDeserializers() { return new Dictionary>(base.GetFieldDeserializers()) { {"defaultLanguageTag", (o,n) => { (o as Store).DefaultLanguageTag = n.GetStringValue(); } }, - {"groups", (o,n) => { (o as Store).Groups = n.GetCollectionOfObjectValues().ToList(); } }, + {"groups", (o,n) => { (o as Store).Groups = n.GetCollectionOfObjectValues().ToList(); } }, {"languageTags", (o,n) => { (o as Store).LanguageTags = n.GetCollectionOfPrimitiveValues().ToList(); } }, {"sets", (o,n) => { (o as Store).Sets = n.GetCollectionOfObjectValues().ToList(); } }, }; @@ -32,7 +32,7 @@ public class Store : Entity, IParsable { _ = writer ?? throw new ArgumentNullException(nameof(writer)); base.Serialize(writer); writer.WriteStringValue("defaultLanguageTag", DefaultLanguageTag); - writer.WriteCollectionOfObjectValues("groups", Groups); + writer.WriteCollectionOfObjectValues("groups", Groups); writer.WriteCollectionOfPrimitiveValues("languageTags", LanguageTags); writer.WriteCollectionOfObjectValues("sets", Sets); } diff --git a/src/generated/Models/Microsoft/Graph/TermsExpiration.cs b/src/generated/Models/Microsoft/Graph/TermsExpiration.cs index f01d3bd8909..40d0b2f9386 100644 --- a/src/generated/Models/Microsoft/Graph/TermsExpiration.cs +++ b/src/generated/Models/Microsoft/Graph/TermsExpiration.cs @@ -8,7 +8,7 @@ public class TermsExpiration : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } /// Represents the frequency at which the terms will expire, after its first expiration as set in startDateTime. The value is represented in ISO 8601 format for durations. For example, PT1M represents a time period of 1 month. - public string Frequency { get; set; } + public TimeSpan? Frequency { get; set; } /// The DateTime when the agreement is set to expire for all users. The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time. For example, midnight UTC on Jan 1, 2014 is 2014-01-01T00:00:00Z. public DateTimeOffset? StartDateTime { get; set; } /// @@ -22,7 +22,7 @@ public TermsExpiration() { /// public IDictionary> GetFieldDeserializers() { return new Dictionary> { - {"frequency", (o,n) => { (o as TermsExpiration).Frequency = n.GetStringValue(); } }, + {"frequency", (o,n) => { (o as TermsExpiration).Frequency = n.GetTimeSpanValue(); } }, {"startDateTime", (o,n) => { (o as TermsExpiration).StartDateTime = n.GetDateTimeOffsetValue(); } }, }; } @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { /// public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("frequency", Frequency); + writer.WriteTimeSpanValue("frequency", Frequency); writer.WriteDateTimeOffsetValue("startDateTime", StartDateTime); writer.WriteAdditionalData(AdditionalData); } diff --git a/src/generated/Models/Microsoft/Graph/TimeRange.cs b/src/generated/Models/Microsoft/Graph/TimeRange.cs index cb870eec16c..ac1ff3d52e8 100644 --- a/src/generated/Models/Microsoft/Graph/TimeRange.cs +++ b/src/generated/Models/Microsoft/Graph/TimeRange.cs @@ -1,3 +1,4 @@ +using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; using System; using System.Collections.Generic; @@ -8,9 +9,9 @@ public class TimeRange : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } /// End time for the time range. - public string EndTime { get; set; } + public Time? EndTime { get; set; } /// Start time for the time range. - public string StartTime { get; set; } + public Time? StartTime { get; set; } /// /// Instantiates a new timeRange and sets the default values. /// @@ -22,8 +23,8 @@ public TimeRange() { /// public IDictionary> GetFieldDeserializers() { return new Dictionary> { - {"endTime", (o,n) => { (o as TimeRange).EndTime = n.GetStringValue(); } }, - {"startTime", (o,n) => { (o as TimeRange).StartTime = n.GetStringValue(); } }, + {"endTime", (o,n) => { (o as TimeRange).EndTime = n.GetTimeValue(); } }, + {"startTime", (o,n) => { (o as TimeRange).StartTime = n.GetTimeValue(); } }, }; } /// @@ -32,8 +33,8 @@ public IDictionary> GetFieldDeserializers() { /// public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("endTime", EndTime); - writer.WriteStringValue("startTime", StartTime); + writer.WriteTimeValue("endTime", EndTime); + writer.WriteTimeValue("startTime", StartTime); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Models/Microsoft/Graph/TimeZoneInformation.cs b/src/generated/Models/Microsoft/Graph/TimeZoneInformation.cs new file mode 100644 index 00000000000..f2ee36935cc --- /dev/null +++ b/src/generated/Models/Microsoft/Graph/TimeZoneInformation.cs @@ -0,0 +1,40 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Models.Microsoft.Graph { + public class TimeZoneInformation : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// An identifier for the time zone. + public string Alias { get; set; } + /// A display string that represents the time zone. + public string DisplayName { get; set; } + /// + /// Instantiates a new TimeZoneInformation and sets the default values. + /// + public TimeZoneInformation() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"alias", (o,n) => { (o as TimeZoneInformation).Alias = n.GetStringValue(); } }, + {"displayName", (o,n) => { (o as TimeZoneInformation).DisplayName = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("alias", Alias); + writer.WriteStringValue("displayName", DisplayName); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Models/Microsoft/Graph/User.cs b/src/generated/Models/Microsoft/Graph/User.cs index 11622735cef..4e41881666b 100644 --- a/src/generated/Models/Microsoft/Graph/User.cs +++ b/src/generated/Models/Microsoft/Graph/User.cs @@ -33,7 +33,7 @@ public class User : DirectoryObject, IParsable { /// The user's calendars. Read-only. Nullable. public List Calendars { get; set; } /// The calendar view for the calendar. Read-only. Nullable. - public List<@Event> CalendarView { get; set; } + public List CalendarView { get; set; } public List Chats { get; set; } /// The city in which the user is located. Maximum length is 128 characters. Supports $filter (eq, ne, not, ge, le, in, startsWith, and eq on null values). public string City { get; set; } @@ -76,7 +76,7 @@ public class User : DirectoryObject, IParsable { /// Captures enterprise worker type. For example, Employee, Contractor, Consultant, or Vendor. Supports $filter (eq, ne, not , ge, le, in, startsWith). public string EmployeeType { get; set; } /// The user's events. Default is to show events under the Default Calendar. Read-only. Nullable. - public List<@Event> Events { get; set; } + public List Events { get; set; } /// The collection of open extensions defined for the user. Nullable. public List Extensions { get; set; } /// For an external user invited to the tenant using the invitation API, this property represents the invited user's invitation status. For invited users, the state can be PendingAcceptance or Accepted, or null for all other users. Supports $filter (eq, ne, not , in). @@ -247,7 +247,7 @@ public class User : DirectoryObject, IParsable { {"calendar", (o,n) => { (o as User).Calendar = n.GetObjectValue(); } }, {"calendarGroups", (o,n) => { (o as User).CalendarGroups = n.GetCollectionOfObjectValues().ToList(); } }, {"calendars", (o,n) => { (o as User).Calendars = n.GetCollectionOfObjectValues().ToList(); } }, - {"calendarView", (o,n) => { (o as User).CalendarView = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"calendarView", (o,n) => { (o as User).CalendarView = n.GetCollectionOfObjectValues().ToList(); } }, {"chats", (o,n) => { (o as User).Chats = n.GetCollectionOfObjectValues().ToList(); } }, {"city", (o,n) => { (o as User).City = n.GetStringValue(); } }, {"companyName", (o,n) => { (o as User).CompanyName = n.GetStringValue(); } }, @@ -269,7 +269,7 @@ public class User : DirectoryObject, IParsable { {"employeeId", (o,n) => { (o as User).EmployeeId = n.GetStringValue(); } }, {"employeeOrgData", (o,n) => { (o as User).EmployeeOrgData = n.GetObjectValue(); } }, {"employeeType", (o,n) => { (o as User).EmployeeType = n.GetStringValue(); } }, - {"events", (o,n) => { (o as User).Events = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"events", (o,n) => { (o as User).Events = n.GetCollectionOfObjectValues().ToList(); } }, {"extensions", (o,n) => { (o as User).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, {"externalUserState", (o,n) => { (o as User).ExternalUserState = n.GetStringValue(); } }, {"externalUserStateChangeDateTime", (o,n) => { (o as User).ExternalUserStateChangeDateTime = n.GetDateTimeOffsetValue(); } }, @@ -371,7 +371,7 @@ public class User : DirectoryObject, IParsable { writer.WriteObjectValue("calendar", Calendar); writer.WriteCollectionOfObjectValues("calendarGroups", CalendarGroups); writer.WriteCollectionOfObjectValues("calendars", Calendars); - writer.WriteCollectionOfObjectValues<@Event>("calendarView", CalendarView); + writer.WriteCollectionOfObjectValues("calendarView", CalendarView); writer.WriteCollectionOfObjectValues("chats", Chats); writer.WriteStringValue("city", City); writer.WriteStringValue("companyName", CompanyName); @@ -393,7 +393,7 @@ public class User : DirectoryObject, IParsable { writer.WriteStringValue("employeeId", EmployeeId); writer.WriteObjectValue("employeeOrgData", EmployeeOrgData); writer.WriteStringValue("employeeType", EmployeeType); - writer.WriteCollectionOfObjectValues<@Event>("events", Events); + writer.WriteCollectionOfObjectValues("events", Events); writer.WriteCollectionOfObjectValues("extensions", Extensions); writer.WriteStringValue("externalUserState", ExternalUserState); writer.WriteDateTimeOffsetValue("externalUserStateChangeDateTime", ExternalUserStateChangeDateTime); diff --git a/src/generated/Models/Microsoft/Graph/WorkbookFilterCriteria.cs b/src/generated/Models/Microsoft/Graph/WorkbookFilterCriteria.cs index b75efd66f37..9051e216396 100644 --- a/src/generated/Models/Microsoft/Graph/WorkbookFilterCriteria.cs +++ b/src/generated/Models/Microsoft/Graph/WorkbookFilterCriteria.cs @@ -5,7 +5,6 @@ using System.Linq; namespace ApiSdk.Models.Microsoft.Graph { public class WorkbookFilterCriteria : IParsable { - public string @Operator { get; set; } /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string Color { get; set; } @@ -14,6 +13,7 @@ public class WorkbookFilterCriteria : IParsable { public string DynamicCriteria { get; set; } public string FilterOn { get; set; } public WorkbookIcon Icon { get; set; } + public string Operator { get; set; } public Json Values { get; set; } /// /// Instantiates a new workbookFilterCriteria and sets the default values. @@ -26,13 +26,13 @@ public WorkbookFilterCriteria() { /// public IDictionary> GetFieldDeserializers() { return new Dictionary> { - {"operator", (o,n) => { (o as WorkbookFilterCriteria).@Operator = n.GetStringValue(); } }, {"color", (o,n) => { (o as WorkbookFilterCriteria).Color = n.GetStringValue(); } }, {"criterion1", (o,n) => { (o as WorkbookFilterCriteria).Criterion1 = n.GetStringValue(); } }, {"criterion2", (o,n) => { (o as WorkbookFilterCriteria).Criterion2 = n.GetStringValue(); } }, {"dynamicCriteria", (o,n) => { (o as WorkbookFilterCriteria).DynamicCriteria = n.GetStringValue(); } }, {"filterOn", (o,n) => { (o as WorkbookFilterCriteria).FilterOn = n.GetStringValue(); } }, {"icon", (o,n) => { (o as WorkbookFilterCriteria).Icon = n.GetObjectValue(); } }, + {"operator", (o,n) => { (o as WorkbookFilterCriteria).Operator = n.GetStringValue(); } }, {"values", (o,n) => { (o as WorkbookFilterCriteria).Values = n.GetObjectValue(); } }, }; } @@ -42,13 +42,13 @@ public IDictionary> GetFieldDeserializers() { /// public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("operator", @Operator); writer.WriteStringValue("color", Color); writer.WriteStringValue("criterion1", Criterion1); writer.WriteStringValue("criterion2", Criterion2); writer.WriteStringValue("dynamicCriteria", DynamicCriteria); writer.WriteStringValue("filterOn", FilterOn); writer.WriteObjectValue("icon", Icon); + writer.WriteStringValue("operator", Operator); writer.WriteObjectValue("values", Values); writer.WriteAdditionalData(AdditionalData); } diff --git a/src/generated/Models/Microsoft/Graph/WorkbookSortField.cs b/src/generated/Models/Microsoft/Graph/WorkbookSortField.cs index 7c9d8dd6acf..fc486c549fc 100644 --- a/src/generated/Models/Microsoft/Graph/WorkbookSortField.cs +++ b/src/generated/Models/Microsoft/Graph/WorkbookSortField.cs @@ -5,10 +5,10 @@ using System.Linq; namespace ApiSdk.Models.Microsoft.Graph { public class WorkbookSortField : IParsable { - /// Represents whether the sorting is done in an ascending fashion. - public bool? @Ascending { get; set; } /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } + /// Represents whether the sorting is done in an ascending fashion. + public bool? Ascending { get; set; } /// Represents the color that is the target of the condition if the sorting is on font or cell color. public string Color { get; set; } /// Represents additional sorting options for this field. Possible values are: Normal, TextAsNumber. @@ -30,7 +30,7 @@ public WorkbookSortField() { /// public IDictionary> GetFieldDeserializers() { return new Dictionary> { - {"ascending", (o,n) => { (o as WorkbookSortField).@Ascending = n.GetBoolValue(); } }, + {"ascending", (o,n) => { (o as WorkbookSortField).Ascending = n.GetBoolValue(); } }, {"color", (o,n) => { (o as WorkbookSortField).Color = n.GetStringValue(); } }, {"dataOption", (o,n) => { (o as WorkbookSortField).DataOption = n.GetStringValue(); } }, {"icon", (o,n) => { (o as WorkbookSortField).Icon = n.GetObjectValue(); } }, @@ -44,7 +44,7 @@ public IDictionary> GetFieldDeserializers() { /// public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteBoolValue("ascending", @Ascending); + writer.WriteBoolValue("ascending", Ascending); writer.WriteStringValue("color", Color); writer.WriteStringValue("dataOption", DataOption); writer.WriteObjectValue("icon", Icon); diff --git a/src/generated/Models/Microsoft/Graph/WorkbookWorksheetProtection.cs b/src/generated/Models/Microsoft/Graph/WorkbookWorksheetProtection.cs index dab87188fd9..13bdaa41aea 100644 --- a/src/generated/Models/Microsoft/Graph/WorkbookWorksheetProtection.cs +++ b/src/generated/Models/Microsoft/Graph/WorkbookWorksheetProtection.cs @@ -5,17 +5,17 @@ using System.Linq; namespace ApiSdk.Models.Microsoft.Graph { public class WorkbookWorksheetProtection : Entity, IParsable { - /// Indicates if the worksheet is protected. Read-only. - public bool? @Protected { get; set; } /// Sheet protection options. Read-only. public WorkbookWorksheetProtectionOptions Options { get; set; } + /// Indicates if the worksheet is protected. Read-only. + public bool? Protected { get; set; } /// /// The deserialization information for the current model /// public new IDictionary> GetFieldDeserializers() { return new Dictionary>(base.GetFieldDeserializers()) { - {"protected", (o,n) => { (o as WorkbookWorksheetProtection).@Protected = n.GetBoolValue(); } }, {"options", (o,n) => { (o as WorkbookWorksheetProtection).Options = n.GetObjectValue(); } }, + {"protected", (o,n) => { (o as WorkbookWorksheetProtection).Protected = n.GetBoolValue(); } }, }; } /// @@ -25,8 +25,8 @@ public class WorkbookWorksheetProtection : Entity, IParsable { public new void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); base.Serialize(writer); - writer.WriteBoolValue("protected", @Protected); writer.WriteObjectValue("options", Options); + writer.WriteBoolValue("protected", Protected); } } } diff --git a/src/generated/Models/Microsoft/Graph/WorkingHours.cs b/src/generated/Models/Microsoft/Graph/WorkingHours.cs index 32da091a9d3..d227b75a847 100644 --- a/src/generated/Models/Microsoft/Graph/WorkingHours.cs +++ b/src/generated/Models/Microsoft/Graph/WorkingHours.cs @@ -1,3 +1,4 @@ +using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; using System; using System.Collections.Generic; @@ -10,9 +11,9 @@ public class WorkingHours : IParsable { /// The days of the week on which the user works. public List DaysOfWeek { get; set; } /// The time of the day that the user stops working. - public string EndTime { get; set; } + public Time? EndTime { get; set; } /// The time of the day that the user starts working. - public string StartTime { get; set; } + public Time? StartTime { get; set; } /// The time zone to which the working hours apply. public TimeZoneBase TimeZone { get; set; } /// @@ -27,8 +28,8 @@ public WorkingHours() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"daysOfWeek", (o,n) => { (o as WorkingHours).DaysOfWeek = n.GetCollectionOfEnumValues().ToList(); } }, - {"endTime", (o,n) => { (o as WorkingHours).EndTime = n.GetStringValue(); } }, - {"startTime", (o,n) => { (o as WorkingHours).StartTime = n.GetStringValue(); } }, + {"endTime", (o,n) => { (o as WorkingHours).EndTime = n.GetTimeValue(); } }, + {"startTime", (o,n) => { (o as WorkingHours).StartTime = n.GetTimeValue(); } }, {"timeZone", (o,n) => { (o as WorkingHours).TimeZone = n.GetObjectValue(); } }, }; } @@ -39,8 +40,8 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteCollectionOfEnumValues("daysOfWeek", DaysOfWeek); - writer.WriteStringValue("endTime", EndTime); - writer.WriteStringValue("startTime", StartTime); + writer.WriteTimeValue("endTime", EndTime); + writer.WriteTimeValue("startTime", StartTime); writer.WriteObjectValue("timeZone", TimeZone); writer.WriteAdditionalData(AdditionalData); } diff --git a/src/generated/Oauth2PermissionGrants/Delta/DeltaRequestBuilder.cs b/src/generated/Oauth2PermissionGrants/Delta/DeltaRequestBuilder.cs index 502e6b54104..d0e2c91fe17 100644 --- a/src/generated/Oauth2PermissionGrants/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Oauth2PermissionGrants/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Oauth2PermissionGrants/Item/OAuth2PermissionGrantRequestBuilder.cs b/src/generated/Oauth2PermissionGrants/Item/OAuth2PermissionGrantRequestBuilder.cs index b48962bd4a8..be07c9db474 100644 --- a/src/generated/Oauth2PermissionGrants/Item/OAuth2PermissionGrantRequestBuilder.cs +++ b/src/generated/Oauth2PermissionGrants/Item/OAuth2PermissionGrantRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete entity from oauth2PermissionGrants"; // Create options for all the parameters - var oAuth2PermissionGrantIdOption = new Option("--oauth2permissiongrant-id", description: "key: id of oAuth2PermissionGrant") { + var oAuth2PermissionGrantIdOption = new Option("--o-auth2permission-grant-id", description: "key: id of oAuth2PermissionGrant") { }; oAuth2PermissionGrantIdOption.IsRequired = true; command.AddOption(oAuth2PermissionGrantIdOption); - command.SetHandler(async (string oAuth2PermissionGrantId) => { + command.SetHandler(async (string oAuth2PermissionGrantId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, oAuth2PermissionGrantIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get entity from oauth2PermissionGrants by key"; // Create options for all the parameters - var oAuth2PermissionGrantIdOption = new Option("--oauth2permissiongrant-id", description: "key: id of oAuth2PermissionGrant") { + var oAuth2PermissionGrantIdOption = new Option("--o-auth2permission-grant-id", description: "key: id of oAuth2PermissionGrant") { }; oAuth2PermissionGrantIdOption.IsRequired = true; command.AddOption(oAuth2PermissionGrantIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string oAuth2PermissionGrantId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string oAuth2PermissionGrantId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, oAuth2PermissionGrantIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, oAuth2PermissionGrantIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update entity in oauth2PermissionGrants"; // Create options for all the parameters - var oAuth2PermissionGrantIdOption = new Option("--oauth2permissiongrant-id", description: "key: id of oAuth2PermissionGrant") { + var oAuth2PermissionGrantIdOption = new Option("--o-auth2permission-grant-id", description: "key: id of oAuth2PermissionGrant") { }; oAuth2PermissionGrantIdOption.IsRequired = true; command.AddOption(oAuth2PermissionGrantIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string oAuth2PermissionGrantId, string body) => { + command.SetHandler(async (string oAuth2PermissionGrantId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, oAuth2PermissionGrantIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(OAuth2PermissionGrant bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from oauth2PermissionGrants - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from oauth2PermissionGrants by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in oauth2PermissionGrants - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OAuth2PermissionGrant model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from oauth2PermissionGrants by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Oauth2PermissionGrants/Oauth2PermissionGrantsRequestBuilder.cs b/src/generated/Oauth2PermissionGrants/Oauth2PermissionGrantsRequestBuilder.cs index 5edc4987938..a752f6bfcd0 100644 --- a/src/generated/Oauth2PermissionGrants/Oauth2PermissionGrantsRequestBuilder.cs +++ b/src/generated/Oauth2PermissionGrants/Oauth2PermissionGrantsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Oauth2PermissionGrants.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class Oauth2PermissionGrantsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OAuth2PermissionGrantRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -180,31 +177,6 @@ public RequestInformation CreatePostRequestInformation(OAuth2PermissionGrant bod public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// Get entities from oauth2PermissionGrants - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to oauth2PermissionGrants - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OAuth2PermissionGrant model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from oauth2PermissionGrants public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Organization/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs b/src/generated/Organization/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs deleted file mode 100644 index 30b4fc04090..00000000000 --- a/src/generated/Organization/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs +++ /dev/null @@ -1,45 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Organization.GetAvailableExtensionProperties { - public class GetAvailableExtensionProperties : DirectoryObject, IParsable { - /// Display name of the application object on which this extension property is defined. Read-only. - public string AppDisplayName { get; set; } - /// Specifies the data type of the value the extension property can hold. Following values are supported. Not nullable. Binary - 256 bytes maximumBooleanDateTime - Must be specified in ISO 8601 format. Will be stored in UTC.Integer - 32-bit value.LargeInteger - 64-bit value.String - 256 characters maximum - public string DataType { get; set; } - /// Indicates if this extension property was sycned from onpremises directory using Azure AD Connect. Read-only. - public bool? IsSyncedFromOnPremises { get; set; } - /// Name of the extension property. Not nullable. - public string Name { get; set; } - /// Following values are supported. Not nullable. UserGroupOrganizationDeviceApplication - public List TargetObjects { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"appDisplayName", (o,n) => { (o as GetAvailableExtensionProperties).AppDisplayName = n.GetStringValue(); } }, - {"dataType", (o,n) => { (o as GetAvailableExtensionProperties).DataType = n.GetStringValue(); } }, - {"isSyncedFromOnPremises", (o,n) => { (o as GetAvailableExtensionProperties).IsSyncedFromOnPremises = n.GetBoolValue(); } }, - {"name", (o,n) => { (o as GetAvailableExtensionProperties).Name = n.GetStringValue(); } }, - {"targetObjects", (o,n) => { (o as GetAvailableExtensionProperties).TargetObjects = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteStringValue("appDisplayName", AppDisplayName); - writer.WriteStringValue("dataType", DataType); - writer.WriteBoolValue("isSyncedFromOnPremises", IsSyncedFromOnPremises); - writer.WriteStringValue("name", Name); - writer.WriteCollectionOfPrimitiveValues("targetObjects", TargetObjects); - } - } -} diff --git a/src/generated/Organization/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs b/src/generated/Organization/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs index 6002696f79c..f889ae275fd 100644 --- a/src/generated/Organization/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs +++ b/src/generated/Organization/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(GetAvailableExtensionProp requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getAvailableExtensionProperties - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetAvailableExtensionPropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Organization/GetByIds/GetByIds.cs b/src/generated/Organization/GetByIds/GetByIds.cs deleted file mode 100644 index e51068e8cc6..00000000000 --- a/src/generated/Organization/GetByIds/GetByIds.cs +++ /dev/null @@ -1,28 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Organization.GetByIds { - public class GetByIds : Entity, IParsable { - public DateTimeOffset? DeletedDateTime { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"deletedDateTime", (o,n) => { (o as GetByIds).DeletedDateTime = n.GetDateTimeOffsetValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteDateTimeOffsetValue("deletedDateTime", DeletedDateTime); - } - } -} diff --git a/src/generated/Organization/GetByIds/GetByIdsRequestBuilder.cs b/src/generated/Organization/GetByIds/GetByIdsRequestBuilder.cs index 0167b2014c1..295cf26f32e 100644 --- a/src/generated/Organization/GetByIds/GetByIdsRequestBuilder.cs +++ b/src/generated/Organization/GetByIds/GetByIdsRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(GetByIdsRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getByIds - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetByIdsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Organization/Item/Branding/BrandingRequestBuilder.cs b/src/generated/Organization/Item/Branding/BrandingRequestBuilder.cs index cbdacc2ac4c..834f573f9fc 100644 --- a/src/generated/Organization/Item/Branding/BrandingRequestBuilder.cs +++ b/src/generated/Organization/Item/Branding/BrandingRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Organization.Item.Branding { - /// Builds and executes requests for operations under \organization\{organization-id}\branding + /// Builds and executes requests for operations under \organization\{organizationItem-Id}\branding public class BrandingRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,17 +26,16 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property branding for organization"; // Create options for all the parameters - var organizationIdOption = new Option("--organization-id", description: "key: id of organization") { + var organizationItemIdOption = new Option("--organization-item-id", description: "key: id of organization") { }; - organizationIdOption.IsRequired = true; - command.AddOption(organizationIdOption); - command.SetHandler(async (string organizationId) => { + organizationItemIdOption.IsRequired = true; + command.AddOption(organizationItemIdOption); + command.SetHandler(async (string organizationItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, organizationIdOption); + }, organizationItemIdOption); return command; } /// @@ -46,10 +45,10 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get branding from organization"; // Create options for all the parameters - var organizationIdOption = new Option("--organization-id", description: "key: id of organization") { + var organizationItemIdOption = new Option("--organization-item-id", description: "key: id of organization") { }; - organizationIdOption.IsRequired = true; - command.AddOption(organizationIdOption); + organizationItemIdOption.IsRequired = true; + command.AddOption(organizationItemIdOption); var selectOption = new Option("--select", description: "Select properties to be returned") { Arity = ArgumentArity.ZeroOrMore }; @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string organizationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string organizationItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, organizationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, organizationItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,24 +81,23 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property branding in organization"; // Create options for all the parameters - var organizationIdOption = new Option("--organization-id", description: "key: id of organization") { + var organizationItemIdOption = new Option("--organization-item-id", description: "key: id of organization") { }; - organizationIdOption.IsRequired = true; - command.AddOption(organizationIdOption); + organizationItemIdOption.IsRequired = true; + command.AddOption(organizationItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string organizationId, string body) => { + command.SetHandler(async (string organizationItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, organizationIdOption, bodyOption); + }, organizationItemIdOption, bodyOption); return command; } /// @@ -111,7 +108,7 @@ public Command BuildPatchCommand() { public BrandingRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/organization/{organization_id}/branding{?select,expand}"; + UrlTemplate = "{+baseurl}/organization/{organizationItem_Id}/branding{?select,expand}"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(OrganizationalBranding b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property branding for organization - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get branding from organization - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property branding in organization - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OrganizationalBranding model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get branding from organization public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Organization/Item/CertificateBasedAuthConfiguration/@Ref/@Ref.cs b/src/generated/Organization/Item/CertificateBasedAuthConfiguration/@Ref/@Ref.cs deleted file mode 100644 index f30af49231c..00000000000 --- a/src/generated/Organization/Item/CertificateBasedAuthConfiguration/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Organization.Item.CertificateBasedAuthConfiguration.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Organization/Item/CertificateBasedAuthConfiguration/@Ref/RefRequestBuilder.cs b/src/generated/Organization/Item/CertificateBasedAuthConfiguration/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 91d5eefa922..00000000000 --- a/src/generated/Organization/Item/CertificateBasedAuthConfiguration/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Organization.Item.CertificateBasedAuthConfiguration.@Ref { - /// Builds and executes requests for operations under \organization\{organization-id}\certificateBasedAuthConfiguration\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Navigation property to manage certificate-based authentication configuration. Only a single instance of certificateBasedAuthConfiguration can be created in the collection. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Navigation property to manage certificate-based authentication configuration. Only a single instance of certificateBasedAuthConfiguration can be created in the collection."; - // Create options for all the parameters - var organizationIdOption = new Option("--organization-id", description: "key: id of organization") { - }; - organizationIdOption.IsRequired = true; - command.AddOption(organizationIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string organizationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, organizationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Navigation property to manage certificate-based authentication configuration. Only a single instance of certificateBasedAuthConfiguration can be created in the collection. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Navigation property to manage certificate-based authentication configuration. Only a single instance of certificateBasedAuthConfiguration can be created in the collection."; - // Create options for all the parameters - var organizationIdOption = new Option("--organization-id", description: "key: id of organization") { - }; - organizationIdOption.IsRequired = true; - command.AddOption(organizationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string organizationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, organizationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/organization/{organization_id}/certificateBasedAuthConfiguration/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Navigation property to manage certificate-based authentication configuration. Only a single instance of certificateBasedAuthConfiguration can be created in the collection. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Navigation property to manage certificate-based authentication configuration. Only a single instance of certificateBasedAuthConfiguration can be created in the collection. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Organization.Item.CertificateBasedAuthConfiguration.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Navigation property to manage certificate-based authentication configuration. Only a single instance of certificateBasedAuthConfiguration can be created in the collection. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Navigation property to manage certificate-based authentication configuration. Only a single instance of certificateBasedAuthConfiguration can be created in the collection. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Organization.Item.CertificateBasedAuthConfiguration.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Navigation property to manage certificate-based authentication configuration. Only a single instance of certificateBasedAuthConfiguration can be created in the collection. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Organization/Item/CertificateBasedAuthConfiguration/@Ref/RefResponse.cs b/src/generated/Organization/Item/CertificateBasedAuthConfiguration/@Ref/RefResponse.cs deleted file mode 100644 index 0e3dfb6f21a..00000000000 --- a/src/generated/Organization/Item/CertificateBasedAuthConfiguration/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Organization.Item.CertificateBasedAuthConfiguration.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Organization/Item/CertificateBasedAuthConfiguration/CertificateBasedAuthConfigurationRequestBuilder.cs b/src/generated/Organization/Item/CertificateBasedAuthConfiguration/CertificateBasedAuthConfigurationRequestBuilder.cs index 55e39e23e1b..a4c22ad16bb 100644 --- a/src/generated/Organization/Item/CertificateBasedAuthConfiguration/CertificateBasedAuthConfigurationRequestBuilder.cs +++ b/src/generated/Organization/Item/CertificateBasedAuthConfiguration/CertificateBasedAuthConfigurationRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Organization.Item.CertificateBasedAuthConfiguration.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Organization.Item.CertificateBasedAuthConfiguration { - /// Builds and executes requests for operations under \organization\{organization-id}\certificateBasedAuthConfiguration + /// Builds and executes requests for operations under \organization\{organizationItem-Id}\certificateBasedAuthConfiguration public class CertificateBasedAuthConfigurationRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,10 +26,10 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Navigation property to manage certificate-based authentication configuration. Only a single instance of certificateBasedAuthConfiguration can be created in the collection."; // Create options for all the parameters - var organizationIdOption = new Option("--organization-id", description: "key: id of organization") { + var organizationItemIdOption = new Option("--organization-item-id", description: "key: id of organization") { }; - organizationIdOption.IsRequired = true; - command.AddOption(organizationIdOption); + organizationItemIdOption.IsRequired = true; + command.AddOption(organizationItemIdOption); var topOption = new Option("--top", description: "Show only the first n items") { }; topOption.IsRequired = false; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string organizationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string organizationItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, organizationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, organizationItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Organization.Item.CertificateBasedAuthConfiguration.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Organization.Item.CertificateBasedAuthConfiguration.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -102,7 +101,7 @@ public Command BuildRefCommand() { public CertificateBasedAuthConfigurationRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/organization/{organization_id}/certificateBasedAuthConfiguration{?top,skip,search,filter,count,orderby,select,expand}"; + UrlTemplate = "{+baseurl}/organization/{organizationItem_Id}/certificateBasedAuthConfiguration{?top,skip,search,filter,count,orderby,select,expand}"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Navigation property to manage certificate-based authentication configuration. Only a single instance of certificateBasedAuthConfiguration can be created in the collection. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Navigation property to manage certificate-based authentication configuration. Only a single instance of certificateBasedAuthConfiguration can be created in the collection. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Organization/Item/CertificateBasedAuthConfiguration/Ref/Ref.cs b/src/generated/Organization/Item/CertificateBasedAuthConfiguration/Ref/Ref.cs new file mode 100644 index 00000000000..6868d60328e --- /dev/null +++ b/src/generated/Organization/Item/CertificateBasedAuthConfiguration/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Organization.Item.CertificateBasedAuthConfiguration.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Organization/Item/CertificateBasedAuthConfiguration/Ref/RefRequestBuilder.cs b/src/generated/Organization/Item/CertificateBasedAuthConfiguration/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..c2862ebe18b --- /dev/null +++ b/src/generated/Organization/Item/CertificateBasedAuthConfiguration/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Organization.Item.CertificateBasedAuthConfiguration.Ref { + /// Builds and executes requests for operations under \organization\{organizationItem-Id}\certificateBasedAuthConfiguration\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Navigation property to manage certificate-based authentication configuration. Only a single instance of certificateBasedAuthConfiguration can be created in the collection. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Navigation property to manage certificate-based authentication configuration. Only a single instance of certificateBasedAuthConfiguration can be created in the collection."; + // Create options for all the parameters + var organizationItemIdOption = new Option("--organization-item-id", description: "key: id of organization") { + }; + organizationItemIdOption.IsRequired = true; + command.AddOption(organizationItemIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string organizationItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, organizationItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Navigation property to manage certificate-based authentication configuration. Only a single instance of certificateBasedAuthConfiguration can be created in the collection. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Navigation property to manage certificate-based authentication configuration. Only a single instance of certificateBasedAuthConfiguration can be created in the collection."; + // Create options for all the parameters + var organizationItemIdOption = new Option("--organization-item-id", description: "key: id of organization") { + }; + organizationItemIdOption.IsRequired = true; + command.AddOption(organizationItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string organizationItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, organizationItemIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/organization/{organizationItem_Id}/certificateBasedAuthConfiguration/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Navigation property to manage certificate-based authentication configuration. Only a single instance of certificateBasedAuthConfiguration can be created in the collection. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Navigation property to manage certificate-based authentication configuration. Only a single instance of certificateBasedAuthConfiguration can be created in the collection. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Organization.Item.CertificateBasedAuthConfiguration.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Navigation property to manage certificate-based authentication configuration. Only a single instance of certificateBasedAuthConfiguration can be created in the collection. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Organization/Item/CertificateBasedAuthConfiguration/Ref/RefResponse.cs b/src/generated/Organization/Item/CertificateBasedAuthConfiguration/Ref/RefResponse.cs new file mode 100644 index 00000000000..63a2eeee606 --- /dev/null +++ b/src/generated/Organization/Item/CertificateBasedAuthConfiguration/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Organization.Item.CertificateBasedAuthConfiguration.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Organization/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs b/src/generated/Organization/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs index 557c66f69b4..d011da7ec53 100644 --- a/src/generated/Organization/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs +++ b/src/generated/Organization/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Organization.Item.CheckMemberGroups { - /// Builds and executes requests for operations under \organization\{organization-id}\microsoft.graph.checkMemberGroups + /// Builds and executes requests for operations under \organization\{organizationItem-Id}\microsoft.graph.checkMemberGroups public class CheckMemberGroupsRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -25,29 +25,28 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action checkMemberGroups"; // Create options for all the parameters - var organizationIdOption = new Option("--organization-id", description: "key: id of organization") { + var organizationItemIdOption = new Option("--organization-item-id", description: "key: id of organization") { }; - organizationIdOption.IsRequired = true; - command.AddOption(organizationIdOption); + organizationItemIdOption.IsRequired = true; + command.AddOption(organizationItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string organizationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string organizationItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, organizationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, organizationItemIdOption, bodyOption, outputOption); return command; } /// @@ -58,7 +57,7 @@ public Command BuildPostCommand() { public CheckMemberGroupsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/organization/{organization_id}/microsoft.graph.checkMemberGroups"; + UrlTemplate = "{+baseurl}/organization/{organizationItem_Id}/microsoft.graph.checkMemberGroups"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberGroupsRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Organization/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs b/src/generated/Organization/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs index 68568306269..590ed02c550 100644 --- a/src/generated/Organization/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs +++ b/src/generated/Organization/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Organization.Item.CheckMemberObjects { - /// Builds and executes requests for operations under \organization\{organization-id}\microsoft.graph.checkMemberObjects + /// Builds and executes requests for operations under \organization\{organizationItem-Id}\microsoft.graph.checkMemberObjects public class CheckMemberObjectsRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -25,29 +25,28 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action checkMemberObjects"; // Create options for all the parameters - var organizationIdOption = new Option("--organization-id", description: "key: id of organization") { + var organizationItemIdOption = new Option("--organization-item-id", description: "key: id of organization") { }; - organizationIdOption.IsRequired = true; - command.AddOption(organizationIdOption); + organizationItemIdOption.IsRequired = true; + command.AddOption(organizationItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string organizationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string organizationItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, organizationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, organizationItemIdOption, bodyOption, outputOption); return command; } /// @@ -58,7 +57,7 @@ public Command BuildPostCommand() { public CheckMemberObjectsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/organization/{organization_id}/microsoft.graph.checkMemberObjects"; + UrlTemplate = "{+baseurl}/organization/{organizationItem_Id}/microsoft.graph.checkMemberObjects"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberObjectsRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Organization/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Organization/Item/Extensions/ExtensionsRequestBuilder.cs index 014aa972a04..bb3f637c4ca 100644 --- a/src/generated/Organization/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Organization/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,17 +2,17 @@ using ApiSdk.Organization.Item.Extensions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Organization.Item.Extensions { - /// Builds and executes requests for operations under \organization\{organization-id}\extensions + /// Builds and executes requests for operations under \organization\{organizationItem-Id}\extensions public class ExtensionsRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,29 +35,28 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of open extensions defined for the organization resource. Nullable."; // Create options for all the parameters - var organizationIdOption = new Option("--organization-id", description: "key: id of organization") { + var organizationItemIdOption = new Option("--organization-item-id", description: "key: id of organization") { }; - organizationIdOption.IsRequired = true; - command.AddOption(organizationIdOption); + organizationItemIdOption.IsRequired = true; + command.AddOption(organizationItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string organizationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string organizationItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, organizationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, organizationItemIdOption, bodyOption, outputOption); return command; } /// @@ -68,10 +66,10 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of open extensions defined for the organization resource. Nullable."; // Create options for all the parameters - var organizationIdOption = new Option("--organization-id", description: "key: id of organization") { + var organizationItemIdOption = new Option("--organization-item-id", description: "key: id of organization") { }; - organizationIdOption.IsRequired = true; - command.AddOption(organizationIdOption); + organizationItemIdOption.IsRequired = true; + command.AddOption(organizationItemIdOption); var topOption = new Option("--top", description: "Show only the first n items") { }; topOption.IsRequired = false; @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string organizationId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string organizationItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, organizationIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, organizationItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -137,7 +134,7 @@ public Command BuildListCommand() { public ExtensionsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/organization/{organization_id}/extensions{?top,skip,search,filter,count,orderby,select,expand}"; + UrlTemplate = "{+baseurl}/organization/{organizationItem_Id}/extensions{?top,skip,search,filter,count,orderby,select,expand}"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the organization resource. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the organization resource. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the organization resource. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Organization/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Organization/Item/Extensions/Item/ExtensionRequestBuilder.cs index 5f8ddda7a12..ac4c9854759 100644 --- a/src/generated/Organization/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Organization/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Organization.Item.Extensions.Item { - /// Builds and executes requests for operations under \organization\{organization-id}\extensions\{extension-id} + /// Builds and executes requests for operations under \organization\{organizationItem-Id}\extensions\{extension-id} public class ExtensionRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,21 +26,20 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of open extensions defined for the organization resource. Nullable."; // Create options for all the parameters - var organizationIdOption = new Option("--organization-id", description: "key: id of organization") { + var organizationItemIdOption = new Option("--organization-item-id", description: "key: id of organization") { }; - organizationIdOption.IsRequired = true; - command.AddOption(organizationIdOption); + organizationItemIdOption.IsRequired = true; + command.AddOption(organizationItemIdOption); var extensionIdOption = new Option("--extension-id", description: "key: id of extension") { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string organizationId, string extensionId) => { + command.SetHandler(async (string organizationItemId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, organizationIdOption, extensionIdOption); + }, organizationItemIdOption, extensionIdOption); return command; } /// @@ -50,10 +49,10 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of open extensions defined for the organization resource. Nullable."; // Create options for all the parameters - var organizationIdOption = new Option("--organization-id", description: "key: id of organization") { + var organizationItemIdOption = new Option("--organization-item-id", description: "key: id of organization") { }; - organizationIdOption.IsRequired = true; - command.AddOption(organizationIdOption); + organizationItemIdOption.IsRequired = true; + command.AddOption(organizationItemIdOption); var extensionIdOption = new Option("--extension-id", description: "key: id of extension") { }; extensionIdOption.IsRequired = true; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string organizationId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string organizationItemId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, organizationIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, organizationItemIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,10 +89,10 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of open extensions defined for the organization resource. Nullable."; // Create options for all the parameters - var organizationIdOption = new Option("--organization-id", description: "key: id of organization") { + var organizationItemIdOption = new Option("--organization-item-id", description: "key: id of organization") { }; - organizationIdOption.IsRequired = true; - command.AddOption(organizationIdOption); + organizationItemIdOption.IsRequired = true; + command.AddOption(organizationItemIdOption); var extensionIdOption = new Option("--extension-id", description: "key: id of extension") { }; extensionIdOption.IsRequired = true; @@ -103,16 +101,15 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string organizationId, string extensionId, string body) => { + command.SetHandler(async (string organizationItemId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, organizationIdOption, extensionIdOption, bodyOption); + }, organizationItemIdOption, extensionIdOption, bodyOption); return command; } /// @@ -123,7 +120,7 @@ public Command BuildPatchCommand() { public ExtensionRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/organization/{organization_id}/extensions/{extension_id}{?select,expand}"; + UrlTemplate = "{+baseurl}/organization/{organizationItem_Id}/extensions/{extension_id}{?select,expand}"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the organization resource. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the organization resource. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the organization resource. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the organization resource. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Organization/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs b/src/generated/Organization/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs index 616a7899f6f..e3f06f2a582 100644 --- a/src/generated/Organization/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs +++ b/src/generated/Organization/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Organization.Item.GetMemberGroups { - /// Builds and executes requests for operations under \organization\{organization-id}\microsoft.graph.getMemberGroups + /// Builds and executes requests for operations under \organization\{organizationItem-Id}\microsoft.graph.getMemberGroups public class GetMemberGroupsRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -25,29 +25,28 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action getMemberGroups"; // Create options for all the parameters - var organizationIdOption = new Option("--organization-id", description: "key: id of organization") { + var organizationItemIdOption = new Option("--organization-item-id", description: "key: id of organization") { }; - organizationIdOption.IsRequired = true; - command.AddOption(organizationIdOption); + organizationItemIdOption.IsRequired = true; + command.AddOption(organizationItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string organizationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string organizationItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, organizationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, organizationItemIdOption, bodyOption, outputOption); return command; } /// @@ -58,7 +57,7 @@ public Command BuildPostCommand() { public GetMemberGroupsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/organization/{organization_id}/microsoft.graph.getMemberGroups"; + UrlTemplate = "{+baseurl}/organization/{organizationItem_Id}/microsoft.graph.getMemberGroups"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberGroupsRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Organization/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs b/src/generated/Organization/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs index 3cb8dc879ee..9a4aa2a973f 100644 --- a/src/generated/Organization/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs +++ b/src/generated/Organization/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Organization.Item.GetMemberObjects { - /// Builds and executes requests for operations under \organization\{organization-id}\microsoft.graph.getMemberObjects + /// Builds and executes requests for operations under \organization\{organizationItem-Id}\microsoft.graph.getMemberObjects public class GetMemberObjectsRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -25,29 +25,28 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action getMemberObjects"; // Create options for all the parameters - var organizationIdOption = new Option("--organization-id", description: "key: id of organization") { + var organizationItemIdOption = new Option("--organization-item-id", description: "key: id of organization") { }; - organizationIdOption.IsRequired = true; - command.AddOption(organizationIdOption); + organizationItemIdOption.IsRequired = true; + command.AddOption(organizationItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string organizationId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string organizationItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, organizationIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, organizationItemIdOption, bodyOption, outputOption); return command; } /// @@ -58,7 +57,7 @@ public Command BuildPostCommand() { public GetMemberObjectsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/organization/{organization_id}/microsoft.graph.getMemberObjects"; + UrlTemplate = "{+baseurl}/organization/{organizationItem_Id}/microsoft.graph.getMemberObjects"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberObjectsRequestBo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Organization/Item/OrganizationItemRequestBuilder.cs b/src/generated/Organization/Item/OrganizationItemRequestBuilder.cs new file mode 100644 index 00000000000..6c47c2f84a8 --- /dev/null +++ b/src/generated/Organization/Item/OrganizationItemRequestBuilder.cs @@ -0,0 +1,248 @@ +using ApiSdk.Models.Microsoft.Graph; +using ApiSdk.Organization.Item.Branding; +using ApiSdk.Organization.Item.CertificateBasedAuthConfiguration; +using ApiSdk.Organization.Item.CheckMemberGroups; +using ApiSdk.Organization.Item.CheckMemberObjects; +using ApiSdk.Organization.Item.Extensions; +using ApiSdk.Organization.Item.GetMemberGroups; +using ApiSdk.Organization.Item.GetMemberObjects; +using ApiSdk.Organization.Item.Restore; +using ApiSdk.Organization.Item.SetMobileDeviceManagementAuthority; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Organization.Item { + /// Builds and executes requests for operations under \organization\{organizationItem-Id} + public class OrganizationItemRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + public Command BuildBrandingCommand() { + var command = new Command("branding"); + var builder = new ApiSdk.Organization.Item.Branding.BrandingRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildDeleteCommand()); + command.AddCommand(builder.BuildGetCommand()); + command.AddCommand(builder.BuildPatchCommand()); + return command; + } + public Command BuildCertificateBasedAuthConfigurationCommand() { + var command = new Command("certificate-based-auth-configuration"); + var builder = new ApiSdk.Organization.Item.CertificateBasedAuthConfiguration.CertificateBasedAuthConfigurationRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildGetCommand()); + command.AddCommand(builder.BuildRefCommand()); + return command; + } + public Command BuildCheckMemberGroupsCommand() { + var command = new Command("check-member-groups"); + var builder = new ApiSdk.Organization.Item.CheckMemberGroups.CheckMemberGroupsRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildPostCommand()); + return command; + } + public Command BuildCheckMemberObjectsCommand() { + var command = new Command("check-member-objects"); + var builder = new ApiSdk.Organization.Item.CheckMemberObjects.CheckMemberObjectsRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildPostCommand()); + return command; + } + /// + /// Delete entity from organization + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Delete entity from organization"; + // Create options for all the parameters + var organizationItemIdOption = new Option("--organization-item-id", description: "key: id of organization") { + }; + organizationItemIdOption.IsRequired = true; + command.AddOption(organizationItemIdOption); + command.SetHandler(async (string organizationItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, organizationItemIdOption); + return command; + } + public Command BuildExtensionsCommand() { + var command = new Command("extensions"); + var builder = new ApiSdk.Organization.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } + command.AddCommand(builder.BuildCreateCommand()); + command.AddCommand(builder.BuildListCommand()); + return command; + } + /// + /// Get entity from organization by key + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Get entity from organization by key"; + // Create options for all the parameters + var organizationItemIdOption = new Option("--organization-item-id", description: "key: id of organization") { + }; + organizationItemIdOption.IsRequired = true; + command.AddOption(organizationItemIdOption); + var selectOption = new Option("--select", description: "Select properties to be returned") { + Arity = ArgumentArity.ZeroOrMore + }; + selectOption.IsRequired = false; + command.AddOption(selectOption); + var expandOption = new Option("--expand", description: "Expand related entities") { + Arity = ArgumentArity.ZeroOrMore + }; + expandOption.IsRequired = false; + command.AddOption(expandOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string organizationItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Select = select; + q.Expand = expand; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, organizationItemIdOption, selectOption, expandOption, outputOption); + return command; + } + public Command BuildGetMemberGroupsCommand() { + var command = new Command("get-member-groups"); + var builder = new ApiSdk.Organization.Item.GetMemberGroups.GetMemberGroupsRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildPostCommand()); + return command; + } + public Command BuildGetMemberObjectsCommand() { + var command = new Command("get-member-objects"); + var builder = new ApiSdk.Organization.Item.GetMemberObjects.GetMemberObjectsRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildPostCommand()); + return command; + } + /// + /// Update entity in organization + /// + public Command BuildPatchCommand() { + var command = new Command("patch"); + command.Description = "Update entity in organization"; + // Create options for all the parameters + var organizationItemIdOption = new Option("--organization-item-id", description: "key: id of organization") { + }; + organizationItemIdOption.IsRequired = true; + command.AddOption(organizationItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string organizationItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePatchRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, organizationItemIdOption, bodyOption); + return command; + } + public Command BuildRestoreCommand() { + var command = new Command("restore"); + var builder = new ApiSdk.Organization.Item.Restore.RestoreRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildPostCommand()); + return command; + } + public Command BuildSetMobileDeviceManagementAuthorityCommand() { + var command = new Command("set-mobile-device-management-authority"); + var builder = new ApiSdk.Organization.Item.SetMobileDeviceManagementAuthority.SetMobileDeviceManagementAuthorityRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildPostCommand()); + return command; + } + /// + /// Instantiates a new OrganizationItemRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public OrganizationItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/organization/{organizationItem_Id}{?select,expand}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Delete entity from organization + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Get entity from organization by key + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Update entity in organization + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft.Graph.Organization body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PATCH, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Get entity from organization by key + public class GetQueryParameters : QueryParametersBase { + /// Expand related entities + public string[] Expand { get; set; } + /// Select properties to be returned + public string[] Select { get; set; } + } + } +} diff --git a/src/generated/Organization/Item/OrganizationRequestBuilder.cs b/src/generated/Organization/Item/OrganizationRequestBuilder.cs deleted file mode 100644 index bd3ae52cddc..00000000000 --- a/src/generated/Organization/Item/OrganizationRequestBuilder.cs +++ /dev/null @@ -1,284 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using ApiSdk.Organization.Item.Branding; -using ApiSdk.Organization.Item.CertificateBasedAuthConfiguration; -using ApiSdk.Organization.Item.CheckMemberGroups; -using ApiSdk.Organization.Item.CheckMemberObjects; -using ApiSdk.Organization.Item.Extensions; -using ApiSdk.Organization.Item.GetMemberGroups; -using ApiSdk.Organization.Item.GetMemberObjects; -using ApiSdk.Organization.Item.Restore; -using ApiSdk.Organization.Item.SetMobileDeviceManagementAuthority; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Organization.Item { - /// Builds and executes requests for operations under \organization\{organization-id} - public class OrganizationRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - public Command BuildBrandingCommand() { - var command = new Command("branding"); - var builder = new ApiSdk.Organization.Item.Branding.BrandingRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildDeleteCommand()); - command.AddCommand(builder.BuildGetCommand()); - command.AddCommand(builder.BuildPatchCommand()); - return command; - } - public Command BuildCertificateBasedAuthConfigurationCommand() { - var command = new Command("certificate-based-auth-configuration"); - var builder = new ApiSdk.Organization.Item.CertificateBasedAuthConfiguration.CertificateBasedAuthConfigurationRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildGetCommand()); - command.AddCommand(builder.BuildRefCommand()); - return command; - } - public Command BuildCheckMemberGroupsCommand() { - var command = new Command("check-member-groups"); - var builder = new ApiSdk.Organization.Item.CheckMemberGroups.CheckMemberGroupsRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildPostCommand()); - return command; - } - public Command BuildCheckMemberObjectsCommand() { - var command = new Command("check-member-objects"); - var builder = new ApiSdk.Organization.Item.CheckMemberObjects.CheckMemberObjectsRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildPostCommand()); - return command; - } - /// - /// Delete entity from organization - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Delete entity from organization"; - // Create options for all the parameters - var organizationIdOption = new Option("--organization-id", description: "key: id of organization") { - }; - organizationIdOption.IsRequired = true; - command.AddOption(organizationIdOption); - command.SetHandler(async (string organizationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, organizationIdOption); - return command; - } - public Command BuildExtensionsCommand() { - var command = new Command("extensions"); - var builder = new ApiSdk.Organization.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildCreateCommand()); - command.AddCommand(builder.BuildListCommand()); - return command; - } - /// - /// Get entity from organization by key - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Get entity from organization by key"; - // Create options for all the parameters - var organizationIdOption = new Option("--organization-id", description: "key: id of organization") { - }; - organizationIdOption.IsRequired = true; - command.AddOption(organizationIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string organizationId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, organizationIdOption, selectOption, expandOption); - return command; - } - public Command BuildGetMemberGroupsCommand() { - var command = new Command("get-member-groups"); - var builder = new ApiSdk.Organization.Item.GetMemberGroups.GetMemberGroupsRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildPostCommand()); - return command; - } - public Command BuildGetMemberObjectsCommand() { - var command = new Command("get-member-objects"); - var builder = new ApiSdk.Organization.Item.GetMemberObjects.GetMemberObjectsRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildPostCommand()); - return command; - } - /// - /// Update entity in organization - /// - public Command BuildPatchCommand() { - var command = new Command("patch"); - command.Description = "Update entity in organization"; - // Create options for all the parameters - var organizationIdOption = new Option("--organization-id", description: "key: id of organization") { - }; - organizationIdOption.IsRequired = true; - command.AddOption(organizationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string organizationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePatchRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, organizationIdOption, bodyOption); - return command; - } - public Command BuildRestoreCommand() { - var command = new Command("restore"); - var builder = new ApiSdk.Organization.Item.Restore.RestoreRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildPostCommand()); - return command; - } - public Command BuildSetMobileDeviceManagementAuthorityCommand() { - var command = new Command("set-mobile-device-management-authority"); - var builder = new ApiSdk.Organization.Item.SetMobileDeviceManagementAuthority.SetMobileDeviceManagementAuthorityRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildPostCommand()); - return command; - } - /// - /// Instantiates a new OrganizationRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public OrganizationRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/organization/{organization_id}{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Delete entity from organization - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Get entity from organization by key - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Update entity in organization - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft.Graph.Organization body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PATCH, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Delete entity from organization - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from organization by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in organization - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Organization model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// Get entity from organization by key - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/Organization/Item/Restore/RestoreRequestBuilder.cs b/src/generated/Organization/Item/Restore/RestoreRequestBuilder.cs index 9b21c1d3973..a5abaf705af 100644 --- a/src/generated/Organization/Item/Restore/RestoreRequestBuilder.cs +++ b/src/generated/Organization/Item/Restore/RestoreRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Organization.Item.Restore { - /// Builds and executes requests for operations under \organization\{organization-id}\microsoft.graph.restore + /// Builds and executes requests for operations under \organization\{organizationItem-Id}\microsoft.graph.restore public class RestoreRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -26,22 +26,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action restore"; // Create options for all the parameters - var organizationIdOption = new Option("--organization-id", description: "key: id of organization") { + var organizationItemIdOption = new Option("--organization-item-id", description: "key: id of organization") { }; - organizationIdOption.IsRequired = true; - command.AddOption(organizationIdOption); - command.SetHandler(async (string organizationId) => { + organizationItemIdOption.IsRequired = true; + command.AddOption(organizationItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string organizationItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, organizationIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, organizationItemIdOption, outputOption); return command; } /// @@ -52,7 +51,7 @@ public Command BuildPostCommand() { public RestoreRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/organization/{organization_id}/microsoft.graph.restore"; + UrlTemplate = "{+baseurl}/organization/{organizationItem_Id}/microsoft.graph.restore"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action restore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes directoryObject public class RestoreResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Organization/Item/SetMobileDeviceManagementAuthority/SetMobileDeviceManagementAuthorityRequestBuilder.cs b/src/generated/Organization/Item/SetMobileDeviceManagementAuthority/SetMobileDeviceManagementAuthorityRequestBuilder.cs index 9bcf2d89008..8ad1f76fdd8 100644 --- a/src/generated/Organization/Item/SetMobileDeviceManagementAuthority/SetMobileDeviceManagementAuthorityRequestBuilder.cs +++ b/src/generated/Organization/Item/SetMobileDeviceManagementAuthority/SetMobileDeviceManagementAuthorityRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Organization.Item.SetMobileDeviceManagementAuthority { - /// Builds and executes requests for operations under \organization\{organization-id}\microsoft.graph.setMobileDeviceManagementAuthority + /// Builds and executes requests for operations under \organization\{organizationItem-Id}\microsoft.graph.setMobileDeviceManagementAuthority public class SetMobileDeviceManagementAuthorityRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -25,22 +25,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Set mobile device management authority"; // Create options for all the parameters - var organizationIdOption = new Option("--organization-id", description: "key: id of organization") { + var organizationItemIdOption = new Option("--organization-item-id", description: "key: id of organization") { }; - organizationIdOption.IsRequired = true; - command.AddOption(organizationIdOption); - command.SetHandler(async (string organizationId) => { + organizationItemIdOption.IsRequired = true; + command.AddOption(organizationItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string organizationItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteIntValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, organizationIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, organizationItemIdOption, outputOption); return command; } /// @@ -51,7 +50,7 @@ public Command BuildPostCommand() { public SetMobileDeviceManagementAuthorityRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/organization/{organization_id}/microsoft.graph.setMobileDeviceManagementAuthority"; + UrlTemplate = "{+baseurl}/organization/{organizationItem_Id}/microsoft.graph.setMobileDeviceManagementAuthority"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -71,16 +70,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Set mobile device management authority - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Organization/OrganizationRequestBuilder.cs b/src/generated/Organization/OrganizationRequestBuilder.cs index f249d05da06..80bfb0be665 100644 --- a/src/generated/Organization/OrganizationRequestBuilder.cs +++ b/src/generated/Organization/OrganizationRequestBuilder.cs @@ -1,13 +1,14 @@ using ApiSdk.Models.Microsoft.Graph; using ApiSdk.Organization.GetAvailableExtensionProperties; using ApiSdk.Organization.GetByIds; +using ApiSdk.Organization.Item; using ApiSdk.Organization.ValidateProperties; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,14 +24,20 @@ public class OrganizationRequestBuilder { /// Url template to use to build the URL for the current request builder private string UrlTemplate { get; set; } public List BuildCommand() { - var builder = new OrganizationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCreateCommand(), - builder.BuildGetAvailableExtensionPropertiesCommand(), - builder.BuildGetByIdsCommand(), - builder.BuildListCommand(), - builder.BuildValidatePropertiesCommand(), - }; + var builder = new OrganizationItemRequestBuilder(PathParameters, RequestAdapter); + var commands = new List(); + commands.Add(builder.BuildBrandingCommand()); + commands.Add(builder.BuildCertificateBasedAuthConfigurationCommand()); + commands.Add(builder.BuildCheckMemberGroupsCommand()); + commands.Add(builder.BuildCheckMemberObjectsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildGetMemberGroupsCommand()); + commands.Add(builder.BuildGetMemberObjectsCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRestoreCommand()); + commands.Add(builder.BuildSetMobileDeviceManagementAuthorityCommand()); return commands; } /// @@ -44,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } public Command BuildGetAvailableExtensionPropertiesCommand() { @@ -115,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildValidatePropertiesCommand() { @@ -195,31 +200,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get entities from organization - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to organization - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Organization model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from organization public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Organization/ValidateProperties/ValidatePropertiesRequestBuilder.cs b/src/generated/Organization/ValidateProperties/ValidatePropertiesRequestBuilder.cs index 762fbba8118..e5b9139c3a1 100644 --- a/src/generated/Organization/ValidateProperties/ValidatePropertiesRequestBuilder.cs +++ b/src/generated/Organization/ValidateProperties/ValidatePropertiesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,14 +29,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -72,18 +71,5 @@ public RequestInformation CreatePostRequestInformation(ValidatePropertiesRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action validateProperties - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ValidatePropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/PermissionGrants/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs b/src/generated/PermissionGrants/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs deleted file mode 100644 index ebdcba77481..00000000000 --- a/src/generated/PermissionGrants/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs +++ /dev/null @@ -1,45 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.PermissionGrants.GetAvailableExtensionProperties { - public class GetAvailableExtensionProperties : DirectoryObject, IParsable { - /// Display name of the application object on which this extension property is defined. Read-only. - public string AppDisplayName { get; set; } - /// Specifies the data type of the value the extension property can hold. Following values are supported. Not nullable. Binary - 256 bytes maximumBooleanDateTime - Must be specified in ISO 8601 format. Will be stored in UTC.Integer - 32-bit value.LargeInteger - 64-bit value.String - 256 characters maximum - public string DataType { get; set; } - /// Indicates if this extension property was sycned from onpremises directory using Azure AD Connect. Read-only. - public bool? IsSyncedFromOnPremises { get; set; } - /// Name of the extension property. Not nullable. - public string Name { get; set; } - /// Following values are supported. Not nullable. UserGroupOrganizationDeviceApplication - public List TargetObjects { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"appDisplayName", (o,n) => { (o as GetAvailableExtensionProperties).AppDisplayName = n.GetStringValue(); } }, - {"dataType", (o,n) => { (o as GetAvailableExtensionProperties).DataType = n.GetStringValue(); } }, - {"isSyncedFromOnPremises", (o,n) => { (o as GetAvailableExtensionProperties).IsSyncedFromOnPremises = n.GetBoolValue(); } }, - {"name", (o,n) => { (o as GetAvailableExtensionProperties).Name = n.GetStringValue(); } }, - {"targetObjects", (o,n) => { (o as GetAvailableExtensionProperties).TargetObjects = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteStringValue("appDisplayName", AppDisplayName); - writer.WriteStringValue("dataType", DataType); - writer.WriteBoolValue("isSyncedFromOnPremises", IsSyncedFromOnPremises); - writer.WriteStringValue("name", Name); - writer.WriteCollectionOfPrimitiveValues("targetObjects", TargetObjects); - } - } -} diff --git a/src/generated/PermissionGrants/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs b/src/generated/PermissionGrants/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs index f19db0eb75a..bbd6b7986e0 100644 --- a/src/generated/PermissionGrants/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs +++ b/src/generated/PermissionGrants/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(GetAvailableExtensionProp requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getAvailableExtensionProperties - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetAvailableExtensionPropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/PermissionGrants/GetByIds/GetByIds.cs b/src/generated/PermissionGrants/GetByIds/GetByIds.cs deleted file mode 100644 index 1f8d7f08476..00000000000 --- a/src/generated/PermissionGrants/GetByIds/GetByIds.cs +++ /dev/null @@ -1,28 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.PermissionGrants.GetByIds { - public class GetByIds : Entity, IParsable { - public DateTimeOffset? DeletedDateTime { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"deletedDateTime", (o,n) => { (o as GetByIds).DeletedDateTime = n.GetDateTimeOffsetValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteDateTimeOffsetValue("deletedDateTime", DeletedDateTime); - } - } -} diff --git a/src/generated/PermissionGrants/GetByIds/GetByIdsRequestBuilder.cs b/src/generated/PermissionGrants/GetByIds/GetByIdsRequestBuilder.cs index 75cd7318017..5b1c955f2c0 100644 --- a/src/generated/PermissionGrants/GetByIds/GetByIdsRequestBuilder.cs +++ b/src/generated/PermissionGrants/GetByIds/GetByIdsRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(GetByIdsRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getByIds - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetByIdsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/PermissionGrants/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs b/src/generated/PermissionGrants/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs index fa5407ec413..5e73a7ae839 100644 --- a/src/generated/PermissionGrants/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs +++ b/src/generated/PermissionGrants/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action checkMemberGroups"; // Create options for all the parameters - var resourceSpecificPermissionGrantIdOption = new Option("--resourcespecificpermissiongrant-id", description: "key: id of resourceSpecificPermissionGrant") { + var resourceSpecificPermissionGrantIdOption = new Option("--resource-specific-permission-grant-id", description: "key: id of resourceSpecificPermissionGrant") { }; resourceSpecificPermissionGrantIdOption.IsRequired = true; command.AddOption(resourceSpecificPermissionGrantIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string resourceSpecificPermissionGrantId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string resourceSpecificPermissionGrantId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, resourceSpecificPermissionGrantIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, resourceSpecificPermissionGrantIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberGroupsRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/PermissionGrants/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs b/src/generated/PermissionGrants/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs index 26f84efb090..610913082d6 100644 --- a/src/generated/PermissionGrants/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs +++ b/src/generated/PermissionGrants/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action checkMemberObjects"; // Create options for all the parameters - var resourceSpecificPermissionGrantIdOption = new Option("--resourcespecificpermissiongrant-id", description: "key: id of resourceSpecificPermissionGrant") { + var resourceSpecificPermissionGrantIdOption = new Option("--resource-specific-permission-grant-id", description: "key: id of resourceSpecificPermissionGrant") { }; resourceSpecificPermissionGrantIdOption.IsRequired = true; command.AddOption(resourceSpecificPermissionGrantIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string resourceSpecificPermissionGrantId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string resourceSpecificPermissionGrantId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, resourceSpecificPermissionGrantIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, resourceSpecificPermissionGrantIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberObjectsRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/PermissionGrants/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs b/src/generated/PermissionGrants/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs index f8a73f11533..247c8f14ae9 100644 --- a/src/generated/PermissionGrants/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs +++ b/src/generated/PermissionGrants/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action getMemberGroups"; // Create options for all the parameters - var resourceSpecificPermissionGrantIdOption = new Option("--resourcespecificpermissiongrant-id", description: "key: id of resourceSpecificPermissionGrant") { + var resourceSpecificPermissionGrantIdOption = new Option("--resource-specific-permission-grant-id", description: "key: id of resourceSpecificPermissionGrant") { }; resourceSpecificPermissionGrantIdOption.IsRequired = true; command.AddOption(resourceSpecificPermissionGrantIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string resourceSpecificPermissionGrantId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string resourceSpecificPermissionGrantId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, resourceSpecificPermissionGrantIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, resourceSpecificPermissionGrantIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberGroupsRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/PermissionGrants/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs b/src/generated/PermissionGrants/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs index db55216f62b..133bbdecf18 100644 --- a/src/generated/PermissionGrants/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs +++ b/src/generated/PermissionGrants/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action getMemberObjects"; // Create options for all the parameters - var resourceSpecificPermissionGrantIdOption = new Option("--resourcespecificpermissiongrant-id", description: "key: id of resourceSpecificPermissionGrant") { + var resourceSpecificPermissionGrantIdOption = new Option("--resource-specific-permission-grant-id", description: "key: id of resourceSpecificPermissionGrant") { }; resourceSpecificPermissionGrantIdOption.IsRequired = true; command.AddOption(resourceSpecificPermissionGrantIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string resourceSpecificPermissionGrantId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string resourceSpecificPermissionGrantId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, resourceSpecificPermissionGrantIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, resourceSpecificPermissionGrantIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberObjectsRequestBo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/PermissionGrants/Item/ResourceSpecificPermissionGrantRequestBuilder.cs b/src/generated/PermissionGrants/Item/ResourceSpecificPermissionGrantRequestBuilder.cs index 6926f2a326e..c2e81e97a5f 100644 --- a/src/generated/PermissionGrants/Item/ResourceSpecificPermissionGrantRequestBuilder.cs +++ b/src/generated/PermissionGrants/Item/ResourceSpecificPermissionGrantRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.PermissionGrants.Item.Restore; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -43,15 +43,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete entity from permissionGrants"; // Create options for all the parameters - var resourceSpecificPermissionGrantIdOption = new Option("--resourcespecificpermissiongrant-id", description: "key: id of resourceSpecificPermissionGrant") { + var resourceSpecificPermissionGrantIdOption = new Option("--resource-specific-permission-grant-id", description: "key: id of resourceSpecificPermissionGrant") { }; resourceSpecificPermissionGrantIdOption.IsRequired = true; command.AddOption(resourceSpecificPermissionGrantIdOption); - command.SetHandler(async (string resourceSpecificPermissionGrantId) => { + command.SetHandler(async (string resourceSpecificPermissionGrantId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, resourceSpecificPermissionGrantIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get entity from permissionGrants by key"; // Create options for all the parameters - var resourceSpecificPermissionGrantIdOption = new Option("--resourcespecificpermissiongrant-id", description: "key: id of resourceSpecificPermissionGrant") { + var resourceSpecificPermissionGrantIdOption = new Option("--resource-specific-permission-grant-id", description: "key: id of resourceSpecificPermissionGrant") { }; resourceSpecificPermissionGrantIdOption.IsRequired = true; command.AddOption(resourceSpecificPermissionGrantIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string resourceSpecificPermissionGrantId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string resourceSpecificPermissionGrantId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, resourceSpecificPermissionGrantIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, resourceSpecificPermissionGrantIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildGetMemberGroupsCommand() { @@ -112,7 +110,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update entity in permissionGrants"; // Create options for all the parameters - var resourceSpecificPermissionGrantIdOption = new Option("--resourcespecificpermissiongrant-id", description: "key: id of resourceSpecificPermissionGrant") { + var resourceSpecificPermissionGrantIdOption = new Option("--resource-specific-permission-grant-id", description: "key: id of resourceSpecificPermissionGrant") { }; resourceSpecificPermissionGrantIdOption.IsRequired = true; command.AddOption(resourceSpecificPermissionGrantIdOption); @@ -120,14 +118,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string resourceSpecificPermissionGrantId, string body) => { + command.SetHandler(async (string resourceSpecificPermissionGrantId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, resourceSpecificPermissionGrantIdOption, bodyOption); return command; @@ -205,42 +202,6 @@ public RequestInformation CreatePatchRequestInformation(ResourceSpecificPermissi requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from permissionGrants - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from permissionGrants by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in permissionGrants - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ResourceSpecificPermissionGrant model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from permissionGrants by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/PermissionGrants/Item/Restore/RestoreRequestBuilder.cs b/src/generated/PermissionGrants/Item/Restore/RestoreRequestBuilder.cs index 8a3d046095f..c019d0b39c7 100644 --- a/src/generated/PermissionGrants/Item/Restore/RestoreRequestBuilder.cs +++ b/src/generated/PermissionGrants/Item/Restore/RestoreRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action restore"; // Create options for all the parameters - var resourceSpecificPermissionGrantIdOption = new Option("--resourcespecificpermissiongrant-id", description: "key: id of resourceSpecificPermissionGrant") { + var resourceSpecificPermissionGrantIdOption = new Option("--resource-specific-permission-grant-id", description: "key: id of resourceSpecificPermissionGrant") { }; resourceSpecificPermissionGrantIdOption.IsRequired = true; command.AddOption(resourceSpecificPermissionGrantIdOption); - command.SetHandler(async (string resourceSpecificPermissionGrantId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string resourceSpecificPermissionGrantId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, resourceSpecificPermissionGrantIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, resourceSpecificPermissionGrantIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action restore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes directoryObject public class RestoreResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/PermissionGrants/PermissionGrantsRequestBuilder.cs b/src/generated/PermissionGrants/PermissionGrantsRequestBuilder.cs index 813c44c494d..e699b764e7e 100644 --- a/src/generated/PermissionGrants/PermissionGrantsRequestBuilder.cs +++ b/src/generated/PermissionGrants/PermissionGrantsRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.PermissionGrants.ValidateProperties; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,16 +25,15 @@ public class PermissionGrantsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ResourceSpecificPermissionGrantRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCheckMemberGroupsCommand(), - builder.BuildCheckMemberObjectsCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildGetMemberGroupsCommand(), - builder.BuildGetMemberObjectsCommand(), - builder.BuildPatchCommand(), - builder.BuildRestoreCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCheckMemberGroupsCommand()); + commands.Add(builder.BuildCheckMemberObjectsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildGetMemberGroupsCommand()); + commands.Add(builder.BuildGetMemberObjectsCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRestoreCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } public Command BuildGetAvailableExtensionPropertiesCommand() { @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string search, string filter, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string search, string filter, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { if (!String.IsNullOrEmpty(search)) q.Search = search; if (!String.IsNullOrEmpty(filter)) q.Filter = filter; @@ -115,15 +117,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, searchOption, filterOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, searchOption, filterOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildValidatePropertiesCommand() { @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(ResourceSpecificPermissio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get entities from permissionGrants - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to permissionGrants - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ResourceSpecificPermissionGrant model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from permissionGrants public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/PermissionGrants/ValidateProperties/ValidatePropertiesRequestBuilder.cs b/src/generated/PermissionGrants/ValidateProperties/ValidatePropertiesRequestBuilder.cs index 2102e663c99..7408cb585e9 100644 --- a/src/generated/PermissionGrants/ValidateProperties/ValidatePropertiesRequestBuilder.cs +++ b/src/generated/PermissionGrants/ValidateProperties/ValidatePropertiesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,14 +29,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -72,18 +71,5 @@ public RequestInformation CreatePostRequestInformation(ValidatePropertiesRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action validateProperties - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ValidatePropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Places/Item/PlaceRequestBuilder.cs b/src/generated/Places/Item/PlaceRequestBuilder.cs index 5b2a4ae80f6..d7147bf586d 100644 --- a/src/generated/Places/Item/PlaceRequestBuilder.cs +++ b/src/generated/Places/Item/PlaceRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,10 @@ public Command BuildDeleteCommand() { }; placeIdOption.IsRequired = true; command.AddOption(placeIdOption); - command.SetHandler(async (string placeId) => { + command.SetHandler(async (string placeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, placeIdOption); return command; @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string placeId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string placeId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, placeIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, placeIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string placeId, string body) => { + command.SetHandler(async (string placeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, placeIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(Place body, Action - /// Delete entity from places - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from places by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in places - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Place model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from places by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Places/PlacesRequestBuilder.cs b/src/generated/Places/PlacesRequestBuilder.cs index 487116223fe..6fbd2691519 100644 --- a/src/generated/Places/PlacesRequestBuilder.cs +++ b/src/generated/Places/PlacesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Places.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class PlacesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PlaceRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(Place body, Action - /// Get entities from places - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to places - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Place model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from places public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Planner/Buckets/BucketsRequestBuilder.cs b/src/generated/Planner/Buckets/BucketsRequestBuilder.cs index 6107f48b4e4..b5ba1382190 100644 --- a/src/generated/Planner/Buckets/BucketsRequestBuilder.cs +++ b/src/generated/Planner/Buckets/BucketsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Planner.Buckets.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class BucketsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PlannerBucketRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildTasksCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildTasksCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(PlannerBucket body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Returns a collection of the specified buckets - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns a collection of the specified buckets - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PlannerBucket model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Returns a collection of the specified buckets public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Planner/Buckets/Item/PlannerBucketRequestBuilder.cs b/src/generated/Planner/Buckets/Item/PlannerBucketRequestBuilder.cs index 2a64a21a31f..287de2c8635 100644 --- a/src/generated/Planner/Buckets/Item/PlannerBucketRequestBuilder.cs +++ b/src/generated/Planner/Buckets/Item/PlannerBucketRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Planner.Buckets.Item.Tasks; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,15 +27,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Returns a collection of the specified buckets"; // Create options for all the parameters - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - command.SetHandler(async (string plannerBucketId) => { + command.SetHandler(async (string plannerBucketId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerBucketIdOption); return command; @@ -47,7 +46,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Returns a collection of the specified buckets"; // Create options for all the parameters - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); @@ -61,20 +60,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerBucketId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerBucketId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerBucketIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerBucketIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Returns a collection of the specified buckets"; // Create options for all the parameters - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); @@ -92,14 +90,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerBucketId, string body) => { + command.SetHandler(async (string plannerBucketId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerBucketIdOption, bodyOption); return command; @@ -107,6 +104,9 @@ public Command BuildPatchCommand() { public Command BuildTasksCommand() { var command = new Command("tasks"); var builder = new ApiSdk.Planner.Buckets.Item.Tasks.TasksRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -178,42 +178,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerBucket body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Returns a collection of the specified buckets - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns a collection of the specified buckets - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns a collection of the specified buckets - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerBucket model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Returns a collection of the specified buckets public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Planner/Buckets/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs b/src/generated/Planner/Buckets/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs index 338e4826db0..7f051bb7aaf 100644 --- a/src/generated/Planner/Buckets/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Planner/Buckets/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo."; // Create options for all the parameters - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerBucketId, string plannerTaskId) => { + command.SetHandler(async (string plannerBucketId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerBucketIdOption, plannerTaskIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo."; // Create options for all the parameters - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerBucketId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerBucketId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo."; // Create options for all the parameters - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerBucketId, string plannerTaskId, string body) => { + command.SetHandler(async (string plannerBucketId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerBucketIdOption, plannerTaskIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerAssignedToTaskBoa requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerAssignedToTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Planner/Buckets/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs b/src/generated/Planner/Buckets/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs index 71ae3a92516..57733a21943 100644 --- a/src/generated/Planner/Buckets/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Planner/Buckets/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket."; // Create options for all the parameters - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerBucketId, string plannerTaskId) => { + command.SetHandler(async (string plannerBucketId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerBucketIdOption, plannerTaskIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket."; // Create options for all the parameters - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerBucketId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerBucketId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket."; // Create options for all the parameters - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerBucketId, string plannerTaskId, string body) => { + command.SetHandler(async (string plannerBucketId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerBucketIdOption, plannerTaskIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerBucketTaskBoardTa requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerBucketTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Planner/Buckets/Item/Tasks/Item/Details/DetailsRequestBuilder.cs b/src/generated/Planner/Buckets/Item/Tasks/Item/Details/DetailsRequestBuilder.cs index 2fe91b36933..d6c454d3606 100644 --- a/src/generated/Planner/Buckets/Item/Tasks/Item/Details/DetailsRequestBuilder.cs +++ b/src/generated/Planner/Buckets/Item/Tasks/Item/Details/DetailsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Additional details about the task."; // Create options for all the parameters - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerBucketId, string plannerTaskId) => { + command.SetHandler(async (string plannerBucketId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerBucketIdOption, plannerTaskIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Additional details about the task."; // Create options for all the parameters - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerBucketId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerBucketId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Additional details about the task."; // Create options for all the parameters - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerBucketId, string plannerTaskId, string body) => { + command.SetHandler(async (string plannerBucketId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerBucketIdOption, plannerTaskIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerTaskDetails body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerTaskDetails model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Additional details about the task. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Planner/Buckets/Item/Tasks/Item/PlannerTaskRequestBuilder.cs b/src/generated/Planner/Buckets/Item/Tasks/Item/PlannerTaskRequestBuilder.cs index d4cf173ab01..cf06a428f78 100644 --- a/src/generated/Planner/Buckets/Item/Tasks/Item/PlannerTaskRequestBuilder.cs +++ b/src/generated/Planner/Buckets/Item/Tasks/Item/PlannerTaskRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Planner.Buckets.Item.Tasks.Item.ProgressTaskBoardFormat; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -46,19 +46,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. The collection of tasks in the bucket."; // Create options for all the parameters - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerBucketId, string plannerTaskId) => { + command.SetHandler(async (string plannerBucketId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerBucketIdOption, plannerTaskIdOption); return command; @@ -78,11 +77,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. The collection of tasks in the bucket."; // Create options for all the parameters - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -96,20 +95,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerBucketId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerBucketId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,11 +117,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. The collection of tasks in the bucket."; // Create options for all the parameters - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -131,14 +129,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerBucketId, string plannerTaskId, string body) => { + command.SetHandler(async (string plannerBucketId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerBucketIdOption, plannerTaskIdOption, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerTask body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. The collection of tasks in the bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. The collection of tasks in the bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. The collection of tasks in the bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. The collection of tasks in the bucket. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Planner/Buckets/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs b/src/generated/Planner/Buckets/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs index 19121231a07..818c04d3c6d 100644 --- a/src/generated/Planner/Buckets/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Planner/Buckets/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress."; // Create options for all the parameters - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerBucketId, string plannerTaskId) => { + command.SetHandler(async (string plannerBucketId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerBucketIdOption, plannerTaskIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress."; // Create options for all the parameters - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerBucketId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerBucketId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress."; // Create options for all the parameters - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerBucketId, string plannerTaskId, string body) => { + command.SetHandler(async (string plannerBucketId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerBucketIdOption, plannerTaskIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerProgressTaskBoard requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerProgressTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Planner/Buckets/Item/Tasks/TasksRequestBuilder.cs b/src/generated/Planner/Buckets/Item/Tasks/TasksRequestBuilder.cs index 1e647fc3858..cc4b599258d 100644 --- a/src/generated/Planner/Buckets/Item/Tasks/TasksRequestBuilder.cs +++ b/src/generated/Planner/Buckets/Item/Tasks/TasksRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Planner.Buckets.Item.Tasks.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class TasksRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PlannerTaskRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAssignedToTaskBoardFormatCommand(), - builder.BuildBucketTaskBoardFormatCommand(), - builder.BuildDeleteCommand(), - builder.BuildDetailsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildProgressTaskBoardFormatCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAssignedToTaskBoardFormatCommand()); + commands.Add(builder.BuildBucketTaskBoardFormatCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDetailsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildProgressTaskBoardFormatCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Read-only. Nullable. The collection of tasks in the bucket."; // Create options for all the parameters - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerBucketId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerBucketId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerBucketIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerBucketIdOption, bodyOption, outputOption); return command; } /// @@ -72,7 +70,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Read-only. Nullable. The collection of tasks in the bucket."; // Create options for all the parameters - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerBucketId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerBucketId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -122,15 +124,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerBucketIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerBucketIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -185,31 +182,6 @@ public RequestInformation CreatePostRequestInformation(PlannerTask body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. The collection of tasks in the bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. The collection of tasks in the bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PlannerTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. The collection of tasks in the bucket. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Planner/PlannerRequestBuilder.cs b/src/generated/Planner/PlannerRequestBuilder.cs index ac87f05ff3b..a9517559bd0 100644 --- a/src/generated/Planner/PlannerRequestBuilder.cs +++ b/src/generated/Planner/PlannerRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Planner.Tasks; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,6 +25,9 @@ public class PlannerRequestBuilder { public Command BuildBucketsCommand() { var command = new Command("buckets"); var builder = new ApiSdk.Planner.Buckets.BucketsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -46,20 +49,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -73,14 +75,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -88,6 +89,9 @@ public Command BuildPatchCommand() { public Command BuildPlansCommand() { var command = new Command("plans"); var builder = new ApiSdk.Planner.Plans.PlansRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -95,6 +99,9 @@ public Command BuildPlansCommand() { public Command BuildTasksCommand() { var command = new Command("tasks"); var builder = new ApiSdk.Planner.Tasks.TasksRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -151,31 +158,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get planner - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update planner - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Planner model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get planner public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Planner/Plans/Item/Buckets/BucketsRequestBuilder.cs b/src/generated/Planner/Plans/Item/Buckets/BucketsRequestBuilder.cs index 882ab902092..a64dd0bef2d 100644 --- a/src/generated/Planner/Plans/Item/Buckets/BucketsRequestBuilder.cs +++ b/src/generated/Planner/Plans/Item/Buckets/BucketsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Planner.Plans.Item.Buckets.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class BucketsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PlannerBucketRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildTasksCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildTasksCommand()); return commands; } /// @@ -37,7 +36,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Collection of buckets in the plan. Read-only. Nullable."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, bodyOption, outputOption); return command; } /// @@ -69,7 +67,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Collection of buckets in the plan. Read-only. Nullable."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(PlannerBucket body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of buckets in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of buckets in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PlannerBucket model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of buckets in the plan. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Planner/Plans/Item/Buckets/Item/PlannerBucketRequestBuilder.cs b/src/generated/Planner/Plans/Item/Buckets/Item/PlannerBucketRequestBuilder.cs index 5c7331e2416..f3168f9cff9 100644 --- a/src/generated/Planner/Plans/Item/Buckets/Item/PlannerBucketRequestBuilder.cs +++ b/src/generated/Planner/Plans/Item/Buckets/Item/PlannerBucketRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Planner.Plans.Item.Buckets.Item.Tasks; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,19 +27,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Collection of buckets in the plan. Read-only. Nullable."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId) => { + command.SetHandler(async (string plannerPlanId, string plannerBucketId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerBucketIdOption); return command; @@ -51,11 +50,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Collection of buckets in the plan. Read-only. Nullable."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, plannerBucketIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, plannerBucketIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -92,11 +90,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Collection of buckets in the plan. Read-only. Nullable."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); @@ -104,14 +102,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string body) => { + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerBucketIdOption, bodyOption); return command; @@ -119,6 +116,9 @@ public Command BuildPatchCommand() { public Command BuildTasksCommand() { var command = new Command("tasks"); var builder = new ApiSdk.Planner.Plans.Item.Buckets.Item.Tasks.TasksRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -190,42 +190,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerBucket body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of buckets in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of buckets in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of buckets in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerBucket model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of buckets in the plan. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Planner/Plans/Item/Buckets/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs b/src/generated/Planner/Plans/Item/Buckets/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs index 7d899023e95..6c3583ef10f 100644 --- a/src/generated/Planner/Plans/Item/Buckets/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Planner/Plans/Item/Buckets/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId) => { + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string body) => { + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerAssignedToTaskBoa requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerAssignedToTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Planner/Plans/Item/Buckets/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs b/src/generated/Planner/Plans/Item/Buckets/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs index e5f0a17bb96..342c2468010 100644 --- a/src/generated/Planner/Plans/Item/Buckets/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Planner/Plans/Item/Buckets/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId) => { + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string body) => { + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerBucketTaskBoardTa requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerBucketTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Planner/Plans/Item/Buckets/Item/Tasks/Item/Details/DetailsRequestBuilder.cs b/src/generated/Planner/Plans/Item/Buckets/Item/Tasks/Item/Details/DetailsRequestBuilder.cs index e1dd9a4606f..5e53ba9fe72 100644 --- a/src/generated/Planner/Plans/Item/Buckets/Item/Tasks/Item/Details/DetailsRequestBuilder.cs +++ b/src/generated/Planner/Plans/Item/Buckets/Item/Tasks/Item/Details/DetailsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Additional details about the task."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId) => { + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Additional details about the task."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Additional details about the task."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string body) => { + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerTaskDetails body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerTaskDetails model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Additional details about the task. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Planner/Plans/Item/Buckets/Item/Tasks/Item/PlannerTaskRequestBuilder.cs b/src/generated/Planner/Plans/Item/Buckets/Item/Tasks/Item/PlannerTaskRequestBuilder.cs index 7ca8c95a4b8..3a6f5af374e 100644 --- a/src/generated/Planner/Plans/Item/Buckets/Item/Tasks/Item/PlannerTaskRequestBuilder.cs +++ b/src/generated/Planner/Plans/Item/Buckets/Item/Tasks/Item/PlannerTaskRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Planner.Plans.Item.Buckets.Item.Tasks.Item.ProgressTaskBoardFormat; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -46,23 +46,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. The collection of tasks in the bucket."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId) => { + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption); return command; @@ -82,15 +81,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. The collection of tasks in the bucket."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -104,20 +103,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -127,15 +125,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. The collection of tasks in the bucket."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -143,14 +141,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string body) => { + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, bodyOption); return command; @@ -230,42 +227,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerTask body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. The collection of tasks in the bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. The collection of tasks in the bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. The collection of tasks in the bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. The collection of tasks in the bucket. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Planner/Plans/Item/Buckets/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs b/src/generated/Planner/Plans/Item/Buckets/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs index f681e9e17cd..5bcecfe56ae 100644 --- a/src/generated/Planner/Plans/Item/Buckets/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Planner/Plans/Item/Buckets/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId) => { + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string body) => { + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerProgressTaskBoard requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerProgressTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Planner/Plans/Item/Buckets/Item/Tasks/TasksRequestBuilder.cs b/src/generated/Planner/Plans/Item/Buckets/Item/Tasks/TasksRequestBuilder.cs index c7208dedf35..49290f54d91 100644 --- a/src/generated/Planner/Plans/Item/Buckets/Item/Tasks/TasksRequestBuilder.cs +++ b/src/generated/Planner/Plans/Item/Buckets/Item/Tasks/TasksRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Planner.Plans.Item.Buckets.Item.Tasks.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class TasksRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PlannerTaskRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAssignedToTaskBoardFormatCommand(), - builder.BuildBucketTaskBoardFormatCommand(), - builder.BuildDeleteCommand(), - builder.BuildDetailsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildProgressTaskBoardFormatCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAssignedToTaskBoardFormatCommand()); + commands.Add(builder.BuildBucketTaskBoardFormatCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDetailsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildProgressTaskBoardFormatCommand()); return commands; } /// @@ -40,11 +39,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Read-only. Nullable. The collection of tasks in the bucket."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string plannerBucketId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, plannerBucketIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, plannerBucketIdOption, bodyOption, outputOption); return command; } /// @@ -76,11 +74,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Read-only. Nullable. The collection of tasks in the bucket."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string plannerBucketId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string plannerBucketId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -130,15 +132,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, plannerBucketIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, plannerBucketIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -193,31 +190,6 @@ public RequestInformation CreatePostRequestInformation(PlannerTask body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. The collection of tasks in the bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. The collection of tasks in the bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PlannerTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. The collection of tasks in the bucket. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Planner/Plans/Item/Details/DetailsRequestBuilder.cs b/src/generated/Planner/Plans/Item/Details/DetailsRequestBuilder.cs index 1e9962a81c0..f71582b530f 100644 --- a/src/generated/Planner/Plans/Item/Details/DetailsRequestBuilder.cs +++ b/src/generated/Planner/Plans/Item/Details/DetailsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Additional details about the plan. Read-only. Nullable."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - command.SetHandler(async (string plannerPlanId) => { + command.SetHandler(async (string plannerPlanId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Additional details about the plan. Read-only. Nullable."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Additional details about the plan. Read-only. Nullable."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string body) => { + command.SetHandler(async (string plannerPlanId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerPlanDetails body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Additional details about the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Additional details about the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Additional details about the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerPlanDetails model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Additional details about the plan. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Planner/Plans/Item/PlannerPlanRequestBuilder.cs b/src/generated/Planner/Plans/Item/PlannerPlanRequestBuilder.cs index ffb68d00c42..3cc1d0135f3 100644 --- a/src/generated/Planner/Plans/Item/PlannerPlanRequestBuilder.cs +++ b/src/generated/Planner/Plans/Item/PlannerPlanRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Planner.Plans.Item.Tasks; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,6 +25,9 @@ public class PlannerPlanRequestBuilder { public Command BuildBucketsCommand() { var command = new Command("buckets"); var builder = new ApiSdk.Planner.Plans.Item.Buckets.BucketsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -36,15 +39,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Returns a collection of the specified plans"; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - command.SetHandler(async (string plannerPlanId) => { + command.SetHandler(async (string plannerPlanId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption); return command; @@ -64,7 +66,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Returns a collection of the specified plans"; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -78,20 +80,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -101,7 +102,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Returns a collection of the specified plans"; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -109,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string body) => { + command.SetHandler(async (string plannerPlanId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, bodyOption); return command; @@ -124,6 +124,9 @@ public Command BuildPatchCommand() { public Command BuildTasksCommand() { var command = new Command("tasks"); var builder = new ApiSdk.Planner.Plans.Item.Tasks.TasksRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -195,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerPlan body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Returns a collection of the specified plans - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns a collection of the specified plans - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns a collection of the specified plans - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerPlan model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Returns a collection of the specified plans public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Planner/Plans/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs b/src/generated/Planner/Plans/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs index 32a8f5b1858..64c354297a6 100644 --- a/src/generated/Planner/Plans/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Planner/Plans/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId) => { + command.SetHandler(async (string plannerPlanId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerTaskIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId, string body) => { + command.SetHandler(async (string plannerPlanId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerTaskIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerAssignedToTaskBoa requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerAssignedToTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Planner/Plans/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs b/src/generated/Planner/Plans/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs index cef8da16dbb..82b2099e993 100644 --- a/src/generated/Planner/Plans/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Planner/Plans/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId) => { + command.SetHandler(async (string plannerPlanId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerTaskIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId, string body) => { + command.SetHandler(async (string plannerPlanId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerTaskIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerBucketTaskBoardTa requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerBucketTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Planner/Plans/Item/Tasks/Item/Details/DetailsRequestBuilder.cs b/src/generated/Planner/Plans/Item/Tasks/Item/Details/DetailsRequestBuilder.cs index 9b7ba3f98e6..196fb8fd40b 100644 --- a/src/generated/Planner/Plans/Item/Tasks/Item/Details/DetailsRequestBuilder.cs +++ b/src/generated/Planner/Plans/Item/Tasks/Item/Details/DetailsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Additional details about the task."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId) => { + command.SetHandler(async (string plannerPlanId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerTaskIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Additional details about the task."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Additional details about the task."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId, string body) => { + command.SetHandler(async (string plannerPlanId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerTaskIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerTaskDetails body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerTaskDetails model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Additional details about the task. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Planner/Plans/Item/Tasks/Item/PlannerTaskRequestBuilder.cs b/src/generated/Planner/Plans/Item/Tasks/Item/PlannerTaskRequestBuilder.cs index 2af6ea06b92..feae080a5f3 100644 --- a/src/generated/Planner/Plans/Item/Tasks/Item/PlannerTaskRequestBuilder.cs +++ b/src/generated/Planner/Plans/Item/Tasks/Item/PlannerTaskRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Planner.Plans.Item.Tasks.Item.ProgressTaskBoardFormat; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -46,19 +46,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Collection of tasks in the plan. Read-only. Nullable."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId) => { + command.SetHandler(async (string plannerPlanId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerTaskIdOption); return command; @@ -78,11 +77,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Collection of tasks in the plan. Read-only. Nullable."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -96,20 +95,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,11 +117,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Collection of tasks in the plan. Read-only. Nullable."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -131,14 +129,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId, string body) => { + command.SetHandler(async (string plannerPlanId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerTaskIdOption, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerTask body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of tasks in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of tasks in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of tasks in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of tasks in the plan. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Planner/Plans/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs b/src/generated/Planner/Plans/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs index 9b9410de660..70bac708c2e 100644 --- a/src/generated/Planner/Plans/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Planner/Plans/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId) => { + command.SetHandler(async (string plannerPlanId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerTaskIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string plannerTaskId, string body) => { + command.SetHandler(async (string plannerPlanId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerPlanIdOption, plannerTaskIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerProgressTaskBoard requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerProgressTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Planner/Plans/Item/Tasks/TasksRequestBuilder.cs b/src/generated/Planner/Plans/Item/Tasks/TasksRequestBuilder.cs index 0492bc7d871..1f0e0d556d7 100644 --- a/src/generated/Planner/Plans/Item/Tasks/TasksRequestBuilder.cs +++ b/src/generated/Planner/Plans/Item/Tasks/TasksRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Planner.Plans.Item.Tasks.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class TasksRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PlannerTaskRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAssignedToTaskBoardFormatCommand(), - builder.BuildBucketTaskBoardFormatCommand(), - builder.BuildDeleteCommand(), - builder.BuildDetailsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildProgressTaskBoardFormatCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAssignedToTaskBoardFormatCommand()); + commands.Add(builder.BuildBucketTaskBoardFormatCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDetailsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildProgressTaskBoardFormatCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Collection of tasks in the plan. Read-only. Nullable."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerPlanId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, bodyOption, outputOption); return command; } /// @@ -72,7 +70,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Collection of tasks in the plan. Read-only. Nullable."; // Create options for all the parameters - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerPlanId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerPlanId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -122,15 +124,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerPlanIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerPlanIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -185,31 +182,6 @@ public RequestInformation CreatePostRequestInformation(PlannerTask body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of tasks in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of tasks in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PlannerTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of tasks in the plan. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Planner/Plans/PlansRequestBuilder.cs b/src/generated/Planner/Plans/PlansRequestBuilder.cs index ec4720c21b2..e481549e2a3 100644 --- a/src/generated/Planner/Plans/PlansRequestBuilder.cs +++ b/src/generated/Planner/Plans/PlansRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Planner.Plans.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class PlansRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PlannerPlanRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildBucketsCommand(), - builder.BuildDeleteCommand(), - builder.BuildDetailsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildTasksCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildBucketsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDetailsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildTasksCommand()); return commands; } /// @@ -43,21 +42,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -102,7 +100,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -113,15 +115,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -176,31 +173,6 @@ public RequestInformation CreatePostRequestInformation(PlannerPlan body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Returns a collection of the specified plans - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns a collection of the specified plans - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PlannerPlan model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Returns a collection of the specified plans public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Planner/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs b/src/generated/Planner/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs index 1daafbc2378..a856511ad5b 100644 --- a/src/generated/Planner/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Planner/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo."; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerTaskId) => { + command.SetHandler(async (string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerTaskIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo."; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo."; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerTaskId, string body) => { + command.SetHandler(async (string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerTaskIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerAssignedToTaskBoa requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerAssignedToTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Planner/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs b/src/generated/Planner/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs index 47661b4a063..34d7d9fc928 100644 --- a/src/generated/Planner/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Planner/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket."; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerTaskId) => { + command.SetHandler(async (string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerTaskIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket."; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket."; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerTaskId, string body) => { + command.SetHandler(async (string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerTaskIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerBucketTaskBoardTa requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerBucketTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Planner/Tasks/Item/Details/DetailsRequestBuilder.cs b/src/generated/Planner/Tasks/Item/Details/DetailsRequestBuilder.cs index 33cfc6995b6..963dc3e6d8d 100644 --- a/src/generated/Planner/Tasks/Item/Details/DetailsRequestBuilder.cs +++ b/src/generated/Planner/Tasks/Item/Details/DetailsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Additional details about the task."; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerTaskId) => { + command.SetHandler(async (string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerTaskIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Additional details about the task."; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Additional details about the task."; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerTaskId, string body) => { + command.SetHandler(async (string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerTaskIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerTaskDetails body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerTaskDetails model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Additional details about the task. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Planner/Tasks/Item/PlannerTaskRequestBuilder.cs b/src/generated/Planner/Tasks/Item/PlannerTaskRequestBuilder.cs index 2e168eb6edc..e67f85fdab1 100644 --- a/src/generated/Planner/Tasks/Item/PlannerTaskRequestBuilder.cs +++ b/src/generated/Planner/Tasks/Item/PlannerTaskRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Planner.Tasks.Item.ProgressTaskBoardFormat; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -46,15 +46,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Returns a collection of the specified tasks"; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerTaskId) => { + command.SetHandler(async (string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerTaskIdOption); return command; @@ -74,7 +73,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Returns a collection of the specified tasks"; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -88,20 +87,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,7 +109,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Returns a collection of the specified tasks"; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -119,14 +117,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerTaskId, string body) => { + command.SetHandler(async (string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerTaskIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerTask body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Returns a collection of the specified tasks - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns a collection of the specified tasks - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns a collection of the specified tasks - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Returns a collection of the specified tasks public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Planner/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs b/src/generated/Planner/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs index d1dcb4892a4..bda685e282f 100644 --- a/src/generated/Planner/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Planner/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress."; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string plannerTaskId) => { + command.SetHandler(async (string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerTaskIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress."; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress."; // Create options for all the parameters - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string plannerTaskId, string body) => { + command.SetHandler(async (string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, plannerTaskIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerProgressTaskBoard requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerProgressTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Planner/Tasks/TasksRequestBuilder.cs b/src/generated/Planner/Tasks/TasksRequestBuilder.cs index 3a4629fa511..9a2c9a4d829 100644 --- a/src/generated/Planner/Tasks/TasksRequestBuilder.cs +++ b/src/generated/Planner/Tasks/TasksRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Planner.Tasks.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class TasksRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PlannerTaskRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAssignedToTaskBoardFormatCommand(), - builder.BuildBucketTaskBoardFormatCommand(), - builder.BuildDeleteCommand(), - builder.BuildDetailsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildProgressTaskBoardFormatCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAssignedToTaskBoardFormatCommand()); + commands.Add(builder.BuildBucketTaskBoardFormatCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDetailsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildProgressTaskBoardFormatCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -103,7 +101,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -114,15 +116,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -177,31 +174,6 @@ public RequestInformation CreatePostRequestInformation(PlannerTask body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Returns a collection of the specified tasks - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns a collection of the specified tasks - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PlannerTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Returns a collection of the specified tasks public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Policies/ActivityBasedTimeoutPolicies/ActivityBasedTimeoutPoliciesRequestBuilder.cs b/src/generated/Policies/ActivityBasedTimeoutPolicies/ActivityBasedTimeoutPoliciesRequestBuilder.cs index 41b239e4f97..d5a219d0457 100644 --- a/src/generated/Policies/ActivityBasedTimeoutPolicies/ActivityBasedTimeoutPoliciesRequestBuilder.cs +++ b/src/generated/Policies/ActivityBasedTimeoutPolicies/ActivityBasedTimeoutPoliciesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Policies.ActivityBasedTimeoutPolicies.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ActivityBasedTimeoutPoliciesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ActivityBasedTimeoutPolicyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(ActivityBasedTimeoutPolic requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The policy that controls the idle time out for web sessions for applications. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The policy that controls the idle time out for web sessions for applications. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ActivityBasedTimeoutPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The policy that controls the idle time out for web sessions for applications. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Policies/ActivityBasedTimeoutPolicies/Item/ActivityBasedTimeoutPolicyRequestBuilder.cs b/src/generated/Policies/ActivityBasedTimeoutPolicies/Item/ActivityBasedTimeoutPolicyRequestBuilder.cs index 25a220c6c88..a35254ca18d 100644 --- a/src/generated/Policies/ActivityBasedTimeoutPolicies/Item/ActivityBasedTimeoutPolicyRequestBuilder.cs +++ b/src/generated/Policies/ActivityBasedTimeoutPolicies/Item/ActivityBasedTimeoutPolicyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The policy that controls the idle time out for web sessions for applications."; // Create options for all the parameters - var activityBasedTimeoutPolicyIdOption = new Option("--activitybasedtimeoutpolicy-id", description: "key: id of activityBasedTimeoutPolicy") { + var activityBasedTimeoutPolicyIdOption = new Option("--activity-based-timeout-policy-id", description: "key: id of activityBasedTimeoutPolicy") { }; activityBasedTimeoutPolicyIdOption.IsRequired = true; command.AddOption(activityBasedTimeoutPolicyIdOption); - command.SetHandler(async (string activityBasedTimeoutPolicyId) => { + command.SetHandler(async (string activityBasedTimeoutPolicyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, activityBasedTimeoutPolicyIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The policy that controls the idle time out for web sessions for applications."; // Create options for all the parameters - var activityBasedTimeoutPolicyIdOption = new Option("--activitybasedtimeoutpolicy-id", description: "key: id of activityBasedTimeoutPolicy") { + var activityBasedTimeoutPolicyIdOption = new Option("--activity-based-timeout-policy-id", description: "key: id of activityBasedTimeoutPolicy") { }; activityBasedTimeoutPolicyIdOption.IsRequired = true; command.AddOption(activityBasedTimeoutPolicyIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string activityBasedTimeoutPolicyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string activityBasedTimeoutPolicyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, activityBasedTimeoutPolicyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, activityBasedTimeoutPolicyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The policy that controls the idle time out for web sessions for applications."; // Create options for all the parameters - var activityBasedTimeoutPolicyIdOption = new Option("--activitybasedtimeoutpolicy-id", description: "key: id of activityBasedTimeoutPolicy") { + var activityBasedTimeoutPolicyIdOption = new Option("--activity-based-timeout-policy-id", description: "key: id of activityBasedTimeoutPolicy") { }; activityBasedTimeoutPolicyIdOption.IsRequired = true; command.AddOption(activityBasedTimeoutPolicyIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string activityBasedTimeoutPolicyId, string body) => { + command.SetHandler(async (string activityBasedTimeoutPolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, activityBasedTimeoutPolicyIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ActivityBasedTimeoutPoli requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The policy that controls the idle time out for web sessions for applications. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The policy that controls the idle time out for web sessions for applications. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The policy that controls the idle time out for web sessions for applications. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ActivityBasedTimeoutPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The policy that controls the idle time out for web sessions for applications. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Policies/AdminConsentRequestPolicy/AdminConsentRequestPolicyRequestBuilder.cs b/src/generated/Policies/AdminConsentRequestPolicy/AdminConsentRequestPolicyRequestBuilder.cs index 580e2fc7c2e..fe441fd41bb 100644 --- a/src/generated/Policies/AdminConsentRequestPolicy/AdminConsentRequestPolicyRequestBuilder.cs +++ b/src/generated/Policies/AdminConsentRequestPolicy/AdminConsentRequestPolicyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The policy by which consent requests are created and managed for the entire tenant."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -52,20 +51,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -79,14 +77,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -158,42 +155,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The policy by which consent requests are created and managed for the entire tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The policy by which consent requests are created and managed for the entire tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The policy by which consent requests are created and managed for the entire tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.AdminConsentRequestPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The policy by which consent requests are created and managed for the entire tenant. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Policies/AuthenticationFlowsPolicy/AuthenticationFlowsPolicyRequestBuilder.cs b/src/generated/Policies/AuthenticationFlowsPolicy/AuthenticationFlowsPolicyRequestBuilder.cs index 2e7cc752dc3..95308a3d2c2 100644 --- a/src/generated/Policies/AuthenticationFlowsPolicy/AuthenticationFlowsPolicyRequestBuilder.cs +++ b/src/generated/Policies/AuthenticationFlowsPolicy/AuthenticationFlowsPolicyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The policy configuration of the self-service sign-up experience of external users."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -52,20 +51,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -79,14 +77,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -158,42 +155,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The policy configuration of the self-service sign-up experience of external users. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The policy configuration of the self-service sign-up experience of external users. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The policy configuration of the self-service sign-up experience of external users. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.AuthenticationFlowsPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The policy configuration of the self-service sign-up experience of external users. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Policies/AuthenticationMethodsPolicy/AuthenticationMethodsPolicyRequestBuilder.cs b/src/generated/Policies/AuthenticationMethodsPolicy/AuthenticationMethodsPolicyRequestBuilder.cs index 2b551a979b6..5183accb946 100644 --- a/src/generated/Policies/AuthenticationMethodsPolicy/AuthenticationMethodsPolicyRequestBuilder.cs +++ b/src/generated/Policies/AuthenticationMethodsPolicy/AuthenticationMethodsPolicyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The authentication methods and the users that are allowed to use them to sign in and perform multi-factor authentication (MFA) in Azure Active Directory (Azure AD)."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -52,20 +51,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -79,14 +77,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -158,42 +155,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The authentication methods and the users that are allowed to use them to sign in and perform multi-factor authentication (MFA) in Azure Active Directory (Azure AD). - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The authentication methods and the users that are allowed to use them to sign in and perform multi-factor authentication (MFA) in Azure Active Directory (Azure AD). - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The authentication methods and the users that are allowed to use them to sign in and perform multi-factor authentication (MFA) in Azure Active Directory (Azure AD). - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.AuthenticationMethodsPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The authentication methods and the users that are allowed to use them to sign in and perform multi-factor authentication (MFA) in Azure Active Directory (Azure AD). public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Policies/AuthorizationPolicy/AuthorizationPolicyRequestBuilder.cs b/src/generated/Policies/AuthorizationPolicy/AuthorizationPolicyRequestBuilder.cs index fe7f2555847..1d09c1c8fba 100644 --- a/src/generated/Policies/AuthorizationPolicy/AuthorizationPolicyRequestBuilder.cs +++ b/src/generated/Policies/AuthorizationPolicy/AuthorizationPolicyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The policy that controls Azure AD authorization settings."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -52,20 +51,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -79,14 +77,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -158,42 +155,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The policy that controls Azure AD authorization settings. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The policy that controls Azure AD authorization settings. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The policy that controls Azure AD authorization settings. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.AuthorizationPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The policy that controls Azure AD authorization settings. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Policies/ClaimsMappingPolicies/ClaimsMappingPoliciesRequestBuilder.cs b/src/generated/Policies/ClaimsMappingPolicies/ClaimsMappingPoliciesRequestBuilder.cs index 3a963db91bb..cf4229b199e 100644 --- a/src/generated/Policies/ClaimsMappingPolicies/ClaimsMappingPoliciesRequestBuilder.cs +++ b/src/generated/Policies/ClaimsMappingPolicies/ClaimsMappingPoliciesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Policies.ClaimsMappingPolicies.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ClaimsMappingPoliciesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ClaimsMappingPolicyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(ClaimsMappingPolicy body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The claim-mapping policies for WS-Fed, SAML, OAuth 2.0, and OpenID Connect protocols, for tokens issued to a specific application. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The claim-mapping policies for WS-Fed, SAML, OAuth 2.0, and OpenID Connect protocols, for tokens issued to a specific application. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ClaimsMappingPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The claim-mapping policies for WS-Fed, SAML, OAuth 2.0, and OpenID Connect protocols, for tokens issued to a specific application. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Policies/ClaimsMappingPolicies/Item/ClaimsMappingPolicyRequestBuilder.cs b/src/generated/Policies/ClaimsMappingPolicies/Item/ClaimsMappingPolicyRequestBuilder.cs index 7b35c11886e..78cb23c85ad 100644 --- a/src/generated/Policies/ClaimsMappingPolicies/Item/ClaimsMappingPolicyRequestBuilder.cs +++ b/src/generated/Policies/ClaimsMappingPolicies/Item/ClaimsMappingPolicyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The claim-mapping policies for WS-Fed, SAML, OAuth 2.0, and OpenID Connect protocols, for tokens issued to a specific application."; // Create options for all the parameters - var claimsMappingPolicyIdOption = new Option("--claimsmappingpolicy-id", description: "key: id of claimsMappingPolicy") { + var claimsMappingPolicyIdOption = new Option("--claims-mapping-policy-id", description: "key: id of claimsMappingPolicy") { }; claimsMappingPolicyIdOption.IsRequired = true; command.AddOption(claimsMappingPolicyIdOption); - command.SetHandler(async (string claimsMappingPolicyId) => { + command.SetHandler(async (string claimsMappingPolicyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, claimsMappingPolicyIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The claim-mapping policies for WS-Fed, SAML, OAuth 2.0, and OpenID Connect protocols, for tokens issued to a specific application."; // Create options for all the parameters - var claimsMappingPolicyIdOption = new Option("--claimsmappingpolicy-id", description: "key: id of claimsMappingPolicy") { + var claimsMappingPolicyIdOption = new Option("--claims-mapping-policy-id", description: "key: id of claimsMappingPolicy") { }; claimsMappingPolicyIdOption.IsRequired = true; command.AddOption(claimsMappingPolicyIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string claimsMappingPolicyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string claimsMappingPolicyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, claimsMappingPolicyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, claimsMappingPolicyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The claim-mapping policies for WS-Fed, SAML, OAuth 2.0, and OpenID Connect protocols, for tokens issued to a specific application."; // Create options for all the parameters - var claimsMappingPolicyIdOption = new Option("--claimsmappingpolicy-id", description: "key: id of claimsMappingPolicy") { + var claimsMappingPolicyIdOption = new Option("--claims-mapping-policy-id", description: "key: id of claimsMappingPolicy") { }; claimsMappingPolicyIdOption.IsRequired = true; command.AddOption(claimsMappingPolicyIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string claimsMappingPolicyId, string body) => { + command.SetHandler(async (string claimsMappingPolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, claimsMappingPolicyIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ClaimsMappingPolicy body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The claim-mapping policies for WS-Fed, SAML, OAuth 2.0, and OpenID Connect protocols, for tokens issued to a specific application. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The claim-mapping policies for WS-Fed, SAML, OAuth 2.0, and OpenID Connect protocols, for tokens issued to a specific application. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The claim-mapping policies for WS-Fed, SAML, OAuth 2.0, and OpenID Connect protocols, for tokens issued to a specific application. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ClaimsMappingPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The claim-mapping policies for WS-Fed, SAML, OAuth 2.0, and OpenID Connect protocols, for tokens issued to a specific application. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Policies/ConditionalAccessPolicies/ConditionalAccessPoliciesRequestBuilder.cs b/src/generated/Policies/ConditionalAccessPolicies/ConditionalAccessPoliciesRequestBuilder.cs index 895d6839a6a..052c13bb724 100644 --- a/src/generated/Policies/ConditionalAccessPolicies/ConditionalAccessPoliciesRequestBuilder.cs +++ b/src/generated/Policies/ConditionalAccessPolicies/ConditionalAccessPoliciesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Policies.ConditionalAccessPolicies.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ConditionalAccessPoliciesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ConditionalAccessPolicyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(ConditionalAccessPolicy b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The custom rules that define an access scenario. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The custom rules that define an access scenario. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ConditionalAccessPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The custom rules that define an access scenario. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Policies/ConditionalAccessPolicies/Item/ConditionalAccessPolicyRequestBuilder.cs b/src/generated/Policies/ConditionalAccessPolicies/Item/ConditionalAccessPolicyRequestBuilder.cs index d015edd2690..f09df71a5d5 100644 --- a/src/generated/Policies/ConditionalAccessPolicies/Item/ConditionalAccessPolicyRequestBuilder.cs +++ b/src/generated/Policies/ConditionalAccessPolicies/Item/ConditionalAccessPolicyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The custom rules that define an access scenario."; // Create options for all the parameters - var conditionalAccessPolicyIdOption = new Option("--conditionalaccesspolicy-id", description: "key: id of conditionalAccessPolicy") { + var conditionalAccessPolicyIdOption = new Option("--conditional-access-policy-id", description: "key: id of conditionalAccessPolicy") { }; conditionalAccessPolicyIdOption.IsRequired = true; command.AddOption(conditionalAccessPolicyIdOption); - command.SetHandler(async (string conditionalAccessPolicyId) => { + command.SetHandler(async (string conditionalAccessPolicyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, conditionalAccessPolicyIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The custom rules that define an access scenario."; // Create options for all the parameters - var conditionalAccessPolicyIdOption = new Option("--conditionalaccesspolicy-id", description: "key: id of conditionalAccessPolicy") { + var conditionalAccessPolicyIdOption = new Option("--conditional-access-policy-id", description: "key: id of conditionalAccessPolicy") { }; conditionalAccessPolicyIdOption.IsRequired = true; command.AddOption(conditionalAccessPolicyIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string conditionalAccessPolicyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string conditionalAccessPolicyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, conditionalAccessPolicyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, conditionalAccessPolicyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The custom rules that define an access scenario."; // Create options for all the parameters - var conditionalAccessPolicyIdOption = new Option("--conditionalaccesspolicy-id", description: "key: id of conditionalAccessPolicy") { + var conditionalAccessPolicyIdOption = new Option("--conditional-access-policy-id", description: "key: id of conditionalAccessPolicy") { }; conditionalAccessPolicyIdOption.IsRequired = true; command.AddOption(conditionalAccessPolicyIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string conditionalAccessPolicyId, string body) => { + command.SetHandler(async (string conditionalAccessPolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, conditionalAccessPolicyIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ConditionalAccessPolicy requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The custom rules that define an access scenario. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The custom rules that define an access scenario. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The custom rules that define an access scenario. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ConditionalAccessPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The custom rules that define an access scenario. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Policies/FeatureRolloutPolicies/FeatureRolloutPoliciesRequestBuilder.cs b/src/generated/Policies/FeatureRolloutPolicies/FeatureRolloutPoliciesRequestBuilder.cs index 72c7f8be5a2..4effe7c395e 100644 --- a/src/generated/Policies/FeatureRolloutPolicies/FeatureRolloutPoliciesRequestBuilder.cs +++ b/src/generated/Policies/FeatureRolloutPolicies/FeatureRolloutPoliciesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Policies.FeatureRolloutPolicies.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class FeatureRolloutPoliciesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new FeatureRolloutPolicyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAppliesToCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAppliesToCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(FeatureRolloutPolicy body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The feature rollout policy associated with a directory object. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The feature rollout policy associated with a directory object. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(FeatureRolloutPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The feature rollout policy associated with a directory object. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Policies/FeatureRolloutPolicies/Item/AppliesTo/AppliesToRequestBuilder.cs b/src/generated/Policies/FeatureRolloutPolicies/Item/AppliesTo/AppliesToRequestBuilder.cs index cba0e3ff57c..9cdd088ab41 100644 --- a/src/generated/Policies/FeatureRolloutPolicies/Item/AppliesTo/AppliesToRequestBuilder.cs +++ b/src/generated/Policies/FeatureRolloutPolicies/Item/AppliesTo/AppliesToRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Policies.FeatureRolloutPolicies.Item.AppliesTo.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AppliesToRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DirectoryObjectRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Nullable. Specifies a list of directoryObjects that feature is enabled for."; // Create options for all the parameters - var featureRolloutPolicyIdOption = new Option("--featurerolloutpolicy-id", description: "key: id of featureRolloutPolicy") { + var featureRolloutPolicyIdOption = new Option("--feature-rollout-policy-id", description: "key: id of featureRolloutPolicy") { }; featureRolloutPolicyIdOption.IsRequired = true; command.AddOption(featureRolloutPolicyIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string featureRolloutPolicyId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string featureRolloutPolicyId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, featureRolloutPolicyIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, featureRolloutPolicyIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Nullable. Specifies a list of directoryObjects that feature is enabled for."; // Create options for all the parameters - var featureRolloutPolicyIdOption = new Option("--featurerolloutpolicy-id", description: "key: id of featureRolloutPolicy") { + var featureRolloutPolicyIdOption = new Option("--feature-rollout-policy-id", description: "key: id of featureRolloutPolicy") { }; featureRolloutPolicyIdOption.IsRequired = true; command.AddOption(featureRolloutPolicyIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string featureRolloutPolicyId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string featureRolloutPolicyId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, featureRolloutPolicyIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, featureRolloutPolicyIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(DirectoryObject body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Nullable. Specifies a list of directoryObjects that feature is enabled for. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Nullable. Specifies a list of directoryObjects that feature is enabled for. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DirectoryObject model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Nullable. Specifies a list of directoryObjects that feature is enabled for. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Policies/FeatureRolloutPolicies/Item/AppliesTo/Item/DirectoryObjectRequestBuilder.cs b/src/generated/Policies/FeatureRolloutPolicies/Item/AppliesTo/Item/DirectoryObjectRequestBuilder.cs index 7c3388006f7..8da0c114ae0 100644 --- a/src/generated/Policies/FeatureRolloutPolicies/Item/AppliesTo/Item/DirectoryObjectRequestBuilder.cs +++ b/src/generated/Policies/FeatureRolloutPolicies/Item/AppliesTo/Item/DirectoryObjectRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Nullable. Specifies a list of directoryObjects that feature is enabled for."; // Create options for all the parameters - var featureRolloutPolicyIdOption = new Option("--featurerolloutpolicy-id", description: "key: id of featureRolloutPolicy") { + var featureRolloutPolicyIdOption = new Option("--feature-rollout-policy-id", description: "key: id of featureRolloutPolicy") { }; featureRolloutPolicyIdOption.IsRequired = true; command.AddOption(featureRolloutPolicyIdOption); - var directoryObjectIdOption = new Option("--directoryobject-id", description: "key: id of directoryObject") { + var directoryObjectIdOption = new Option("--directory-object-id", description: "key: id of directoryObject") { }; directoryObjectIdOption.IsRequired = true; command.AddOption(directoryObjectIdOption); - command.SetHandler(async (string featureRolloutPolicyId, string directoryObjectId) => { + command.SetHandler(async (string featureRolloutPolicyId, string directoryObjectId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, featureRolloutPolicyIdOption, directoryObjectIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Nullable. Specifies a list of directoryObjects that feature is enabled for."; // Create options for all the parameters - var featureRolloutPolicyIdOption = new Option("--featurerolloutpolicy-id", description: "key: id of featureRolloutPolicy") { + var featureRolloutPolicyIdOption = new Option("--feature-rollout-policy-id", description: "key: id of featureRolloutPolicy") { }; featureRolloutPolicyIdOption.IsRequired = true; command.AddOption(featureRolloutPolicyIdOption); - var directoryObjectIdOption = new Option("--directoryobject-id", description: "key: id of directoryObject") { + var directoryObjectIdOption = new Option("--directory-object-id", description: "key: id of directoryObject") { }; directoryObjectIdOption.IsRequired = true; command.AddOption(directoryObjectIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string featureRolloutPolicyId, string directoryObjectId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string featureRolloutPolicyId, string directoryObjectId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, featureRolloutPolicyIdOption, directoryObjectIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, featureRolloutPolicyIdOption, directoryObjectIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Nullable. Specifies a list of directoryObjects that feature is enabled for."; // Create options for all the parameters - var featureRolloutPolicyIdOption = new Option("--featurerolloutpolicy-id", description: "key: id of featureRolloutPolicy") { + var featureRolloutPolicyIdOption = new Option("--feature-rollout-policy-id", description: "key: id of featureRolloutPolicy") { }; featureRolloutPolicyIdOption.IsRequired = true; command.AddOption(featureRolloutPolicyIdOption); - var directoryObjectIdOption = new Option("--directoryobject-id", description: "key: id of directoryObject") { + var directoryObjectIdOption = new Option("--directory-object-id", description: "key: id of directoryObject") { }; directoryObjectIdOption.IsRequired = true; command.AddOption(directoryObjectIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string featureRolloutPolicyId, string directoryObjectId, string body) => { + command.SetHandler(async (string featureRolloutPolicyId, string directoryObjectId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, featureRolloutPolicyIdOption, directoryObjectIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(DirectoryObject body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Nullable. Specifies a list of directoryObjects that feature is enabled for. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Nullable. Specifies a list of directoryObjects that feature is enabled for. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Nullable. Specifies a list of directoryObjects that feature is enabled for. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DirectoryObject model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Nullable. Specifies a list of directoryObjects that feature is enabled for. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Policies/FeatureRolloutPolicies/Item/FeatureRolloutPolicyRequestBuilder.cs b/src/generated/Policies/FeatureRolloutPolicies/Item/FeatureRolloutPolicyRequestBuilder.cs index f8ae338d304..3dac17530d0 100644 --- a/src/generated/Policies/FeatureRolloutPolicies/Item/FeatureRolloutPolicyRequestBuilder.cs +++ b/src/generated/Policies/FeatureRolloutPolicies/Item/FeatureRolloutPolicyRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Policies.FeatureRolloutPolicies.Item.AppliesTo; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,6 +23,9 @@ public class FeatureRolloutPolicyRequestBuilder { public Command BuildAppliesToCommand() { var command = new Command("applies-to"); var builder = new ApiSdk.Policies.FeatureRolloutPolicies.Item.AppliesTo.AppliesToRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -34,15 +37,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The feature rollout policy associated with a directory object."; // Create options for all the parameters - var featureRolloutPolicyIdOption = new Option("--featurerolloutpolicy-id", description: "key: id of featureRolloutPolicy") { + var featureRolloutPolicyIdOption = new Option("--feature-rollout-policy-id", description: "key: id of featureRolloutPolicy") { }; featureRolloutPolicyIdOption.IsRequired = true; command.AddOption(featureRolloutPolicyIdOption); - command.SetHandler(async (string featureRolloutPolicyId) => { + command.SetHandler(async (string featureRolloutPolicyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, featureRolloutPolicyIdOption); return command; @@ -54,7 +56,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The feature rollout policy associated with a directory object."; // Create options for all the parameters - var featureRolloutPolicyIdOption = new Option("--featurerolloutpolicy-id", description: "key: id of featureRolloutPolicy") { + var featureRolloutPolicyIdOption = new Option("--feature-rollout-policy-id", description: "key: id of featureRolloutPolicy") { }; featureRolloutPolicyIdOption.IsRequired = true; command.AddOption(featureRolloutPolicyIdOption); @@ -68,20 +70,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string featureRolloutPolicyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string featureRolloutPolicyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, featureRolloutPolicyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, featureRolloutPolicyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,7 +92,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The feature rollout policy associated with a directory object."; // Create options for all the parameters - var featureRolloutPolicyIdOption = new Option("--featurerolloutpolicy-id", description: "key: id of featureRolloutPolicy") { + var featureRolloutPolicyIdOption = new Option("--feature-rollout-policy-id", description: "key: id of featureRolloutPolicy") { }; featureRolloutPolicyIdOption.IsRequired = true; command.AddOption(featureRolloutPolicyIdOption); @@ -99,14 +100,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string featureRolloutPolicyId, string body) => { + command.SetHandler(async (string featureRolloutPolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, featureRolloutPolicyIdOption, bodyOption); return command; @@ -178,42 +178,6 @@ public RequestInformation CreatePatchRequestInformation(FeatureRolloutPolicy bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The feature rollout policy associated with a directory object. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The feature rollout policy associated with a directory object. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The feature rollout policy associated with a directory object. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(FeatureRolloutPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The feature rollout policy associated with a directory object. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Policies/HomeRealmDiscoveryPolicies/HomeRealmDiscoveryPoliciesRequestBuilder.cs b/src/generated/Policies/HomeRealmDiscoveryPolicies/HomeRealmDiscoveryPoliciesRequestBuilder.cs index 341935fa32d..7a76bcb6e48 100644 --- a/src/generated/Policies/HomeRealmDiscoveryPolicies/HomeRealmDiscoveryPoliciesRequestBuilder.cs +++ b/src/generated/Policies/HomeRealmDiscoveryPolicies/HomeRealmDiscoveryPoliciesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Policies.HomeRealmDiscoveryPolicies.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class HomeRealmDiscoveryPoliciesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new HomeRealmDiscoveryPolicyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(HomeRealmDiscoveryPolicy requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The policy to control Azure AD authentication behavior for federated users. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The policy to control Azure AD authentication behavior for federated users. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(HomeRealmDiscoveryPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The policy to control Azure AD authentication behavior for federated users. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Policies/HomeRealmDiscoveryPolicies/Item/HomeRealmDiscoveryPolicyRequestBuilder.cs b/src/generated/Policies/HomeRealmDiscoveryPolicies/Item/HomeRealmDiscoveryPolicyRequestBuilder.cs index 1dd4902791d..1053603e92b 100644 --- a/src/generated/Policies/HomeRealmDiscoveryPolicies/Item/HomeRealmDiscoveryPolicyRequestBuilder.cs +++ b/src/generated/Policies/HomeRealmDiscoveryPolicies/Item/HomeRealmDiscoveryPolicyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The policy to control Azure AD authentication behavior for federated users."; // Create options for all the parameters - var homeRealmDiscoveryPolicyIdOption = new Option("--homerealmdiscoverypolicy-id", description: "key: id of homeRealmDiscoveryPolicy") { + var homeRealmDiscoveryPolicyIdOption = new Option("--home-realm-discovery-policy-id", description: "key: id of homeRealmDiscoveryPolicy") { }; homeRealmDiscoveryPolicyIdOption.IsRequired = true; command.AddOption(homeRealmDiscoveryPolicyIdOption); - command.SetHandler(async (string homeRealmDiscoveryPolicyId) => { + command.SetHandler(async (string homeRealmDiscoveryPolicyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, homeRealmDiscoveryPolicyIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The policy to control Azure AD authentication behavior for federated users."; // Create options for all the parameters - var homeRealmDiscoveryPolicyIdOption = new Option("--homerealmdiscoverypolicy-id", description: "key: id of homeRealmDiscoveryPolicy") { + var homeRealmDiscoveryPolicyIdOption = new Option("--home-realm-discovery-policy-id", description: "key: id of homeRealmDiscoveryPolicy") { }; homeRealmDiscoveryPolicyIdOption.IsRequired = true; command.AddOption(homeRealmDiscoveryPolicyIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string homeRealmDiscoveryPolicyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string homeRealmDiscoveryPolicyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, homeRealmDiscoveryPolicyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, homeRealmDiscoveryPolicyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The policy to control Azure AD authentication behavior for federated users."; // Create options for all the parameters - var homeRealmDiscoveryPolicyIdOption = new Option("--homerealmdiscoverypolicy-id", description: "key: id of homeRealmDiscoveryPolicy") { + var homeRealmDiscoveryPolicyIdOption = new Option("--home-realm-discovery-policy-id", description: "key: id of homeRealmDiscoveryPolicy") { }; homeRealmDiscoveryPolicyIdOption.IsRequired = true; command.AddOption(homeRealmDiscoveryPolicyIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string homeRealmDiscoveryPolicyId, string body) => { + command.SetHandler(async (string homeRealmDiscoveryPolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, homeRealmDiscoveryPolicyIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(HomeRealmDiscoveryPolicy requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The policy to control Azure AD authentication behavior for federated users. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The policy to control Azure AD authentication behavior for federated users. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The policy to control Azure AD authentication behavior for federated users. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(HomeRealmDiscoveryPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The policy to control Azure AD authentication behavior for federated users. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Policies/IdentitySecurityDefaultsEnforcementPolicy/IdentitySecurityDefaultsEnforcementPolicyRequestBuilder.cs b/src/generated/Policies/IdentitySecurityDefaultsEnforcementPolicy/IdentitySecurityDefaultsEnforcementPolicyRequestBuilder.cs index bba46f8e8ed..2ba8ae3d900 100644 --- a/src/generated/Policies/IdentitySecurityDefaultsEnforcementPolicy/IdentitySecurityDefaultsEnforcementPolicyRequestBuilder.cs +++ b/src/generated/Policies/IdentitySecurityDefaultsEnforcementPolicy/IdentitySecurityDefaultsEnforcementPolicyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The policy that represents the security defaults that protect against common attacks."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -52,20 +51,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -79,14 +77,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -158,42 +155,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The policy that represents the security defaults that protect against common attacks. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The policy that represents the security defaults that protect against common attacks. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The policy that represents the security defaults that protect against common attacks. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.IdentitySecurityDefaultsEnforcementPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The policy that represents the security defaults that protect against common attacks. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Policies/PermissionGrantPolicies/Item/Excludes/ExcludesRequestBuilder.cs b/src/generated/Policies/PermissionGrantPolicies/Item/Excludes/ExcludesRequestBuilder.cs index f861015fc73..13e5a3bd402 100644 --- a/src/generated/Policies/PermissionGrantPolicies/Item/Excludes/ExcludesRequestBuilder.cs +++ b/src/generated/Policies/PermissionGrantPolicies/Item/Excludes/ExcludesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Policies.PermissionGrantPolicies.Item.Excludes.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExcludesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PermissionGrantConditionSetRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Condition sets which are excluded in this permission grant policy. Automatically expanded on GET."; // Create options for all the parameters - var permissionGrantPolicyIdOption = new Option("--permissiongrantpolicy-id", description: "key: id of permissionGrantPolicy") { + var permissionGrantPolicyIdOption = new Option("--permission-grant-policy-id", description: "key: id of permissionGrantPolicy") { }; permissionGrantPolicyIdOption.IsRequired = true; command.AddOption(permissionGrantPolicyIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string permissionGrantPolicyId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string permissionGrantPolicyId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, permissionGrantPolicyIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, permissionGrantPolicyIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Condition sets which are excluded in this permission grant policy. Automatically expanded on GET."; // Create options for all the parameters - var permissionGrantPolicyIdOption = new Option("--permissiongrantpolicy-id", description: "key: id of permissionGrantPolicy") { + var permissionGrantPolicyIdOption = new Option("--permission-grant-policy-id", description: "key: id of permissionGrantPolicy") { }; permissionGrantPolicyIdOption.IsRequired = true; command.AddOption(permissionGrantPolicyIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string permissionGrantPolicyId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string permissionGrantPolicyId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, permissionGrantPolicyIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, permissionGrantPolicyIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(PermissionGrantConditionS requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Condition sets which are excluded in this permission grant policy. Automatically expanded on GET. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Condition sets which are excluded in this permission grant policy. Automatically expanded on GET. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PermissionGrantConditionSet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Condition sets which are excluded in this permission grant policy. Automatically expanded on GET. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Policies/PermissionGrantPolicies/Item/Excludes/Item/PermissionGrantConditionSetRequestBuilder.cs b/src/generated/Policies/PermissionGrantPolicies/Item/Excludes/Item/PermissionGrantConditionSetRequestBuilder.cs index 51e3f5b060a..8427a83b3c1 100644 --- a/src/generated/Policies/PermissionGrantPolicies/Item/Excludes/Item/PermissionGrantConditionSetRequestBuilder.cs +++ b/src/generated/Policies/PermissionGrantPolicies/Item/Excludes/Item/PermissionGrantConditionSetRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Condition sets which are excluded in this permission grant policy. Automatically expanded on GET."; // Create options for all the parameters - var permissionGrantPolicyIdOption = new Option("--permissiongrantpolicy-id", description: "key: id of permissionGrantPolicy") { + var permissionGrantPolicyIdOption = new Option("--permission-grant-policy-id", description: "key: id of permissionGrantPolicy") { }; permissionGrantPolicyIdOption.IsRequired = true; command.AddOption(permissionGrantPolicyIdOption); - var permissionGrantConditionSetIdOption = new Option("--permissiongrantconditionset-id", description: "key: id of permissionGrantConditionSet") { + var permissionGrantConditionSetIdOption = new Option("--permission-grant-condition-set-id", description: "key: id of permissionGrantConditionSet") { }; permissionGrantConditionSetIdOption.IsRequired = true; command.AddOption(permissionGrantConditionSetIdOption); - command.SetHandler(async (string permissionGrantPolicyId, string permissionGrantConditionSetId) => { + command.SetHandler(async (string permissionGrantPolicyId, string permissionGrantConditionSetId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, permissionGrantPolicyIdOption, permissionGrantConditionSetIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Condition sets which are excluded in this permission grant policy. Automatically expanded on GET."; // Create options for all the parameters - var permissionGrantPolicyIdOption = new Option("--permissiongrantpolicy-id", description: "key: id of permissionGrantPolicy") { + var permissionGrantPolicyIdOption = new Option("--permission-grant-policy-id", description: "key: id of permissionGrantPolicy") { }; permissionGrantPolicyIdOption.IsRequired = true; command.AddOption(permissionGrantPolicyIdOption); - var permissionGrantConditionSetIdOption = new Option("--permissiongrantconditionset-id", description: "key: id of permissionGrantConditionSet") { + var permissionGrantConditionSetIdOption = new Option("--permission-grant-condition-set-id", description: "key: id of permissionGrantConditionSet") { }; permissionGrantConditionSetIdOption.IsRequired = true; command.AddOption(permissionGrantConditionSetIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string permissionGrantPolicyId, string permissionGrantConditionSetId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string permissionGrantPolicyId, string permissionGrantConditionSetId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, permissionGrantPolicyIdOption, permissionGrantConditionSetIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, permissionGrantPolicyIdOption, permissionGrantConditionSetIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Condition sets which are excluded in this permission grant policy. Automatically expanded on GET."; // Create options for all the parameters - var permissionGrantPolicyIdOption = new Option("--permissiongrantpolicy-id", description: "key: id of permissionGrantPolicy") { + var permissionGrantPolicyIdOption = new Option("--permission-grant-policy-id", description: "key: id of permissionGrantPolicy") { }; permissionGrantPolicyIdOption.IsRequired = true; command.AddOption(permissionGrantPolicyIdOption); - var permissionGrantConditionSetIdOption = new Option("--permissiongrantconditionset-id", description: "key: id of permissionGrantConditionSet") { + var permissionGrantConditionSetIdOption = new Option("--permission-grant-condition-set-id", description: "key: id of permissionGrantConditionSet") { }; permissionGrantConditionSetIdOption.IsRequired = true; command.AddOption(permissionGrantConditionSetIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string permissionGrantPolicyId, string permissionGrantConditionSetId, string body) => { + command.SetHandler(async (string permissionGrantPolicyId, string permissionGrantConditionSetId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, permissionGrantPolicyIdOption, permissionGrantConditionSetIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(PermissionGrantCondition requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Condition sets which are excluded in this permission grant policy. Automatically expanded on GET. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Condition sets which are excluded in this permission grant policy. Automatically expanded on GET. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Condition sets which are excluded in this permission grant policy. Automatically expanded on GET. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PermissionGrantConditionSet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Condition sets which are excluded in this permission grant policy. Automatically expanded on GET. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Policies/PermissionGrantPolicies/Item/Includes/IncludesRequestBuilder.cs b/src/generated/Policies/PermissionGrantPolicies/Item/Includes/IncludesRequestBuilder.cs index 13064221603..11d99a46fe4 100644 --- a/src/generated/Policies/PermissionGrantPolicies/Item/Includes/IncludesRequestBuilder.cs +++ b/src/generated/Policies/PermissionGrantPolicies/Item/Includes/IncludesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Policies.PermissionGrantPolicies.Item.Includes.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class IncludesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PermissionGrantConditionSetRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Condition sets which are included in this permission grant policy. Automatically expanded on GET."; // Create options for all the parameters - var permissionGrantPolicyIdOption = new Option("--permissiongrantpolicy-id", description: "key: id of permissionGrantPolicy") { + var permissionGrantPolicyIdOption = new Option("--permission-grant-policy-id", description: "key: id of permissionGrantPolicy") { }; permissionGrantPolicyIdOption.IsRequired = true; command.AddOption(permissionGrantPolicyIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string permissionGrantPolicyId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string permissionGrantPolicyId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, permissionGrantPolicyIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, permissionGrantPolicyIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Condition sets which are included in this permission grant policy. Automatically expanded on GET."; // Create options for all the parameters - var permissionGrantPolicyIdOption = new Option("--permissiongrantpolicy-id", description: "key: id of permissionGrantPolicy") { + var permissionGrantPolicyIdOption = new Option("--permission-grant-policy-id", description: "key: id of permissionGrantPolicy") { }; permissionGrantPolicyIdOption.IsRequired = true; command.AddOption(permissionGrantPolicyIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string permissionGrantPolicyId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string permissionGrantPolicyId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, permissionGrantPolicyIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, permissionGrantPolicyIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(PermissionGrantConditionS requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Condition sets which are included in this permission grant policy. Automatically expanded on GET. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Condition sets which are included in this permission grant policy. Automatically expanded on GET. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PermissionGrantConditionSet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Condition sets which are included in this permission grant policy. Automatically expanded on GET. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Policies/PermissionGrantPolicies/Item/Includes/Item/PermissionGrantConditionSetRequestBuilder.cs b/src/generated/Policies/PermissionGrantPolicies/Item/Includes/Item/PermissionGrantConditionSetRequestBuilder.cs index 373b1320ba8..729ce675a17 100644 --- a/src/generated/Policies/PermissionGrantPolicies/Item/Includes/Item/PermissionGrantConditionSetRequestBuilder.cs +++ b/src/generated/Policies/PermissionGrantPolicies/Item/Includes/Item/PermissionGrantConditionSetRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Condition sets which are included in this permission grant policy. Automatically expanded on GET."; // Create options for all the parameters - var permissionGrantPolicyIdOption = new Option("--permissiongrantpolicy-id", description: "key: id of permissionGrantPolicy") { + var permissionGrantPolicyIdOption = new Option("--permission-grant-policy-id", description: "key: id of permissionGrantPolicy") { }; permissionGrantPolicyIdOption.IsRequired = true; command.AddOption(permissionGrantPolicyIdOption); - var permissionGrantConditionSetIdOption = new Option("--permissiongrantconditionset-id", description: "key: id of permissionGrantConditionSet") { + var permissionGrantConditionSetIdOption = new Option("--permission-grant-condition-set-id", description: "key: id of permissionGrantConditionSet") { }; permissionGrantConditionSetIdOption.IsRequired = true; command.AddOption(permissionGrantConditionSetIdOption); - command.SetHandler(async (string permissionGrantPolicyId, string permissionGrantConditionSetId) => { + command.SetHandler(async (string permissionGrantPolicyId, string permissionGrantConditionSetId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, permissionGrantPolicyIdOption, permissionGrantConditionSetIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Condition sets which are included in this permission grant policy. Automatically expanded on GET."; // Create options for all the parameters - var permissionGrantPolicyIdOption = new Option("--permissiongrantpolicy-id", description: "key: id of permissionGrantPolicy") { + var permissionGrantPolicyIdOption = new Option("--permission-grant-policy-id", description: "key: id of permissionGrantPolicy") { }; permissionGrantPolicyIdOption.IsRequired = true; command.AddOption(permissionGrantPolicyIdOption); - var permissionGrantConditionSetIdOption = new Option("--permissiongrantconditionset-id", description: "key: id of permissionGrantConditionSet") { + var permissionGrantConditionSetIdOption = new Option("--permission-grant-condition-set-id", description: "key: id of permissionGrantConditionSet") { }; permissionGrantConditionSetIdOption.IsRequired = true; command.AddOption(permissionGrantConditionSetIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string permissionGrantPolicyId, string permissionGrantConditionSetId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string permissionGrantPolicyId, string permissionGrantConditionSetId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, permissionGrantPolicyIdOption, permissionGrantConditionSetIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, permissionGrantPolicyIdOption, permissionGrantConditionSetIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Condition sets which are included in this permission grant policy. Automatically expanded on GET."; // Create options for all the parameters - var permissionGrantPolicyIdOption = new Option("--permissiongrantpolicy-id", description: "key: id of permissionGrantPolicy") { + var permissionGrantPolicyIdOption = new Option("--permission-grant-policy-id", description: "key: id of permissionGrantPolicy") { }; permissionGrantPolicyIdOption.IsRequired = true; command.AddOption(permissionGrantPolicyIdOption); - var permissionGrantConditionSetIdOption = new Option("--permissiongrantconditionset-id", description: "key: id of permissionGrantConditionSet") { + var permissionGrantConditionSetIdOption = new Option("--permission-grant-condition-set-id", description: "key: id of permissionGrantConditionSet") { }; permissionGrantConditionSetIdOption.IsRequired = true; command.AddOption(permissionGrantConditionSetIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string permissionGrantPolicyId, string permissionGrantConditionSetId, string body) => { + command.SetHandler(async (string permissionGrantPolicyId, string permissionGrantConditionSetId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, permissionGrantPolicyIdOption, permissionGrantConditionSetIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(PermissionGrantCondition requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Condition sets which are included in this permission grant policy. Automatically expanded on GET. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Condition sets which are included in this permission grant policy. Automatically expanded on GET. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Condition sets which are included in this permission grant policy. Automatically expanded on GET. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PermissionGrantConditionSet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Condition sets which are included in this permission grant policy. Automatically expanded on GET. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Policies/PermissionGrantPolicies/Item/PermissionGrantPolicyRequestBuilder.cs b/src/generated/Policies/PermissionGrantPolicies/Item/PermissionGrantPolicyRequestBuilder.cs index bd4ea841399..0544125a81c 100644 --- a/src/generated/Policies/PermissionGrantPolicies/Item/PermissionGrantPolicyRequestBuilder.cs +++ b/src/generated/Policies/PermissionGrantPolicies/Item/PermissionGrantPolicyRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Policies.PermissionGrantPolicies.Item.Includes; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,15 +28,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The policy that specifies the conditions under which consent can be granted."; // Create options for all the parameters - var permissionGrantPolicyIdOption = new Option("--permissiongrantpolicy-id", description: "key: id of permissionGrantPolicy") { + var permissionGrantPolicyIdOption = new Option("--permission-grant-policy-id", description: "key: id of permissionGrantPolicy") { }; permissionGrantPolicyIdOption.IsRequired = true; command.AddOption(permissionGrantPolicyIdOption); - command.SetHandler(async (string permissionGrantPolicyId) => { + command.SetHandler(async (string permissionGrantPolicyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, permissionGrantPolicyIdOption); return command; @@ -44,6 +43,9 @@ public Command BuildDeleteCommand() { public Command BuildExcludesCommand() { var command = new Command("excludes"); var builder = new ApiSdk.Policies.PermissionGrantPolicies.Item.Excludes.ExcludesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -55,7 +57,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The policy that specifies the conditions under which consent can be granted."; // Create options for all the parameters - var permissionGrantPolicyIdOption = new Option("--permissiongrantpolicy-id", description: "key: id of permissionGrantPolicy") { + var permissionGrantPolicyIdOption = new Option("--permission-grant-policy-id", description: "key: id of permissionGrantPolicy") { }; permissionGrantPolicyIdOption.IsRequired = true; command.AddOption(permissionGrantPolicyIdOption); @@ -69,25 +71,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string permissionGrantPolicyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string permissionGrantPolicyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, permissionGrantPolicyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, permissionGrantPolicyIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildIncludesCommand() { var command = new Command("includes"); var builder = new ApiSdk.Policies.PermissionGrantPolicies.Item.Includes.IncludesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -99,7 +103,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The policy that specifies the conditions under which consent can be granted."; // Create options for all the parameters - var permissionGrantPolicyIdOption = new Option("--permissiongrantpolicy-id", description: "key: id of permissionGrantPolicy") { + var permissionGrantPolicyIdOption = new Option("--permission-grant-policy-id", description: "key: id of permissionGrantPolicy") { }; permissionGrantPolicyIdOption.IsRequired = true; command.AddOption(permissionGrantPolicyIdOption); @@ -107,14 +111,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string permissionGrantPolicyId, string body) => { + command.SetHandler(async (string permissionGrantPolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, permissionGrantPolicyIdOption, bodyOption); return command; @@ -186,42 +189,6 @@ public RequestInformation CreatePatchRequestInformation(PermissionGrantPolicy bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The policy that specifies the conditions under which consent can be granted. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The policy that specifies the conditions under which consent can be granted. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The policy that specifies the conditions under which consent can be granted. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PermissionGrantPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The policy that specifies the conditions under which consent can be granted. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Policies/PermissionGrantPolicies/PermissionGrantPoliciesRequestBuilder.cs b/src/generated/Policies/PermissionGrantPolicies/PermissionGrantPoliciesRequestBuilder.cs index 9b8249c0cdc..42ca05b2527 100644 --- a/src/generated/Policies/PermissionGrantPolicies/PermissionGrantPoliciesRequestBuilder.cs +++ b/src/generated/Policies/PermissionGrantPolicies/PermissionGrantPoliciesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Policies.PermissionGrantPolicies.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class PermissionGrantPoliciesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PermissionGrantPolicyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildExcludesCommand(), - builder.BuildGetCommand(), - builder.BuildIncludesCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildExcludesCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildIncludesCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,21 +41,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -101,7 +99,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -112,15 +114,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -175,31 +172,6 @@ public RequestInformation CreatePostRequestInformation(PermissionGrantPolicy bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The policy that specifies the conditions under which consent can be granted. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The policy that specifies the conditions under which consent can be granted. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PermissionGrantPolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The policy that specifies the conditions under which consent can be granted. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Policies/PoliciesRequestBuilder.cs b/src/generated/Policies/PoliciesRequestBuilder.cs index c952f70c89a..536dd75ad88 100644 --- a/src/generated/Policies/PoliciesRequestBuilder.cs +++ b/src/generated/Policies/PoliciesRequestBuilder.cs @@ -14,10 +14,10 @@ using ApiSdk.Policies.TokenLifetimePolicies; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,6 +35,9 @@ public class PoliciesRequestBuilder { public Command BuildActivityBasedTimeoutPoliciesCommand() { var command = new Command("activity-based-timeout-policies"); var builder = new ApiSdk.Policies.ActivityBasedTimeoutPolicies.ActivityBasedTimeoutPoliciesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -74,6 +77,9 @@ public Command BuildAuthorizationPolicyCommand() { public Command BuildClaimsMappingPoliciesCommand() { var command = new Command("claims-mapping-policies"); var builder = new ApiSdk.Policies.ClaimsMappingPolicies.ClaimsMappingPoliciesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -81,6 +87,9 @@ public Command BuildClaimsMappingPoliciesCommand() { public Command BuildConditionalAccessPoliciesCommand() { var command = new Command("conditional-access-policies"); var builder = new ApiSdk.Policies.ConditionalAccessPolicies.ConditionalAccessPoliciesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -88,6 +97,9 @@ public Command BuildConditionalAccessPoliciesCommand() { public Command BuildFeatureRolloutPoliciesCommand() { var command = new Command("feature-rollout-policies"); var builder = new ApiSdk.Policies.FeatureRolloutPolicies.FeatureRolloutPoliciesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -109,25 +121,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } public Command BuildHomeRealmDiscoveryPoliciesCommand() { var command = new Command("home-realm-discovery-policies"); var builder = new ApiSdk.Policies.HomeRealmDiscoveryPolicies.HomeRealmDiscoveryPoliciesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -151,14 +165,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -166,6 +179,9 @@ public Command BuildPatchCommand() { public Command BuildPermissionGrantPoliciesCommand() { var command = new Command("permission-grant-policies"); var builder = new ApiSdk.Policies.PermissionGrantPolicies.PermissionGrantPoliciesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -173,6 +189,9 @@ public Command BuildPermissionGrantPoliciesCommand() { public Command BuildTokenIssuancePoliciesCommand() { var command = new Command("token-issuance-policies"); var builder = new ApiSdk.Policies.TokenIssuancePolicies.TokenIssuancePoliciesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -180,6 +199,9 @@ public Command BuildTokenIssuancePoliciesCommand() { public Command BuildTokenLifetimePoliciesCommand() { var command = new Command("token-lifetime-policies"); var builder = new ApiSdk.Policies.TokenLifetimePolicies.TokenLifetimePoliciesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -236,31 +258,6 @@ public RequestInformation CreatePatchRequestInformation(PolicyRoot body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get policies - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update policies - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PolicyRoot model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get policies public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Policies/TokenIssuancePolicies/Item/TokenIssuancePolicyRequestBuilder.cs b/src/generated/Policies/TokenIssuancePolicies/Item/TokenIssuancePolicyRequestBuilder.cs index d3cdf19b980..cc83f317ff9 100644 --- a/src/generated/Policies/TokenIssuancePolicies/Item/TokenIssuancePolicyRequestBuilder.cs +++ b/src/generated/Policies/TokenIssuancePolicies/Item/TokenIssuancePolicyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The policy that specifies the characteristics of SAML tokens issued by Azure AD."; // Create options for all the parameters - var tokenIssuancePolicyIdOption = new Option("--tokenissuancepolicy-id", description: "key: id of tokenIssuancePolicy") { + var tokenIssuancePolicyIdOption = new Option("--token-issuance-policy-id", description: "key: id of tokenIssuancePolicy") { }; tokenIssuancePolicyIdOption.IsRequired = true; command.AddOption(tokenIssuancePolicyIdOption); - command.SetHandler(async (string tokenIssuancePolicyId) => { + command.SetHandler(async (string tokenIssuancePolicyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, tokenIssuancePolicyIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The policy that specifies the characteristics of SAML tokens issued by Azure AD."; // Create options for all the parameters - var tokenIssuancePolicyIdOption = new Option("--tokenissuancepolicy-id", description: "key: id of tokenIssuancePolicy") { + var tokenIssuancePolicyIdOption = new Option("--token-issuance-policy-id", description: "key: id of tokenIssuancePolicy") { }; tokenIssuancePolicyIdOption.IsRequired = true; command.AddOption(tokenIssuancePolicyIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string tokenIssuancePolicyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string tokenIssuancePolicyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, tokenIssuancePolicyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, tokenIssuancePolicyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The policy that specifies the characteristics of SAML tokens issued by Azure AD."; // Create options for all the parameters - var tokenIssuancePolicyIdOption = new Option("--tokenissuancepolicy-id", description: "key: id of tokenIssuancePolicy") { + var tokenIssuancePolicyIdOption = new Option("--token-issuance-policy-id", description: "key: id of tokenIssuancePolicy") { }; tokenIssuancePolicyIdOption.IsRequired = true; command.AddOption(tokenIssuancePolicyIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string tokenIssuancePolicyId, string body) => { + command.SetHandler(async (string tokenIssuancePolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, tokenIssuancePolicyIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(TokenIssuancePolicy body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The policy that specifies the characteristics of SAML tokens issued by Azure AD. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The policy that specifies the characteristics of SAML tokens issued by Azure AD. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The policy that specifies the characteristics of SAML tokens issued by Azure AD. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(TokenIssuancePolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The policy that specifies the characteristics of SAML tokens issued by Azure AD. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Policies/TokenIssuancePolicies/TokenIssuancePoliciesRequestBuilder.cs b/src/generated/Policies/TokenIssuancePolicies/TokenIssuancePoliciesRequestBuilder.cs index 120e144222b..dec49470300 100644 --- a/src/generated/Policies/TokenIssuancePolicies/TokenIssuancePoliciesRequestBuilder.cs +++ b/src/generated/Policies/TokenIssuancePolicies/TokenIssuancePoliciesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Policies.TokenIssuancePolicies.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class TokenIssuancePoliciesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TokenIssuancePolicyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(TokenIssuancePolicy body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The policy that specifies the characteristics of SAML tokens issued by Azure AD. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The policy that specifies the characteristics of SAML tokens issued by Azure AD. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TokenIssuancePolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The policy that specifies the characteristics of SAML tokens issued by Azure AD. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Policies/TokenLifetimePolicies/Item/TokenLifetimePolicyRequestBuilder.cs b/src/generated/Policies/TokenLifetimePolicies/Item/TokenLifetimePolicyRequestBuilder.cs index 70e669e45a5..4c736c369b3 100644 --- a/src/generated/Policies/TokenLifetimePolicies/Item/TokenLifetimePolicyRequestBuilder.cs +++ b/src/generated/Policies/TokenLifetimePolicies/Item/TokenLifetimePolicyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The policy that controls the lifetime of a JWT access token, an ID token, or a SAML 1.1/2.0 token issued by Azure AD."; // Create options for all the parameters - var tokenLifetimePolicyIdOption = new Option("--tokenlifetimepolicy-id", description: "key: id of tokenLifetimePolicy") { + var tokenLifetimePolicyIdOption = new Option("--token-lifetime-policy-id", description: "key: id of tokenLifetimePolicy") { }; tokenLifetimePolicyIdOption.IsRequired = true; command.AddOption(tokenLifetimePolicyIdOption); - command.SetHandler(async (string tokenLifetimePolicyId) => { + command.SetHandler(async (string tokenLifetimePolicyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, tokenLifetimePolicyIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The policy that controls the lifetime of a JWT access token, an ID token, or a SAML 1.1/2.0 token issued by Azure AD."; // Create options for all the parameters - var tokenLifetimePolicyIdOption = new Option("--tokenlifetimepolicy-id", description: "key: id of tokenLifetimePolicy") { + var tokenLifetimePolicyIdOption = new Option("--token-lifetime-policy-id", description: "key: id of tokenLifetimePolicy") { }; tokenLifetimePolicyIdOption.IsRequired = true; command.AddOption(tokenLifetimePolicyIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string tokenLifetimePolicyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string tokenLifetimePolicyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, tokenLifetimePolicyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, tokenLifetimePolicyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The policy that controls the lifetime of a JWT access token, an ID token, or a SAML 1.1/2.0 token issued by Azure AD."; // Create options for all the parameters - var tokenLifetimePolicyIdOption = new Option("--tokenlifetimepolicy-id", description: "key: id of tokenLifetimePolicy") { + var tokenLifetimePolicyIdOption = new Option("--token-lifetime-policy-id", description: "key: id of tokenLifetimePolicy") { }; tokenLifetimePolicyIdOption.IsRequired = true; command.AddOption(tokenLifetimePolicyIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string tokenLifetimePolicyId, string body) => { + command.SetHandler(async (string tokenLifetimePolicyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, tokenLifetimePolicyIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(TokenLifetimePolicy body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The policy that controls the lifetime of a JWT access token, an ID token, or a SAML 1.1/2.0 token issued by Azure AD. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The policy that controls the lifetime of a JWT access token, an ID token, or a SAML 1.1/2.0 token issued by Azure AD. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The policy that controls the lifetime of a JWT access token, an ID token, or a SAML 1.1/2.0 token issued by Azure AD. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(TokenLifetimePolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The policy that controls the lifetime of a JWT access token, an ID token, or a SAML 1.1/2.0 token issued by Azure AD. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Policies/TokenLifetimePolicies/TokenLifetimePoliciesRequestBuilder.cs b/src/generated/Policies/TokenLifetimePolicies/TokenLifetimePoliciesRequestBuilder.cs index 5ae35ffd778..781e3db8f7f 100644 --- a/src/generated/Policies/TokenLifetimePolicies/TokenLifetimePoliciesRequestBuilder.cs +++ b/src/generated/Policies/TokenLifetimePolicies/TokenLifetimePoliciesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Policies.TokenLifetimePolicies.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class TokenLifetimePoliciesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TokenLifetimePolicyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(TokenLifetimePolicy body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The policy that controls the lifetime of a JWT access token, an ID token, or a SAML 1.1/2.0 token issued by Azure AD. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The policy that controls the lifetime of a JWT access token, an ID token, or a SAML 1.1/2.0 token issued by Azure AD. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TokenLifetimePolicy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The policy that controls the lifetime of a JWT access token, an ID token, or a SAML 1.1/2.0 token issued by Azure AD. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Print/Connectors/ConnectorsRequestBuilder.cs b/src/generated/Print/Connectors/ConnectorsRequestBuilder.cs index 5e0af229da9..45870067dc4 100644 --- a/src/generated/Print/Connectors/ConnectorsRequestBuilder.cs +++ b/src/generated/Print/Connectors/ConnectorsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Print.Connectors.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ConnectorsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PrintConnectorRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(PrintConnector body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of available print connectors. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of available print connectors. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PrintConnector model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of available print connectors. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Print/Connectors/Item/PrintConnectorRequestBuilder.cs b/src/generated/Print/Connectors/Item/PrintConnectorRequestBuilder.cs index 7ac0cc4c200..6e3ce310192 100644 --- a/src/generated/Print/Connectors/Item/PrintConnectorRequestBuilder.cs +++ b/src/generated/Print/Connectors/Item/PrintConnectorRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of available print connectors."; // Create options for all the parameters - var printConnectorIdOption = new Option("--printconnector-id", description: "key: id of printConnector") { + var printConnectorIdOption = new Option("--print-connector-id", description: "key: id of printConnector") { }; printConnectorIdOption.IsRequired = true; command.AddOption(printConnectorIdOption); - command.SetHandler(async (string printConnectorId) => { + command.SetHandler(async (string printConnectorId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printConnectorIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of available print connectors."; // Create options for all the parameters - var printConnectorIdOption = new Option("--printconnector-id", description: "key: id of printConnector") { + var printConnectorIdOption = new Option("--print-connector-id", description: "key: id of printConnector") { }; printConnectorIdOption.IsRequired = true; command.AddOption(printConnectorIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string printConnectorId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printConnectorId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printConnectorIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printConnectorIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of available print connectors."; // Create options for all the parameters - var printConnectorIdOption = new Option("--printconnector-id", description: "key: id of printConnector") { + var printConnectorIdOption = new Option("--print-connector-id", description: "key: id of printConnector") { }; printConnectorIdOption.IsRequired = true; command.AddOption(printConnectorIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string printConnectorId, string body) => { + command.SetHandler(async (string printConnectorId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printConnectorIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(PrintConnector body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of available print connectors. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of available print connectors. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of available print connectors. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PrintConnector model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of available print connectors. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Print/Operations/Item/PrintOperationRequestBuilder.cs b/src/generated/Print/Operations/Item/PrintOperationRequestBuilder.cs index c4d972f4416..aa0657ceb3f 100644 --- a/src/generated/Print/Operations/Item/PrintOperationRequestBuilder.cs +++ b/src/generated/Print/Operations/Item/PrintOperationRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of print long running operations."; // Create options for all the parameters - var printOperationIdOption = new Option("--printoperation-id", description: "key: id of printOperation") { + var printOperationIdOption = new Option("--print-operation-id", description: "key: id of printOperation") { }; printOperationIdOption.IsRequired = true; command.AddOption(printOperationIdOption); - command.SetHandler(async (string printOperationId) => { + command.SetHandler(async (string printOperationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printOperationIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of print long running operations."; // Create options for all the parameters - var printOperationIdOption = new Option("--printoperation-id", description: "key: id of printOperation") { + var printOperationIdOption = new Option("--print-operation-id", description: "key: id of printOperation") { }; printOperationIdOption.IsRequired = true; command.AddOption(printOperationIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string printOperationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printOperationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printOperationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printOperationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of print long running operations."; // Create options for all the parameters - var printOperationIdOption = new Option("--printoperation-id", description: "key: id of printOperation") { + var printOperationIdOption = new Option("--print-operation-id", description: "key: id of printOperation") { }; printOperationIdOption.IsRequired = true; command.AddOption(printOperationIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string printOperationId, string body) => { + command.SetHandler(async (string printOperationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printOperationIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(PrintOperation body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of print long running operations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of print long running operations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of print long running operations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PrintOperation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of print long running operations. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Print/Operations/OperationsRequestBuilder.cs b/src/generated/Print/Operations/OperationsRequestBuilder.cs index 6713e4c4d91..5edcde623ac 100644 --- a/src/generated/Print/Operations/OperationsRequestBuilder.cs +++ b/src/generated/Print/Operations/OperationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Print.Operations.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class OperationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PrintOperationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(PrintOperation body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of print long running operations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of print long running operations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PrintOperation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of print long running operations. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Print/PrintRequestBuilder.cs b/src/generated/Print/PrintRequestBuilder.cs index adc86036d85..9eb7843afe4 100644 --- a/src/generated/Print/PrintRequestBuilder.cs +++ b/src/generated/Print/PrintRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Print.TaskDefinitions; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,6 +28,9 @@ public class PrintRequestBuilder { public Command BuildConnectorsCommand() { var command = new Command("connectors"); var builder = new ApiSdk.Print.Connectors.ConnectorsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -49,25 +52,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } public Command BuildOperationsCommand() { var command = new Command("operations"); var builder = new ApiSdk.Print.Operations.OperationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -83,14 +88,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -98,6 +102,9 @@ public Command BuildPatchCommand() { public Command BuildPrintersCommand() { var command = new Command("printers"); var builder = new ApiSdk.Print.Printers.PrintersRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -105,6 +112,9 @@ public Command BuildPrintersCommand() { public Command BuildServicesCommand() { var command = new Command("services"); var builder = new ApiSdk.Print.Services.ServicesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -112,6 +122,9 @@ public Command BuildServicesCommand() { public Command BuildSharesCommand() { var command = new Command("shares"); var builder = new ApiSdk.Print.Shares.SharesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -119,6 +132,9 @@ public Command BuildSharesCommand() { public Command BuildTaskDefinitionsCommand() { var command = new Command("task-definitions"); var builder = new ApiSdk.Print.TaskDefinitions.TaskDefinitionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -175,31 +191,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get print - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update print - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Print model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get print public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Print/Printers/Create/CreateRequestBuilder.cs b/src/generated/Print/Printers/Create/CreateRequestBuilder.cs index bb0133b0345..deb4898b7e5 100644 --- a/src/generated/Print/Printers/Create/CreateRequestBuilder.cs +++ b/src/generated/Print/Printers/Create/CreateRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,14 +29,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -72,18 +71,5 @@ public RequestInformation CreatePostRequestInformation(CreateRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action create - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Print/Printers/Item/Connectors/@Ref/@Ref.cs b/src/generated/Print/Printers/Item/Connectors/@Ref/@Ref.cs deleted file mode 100644 index 2e0cc4c8e36..00000000000 --- a/src/generated/Print/Printers/Item/Connectors/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Print.Printers.Item.Connectors.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Print/Printers/Item/Connectors/@Ref/RefRequestBuilder.cs b/src/generated/Print/Printers/Item/Connectors/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 873ce126f07..00000000000 --- a/src/generated/Print/Printers/Item/Connectors/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Print.Printers.Item.Connectors.@Ref { - /// Builds and executes requests for operations under \print\printers\{printer-id}\connectors\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The connectors that are associated with the printer. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The connectors that are associated with the printer."; - // Create options for all the parameters - var printerIdOption = new Option("--printer-id", description: "key: id of printer") { - }; - printerIdOption.IsRequired = true; - command.AddOption(printerIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string printerId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printerIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The connectors that are associated with the printer. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The connectors that are associated with the printer."; - // Create options for all the parameters - var printerIdOption = new Option("--printer-id", description: "key: id of printer") { - }; - printerIdOption.IsRequired = true; - command.AddOption(printerIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string printerId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printerIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/print/printers/{printer_id}/connectors/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The connectors that are associated with the printer. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The connectors that are associated with the printer. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Print.Printers.Item.Connectors.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The connectors that are associated with the printer. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The connectors that are associated with the printer. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Print.Printers.Item.Connectors.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The connectors that are associated with the printer. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Print/Printers/Item/Connectors/@Ref/RefResponse.cs b/src/generated/Print/Printers/Item/Connectors/@Ref/RefResponse.cs deleted file mode 100644 index 38c7a8be5a6..00000000000 --- a/src/generated/Print/Printers/Item/Connectors/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Print.Printers.Item.Connectors.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Print/Printers/Item/Connectors/ConnectorsRequestBuilder.cs b/src/generated/Print/Printers/Item/Connectors/ConnectorsRequestBuilder.cs index 27704f0fd3d..e0e2f604643 100644 --- a/src/generated/Print/Printers/Item/Connectors/ConnectorsRequestBuilder.cs +++ b/src/generated/Print/Printers/Item/Connectors/ConnectorsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Print.Printers.Item.Connectors.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string printerId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printerId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printerIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printerIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Print.Printers.Item.Connectors.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Print.Printers.Item.Connectors.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The connectors that are associated with the printer. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The connectors that are associated with the printer. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Print/Printers/Item/Connectors/Ref/Ref.cs b/src/generated/Print/Printers/Item/Connectors/Ref/Ref.cs new file mode 100644 index 00000000000..930a27ac132 --- /dev/null +++ b/src/generated/Print/Printers/Item/Connectors/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Print.Printers.Item.Connectors.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Print/Printers/Item/Connectors/Ref/RefRequestBuilder.cs b/src/generated/Print/Printers/Item/Connectors/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..76ee3334759 --- /dev/null +++ b/src/generated/Print/Printers/Item/Connectors/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Print.Printers.Item.Connectors.Ref { + /// Builds and executes requests for operations under \print\printers\{printer-id}\connectors\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The connectors that are associated with the printer. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The connectors that are associated with the printer."; + // Create options for all the parameters + var printerIdOption = new Option("--printer-id", description: "key: id of printer") { + }; + printerIdOption.IsRequired = true; + command.AddOption(printerIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printerId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printerIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The connectors that are associated with the printer. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The connectors that are associated with the printer."; + // Create options for all the parameters + var printerIdOption = new Option("--printer-id", description: "key: id of printer") { + }; + printerIdOption.IsRequired = true; + command.AddOption(printerIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printerId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printerIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/print/printers/{printer_id}/connectors/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The connectors that are associated with the printer. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The connectors that are associated with the printer. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Print.Printers.Item.Connectors.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The connectors that are associated with the printer. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Print/Printers/Item/Connectors/Ref/RefResponse.cs b/src/generated/Print/Printers/Item/Connectors/Ref/RefResponse.cs new file mode 100644 index 00000000000..4842c7c25f8 --- /dev/null +++ b/src/generated/Print/Printers/Item/Connectors/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Print.Printers.Item.Connectors.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Print/Printers/Item/PrinterRequestBuilder.cs b/src/generated/Print/Printers/Item/PrinterRequestBuilder.cs index d8ea02b470a..86c84ad490c 100644 --- a/src/generated/Print/Printers/Item/PrinterRequestBuilder.cs +++ b/src/generated/Print/Printers/Item/PrinterRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Print.Printers.Item.TaskTriggers; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,11 +41,10 @@ public Command BuildDeleteCommand() { }; printerIdOption.IsRequired = true; command.AddOption(printerIdOption); - command.SetHandler(async (string printerId) => { + command.SetHandler(async (string printerId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printerIdOption); return command; @@ -71,20 +70,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string printerId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printerId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printerIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printerIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -102,14 +100,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string printerId, string body) => { + command.SetHandler(async (string printerId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printerIdOption, bodyOption); return command; @@ -130,6 +127,9 @@ public Command BuildSharesCommand() { public Command BuildTaskTriggersCommand() { var command = new Command("task-triggers"); var builder = new ApiSdk.Print.Printers.Item.TaskTriggers.TaskTriggersRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -201,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of printers registered in the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of printers registered in the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of printers registered in the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Printer model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of printers registered in the tenant. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Print/Printers/Item/RestoreFactoryDefaults/RestoreFactoryDefaultsRequestBuilder.cs b/src/generated/Print/Printers/Item/RestoreFactoryDefaults/RestoreFactoryDefaultsRequestBuilder.cs index 722ba4b5c9c..b5f16269851 100644 --- a/src/generated/Print/Printers/Item/RestoreFactoryDefaults/RestoreFactoryDefaultsRequestBuilder.cs +++ b/src/generated/Print/Printers/Item/RestoreFactoryDefaults/RestoreFactoryDefaultsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,10 @@ public Command BuildPostCommand() { }; printerIdOption.IsRequired = true; command.AddOption(printerIdOption); - command.SetHandler(async (string printerId) => { + command.SetHandler(async (string printerId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printerIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action restoreFactoryDefaults - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Print/Printers/Item/Shares/@Ref/@Ref.cs b/src/generated/Print/Printers/Item/Shares/@Ref/@Ref.cs deleted file mode 100644 index 97c7c52a12d..00000000000 --- a/src/generated/Print/Printers/Item/Shares/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Print.Printers.Item.Shares.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Print/Printers/Item/Shares/@Ref/RefRequestBuilder.cs b/src/generated/Print/Printers/Item/Shares/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 94ddba64c1a..00000000000 --- a/src/generated/Print/Printers/Item/Shares/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Print.Printers.Item.Shares.@Ref { - /// Builds and executes requests for operations under \print\printers\{printer-id}\shares\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The list of printerShares that are associated with the printer. Currently, only one printerShare can be associated with the printer. Read-only. Nullable. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The list of printerShares that are associated with the printer. Currently, only one printerShare can be associated with the printer. Read-only. Nullable."; - // Create options for all the parameters - var printerIdOption = new Option("--printer-id", description: "key: id of printer") { - }; - printerIdOption.IsRequired = true; - command.AddOption(printerIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string printerId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printerIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The list of printerShares that are associated with the printer. Currently, only one printerShare can be associated with the printer. Read-only. Nullable. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The list of printerShares that are associated with the printer. Currently, only one printerShare can be associated with the printer. Read-only. Nullable."; - // Create options for all the parameters - var printerIdOption = new Option("--printer-id", description: "key: id of printer") { - }; - printerIdOption.IsRequired = true; - command.AddOption(printerIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string printerId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printerIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/print/printers/{printer_id}/shares/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The list of printerShares that are associated with the printer. Currently, only one printerShare can be associated with the printer. Read-only. Nullable. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The list of printerShares that are associated with the printer. Currently, only one printerShare can be associated with the printer. Read-only. Nullable. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Print.Printers.Item.Shares.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The list of printerShares that are associated with the printer. Currently, only one printerShare can be associated with the printer. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of printerShares that are associated with the printer. Currently, only one printerShare can be associated with the printer. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Print.Printers.Item.Shares.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The list of printerShares that are associated with the printer. Currently, only one printerShare can be associated with the printer. Read-only. Nullable. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Print/Printers/Item/Shares/@Ref/RefResponse.cs b/src/generated/Print/Printers/Item/Shares/@Ref/RefResponse.cs deleted file mode 100644 index f97f04bfe4f..00000000000 --- a/src/generated/Print/Printers/Item/Shares/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Print.Printers.Item.Shares.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Print/Printers/Item/Shares/Ref/Ref.cs b/src/generated/Print/Printers/Item/Shares/Ref/Ref.cs new file mode 100644 index 00000000000..2592639507f --- /dev/null +++ b/src/generated/Print/Printers/Item/Shares/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Print.Printers.Item.Shares.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Print/Printers/Item/Shares/Ref/RefRequestBuilder.cs b/src/generated/Print/Printers/Item/Shares/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..9e4b20750bc --- /dev/null +++ b/src/generated/Print/Printers/Item/Shares/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Print.Printers.Item.Shares.Ref { + /// Builds and executes requests for operations under \print\printers\{printer-id}\shares\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The list of printerShares that are associated with the printer. Currently, only one printerShare can be associated with the printer. Read-only. Nullable. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The list of printerShares that are associated with the printer. Currently, only one printerShare can be associated with the printer. Read-only. Nullable."; + // Create options for all the parameters + var printerIdOption = new Option("--printer-id", description: "key: id of printer") { + }; + printerIdOption.IsRequired = true; + command.AddOption(printerIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printerId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printerIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The list of printerShares that are associated with the printer. Currently, only one printerShare can be associated with the printer. Read-only. Nullable. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The list of printerShares that are associated with the printer. Currently, only one printerShare can be associated with the printer. Read-only. Nullable."; + // Create options for all the parameters + var printerIdOption = new Option("--printer-id", description: "key: id of printer") { + }; + printerIdOption.IsRequired = true; + command.AddOption(printerIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printerId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printerIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/print/printers/{printer_id}/shares/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The list of printerShares that are associated with the printer. Currently, only one printerShare can be associated with the printer. Read-only. Nullable. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The list of printerShares that are associated with the printer. Currently, only one printerShare can be associated with the printer. Read-only. Nullable. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Print.Printers.Item.Shares.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The list of printerShares that are associated with the printer. Currently, only one printerShare can be associated with the printer. Read-only. Nullable. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Print/Printers/Item/Shares/Ref/RefResponse.cs b/src/generated/Print/Printers/Item/Shares/Ref/RefResponse.cs new file mode 100644 index 00000000000..4b20a37d7b9 --- /dev/null +++ b/src/generated/Print/Printers/Item/Shares/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Print.Printers.Item.Shares.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Print/Printers/Item/Shares/SharesRequestBuilder.cs b/src/generated/Print/Printers/Item/Shares/SharesRequestBuilder.cs index 954ca0a0f49..3db8fe4b8de 100644 --- a/src/generated/Print/Printers/Item/Shares/SharesRequestBuilder.cs +++ b/src/generated/Print/Printers/Item/Shares/SharesRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Print.Printers.Item.Shares.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string printerId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printerId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printerIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printerIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Print.Printers.Item.Shares.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Print.Printers.Item.Shares.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of printerShares that are associated with the printer. Currently, only one printerShare can be associated with the printer. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of printerShares that are associated with the printer. Currently, only one printerShare can be associated with the printer. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Print/Printers/Item/TaskTriggers/Item/Definition/@Ref/@Ref.cs b/src/generated/Print/Printers/Item/TaskTriggers/Item/Definition/@Ref/@Ref.cs deleted file mode 100644 index 4f596117fa0..00000000000 --- a/src/generated/Print/Printers/Item/TaskTriggers/Item/Definition/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Print.Printers.Item.TaskTriggers.Item.Definition.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Print/Printers/Item/TaskTriggers/Item/Definition/@Ref/RefRequestBuilder.cs b/src/generated/Print/Printers/Item/TaskTriggers/Item/Definition/@Ref/RefRequestBuilder.cs deleted file mode 100644 index fd5773bb2b3..00000000000 --- a/src/generated/Print/Printers/Item/TaskTriggers/Item/Definition/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Print.Printers.Item.TaskTriggers.Item.Definition.@Ref { - /// Builds and executes requests for operations under \print\printers\{printer-id}\taskTriggers\{printTaskTrigger-id}\definition\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// An abstract definition that will be used to create a printTask when triggered by a print event. Read-only. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "An abstract definition that will be used to create a printTask when triggered by a print event. Read-only."; - // Create options for all the parameters - var printerIdOption = new Option("--printer-id", description: "key: id of printer") { - }; - printerIdOption.IsRequired = true; - command.AddOption(printerIdOption); - var printTaskTriggerIdOption = new Option("--printtasktrigger-id", description: "key: id of printTaskTrigger") { - }; - printTaskTriggerIdOption.IsRequired = true; - command.AddOption(printTaskTriggerIdOption); - command.SetHandler(async (string printerId, string printTaskTriggerId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, printerIdOption, printTaskTriggerIdOption); - return command; - } - /// - /// An abstract definition that will be used to create a printTask when triggered by a print event. Read-only. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "An abstract definition that will be used to create a printTask when triggered by a print event. Read-only."; - // Create options for all the parameters - var printerIdOption = new Option("--printer-id", description: "key: id of printer") { - }; - printerIdOption.IsRequired = true; - command.AddOption(printerIdOption); - var printTaskTriggerIdOption = new Option("--printtasktrigger-id", description: "key: id of printTaskTrigger") { - }; - printTaskTriggerIdOption.IsRequired = true; - command.AddOption(printTaskTriggerIdOption); - command.SetHandler(async (string printerId, string printTaskTriggerId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printerIdOption, printTaskTriggerIdOption); - return command; - } - /// - /// An abstract definition that will be used to create a printTask when triggered by a print event. Read-only. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "An abstract definition that will be used to create a printTask when triggered by a print event. Read-only."; - // Create options for all the parameters - var printerIdOption = new Option("--printer-id", description: "key: id of printer") { - }; - printerIdOption.IsRequired = true; - command.AddOption(printerIdOption); - var printTaskTriggerIdOption = new Option("--printtasktrigger-id", description: "key: id of printTaskTrigger") { - }; - printTaskTriggerIdOption.IsRequired = true; - command.AddOption(printTaskTriggerIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string printerId, string printTaskTriggerId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, printerIdOption, printTaskTriggerIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/print/printers/{printer_id}/taskTriggers/{printTaskTrigger_id}/definition/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// An abstract definition that will be used to create a printTask when triggered by a print event. Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// An abstract definition that will be used to create a printTask when triggered by a print event. Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// An abstract definition that will be used to create a printTask when triggered by a print event. Read-only. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Print.Printers.Item.TaskTriggers.Item.Definition.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// An abstract definition that will be used to create a printTask when triggered by a print event. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// An abstract definition that will be used to create a printTask when triggered by a print event. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// An abstract definition that will be used to create a printTask when triggered by a print event. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Print.Printers.Item.TaskTriggers.Item.Definition.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Print/Printers/Item/TaskTriggers/Item/Definition/DefinitionRequestBuilder.cs b/src/generated/Print/Printers/Item/TaskTriggers/Item/Definition/DefinitionRequestBuilder.cs index ab84722bc8f..4d3c092560c 100644 --- a/src/generated/Print/Printers/Item/TaskTriggers/Item/Definition/DefinitionRequestBuilder.cs +++ b/src/generated/Print/Printers/Item/TaskTriggers/Item/Definition/DefinitionRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Print.Printers.Item.TaskTriggers.Item.Definition.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,7 +31,7 @@ public Command BuildGetCommand() { }; printerIdOption.IsRequired = true; command.AddOption(printerIdOption); - var printTaskTriggerIdOption = new Option("--printtasktrigger-id", description: "key: id of printTaskTrigger") { + var printTaskTriggerIdOption = new Option("--print-task-trigger-id", description: "key: id of printTaskTrigger") { }; printTaskTriggerIdOption.IsRequired = true; command.AddOption(printTaskTriggerIdOption); @@ -45,25 +45,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string printerId, string printTaskTriggerId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printerId, string printTaskTriggerId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printerIdOption, printTaskTriggerIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printerIdOption, printTaskTriggerIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Print.Printers.Item.TaskTriggers.Item.Definition.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Print.Printers.Item.TaskTriggers.Item.Definition.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -103,18 +102,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// An abstract definition that will be used to create a printTask when triggered by a print event. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// An abstract definition that will be used to create a printTask when triggered by a print event. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Print/Printers/Item/TaskTriggers/Item/Definition/Ref/Ref.cs b/src/generated/Print/Printers/Item/TaskTriggers/Item/Definition/Ref/Ref.cs new file mode 100644 index 00000000000..a88e7958301 --- /dev/null +++ b/src/generated/Print/Printers/Item/TaskTriggers/Item/Definition/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Print.Printers.Item.TaskTriggers.Item.Definition.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Print/Printers/Item/TaskTriggers/Item/Definition/Ref/RefRequestBuilder.cs b/src/generated/Print/Printers/Item/TaskTriggers/Item/Definition/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..bcc9f1878e8 --- /dev/null +++ b/src/generated/Print/Printers/Item/TaskTriggers/Item/Definition/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Print.Printers.Item.TaskTriggers.Item.Definition.Ref { + /// Builds and executes requests for operations under \print\printers\{printer-id}\taskTriggers\{printTaskTrigger-id}\definition\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// An abstract definition that will be used to create a printTask when triggered by a print event. Read-only. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "An abstract definition that will be used to create a printTask when triggered by a print event. Read-only."; + // Create options for all the parameters + var printerIdOption = new Option("--printer-id", description: "key: id of printer") { + }; + printerIdOption.IsRequired = true; + command.AddOption(printerIdOption); + var printTaskTriggerIdOption = new Option("--print-task-trigger-id", description: "key: id of printTaskTrigger") { + }; + printTaskTriggerIdOption.IsRequired = true; + command.AddOption(printTaskTriggerIdOption); + command.SetHandler(async (string printerId, string printTaskTriggerId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, printerIdOption, printTaskTriggerIdOption); + return command; + } + /// + /// An abstract definition that will be used to create a printTask when triggered by a print event. Read-only. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "An abstract definition that will be used to create a printTask when triggered by a print event. Read-only."; + // Create options for all the parameters + var printerIdOption = new Option("--printer-id", description: "key: id of printer") { + }; + printerIdOption.IsRequired = true; + command.AddOption(printerIdOption); + var printTaskTriggerIdOption = new Option("--print-task-trigger-id", description: "key: id of printTaskTrigger") { + }; + printTaskTriggerIdOption.IsRequired = true; + command.AddOption(printTaskTriggerIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printerId, string printTaskTriggerId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printerIdOption, printTaskTriggerIdOption, outputOption); + return command; + } + /// + /// An abstract definition that will be used to create a printTask when triggered by a print event. Read-only. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "An abstract definition that will be used to create a printTask when triggered by a print event. Read-only."; + // Create options for all the parameters + var printerIdOption = new Option("--printer-id", description: "key: id of printer") { + }; + printerIdOption.IsRequired = true; + command.AddOption(printerIdOption); + var printTaskTriggerIdOption = new Option("--print-task-trigger-id", description: "key: id of printTaskTrigger") { + }; + printTaskTriggerIdOption.IsRequired = true; + command.AddOption(printTaskTriggerIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string printerId, string printTaskTriggerId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, printerIdOption, printTaskTriggerIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/print/printers/{printer_id}/taskTriggers/{printTaskTrigger_id}/definition/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// An abstract definition that will be used to create a printTask when triggered by a print event. Read-only. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// An abstract definition that will be used to create a printTask when triggered by a print event. Read-only. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// An abstract definition that will be used to create a printTask when triggered by a print event. Read-only. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Print.Printers.Item.TaskTriggers.Item.Definition.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Print/Printers/Item/TaskTriggers/Item/PrintTaskTriggerRequestBuilder.cs b/src/generated/Print/Printers/Item/TaskTriggers/Item/PrintTaskTriggerRequestBuilder.cs index 6c66ea44b7b..49c6678c148 100644 --- a/src/generated/Print/Printers/Item/TaskTriggers/Item/PrintTaskTriggerRequestBuilder.cs +++ b/src/generated/Print/Printers/Item/TaskTriggers/Item/PrintTaskTriggerRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Print.Printers.Item.TaskTriggers.Item.Definition; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; printerIdOption.IsRequired = true; command.AddOption(printerIdOption); - var printTaskTriggerIdOption = new Option("--printtasktrigger-id", description: "key: id of printTaskTrigger") { + var printTaskTriggerIdOption = new Option("--print-task-trigger-id", description: "key: id of printTaskTrigger") { }; printTaskTriggerIdOption.IsRequired = true; command.AddOption(printTaskTriggerIdOption); - command.SetHandler(async (string printerId, string printTaskTriggerId) => { + command.SetHandler(async (string printerId, string printTaskTriggerId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printerIdOption, printTaskTriggerIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; printerIdOption.IsRequired = true; command.AddOption(printerIdOption); - var printTaskTriggerIdOption = new Option("--printtasktrigger-id", description: "key: id of printTaskTrigger") { + var printTaskTriggerIdOption = new Option("--print-task-trigger-id", description: "key: id of printTaskTrigger") { }; printTaskTriggerIdOption.IsRequired = true; command.AddOption(printTaskTriggerIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string printerId, string printTaskTriggerId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printerId, string printTaskTriggerId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printerIdOption, printTaskTriggerIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printerIdOption, printTaskTriggerIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,7 +101,7 @@ public Command BuildPatchCommand() { }; printerIdOption.IsRequired = true; command.AddOption(printerIdOption); - var printTaskTriggerIdOption = new Option("--printtasktrigger-id", description: "key: id of printTaskTrigger") { + var printTaskTriggerIdOption = new Option("--print-task-trigger-id", description: "key: id of printTaskTrigger") { }; printTaskTriggerIdOption.IsRequired = true; command.AddOption(printTaskTriggerIdOption); @@ -111,14 +109,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string printerId, string printTaskTriggerId, string body) => { + command.SetHandler(async (string printerId, string printTaskTriggerId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printerIdOption, printTaskTriggerIdOption, bodyOption); return command; @@ -190,42 +187,6 @@ public RequestInformation CreatePatchRequestInformation(PrintTaskTrigger body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A list of task triggers that are associated with the printer. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A list of task triggers that are associated with the printer. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A list of task triggers that are associated with the printer. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PrintTaskTrigger model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A list of task triggers that are associated with the printer. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Print/Printers/Item/TaskTriggers/TaskTriggersRequestBuilder.cs b/src/generated/Print/Printers/Item/TaskTriggers/TaskTriggersRequestBuilder.cs index d44aab43702..873288fefcb 100644 --- a/src/generated/Print/Printers/Item/TaskTriggers/TaskTriggersRequestBuilder.cs +++ b/src/generated/Print/Printers/Item/TaskTriggers/TaskTriggersRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Print.Printers.Item.TaskTriggers.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class TaskTriggersRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PrintTaskTriggerRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDefinitionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDefinitionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string printerId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printerId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printerIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printerIdOption, bodyOption, outputOption); return command; } /// @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string printerId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printerId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printerIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printerIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(PrintTaskTrigger body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A list of task triggers that are associated with the printer. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A list of task triggers that are associated with the printer. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PrintTaskTrigger model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A list of task triggers that are associated with the printer. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Print/Printers/PrintersRequestBuilder.cs b/src/generated/Print/Printers/PrintersRequestBuilder.cs index 310a4421adc..d00a3547882 100644 --- a/src/generated/Print/Printers/PrintersRequestBuilder.cs +++ b/src/generated/Print/Printers/PrintersRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Print.Printers.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,15 +23,14 @@ public class PrintersRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PrinterRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildConnectorsCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildRestoreFactoryDefaultsCommand(), - builder.BuildSharesCommand(), - builder.BuildTaskTriggersCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildConnectorsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRestoreFactoryDefaultsCommand()); + commands.Add(builder.BuildSharesCommand()); + commands.Add(builder.BuildTaskTriggersCommand()); return commands; } public Command BuildCreateCommand() { @@ -82,7 +81,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -93,15 +96,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -156,31 +154,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of printers registered in the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of printers registered in the tenant. - /// - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Printer body, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = CreatePostRequestInformation(body, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of printers registered in the tenant. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Print/Services/Item/Endpoints/EndpointsRequestBuilder.cs b/src/generated/Print/Services/Item/Endpoints/EndpointsRequestBuilder.cs index e51a744fd36..0d98ee5459f 100644 --- a/src/generated/Print/Services/Item/Endpoints/EndpointsRequestBuilder.cs +++ b/src/generated/Print/Services/Item/Endpoints/EndpointsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Print.Services.Item.Endpoints.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class EndpointsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PrintServiceEndpointRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Endpoints that can be used to access the service. Read-only. Nullable."; // Create options for all the parameters - var printServiceIdOption = new Option("--printservice-id", description: "key: id of printService") { + var printServiceIdOption = new Option("--print-service-id", description: "key: id of printService") { }; printServiceIdOption.IsRequired = true; command.AddOption(printServiceIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string printServiceId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printServiceId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printServiceIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printServiceIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Endpoints that can be used to access the service. Read-only. Nullable."; // Create options for all the parameters - var printServiceIdOption = new Option("--printservice-id", description: "key: id of printService") { + var printServiceIdOption = new Option("--print-service-id", description: "key: id of printService") { }; printServiceIdOption.IsRequired = true; command.AddOption(printServiceIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string printServiceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printServiceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printServiceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printServiceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(PrintServiceEndpoint body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Endpoints that can be used to access the service. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Endpoints that can be used to access the service. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PrintServiceEndpoint model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Endpoints that can be used to access the service. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Print/Services/Item/Endpoints/Item/PrintServiceEndpointRequestBuilder.cs b/src/generated/Print/Services/Item/Endpoints/Item/PrintServiceEndpointRequestBuilder.cs index 3ca8a103c14..ec306b20528 100644 --- a/src/generated/Print/Services/Item/Endpoints/Item/PrintServiceEndpointRequestBuilder.cs +++ b/src/generated/Print/Services/Item/Endpoints/Item/PrintServiceEndpointRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Endpoints that can be used to access the service. Read-only. Nullable."; // Create options for all the parameters - var printServiceIdOption = new Option("--printservice-id", description: "key: id of printService") { + var printServiceIdOption = new Option("--print-service-id", description: "key: id of printService") { }; printServiceIdOption.IsRequired = true; command.AddOption(printServiceIdOption); - var printServiceEndpointIdOption = new Option("--printserviceendpoint-id", description: "key: id of printServiceEndpoint") { + var printServiceEndpointIdOption = new Option("--print-service-endpoint-id", description: "key: id of printServiceEndpoint") { }; printServiceEndpointIdOption.IsRequired = true; command.AddOption(printServiceEndpointIdOption); - command.SetHandler(async (string printServiceId, string printServiceEndpointId) => { + command.SetHandler(async (string printServiceId, string printServiceEndpointId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printServiceIdOption, printServiceEndpointIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Endpoints that can be used to access the service. Read-only. Nullable."; // Create options for all the parameters - var printServiceIdOption = new Option("--printservice-id", description: "key: id of printService") { + var printServiceIdOption = new Option("--print-service-id", description: "key: id of printService") { }; printServiceIdOption.IsRequired = true; command.AddOption(printServiceIdOption); - var printServiceEndpointIdOption = new Option("--printserviceendpoint-id", description: "key: id of printServiceEndpoint") { + var printServiceEndpointIdOption = new Option("--print-service-endpoint-id", description: "key: id of printServiceEndpoint") { }; printServiceEndpointIdOption.IsRequired = true; command.AddOption(printServiceEndpointIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string printServiceId, string printServiceEndpointId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printServiceId, string printServiceEndpointId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printServiceIdOption, printServiceEndpointIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printServiceIdOption, printServiceEndpointIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Endpoints that can be used to access the service. Read-only. Nullable."; // Create options for all the parameters - var printServiceIdOption = new Option("--printservice-id", description: "key: id of printService") { + var printServiceIdOption = new Option("--print-service-id", description: "key: id of printService") { }; printServiceIdOption.IsRequired = true; command.AddOption(printServiceIdOption); - var printServiceEndpointIdOption = new Option("--printserviceendpoint-id", description: "key: id of printServiceEndpoint") { + var printServiceEndpointIdOption = new Option("--print-service-endpoint-id", description: "key: id of printServiceEndpoint") { }; printServiceEndpointIdOption.IsRequired = true; command.AddOption(printServiceEndpointIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string printServiceId, string printServiceEndpointId, string body) => { + command.SetHandler(async (string printServiceId, string printServiceEndpointId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printServiceIdOption, printServiceEndpointIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(PrintServiceEndpoint bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Endpoints that can be used to access the service. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Endpoints that can be used to access the service. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Endpoints that can be used to access the service. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PrintServiceEndpoint model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Endpoints that can be used to access the service. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Print/Services/Item/PrintServiceRequestBuilder.cs b/src/generated/Print/Services/Item/PrintServiceRequestBuilder.cs index 30477598303..452d1ade812 100644 --- a/src/generated/Print/Services/Item/PrintServiceRequestBuilder.cs +++ b/src/generated/Print/Services/Item/PrintServiceRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Print.Services.Item.Endpoints; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,15 +27,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of available Universal Print service endpoints."; // Create options for all the parameters - var printServiceIdOption = new Option("--printservice-id", description: "key: id of printService") { + var printServiceIdOption = new Option("--print-service-id", description: "key: id of printService") { }; printServiceIdOption.IsRequired = true; command.AddOption(printServiceIdOption); - command.SetHandler(async (string printServiceId) => { + command.SetHandler(async (string printServiceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printServiceIdOption); return command; @@ -43,6 +42,9 @@ public Command BuildDeleteCommand() { public Command BuildEndpointsCommand() { var command = new Command("endpoints"); var builder = new ApiSdk.Print.Services.Item.Endpoints.EndpointsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -54,7 +56,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of available Universal Print service endpoints."; // Create options for all the parameters - var printServiceIdOption = new Option("--printservice-id", description: "key: id of printService") { + var printServiceIdOption = new Option("--print-service-id", description: "key: id of printService") { }; printServiceIdOption.IsRequired = true; command.AddOption(printServiceIdOption); @@ -68,20 +70,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string printServiceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printServiceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printServiceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printServiceIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,7 +92,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of available Universal Print service endpoints."; // Create options for all the parameters - var printServiceIdOption = new Option("--printservice-id", description: "key: id of printService") { + var printServiceIdOption = new Option("--print-service-id", description: "key: id of printService") { }; printServiceIdOption.IsRequired = true; command.AddOption(printServiceIdOption); @@ -99,14 +100,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string printServiceId, string body) => { + command.SetHandler(async (string printServiceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printServiceIdOption, bodyOption); return command; @@ -178,42 +178,6 @@ public RequestInformation CreatePatchRequestInformation(PrintService body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of available Universal Print service endpoints. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of available Universal Print service endpoints. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of available Universal Print service endpoints. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PrintService model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of available Universal Print service endpoints. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Print/Services/ServicesRequestBuilder.cs b/src/generated/Print/Services/ServicesRequestBuilder.cs index 0614f4032cd..f1de549bde3 100644 --- a/src/generated/Print/Services/ServicesRequestBuilder.cs +++ b/src/generated/Print/Services/ServicesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Print.Services.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class ServicesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PrintServiceRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildEndpointsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildEndpointsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(PrintService body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of available Universal Print service endpoints. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of available Universal Print service endpoints. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PrintService model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of available Universal Print service endpoints. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Print/Shares/Item/AllowedGroups/@Ref/@Ref.cs b/src/generated/Print/Shares/Item/AllowedGroups/@Ref/@Ref.cs deleted file mode 100644 index 9f28e79b6a0..00000000000 --- a/src/generated/Print/Shares/Item/AllowedGroups/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Print.Shares.Item.AllowedGroups.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Print/Shares/Item/AllowedGroups/@Ref/RefRequestBuilder.cs b/src/generated/Print/Shares/Item/AllowedGroups/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 07bb36613ff..00000000000 --- a/src/generated/Print/Shares/Item/AllowedGroups/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Print.Shares.Item.AllowedGroups.@Ref { - /// Builds and executes requests for operations under \print\shares\{printerShare-id}\allowedGroups\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The groups whose users have access to print using the printer. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The groups whose users have access to print using the printer."; - // Create options for all the parameters - var printerShareIdOption = new Option("--printershare-id", description: "key: id of printerShare") { - }; - printerShareIdOption.IsRequired = true; - command.AddOption(printerShareIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string printerShareId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printerShareIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The groups whose users have access to print using the printer. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The groups whose users have access to print using the printer."; - // Create options for all the parameters - var printerShareIdOption = new Option("--printershare-id", description: "key: id of printerShare") { - }; - printerShareIdOption.IsRequired = true; - command.AddOption(printerShareIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string printerShareId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printerShareIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/print/shares/{printerShare_id}/allowedGroups/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The groups whose users have access to print using the printer. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The groups whose users have access to print using the printer. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Print.Shares.Item.AllowedGroups.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The groups whose users have access to print using the printer. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The groups whose users have access to print using the printer. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Print.Shares.Item.AllowedGroups.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The groups whose users have access to print using the printer. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Print/Shares/Item/AllowedGroups/@Ref/RefResponse.cs b/src/generated/Print/Shares/Item/AllowedGroups/@Ref/RefResponse.cs deleted file mode 100644 index 3eb67a0ede0..00000000000 --- a/src/generated/Print/Shares/Item/AllowedGroups/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Print.Shares.Item.AllowedGroups.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Print/Shares/Item/AllowedGroups/AllowedGroupsRequestBuilder.cs b/src/generated/Print/Shares/Item/AllowedGroups/AllowedGroupsRequestBuilder.cs index 6d670f7a1ab..5fcd2425c0b 100644 --- a/src/generated/Print/Shares/Item/AllowedGroups/AllowedGroupsRequestBuilder.cs +++ b/src/generated/Print/Shares/Item/AllowedGroups/AllowedGroupsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Print.Shares.Item.AllowedGroups.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The groups whose users have access to print using the printer."; // Create options for all the parameters - var printerShareIdOption = new Option("--printershare-id", description: "key: id of printerShare") { + var printerShareIdOption = new Option("--printer-share-id", description: "key: id of printerShare") { }; printerShareIdOption.IsRequired = true; command.AddOption(printerShareIdOption); @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string printerShareId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printerShareId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printerShareIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printerShareIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Print.Shares.Item.AllowedGroups.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Print.Shares.Item.AllowedGroups.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The groups whose users have access to print using the printer. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The groups whose users have access to print using the printer. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Print/Shares/Item/AllowedGroups/Ref/Ref.cs b/src/generated/Print/Shares/Item/AllowedGroups/Ref/Ref.cs new file mode 100644 index 00000000000..5b5b320b750 --- /dev/null +++ b/src/generated/Print/Shares/Item/AllowedGroups/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Print.Shares.Item.AllowedGroups.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Print/Shares/Item/AllowedGroups/Ref/RefRequestBuilder.cs b/src/generated/Print/Shares/Item/AllowedGroups/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..ec2d157384d --- /dev/null +++ b/src/generated/Print/Shares/Item/AllowedGroups/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Print.Shares.Item.AllowedGroups.Ref { + /// Builds and executes requests for operations under \print\shares\{printerShare-id}\allowedGroups\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The groups whose users have access to print using the printer. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The groups whose users have access to print using the printer."; + // Create options for all the parameters + var printerShareIdOption = new Option("--printer-share-id", description: "key: id of printerShare") { + }; + printerShareIdOption.IsRequired = true; + command.AddOption(printerShareIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printerShareId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printerShareIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The groups whose users have access to print using the printer. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The groups whose users have access to print using the printer."; + // Create options for all the parameters + var printerShareIdOption = new Option("--printer-share-id", description: "key: id of printerShare") { + }; + printerShareIdOption.IsRequired = true; + command.AddOption(printerShareIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printerShareId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printerShareIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/print/shares/{printerShare_id}/allowedGroups/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The groups whose users have access to print using the printer. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The groups whose users have access to print using the printer. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Print.Shares.Item.AllowedGroups.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The groups whose users have access to print using the printer. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Print/Shares/Item/AllowedGroups/Ref/RefResponse.cs b/src/generated/Print/Shares/Item/AllowedGroups/Ref/RefResponse.cs new file mode 100644 index 00000000000..7c25448ab1b --- /dev/null +++ b/src/generated/Print/Shares/Item/AllowedGroups/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Print.Shares.Item.AllowedGroups.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Print/Shares/Item/AllowedUsers/@Ref/@Ref.cs b/src/generated/Print/Shares/Item/AllowedUsers/@Ref/@Ref.cs deleted file mode 100644 index 77b8e575083..00000000000 --- a/src/generated/Print/Shares/Item/AllowedUsers/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Print.Shares.Item.AllowedUsers.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Print/Shares/Item/AllowedUsers/@Ref/RefRequestBuilder.cs b/src/generated/Print/Shares/Item/AllowedUsers/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 0f69038134a..00000000000 --- a/src/generated/Print/Shares/Item/AllowedUsers/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Print.Shares.Item.AllowedUsers.@Ref { - /// Builds and executes requests for operations under \print\shares\{printerShare-id}\allowedUsers\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The users who have access to print using the printer. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The users who have access to print using the printer."; - // Create options for all the parameters - var printerShareIdOption = new Option("--printershare-id", description: "key: id of printerShare") { - }; - printerShareIdOption.IsRequired = true; - command.AddOption(printerShareIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string printerShareId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printerShareIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The users who have access to print using the printer. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The users who have access to print using the printer."; - // Create options for all the parameters - var printerShareIdOption = new Option("--printershare-id", description: "key: id of printerShare") { - }; - printerShareIdOption.IsRequired = true; - command.AddOption(printerShareIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string printerShareId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printerShareIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/print/shares/{printerShare_id}/allowedUsers/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The users who have access to print using the printer. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The users who have access to print using the printer. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Print.Shares.Item.AllowedUsers.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The users who have access to print using the printer. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The users who have access to print using the printer. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Print.Shares.Item.AllowedUsers.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The users who have access to print using the printer. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Print/Shares/Item/AllowedUsers/@Ref/RefResponse.cs b/src/generated/Print/Shares/Item/AllowedUsers/@Ref/RefResponse.cs deleted file mode 100644 index 153510d7627..00000000000 --- a/src/generated/Print/Shares/Item/AllowedUsers/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Print.Shares.Item.AllowedUsers.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Print/Shares/Item/AllowedUsers/AllowedUsersRequestBuilder.cs b/src/generated/Print/Shares/Item/AllowedUsers/AllowedUsersRequestBuilder.cs index f0f607f980e..5b1cd6513d5 100644 --- a/src/generated/Print/Shares/Item/AllowedUsers/AllowedUsersRequestBuilder.cs +++ b/src/generated/Print/Shares/Item/AllowedUsers/AllowedUsersRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Print.Shares.Item.AllowedUsers.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The users who have access to print using the printer."; // Create options for all the parameters - var printerShareIdOption = new Option("--printershare-id", description: "key: id of printerShare") { + var printerShareIdOption = new Option("--printer-share-id", description: "key: id of printerShare") { }; printerShareIdOption.IsRequired = true; command.AddOption(printerShareIdOption); @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string printerShareId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printerShareId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printerShareIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printerShareIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Print.Shares.Item.AllowedUsers.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Print.Shares.Item.AllowedUsers.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The users who have access to print using the printer. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The users who have access to print using the printer. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Print/Shares/Item/AllowedUsers/Ref/Ref.cs b/src/generated/Print/Shares/Item/AllowedUsers/Ref/Ref.cs new file mode 100644 index 00000000000..7d137dd3e2a --- /dev/null +++ b/src/generated/Print/Shares/Item/AllowedUsers/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Print.Shares.Item.AllowedUsers.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Print/Shares/Item/AllowedUsers/Ref/RefRequestBuilder.cs b/src/generated/Print/Shares/Item/AllowedUsers/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..664ce72e828 --- /dev/null +++ b/src/generated/Print/Shares/Item/AllowedUsers/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Print.Shares.Item.AllowedUsers.Ref { + /// Builds and executes requests for operations under \print\shares\{printerShare-id}\allowedUsers\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The users who have access to print using the printer. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The users who have access to print using the printer."; + // Create options for all the parameters + var printerShareIdOption = new Option("--printer-share-id", description: "key: id of printerShare") { + }; + printerShareIdOption.IsRequired = true; + command.AddOption(printerShareIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printerShareId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printerShareIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The users who have access to print using the printer. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The users who have access to print using the printer."; + // Create options for all the parameters + var printerShareIdOption = new Option("--printer-share-id", description: "key: id of printerShare") { + }; + printerShareIdOption.IsRequired = true; + command.AddOption(printerShareIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printerShareId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printerShareIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/print/shares/{printerShare_id}/allowedUsers/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The users who have access to print using the printer. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The users who have access to print using the printer. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Print.Shares.Item.AllowedUsers.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The users who have access to print using the printer. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Print/Shares/Item/AllowedUsers/Ref/RefResponse.cs b/src/generated/Print/Shares/Item/AllowedUsers/Ref/RefResponse.cs new file mode 100644 index 00000000000..18ee416b69e --- /dev/null +++ b/src/generated/Print/Shares/Item/AllowedUsers/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Print.Shares.Item.AllowedUsers.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Print/Shares/Item/Printer/@Ref/@Ref.cs b/src/generated/Print/Shares/Item/Printer/@Ref/@Ref.cs deleted file mode 100644 index fcaf515123d..00000000000 --- a/src/generated/Print/Shares/Item/Printer/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Print.Shares.Item.Printer.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Print/Shares/Item/Printer/@Ref/RefRequestBuilder.cs b/src/generated/Print/Shares/Item/Printer/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 6a66d09d321..00000000000 --- a/src/generated/Print/Shares/Item/Printer/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Print.Shares.Item.Printer.@Ref { - /// Builds and executes requests for operations under \print\shares\{printerShare-id}\printer\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The printer that this printer share is related to. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The printer that this printer share is related to."; - // Create options for all the parameters - var printerShareIdOption = new Option("--printershare-id", description: "key: id of printerShare") { - }; - printerShareIdOption.IsRequired = true; - command.AddOption(printerShareIdOption); - command.SetHandler(async (string printerShareId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, printerShareIdOption); - return command; - } - /// - /// The printer that this printer share is related to. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The printer that this printer share is related to."; - // Create options for all the parameters - var printerShareIdOption = new Option("--printershare-id", description: "key: id of printerShare") { - }; - printerShareIdOption.IsRequired = true; - command.AddOption(printerShareIdOption); - command.SetHandler(async (string printerShareId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printerShareIdOption); - return command; - } - /// - /// The printer that this printer share is related to. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The printer that this printer share is related to."; - // Create options for all the parameters - var printerShareIdOption = new Option("--printershare-id", description: "key: id of printerShare") { - }; - printerShareIdOption.IsRequired = true; - command.AddOption(printerShareIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string printerShareId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, printerShareIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/print/shares/{printerShare_id}/printer/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The printer that this printer share is related to. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The printer that this printer share is related to. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The printer that this printer share is related to. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Print.Shares.Item.Printer.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The printer that this printer share is related to. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The printer that this printer share is related to. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The printer that this printer share is related to. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Print.Shares.Item.Printer.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Print/Shares/Item/Printer/PrinterRequestBuilder.cs b/src/generated/Print/Shares/Item/Printer/PrinterRequestBuilder.cs index 1815c3f64cd..231ae253934 100644 --- a/src/generated/Print/Shares/Item/Printer/PrinterRequestBuilder.cs +++ b/src/generated/Print/Shares/Item/Printer/PrinterRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Print.Shares.Item.Printer.RestoreFactoryDefaults; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,7 +28,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The printer that this printer share is related to."; // Create options for all the parameters - var printerShareIdOption = new Option("--printershare-id", description: "key: id of printerShare") { + var printerShareIdOption = new Option("--printer-share-id", description: "key: id of printerShare") { }; printerShareIdOption.IsRequired = true; command.AddOption(printerShareIdOption); @@ -42,25 +42,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string printerShareId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printerShareId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printerShareIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printerShareIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Print.Shares.Item.Printer.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Print.Shares.Item.Printer.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -106,18 +105,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The printer that this printer share is related to. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The printer that this printer share is related to. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Print/Shares/Item/Printer/Ref/Ref.cs b/src/generated/Print/Shares/Item/Printer/Ref/Ref.cs new file mode 100644 index 00000000000..9a2a1e12927 --- /dev/null +++ b/src/generated/Print/Shares/Item/Printer/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Print.Shares.Item.Printer.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Print/Shares/Item/Printer/Ref/RefRequestBuilder.cs b/src/generated/Print/Shares/Item/Printer/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..f9e9871b6d0 --- /dev/null +++ b/src/generated/Print/Shares/Item/Printer/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Print.Shares.Item.Printer.Ref { + /// Builds and executes requests for operations under \print\shares\{printerShare-id}\printer\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The printer that this printer share is related to. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The printer that this printer share is related to."; + // Create options for all the parameters + var printerShareIdOption = new Option("--printer-share-id", description: "key: id of printerShare") { + }; + printerShareIdOption.IsRequired = true; + command.AddOption(printerShareIdOption); + command.SetHandler(async (string printerShareId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, printerShareIdOption); + return command; + } + /// + /// The printer that this printer share is related to. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The printer that this printer share is related to."; + // Create options for all the parameters + var printerShareIdOption = new Option("--printer-share-id", description: "key: id of printerShare") { + }; + printerShareIdOption.IsRequired = true; + command.AddOption(printerShareIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printerShareId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printerShareIdOption, outputOption); + return command; + } + /// + /// The printer that this printer share is related to. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The printer that this printer share is related to."; + // Create options for all the parameters + var printerShareIdOption = new Option("--printer-share-id", description: "key: id of printerShare") { + }; + printerShareIdOption.IsRequired = true; + command.AddOption(printerShareIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string printerShareId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, printerShareIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/print/shares/{printerShare_id}/printer/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The printer that this printer share is related to. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The printer that this printer share is related to. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The printer that this printer share is related to. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Print.Shares.Item.Printer.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Print/Shares/Item/Printer/RestoreFactoryDefaults/RestoreFactoryDefaultsRequestBuilder.cs b/src/generated/Print/Shares/Item/Printer/RestoreFactoryDefaults/RestoreFactoryDefaultsRequestBuilder.cs index 7a4ee4303ac..bf662ebc982 100644 --- a/src/generated/Print/Shares/Item/Printer/RestoreFactoryDefaults/RestoreFactoryDefaultsRequestBuilder.cs +++ b/src/generated/Print/Shares/Item/Printer/RestoreFactoryDefaults/RestoreFactoryDefaultsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action restoreFactoryDefaults"; // Create options for all the parameters - var printerShareIdOption = new Option("--printershare-id", description: "key: id of printerShare") { + var printerShareIdOption = new Option("--printer-share-id", description: "key: id of printerShare") { }; printerShareIdOption.IsRequired = true; command.AddOption(printerShareIdOption); - command.SetHandler(async (string printerShareId) => { + command.SetHandler(async (string printerShareId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printerShareIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action restoreFactoryDefaults - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Print/Shares/Item/PrinterShareRequestBuilder.cs b/src/generated/Print/Shares/Item/PrinterShareRequestBuilder.cs index 9a318d0b30f..cbc0d40fb07 100644 --- a/src/generated/Print/Shares/Item/PrinterShareRequestBuilder.cs +++ b/src/generated/Print/Shares/Item/PrinterShareRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Print.Shares.Item.Printer; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -43,15 +43,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of printer shares registered in the tenant."; // Create options for all the parameters - var printerShareIdOption = new Option("--printershare-id", description: "key: id of printerShare") { + var printerShareIdOption = new Option("--printer-share-id", description: "key: id of printerShare") { }; printerShareIdOption.IsRequired = true; command.AddOption(printerShareIdOption); - command.SetHandler(async (string printerShareId) => { + command.SetHandler(async (string printerShareId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printerShareIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of printer shares registered in the tenant."; // Create options for all the parameters - var printerShareIdOption = new Option("--printershare-id", description: "key: id of printerShare") { + var printerShareIdOption = new Option("--printer-share-id", description: "key: id of printerShare") { }; printerShareIdOption.IsRequired = true; command.AddOption(printerShareIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string printerShareId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printerShareId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printerShareIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printerShareIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -100,7 +98,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of printer shares registered in the tenant."; // Create options for all the parameters - var printerShareIdOption = new Option("--printershare-id", description: "key: id of printerShare") { + var printerShareIdOption = new Option("--printer-share-id", description: "key: id of printerShare") { }; printerShareIdOption.IsRequired = true; command.AddOption(printerShareIdOption); @@ -108,14 +106,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string printerShareId, string body) => { + command.SetHandler(async (string printerShareId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printerShareIdOption, bodyOption); return command; @@ -195,42 +192,6 @@ public RequestInformation CreatePatchRequestInformation(PrinterShare body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of printer shares registered in the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of printer shares registered in the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of printer shares registered in the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PrinterShare model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of printer shares registered in the tenant. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Print/Shares/SharesRequestBuilder.cs b/src/generated/Print/Shares/SharesRequestBuilder.cs index 4407a4cf4c2..50b771936a3 100644 --- a/src/generated/Print/Shares/SharesRequestBuilder.cs +++ b/src/generated/Print/Shares/SharesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Print.Shares.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class SharesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PrinterShareRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAllowedGroupsCommand(), - builder.BuildAllowedUsersCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildPrinterCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAllowedGroupsCommand()); + commands.Add(builder.BuildAllowedUsersCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPrinterCommand()); return commands; } /// @@ -43,21 +42,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -102,7 +100,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -113,15 +115,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -176,31 +173,6 @@ public RequestInformation CreatePostRequestInformation(PrinterShare body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of printer shares registered in the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of printer shares registered in the tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PrinterShare model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of printer shares registered in the tenant. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Print/TaskDefinitions/Item/PrintTaskDefinitionRequestBuilder.cs b/src/generated/Print/TaskDefinitions/Item/PrintTaskDefinitionRequestBuilder.cs index 5704f476556..e02ceea5e94 100644 --- a/src/generated/Print/TaskDefinitions/Item/PrintTaskDefinitionRequestBuilder.cs +++ b/src/generated/Print/TaskDefinitions/Item/PrintTaskDefinitionRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Print.TaskDefinitions.Item.Tasks; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,15 +27,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "List of abstract definition for a task that can be triggered when various events occur within Universal Print."; // Create options for all the parameters - var printTaskDefinitionIdOption = new Option("--printtaskdefinition-id", description: "key: id of printTaskDefinition") { + var printTaskDefinitionIdOption = new Option("--print-task-definition-id", description: "key: id of printTaskDefinition") { }; printTaskDefinitionIdOption.IsRequired = true; command.AddOption(printTaskDefinitionIdOption); - command.SetHandler(async (string printTaskDefinitionId) => { + command.SetHandler(async (string printTaskDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printTaskDefinitionIdOption); return command; @@ -47,7 +46,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "List of abstract definition for a task that can be triggered when various events occur within Universal Print."; // Create options for all the parameters - var printTaskDefinitionIdOption = new Option("--printtaskdefinition-id", description: "key: id of printTaskDefinition") { + var printTaskDefinitionIdOption = new Option("--print-task-definition-id", description: "key: id of printTaskDefinition") { }; printTaskDefinitionIdOption.IsRequired = true; command.AddOption(printTaskDefinitionIdOption); @@ -61,20 +60,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string printTaskDefinitionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printTaskDefinitionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printTaskDefinitionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printTaskDefinitionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "List of abstract definition for a task that can be triggered when various events occur within Universal Print."; // Create options for all the parameters - var printTaskDefinitionIdOption = new Option("--printtaskdefinition-id", description: "key: id of printTaskDefinition") { + var printTaskDefinitionIdOption = new Option("--print-task-definition-id", description: "key: id of printTaskDefinition") { }; printTaskDefinitionIdOption.IsRequired = true; command.AddOption(printTaskDefinitionIdOption); @@ -92,14 +90,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string printTaskDefinitionId, string body) => { + command.SetHandler(async (string printTaskDefinitionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printTaskDefinitionIdOption, bodyOption); return command; @@ -107,6 +104,9 @@ public Command BuildPatchCommand() { public Command BuildTasksCommand() { var command = new Command("tasks"); var builder = new ApiSdk.Print.TaskDefinitions.Item.Tasks.TasksRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -178,42 +178,6 @@ public RequestInformation CreatePatchRequestInformation(PrintTaskDefinition body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of abstract definition for a task that can be triggered when various events occur within Universal Print. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of abstract definition for a task that can be triggered when various events occur within Universal Print. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of abstract definition for a task that can be triggered when various events occur within Universal Print. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PrintTaskDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// List of abstract definition for a task that can be triggered when various events occur within Universal Print. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Definition/@Ref/@Ref.cs b/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Definition/@Ref/@Ref.cs deleted file mode 100644 index 43d1b4909af..00000000000 --- a/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Definition/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Print.TaskDefinitions.Item.Tasks.Item.Definition.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Definition/@Ref/RefRequestBuilder.cs b/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Definition/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 5d2f63b5f47..00000000000 --- a/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Definition/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Print.TaskDefinitions.Item.Tasks.Item.Definition.@Ref { - /// Builds and executes requests for operations under \print\taskDefinitions\{printTaskDefinition-id}\tasks\{printTask-id}\definition\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The printTaskDefinition that was used to create this task. Read-only. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The printTaskDefinition that was used to create this task. Read-only."; - // Create options for all the parameters - var printTaskDefinitionIdOption = new Option("--printtaskdefinition-id", description: "key: id of printTaskDefinition") { - }; - printTaskDefinitionIdOption.IsRequired = true; - command.AddOption(printTaskDefinitionIdOption); - var printTaskIdOption = new Option("--printtask-id", description: "key: id of printTask") { - }; - printTaskIdOption.IsRequired = true; - command.AddOption(printTaskIdOption); - command.SetHandler(async (string printTaskDefinitionId, string printTaskId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, printTaskDefinitionIdOption, printTaskIdOption); - return command; - } - /// - /// The printTaskDefinition that was used to create this task. Read-only. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The printTaskDefinition that was used to create this task. Read-only."; - // Create options for all the parameters - var printTaskDefinitionIdOption = new Option("--printtaskdefinition-id", description: "key: id of printTaskDefinition") { - }; - printTaskDefinitionIdOption.IsRequired = true; - command.AddOption(printTaskDefinitionIdOption); - var printTaskIdOption = new Option("--printtask-id", description: "key: id of printTask") { - }; - printTaskIdOption.IsRequired = true; - command.AddOption(printTaskIdOption); - command.SetHandler(async (string printTaskDefinitionId, string printTaskId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printTaskDefinitionIdOption, printTaskIdOption); - return command; - } - /// - /// The printTaskDefinition that was used to create this task. Read-only. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The printTaskDefinition that was used to create this task. Read-only."; - // Create options for all the parameters - var printTaskDefinitionIdOption = new Option("--printtaskdefinition-id", description: "key: id of printTaskDefinition") { - }; - printTaskDefinitionIdOption.IsRequired = true; - command.AddOption(printTaskDefinitionIdOption); - var printTaskIdOption = new Option("--printtask-id", description: "key: id of printTask") { - }; - printTaskIdOption.IsRequired = true; - command.AddOption(printTaskIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string printTaskDefinitionId, string printTaskId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, printTaskDefinitionIdOption, printTaskIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/print/taskDefinitions/{printTaskDefinition_id}/tasks/{printTask_id}/definition/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The printTaskDefinition that was used to create this task. Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The printTaskDefinition that was used to create this task. Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The printTaskDefinition that was used to create this task. Read-only. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Print.TaskDefinitions.Item.Tasks.Item.Definition.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The printTaskDefinition that was used to create this task. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The printTaskDefinition that was used to create this task. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The printTaskDefinition that was used to create this task. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Print.TaskDefinitions.Item.Tasks.Item.Definition.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Definition/DefinitionRequestBuilder.cs b/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Definition/DefinitionRequestBuilder.cs index 6caa4ea90b6..4edbe71c022 100644 --- a/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Definition/DefinitionRequestBuilder.cs +++ b/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Definition/DefinitionRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Print.TaskDefinitions.Item.Tasks.Item.Definition.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,11 +27,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The printTaskDefinition that was used to create this task. Read-only."; // Create options for all the parameters - var printTaskDefinitionIdOption = new Option("--printtaskdefinition-id", description: "key: id of printTaskDefinition") { + var printTaskDefinitionIdOption = new Option("--print-task-definition-id", description: "key: id of printTaskDefinition") { }; printTaskDefinitionIdOption.IsRequired = true; command.AddOption(printTaskDefinitionIdOption); - var printTaskIdOption = new Option("--printtask-id", description: "key: id of printTask") { + var printTaskIdOption = new Option("--print-task-id", description: "key: id of printTask") { }; printTaskIdOption.IsRequired = true; command.AddOption(printTaskIdOption); @@ -45,25 +45,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string printTaskDefinitionId, string printTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printTaskDefinitionId, string printTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printTaskDefinitionIdOption, printTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printTaskDefinitionIdOption, printTaskIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Print.TaskDefinitions.Item.Tasks.Item.Definition.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Print.TaskDefinitions.Item.Tasks.Item.Definition.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -103,18 +102,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The printTaskDefinition that was used to create this task. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The printTaskDefinition that was used to create this task. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Definition/Ref/Ref.cs b/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Definition/Ref/Ref.cs new file mode 100644 index 00000000000..87e3cf7366b --- /dev/null +++ b/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Definition/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Print.TaskDefinitions.Item.Tasks.Item.Definition.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Definition/Ref/RefRequestBuilder.cs b/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Definition/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..0bc83640a14 --- /dev/null +++ b/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Definition/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Print.TaskDefinitions.Item.Tasks.Item.Definition.Ref { + /// Builds and executes requests for operations under \print\taskDefinitions\{printTaskDefinition-id}\tasks\{printTask-id}\definition\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The printTaskDefinition that was used to create this task. Read-only. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The printTaskDefinition that was used to create this task. Read-only."; + // Create options for all the parameters + var printTaskDefinitionIdOption = new Option("--print-task-definition-id", description: "key: id of printTaskDefinition") { + }; + printTaskDefinitionIdOption.IsRequired = true; + command.AddOption(printTaskDefinitionIdOption); + var printTaskIdOption = new Option("--print-task-id", description: "key: id of printTask") { + }; + printTaskIdOption.IsRequired = true; + command.AddOption(printTaskIdOption); + command.SetHandler(async (string printTaskDefinitionId, string printTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, printTaskDefinitionIdOption, printTaskIdOption); + return command; + } + /// + /// The printTaskDefinition that was used to create this task. Read-only. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The printTaskDefinition that was used to create this task. Read-only."; + // Create options for all the parameters + var printTaskDefinitionIdOption = new Option("--print-task-definition-id", description: "key: id of printTaskDefinition") { + }; + printTaskDefinitionIdOption.IsRequired = true; + command.AddOption(printTaskDefinitionIdOption); + var printTaskIdOption = new Option("--print-task-id", description: "key: id of printTask") { + }; + printTaskIdOption.IsRequired = true; + command.AddOption(printTaskIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printTaskDefinitionId, string printTaskId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printTaskDefinitionIdOption, printTaskIdOption, outputOption); + return command; + } + /// + /// The printTaskDefinition that was used to create this task. Read-only. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The printTaskDefinition that was used to create this task. Read-only."; + // Create options for all the parameters + var printTaskDefinitionIdOption = new Option("--print-task-definition-id", description: "key: id of printTaskDefinition") { + }; + printTaskDefinitionIdOption.IsRequired = true; + command.AddOption(printTaskDefinitionIdOption); + var printTaskIdOption = new Option("--print-task-id", description: "key: id of printTask") { + }; + printTaskIdOption.IsRequired = true; + command.AddOption(printTaskIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string printTaskDefinitionId, string printTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, printTaskDefinitionIdOption, printTaskIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/print/taskDefinitions/{printTaskDefinition_id}/tasks/{printTask_id}/definition/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The printTaskDefinition that was used to create this task. Read-only. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The printTaskDefinition that was used to create this task. Read-only. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The printTaskDefinition that was used to create this task. Read-only. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Print.TaskDefinitions.Item.Tasks.Item.Definition.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Print/TaskDefinitions/Item/Tasks/Item/PrintTaskRequestBuilder.cs b/src/generated/Print/TaskDefinitions/Item/Tasks/Item/PrintTaskRequestBuilder.cs index 8fc5cd2610d..67672752d31 100644 --- a/src/generated/Print/TaskDefinitions/Item/Tasks/Item/PrintTaskRequestBuilder.cs +++ b/src/generated/Print/TaskDefinitions/Item/Tasks/Item/PrintTaskRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Print.TaskDefinitions.Item.Tasks.Item.Trigger; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,19 +35,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "A list of tasks that have been created based on this definition. The list includes currently running tasks and recently completed tasks. Read-only."; // Create options for all the parameters - var printTaskDefinitionIdOption = new Option("--printtaskdefinition-id", description: "key: id of printTaskDefinition") { + var printTaskDefinitionIdOption = new Option("--print-task-definition-id", description: "key: id of printTaskDefinition") { }; printTaskDefinitionIdOption.IsRequired = true; command.AddOption(printTaskDefinitionIdOption); - var printTaskIdOption = new Option("--printtask-id", description: "key: id of printTask") { + var printTaskIdOption = new Option("--print-task-id", description: "key: id of printTask") { }; printTaskIdOption.IsRequired = true; command.AddOption(printTaskIdOption); - command.SetHandler(async (string printTaskDefinitionId, string printTaskId) => { + command.SetHandler(async (string printTaskDefinitionId, string printTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printTaskDefinitionIdOption, printTaskIdOption); return command; @@ -59,11 +58,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "A list of tasks that have been created based on this definition. The list includes currently running tasks and recently completed tasks. Read-only."; // Create options for all the parameters - var printTaskDefinitionIdOption = new Option("--printtaskdefinition-id", description: "key: id of printTaskDefinition") { + var printTaskDefinitionIdOption = new Option("--print-task-definition-id", description: "key: id of printTaskDefinition") { }; printTaskDefinitionIdOption.IsRequired = true; command.AddOption(printTaskDefinitionIdOption); - var printTaskIdOption = new Option("--printtask-id", description: "key: id of printTask") { + var printTaskIdOption = new Option("--print-task-id", description: "key: id of printTask") { }; printTaskIdOption.IsRequired = true; command.AddOption(printTaskIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string printTaskDefinitionId, string printTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printTaskDefinitionId, string printTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printTaskDefinitionIdOption, printTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printTaskDefinitionIdOption, printTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -100,11 +98,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "A list of tasks that have been created based on this definition. The list includes currently running tasks and recently completed tasks. Read-only."; // Create options for all the parameters - var printTaskDefinitionIdOption = new Option("--printtaskdefinition-id", description: "key: id of printTaskDefinition") { + var printTaskDefinitionIdOption = new Option("--print-task-definition-id", description: "key: id of printTaskDefinition") { }; printTaskDefinitionIdOption.IsRequired = true; command.AddOption(printTaskDefinitionIdOption); - var printTaskIdOption = new Option("--printtask-id", description: "key: id of printTask") { + var printTaskIdOption = new Option("--print-task-id", description: "key: id of printTask") { }; printTaskIdOption.IsRequired = true; command.AddOption(printTaskIdOption); @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string printTaskDefinitionId, string printTaskId, string body) => { + command.SetHandler(async (string printTaskDefinitionId, string printTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printTaskDefinitionIdOption, printTaskIdOption, bodyOption); return command; @@ -198,42 +195,6 @@ public RequestInformation CreatePatchRequestInformation(PrintTask body, Action - /// A list of tasks that have been created based on this definition. The list includes currently running tasks and recently completed tasks. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A list of tasks that have been created based on this definition. The list includes currently running tasks and recently completed tasks. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A list of tasks that have been created based on this definition. The list includes currently running tasks and recently completed tasks. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PrintTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A list of tasks that have been created based on this definition. The list includes currently running tasks and recently completed tasks. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Trigger/@Ref/@Ref.cs b/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Trigger/@Ref/@Ref.cs deleted file mode 100644 index 013a40bf89b..00000000000 --- a/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Trigger/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Print.TaskDefinitions.Item.Tasks.Item.Trigger.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Trigger/@Ref/RefRequestBuilder.cs b/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Trigger/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 365ef344272..00000000000 --- a/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Trigger/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Print.TaskDefinitions.Item.Tasks.Item.Trigger.@Ref { - /// Builds and executes requests for operations under \print\taskDefinitions\{printTaskDefinition-id}\tasks\{printTask-id}\trigger\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The printTaskTrigger that triggered this task's execution. Read-only. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The printTaskTrigger that triggered this task's execution. Read-only."; - // Create options for all the parameters - var printTaskDefinitionIdOption = new Option("--printtaskdefinition-id", description: "key: id of printTaskDefinition") { - }; - printTaskDefinitionIdOption.IsRequired = true; - command.AddOption(printTaskDefinitionIdOption); - var printTaskIdOption = new Option("--printtask-id", description: "key: id of printTask") { - }; - printTaskIdOption.IsRequired = true; - command.AddOption(printTaskIdOption); - command.SetHandler(async (string printTaskDefinitionId, string printTaskId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, printTaskDefinitionIdOption, printTaskIdOption); - return command; - } - /// - /// The printTaskTrigger that triggered this task's execution. Read-only. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The printTaskTrigger that triggered this task's execution. Read-only."; - // Create options for all the parameters - var printTaskDefinitionIdOption = new Option("--printtaskdefinition-id", description: "key: id of printTaskDefinition") { - }; - printTaskDefinitionIdOption.IsRequired = true; - command.AddOption(printTaskDefinitionIdOption); - var printTaskIdOption = new Option("--printtask-id", description: "key: id of printTask") { - }; - printTaskIdOption.IsRequired = true; - command.AddOption(printTaskIdOption); - command.SetHandler(async (string printTaskDefinitionId, string printTaskId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printTaskDefinitionIdOption, printTaskIdOption); - return command; - } - /// - /// The printTaskTrigger that triggered this task's execution. Read-only. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The printTaskTrigger that triggered this task's execution. Read-only."; - // Create options for all the parameters - var printTaskDefinitionIdOption = new Option("--printtaskdefinition-id", description: "key: id of printTaskDefinition") { - }; - printTaskDefinitionIdOption.IsRequired = true; - command.AddOption(printTaskDefinitionIdOption); - var printTaskIdOption = new Option("--printtask-id", description: "key: id of printTask") { - }; - printTaskIdOption.IsRequired = true; - command.AddOption(printTaskIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string printTaskDefinitionId, string printTaskId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, printTaskDefinitionIdOption, printTaskIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/print/taskDefinitions/{printTaskDefinition_id}/tasks/{printTask_id}/trigger/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The printTaskTrigger that triggered this task's execution. Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The printTaskTrigger that triggered this task's execution. Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The printTaskTrigger that triggered this task's execution. Read-only. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Print.TaskDefinitions.Item.Tasks.Item.Trigger.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The printTaskTrigger that triggered this task's execution. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The printTaskTrigger that triggered this task's execution. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The printTaskTrigger that triggered this task's execution. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Print.TaskDefinitions.Item.Tasks.Item.Trigger.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Trigger/Ref/Ref.cs b/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Trigger/Ref/Ref.cs new file mode 100644 index 00000000000..ce53e21fcea --- /dev/null +++ b/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Trigger/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Print.TaskDefinitions.Item.Tasks.Item.Trigger.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Trigger/Ref/RefRequestBuilder.cs b/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Trigger/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..e0833d6bba9 --- /dev/null +++ b/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Trigger/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Print.TaskDefinitions.Item.Tasks.Item.Trigger.Ref { + /// Builds and executes requests for operations under \print\taskDefinitions\{printTaskDefinition-id}\tasks\{printTask-id}\trigger\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The printTaskTrigger that triggered this task's execution. Read-only. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The printTaskTrigger that triggered this task's execution. Read-only."; + // Create options for all the parameters + var printTaskDefinitionIdOption = new Option("--print-task-definition-id", description: "key: id of printTaskDefinition") { + }; + printTaskDefinitionIdOption.IsRequired = true; + command.AddOption(printTaskDefinitionIdOption); + var printTaskIdOption = new Option("--print-task-id", description: "key: id of printTask") { + }; + printTaskIdOption.IsRequired = true; + command.AddOption(printTaskIdOption); + command.SetHandler(async (string printTaskDefinitionId, string printTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, printTaskDefinitionIdOption, printTaskIdOption); + return command; + } + /// + /// The printTaskTrigger that triggered this task's execution. Read-only. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The printTaskTrigger that triggered this task's execution. Read-only."; + // Create options for all the parameters + var printTaskDefinitionIdOption = new Option("--print-task-definition-id", description: "key: id of printTaskDefinition") { + }; + printTaskDefinitionIdOption.IsRequired = true; + command.AddOption(printTaskDefinitionIdOption); + var printTaskIdOption = new Option("--print-task-id", description: "key: id of printTask") { + }; + printTaskIdOption.IsRequired = true; + command.AddOption(printTaskIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printTaskDefinitionId, string printTaskId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printTaskDefinitionIdOption, printTaskIdOption, outputOption); + return command; + } + /// + /// The printTaskTrigger that triggered this task's execution. Read-only. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The printTaskTrigger that triggered this task's execution. Read-only."; + // Create options for all the parameters + var printTaskDefinitionIdOption = new Option("--print-task-definition-id", description: "key: id of printTaskDefinition") { + }; + printTaskDefinitionIdOption.IsRequired = true; + command.AddOption(printTaskDefinitionIdOption); + var printTaskIdOption = new Option("--print-task-id", description: "key: id of printTask") { + }; + printTaskIdOption.IsRequired = true; + command.AddOption(printTaskIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string printTaskDefinitionId, string printTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, printTaskDefinitionIdOption, printTaskIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/print/taskDefinitions/{printTaskDefinition_id}/tasks/{printTask_id}/trigger/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The printTaskTrigger that triggered this task's execution. Read-only. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The printTaskTrigger that triggered this task's execution. Read-only. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The printTaskTrigger that triggered this task's execution. Read-only. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Print.TaskDefinitions.Item.Tasks.Item.Trigger.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Trigger/TriggerRequestBuilder.cs b/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Trigger/TriggerRequestBuilder.cs index 7d743ff9008..c2d74fc5e49 100644 --- a/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Trigger/TriggerRequestBuilder.cs +++ b/src/generated/Print/TaskDefinitions/Item/Tasks/Item/Trigger/TriggerRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Print.TaskDefinitions.Item.Tasks.Item.Trigger.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,11 +27,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The printTaskTrigger that triggered this task's execution. Read-only."; // Create options for all the parameters - var printTaskDefinitionIdOption = new Option("--printtaskdefinition-id", description: "key: id of printTaskDefinition") { + var printTaskDefinitionIdOption = new Option("--print-task-definition-id", description: "key: id of printTaskDefinition") { }; printTaskDefinitionIdOption.IsRequired = true; command.AddOption(printTaskDefinitionIdOption); - var printTaskIdOption = new Option("--printtask-id", description: "key: id of printTask") { + var printTaskIdOption = new Option("--print-task-id", description: "key: id of printTask") { }; printTaskIdOption.IsRequired = true; command.AddOption(printTaskIdOption); @@ -45,25 +45,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string printTaskDefinitionId, string printTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printTaskDefinitionId, string printTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printTaskDefinitionIdOption, printTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printTaskDefinitionIdOption, printTaskIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Print.TaskDefinitions.Item.Tasks.Item.Trigger.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Print.TaskDefinitions.Item.Tasks.Item.Trigger.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -103,18 +102,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The printTaskTrigger that triggered this task's execution. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The printTaskTrigger that triggered this task's execution. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Print/TaskDefinitions/Item/Tasks/TasksRequestBuilder.cs b/src/generated/Print/TaskDefinitions/Item/Tasks/TasksRequestBuilder.cs index 40590cd47ea..69592451b15 100644 --- a/src/generated/Print/TaskDefinitions/Item/Tasks/TasksRequestBuilder.cs +++ b/src/generated/Print/TaskDefinitions/Item/Tasks/TasksRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Print.TaskDefinitions.Item.Tasks.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class TasksRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PrintTaskRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDefinitionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildTriggerCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDefinitionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildTriggerCommand()); return commands; } /// @@ -38,7 +37,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "A list of tasks that have been created based on this definition. The list includes currently running tasks and recently completed tasks. Read-only."; // Create options for all the parameters - var printTaskDefinitionIdOption = new Option("--printtaskdefinition-id", description: "key: id of printTaskDefinition") { + var printTaskDefinitionIdOption = new Option("--print-task-definition-id", description: "key: id of printTaskDefinition") { }; printTaskDefinitionIdOption.IsRequired = true; command.AddOption(printTaskDefinitionIdOption); @@ -46,21 +45,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string printTaskDefinitionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printTaskDefinitionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printTaskDefinitionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printTaskDefinitionIdOption, bodyOption, outputOption); return command; } /// @@ -70,7 +68,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "A list of tasks that have been created based on this definition. The list includes currently running tasks and recently completed tasks. Read-only."; // Create options for all the parameters - var printTaskDefinitionIdOption = new Option("--printtaskdefinition-id", description: "key: id of printTaskDefinition") { + var printTaskDefinitionIdOption = new Option("--print-task-definition-id", description: "key: id of printTaskDefinition") { }; printTaskDefinitionIdOption.IsRequired = true; command.AddOption(printTaskDefinitionIdOption); @@ -109,7 +107,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string printTaskDefinitionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printTaskDefinitionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -120,15 +122,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printTaskDefinitionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printTaskDefinitionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -183,31 +180,6 @@ public RequestInformation CreatePostRequestInformation(PrintTask body, Action - /// A list of tasks that have been created based on this definition. The list includes currently running tasks and recently completed tasks. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A list of tasks that have been created based on this definition. The list includes currently running tasks and recently completed tasks. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PrintTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A list of tasks that have been created based on this definition. The list includes currently running tasks and recently completed tasks. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Print/TaskDefinitions/TaskDefinitionsRequestBuilder.cs b/src/generated/Print/TaskDefinitions/TaskDefinitionsRequestBuilder.cs index f04229eea59..6e3996ec21e 100644 --- a/src/generated/Print/TaskDefinitions/TaskDefinitionsRequestBuilder.cs +++ b/src/generated/Print/TaskDefinitions/TaskDefinitionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Print.TaskDefinitions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class TaskDefinitionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PrintTaskDefinitionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildTasksCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildTasksCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(PrintTaskDefinition body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of abstract definition for a task that can be triggered when various events occur within Universal Print. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of abstract definition for a task that can be triggered when various events occur within Universal Print. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PrintTaskDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// List of abstract definition for a task that can be triggered when various events occur within Universal Print. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Privacy/PrivacyRequestBuilder.cs b/src/generated/Privacy/PrivacyRequestBuilder.cs index a54278faf4d..0ff8195c39d 100644 --- a/src/generated/Privacy/PrivacyRequestBuilder.cs +++ b/src/generated/Privacy/PrivacyRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Privacy.SubjectRightsRequests; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,20 +37,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -64,14 +63,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -79,6 +77,9 @@ public Command BuildPatchCommand() { public Command BuildSubjectRightsRequestsCommand() { var command = new Command("subject-rights-requests"); var builder = new ApiSdk.Privacy.SubjectRightsRequests.SubjectRightsRequestsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -135,31 +136,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get privacy - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update privacy - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Privacy model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get privacy public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Privacy/SubjectRightsRequests/Item/GetFinalAttachment/GetFinalAttachmentRequestBuilder.cs b/src/generated/Privacy/SubjectRightsRequests/Item/GetFinalAttachment/GetFinalAttachmentRequestBuilder.cs index 165c349ea71..90aa8767346 100644 --- a/src/generated/Privacy/SubjectRightsRequests/Item/GetFinalAttachment/GetFinalAttachmentRequestBuilder.cs +++ b/src/generated/Privacy/SubjectRightsRequests/Item/GetFinalAttachment/GetFinalAttachmentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,28 +25,30 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function getFinalAttachment"; // Create options for all the parameters - var subjectRightsRequestIdOption = new Option("--subjectrightsrequest-id", description: "key: id of subjectRightsRequest") { + var subjectRightsRequestIdOption = new Option("--subject-rights-request-id", description: "key: id of subjectRightsRequest") { }; subjectRightsRequestIdOption.IsRequired = true; command.AddOption(subjectRightsRequestIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string subjectRightsRequestId, FileInfo output) => { + command.SetHandler(async (string subjectRightsRequestId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, subjectRightsRequestIdOption, outputOption); + }, subjectRightsRequestIdOption, fileOption, outputOption); return command; } /// @@ -77,16 +79,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getFinalAttachment - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Privacy/SubjectRightsRequests/Item/GetFinalReport/GetFinalReportRequestBuilder.cs b/src/generated/Privacy/SubjectRightsRequests/Item/GetFinalReport/GetFinalReportRequestBuilder.cs index 08f166723bf..5972ad41c31 100644 --- a/src/generated/Privacy/SubjectRightsRequests/Item/GetFinalReport/GetFinalReportRequestBuilder.cs +++ b/src/generated/Privacy/SubjectRightsRequests/Item/GetFinalReport/GetFinalReportRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,28 +25,30 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function getFinalReport"; // Create options for all the parameters - var subjectRightsRequestIdOption = new Option("--subjectrightsrequest-id", description: "key: id of subjectRightsRequest") { + var subjectRightsRequestIdOption = new Option("--subject-rights-request-id", description: "key: id of subjectRightsRequest") { }; subjectRightsRequestIdOption.IsRequired = true; command.AddOption(subjectRightsRequestIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string subjectRightsRequestId, FileInfo output) => { + command.SetHandler(async (string subjectRightsRequestId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, subjectRightsRequestIdOption, outputOption); + }, subjectRightsRequestIdOption, fileOption, outputOption); return command; } /// @@ -77,16 +79,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getFinalReport - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Privacy/SubjectRightsRequests/Item/Notes/Item/AuthoredNoteRequestBuilder.cs b/src/generated/Privacy/SubjectRightsRequests/Item/Notes/Item/AuthoredNoteRequestBuilder.cs index 54791676cde..fc0dad4757b 100644 --- a/src/generated/Privacy/SubjectRightsRequests/Item/Notes/Item/AuthoredNoteRequestBuilder.cs +++ b/src/generated/Privacy/SubjectRightsRequests/Item/Notes/Item/AuthoredNoteRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "List of notes associcated with the request."; // Create options for all the parameters - var subjectRightsRequestIdOption = new Option("--subjectrightsrequest-id", description: "key: id of subjectRightsRequest") { + var subjectRightsRequestIdOption = new Option("--subject-rights-request-id", description: "key: id of subjectRightsRequest") { }; subjectRightsRequestIdOption.IsRequired = true; command.AddOption(subjectRightsRequestIdOption); - var authoredNoteIdOption = new Option("--authorednote-id", description: "key: id of authoredNote") { + var authoredNoteIdOption = new Option("--authored-note-id", description: "key: id of authoredNote") { }; authoredNoteIdOption.IsRequired = true; command.AddOption(authoredNoteIdOption); - command.SetHandler(async (string subjectRightsRequestId, string authoredNoteId) => { + command.SetHandler(async (string subjectRightsRequestId, string authoredNoteId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, subjectRightsRequestIdOption, authoredNoteIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "List of notes associcated with the request."; // Create options for all the parameters - var subjectRightsRequestIdOption = new Option("--subjectrightsrequest-id", description: "key: id of subjectRightsRequest") { + var subjectRightsRequestIdOption = new Option("--subject-rights-request-id", description: "key: id of subjectRightsRequest") { }; subjectRightsRequestIdOption.IsRequired = true; command.AddOption(subjectRightsRequestIdOption); - var authoredNoteIdOption = new Option("--authorednote-id", description: "key: id of authoredNote") { + var authoredNoteIdOption = new Option("--authored-note-id", description: "key: id of authoredNote") { }; authoredNoteIdOption.IsRequired = true; command.AddOption(authoredNoteIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string subjectRightsRequestId, string authoredNoteId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string subjectRightsRequestId, string authoredNoteId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, subjectRightsRequestIdOption, authoredNoteIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, subjectRightsRequestIdOption, authoredNoteIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "List of notes associcated with the request."; // Create options for all the parameters - var subjectRightsRequestIdOption = new Option("--subjectrightsrequest-id", description: "key: id of subjectRightsRequest") { + var subjectRightsRequestIdOption = new Option("--subject-rights-request-id", description: "key: id of subjectRightsRequest") { }; subjectRightsRequestIdOption.IsRequired = true; command.AddOption(subjectRightsRequestIdOption); - var authoredNoteIdOption = new Option("--authorednote-id", description: "key: id of authoredNote") { + var authoredNoteIdOption = new Option("--authored-note-id", description: "key: id of authoredNote") { }; authoredNoteIdOption.IsRequired = true; command.AddOption(authoredNoteIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string subjectRightsRequestId, string authoredNoteId, string body) => { + command.SetHandler(async (string subjectRightsRequestId, string authoredNoteId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, subjectRightsRequestIdOption, authoredNoteIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(AuthoredNote body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of notes associcated with the request. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of notes associcated with the request. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of notes associcated with the request. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AuthoredNote model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// List of notes associcated with the request. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Privacy/SubjectRightsRequests/Item/Notes/NotesRequestBuilder.cs b/src/generated/Privacy/SubjectRightsRequests/Item/Notes/NotesRequestBuilder.cs index b466fe609b4..dd4877018f5 100644 --- a/src/generated/Privacy/SubjectRightsRequests/Item/Notes/NotesRequestBuilder.cs +++ b/src/generated/Privacy/SubjectRightsRequests/Item/Notes/NotesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Privacy.SubjectRightsRequests.Item.Notes.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class NotesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AuthoredNoteRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "List of notes associcated with the request."; // Create options for all the parameters - var subjectRightsRequestIdOption = new Option("--subjectrightsrequest-id", description: "key: id of subjectRightsRequest") { + var subjectRightsRequestIdOption = new Option("--subject-rights-request-id", description: "key: id of subjectRightsRequest") { }; subjectRightsRequestIdOption.IsRequired = true; command.AddOption(subjectRightsRequestIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string subjectRightsRequestId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string subjectRightsRequestId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, subjectRightsRequestIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, subjectRightsRequestIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "List of notes associcated with the request."; // Create options for all the parameters - var subjectRightsRequestIdOption = new Option("--subjectrightsrequest-id", description: "key: id of subjectRightsRequest") { + var subjectRightsRequestIdOption = new Option("--subject-rights-request-id", description: "key: id of subjectRightsRequest") { }; subjectRightsRequestIdOption.IsRequired = true; command.AddOption(subjectRightsRequestIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string subjectRightsRequestId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string subjectRightsRequestId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, subjectRightsRequestIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, subjectRightsRequestIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(AuthoredNote body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of notes associcated with the request. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of notes associcated with the request. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AuthoredNote model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// List of notes associcated with the request. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Privacy/SubjectRightsRequests/Item/SubjectRightsRequestRequestBuilder.cs b/src/generated/Privacy/SubjectRightsRequests/Item/SubjectRightsRequestRequestBuilder.cs index 5530ba12fb0..d28e9e2182e 100644 --- a/src/generated/Privacy/SubjectRightsRequests/Item/SubjectRightsRequestRequestBuilder.cs +++ b/src/generated/Privacy/SubjectRightsRequests/Item/SubjectRightsRequestRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Privacy.SubjectRightsRequests.Item.Team; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property subjectRightsRequests for privacy"; // Create options for all the parameters - var subjectRightsRequestIdOption = new Option("--subjectrightsrequest-id", description: "key: id of subjectRightsRequest") { + var subjectRightsRequestIdOption = new Option("--subject-rights-request-id", description: "key: id of subjectRightsRequest") { }; subjectRightsRequestIdOption.IsRequired = true; command.AddOption(subjectRightsRequestIdOption); - command.SetHandler(async (string subjectRightsRequestId) => { + command.SetHandler(async (string subjectRightsRequestId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, subjectRightsRequestIdOption); return command; @@ -50,7 +49,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get subjectRightsRequests from privacy"; // Create options for all the parameters - var subjectRightsRequestIdOption = new Option("--subjectrightsrequest-id", description: "key: id of subjectRightsRequest") { + var subjectRightsRequestIdOption = new Option("--subject-rights-request-id", description: "key: id of subjectRightsRequest") { }; subjectRightsRequestIdOption.IsRequired = true; command.AddOption(subjectRightsRequestIdOption); @@ -64,25 +63,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string subjectRightsRequestId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string subjectRightsRequestId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, subjectRightsRequestIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, subjectRightsRequestIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildNotesCommand() { var command = new Command("notes"); var builder = new ApiSdk.Privacy.SubjectRightsRequests.Item.Notes.NotesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -94,7 +95,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property subjectRightsRequests in privacy"; // Create options for all the parameters - var subjectRightsRequestIdOption = new Option("--subjectrightsrequest-id", description: "key: id of subjectRightsRequest") { + var subjectRightsRequestIdOption = new Option("--subject-rights-request-id", description: "key: id of subjectRightsRequest") { }; subjectRightsRequestIdOption.IsRequired = true; command.AddOption(subjectRightsRequestIdOption); @@ -102,14 +103,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string subjectRightsRequestId, string body) => { + command.SetHandler(async (string subjectRightsRequestId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, subjectRightsRequestIdOption, bodyOption); return command; @@ -189,29 +189,6 @@ public RequestInformation CreatePatchRequestInformation(SubjectRightsRequest bod return requestInfo; } /// - /// Delete navigation property subjectRightsRequests for privacy - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get subjectRightsRequests from privacy - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \privacy\subjectRightsRequests\{subjectRightsRequest-id}\microsoft.graph.getFinalAttachment() /// public GetFinalAttachmentRequestBuilder GetFinalAttachment() { @@ -223,19 +200,6 @@ public GetFinalAttachmentRequestBuilder GetFinalAttachment() { public GetFinalReportRequestBuilder GetFinalReport() { return new GetFinalReportRequestBuilder(PathParameters, RequestAdapter); } - /// - /// Update the navigation property subjectRightsRequests in privacy - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SubjectRightsRequest model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get subjectRightsRequests from privacy public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Privacy/SubjectRightsRequests/Item/Team/@Ref/@Ref.cs b/src/generated/Privacy/SubjectRightsRequests/Item/Team/@Ref/@Ref.cs deleted file mode 100644 index 4a2c4ced4af..00000000000 --- a/src/generated/Privacy/SubjectRightsRequests/Item/Team/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Privacy.SubjectRightsRequests.Item.Team.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Privacy/SubjectRightsRequests/Item/Team/@Ref/RefRequestBuilder.cs b/src/generated/Privacy/SubjectRightsRequests/Item/Team/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 6c4d29a4819..00000000000 --- a/src/generated/Privacy/SubjectRightsRequests/Item/Team/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Privacy.SubjectRightsRequests.Item.Team.@Ref { - /// Builds and executes requests for operations under \privacy\subjectRightsRequests\{subjectRightsRequest-id}\team\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Information about the Microsoft Teams team that was created for the request. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Information about the Microsoft Teams team that was created for the request."; - // Create options for all the parameters - var subjectRightsRequestIdOption = new Option("--subjectrightsrequest-id", description: "key: id of subjectRightsRequest") { - }; - subjectRightsRequestIdOption.IsRequired = true; - command.AddOption(subjectRightsRequestIdOption); - command.SetHandler(async (string subjectRightsRequestId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, subjectRightsRequestIdOption); - return command; - } - /// - /// Information about the Microsoft Teams team that was created for the request. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Information about the Microsoft Teams team that was created for the request."; - // Create options for all the parameters - var subjectRightsRequestIdOption = new Option("--subjectrightsrequest-id", description: "key: id of subjectRightsRequest") { - }; - subjectRightsRequestIdOption.IsRequired = true; - command.AddOption(subjectRightsRequestIdOption); - command.SetHandler(async (string subjectRightsRequestId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, subjectRightsRequestIdOption); - return command; - } - /// - /// Information about the Microsoft Teams team that was created for the request. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Information about the Microsoft Teams team that was created for the request."; - // Create options for all the parameters - var subjectRightsRequestIdOption = new Option("--subjectrightsrequest-id", description: "key: id of subjectRightsRequest") { - }; - subjectRightsRequestIdOption.IsRequired = true; - command.AddOption(subjectRightsRequestIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string subjectRightsRequestId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, subjectRightsRequestIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/privacy/subjectRightsRequests/{subjectRightsRequest_id}/team/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Information about the Microsoft Teams team that was created for the request. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Information about the Microsoft Teams team that was created for the request. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Information about the Microsoft Teams team that was created for the request. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Privacy.SubjectRightsRequests.Item.Team.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Information about the Microsoft Teams team that was created for the request. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Information about the Microsoft Teams team that was created for the request. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Information about the Microsoft Teams team that was created for the request. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Privacy.SubjectRightsRequests.Item.Team.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Privacy/SubjectRightsRequests/Item/Team/Ref/Ref.cs b/src/generated/Privacy/SubjectRightsRequests/Item/Team/Ref/Ref.cs new file mode 100644 index 00000000000..44303560888 --- /dev/null +++ b/src/generated/Privacy/SubjectRightsRequests/Item/Team/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Privacy.SubjectRightsRequests.Item.Team.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Privacy/SubjectRightsRequests/Item/Team/Ref/RefRequestBuilder.cs b/src/generated/Privacy/SubjectRightsRequests/Item/Team/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..1a4b4bb5202 --- /dev/null +++ b/src/generated/Privacy/SubjectRightsRequests/Item/Team/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Privacy.SubjectRightsRequests.Item.Team.Ref { + /// Builds and executes requests for operations under \privacy\subjectRightsRequests\{subjectRightsRequest-id}\team\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Information about the Microsoft Teams team that was created for the request. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Information about the Microsoft Teams team that was created for the request."; + // Create options for all the parameters + var subjectRightsRequestIdOption = new Option("--subject-rights-request-id", description: "key: id of subjectRightsRequest") { + }; + subjectRightsRequestIdOption.IsRequired = true; + command.AddOption(subjectRightsRequestIdOption); + command.SetHandler(async (string subjectRightsRequestId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, subjectRightsRequestIdOption); + return command; + } + /// + /// Information about the Microsoft Teams team that was created for the request. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Information about the Microsoft Teams team that was created for the request."; + // Create options for all the parameters + var subjectRightsRequestIdOption = new Option("--subject-rights-request-id", description: "key: id of subjectRightsRequest") { + }; + subjectRightsRequestIdOption.IsRequired = true; + command.AddOption(subjectRightsRequestIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string subjectRightsRequestId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, subjectRightsRequestIdOption, outputOption); + return command; + } + /// + /// Information about the Microsoft Teams team that was created for the request. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Information about the Microsoft Teams team that was created for the request."; + // Create options for all the parameters + var subjectRightsRequestIdOption = new Option("--subject-rights-request-id", description: "key: id of subjectRightsRequest") { + }; + subjectRightsRequestIdOption.IsRequired = true; + command.AddOption(subjectRightsRequestIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string subjectRightsRequestId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, subjectRightsRequestIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/privacy/subjectRightsRequests/{subjectRightsRequest_id}/team/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Information about the Microsoft Teams team that was created for the request. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Information about the Microsoft Teams team that was created for the request. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Information about the Microsoft Teams team that was created for the request. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Privacy.SubjectRightsRequests.Item.Team.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Privacy/SubjectRightsRequests/Item/Team/TeamRequestBuilder.cs b/src/generated/Privacy/SubjectRightsRequests/Item/Team/TeamRequestBuilder.cs index dd7a51919fb..78e07877614 100644 --- a/src/generated/Privacy/SubjectRightsRequests/Item/Team/TeamRequestBuilder.cs +++ b/src/generated/Privacy/SubjectRightsRequests/Item/Team/TeamRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Privacy.SubjectRightsRequests.Item.Team.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Information about the Microsoft Teams team that was created for the request."; // Create options for all the parameters - var subjectRightsRequestIdOption = new Option("--subjectrightsrequest-id", description: "key: id of subjectRightsRequest") { + var subjectRightsRequestIdOption = new Option("--subject-rights-request-id", description: "key: id of subjectRightsRequest") { }; subjectRightsRequestIdOption.IsRequired = true; command.AddOption(subjectRightsRequestIdOption); @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string subjectRightsRequestId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string subjectRightsRequestId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, subjectRightsRequestIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, subjectRightsRequestIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Privacy.SubjectRightsRequests.Item.Team.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Privacy.SubjectRightsRequests.Item.Team.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Information about the Microsoft Teams team that was created for the request. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Information about the Microsoft Teams team that was created for the request. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Privacy/SubjectRightsRequests/SubjectRightsRequestsRequestBuilder.cs b/src/generated/Privacy/SubjectRightsRequests/SubjectRightsRequestsRequestBuilder.cs index 842add2fcaf..6eed5ca89ba 100644 --- a/src/generated/Privacy/SubjectRightsRequests/SubjectRightsRequestsRequestBuilder.cs +++ b/src/generated/Privacy/SubjectRightsRequests/SubjectRightsRequestsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Privacy.SubjectRightsRequests.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SubjectRightsRequestsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SubjectRightsRequestRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildNotesCommand(), - builder.BuildPatchCommand(), - builder.BuildTeamCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildNotesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildTeamCommand()); return commands; } /// @@ -42,21 +41,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -101,7 +99,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -112,15 +114,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -175,31 +172,6 @@ public RequestInformation CreatePostRequestInformation(SubjectRightsRequest body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get subjectRightsRequests from privacy - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to subjectRightsRequests for privacy - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SubjectRightsRequest model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get subjectRightsRequests from privacy public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Reports/DailyPrintUsageByPrinter/DailyPrintUsageByPrinterRequestBuilder.cs b/src/generated/Reports/DailyPrintUsageByPrinter/DailyPrintUsageByPrinterRequestBuilder.cs index f2483e2dab0..57e55091a7e 100644 --- a/src/generated/Reports/DailyPrintUsageByPrinter/DailyPrintUsageByPrinterRequestBuilder.cs +++ b/src/generated/Reports/DailyPrintUsageByPrinter/DailyPrintUsageByPrinterRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Reports.DailyPrintUsageByPrinter.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DailyPrintUsageByPrinterRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PrintUsageByPrinterRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(PrintUsageByPrinter body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get dailyPrintUsageByPrinter from reports - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to dailyPrintUsageByPrinter for reports - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PrintUsageByPrinter model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get dailyPrintUsageByPrinter from reports public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Reports/DailyPrintUsageByPrinter/Item/PrintUsageByPrinterRequestBuilder.cs b/src/generated/Reports/DailyPrintUsageByPrinter/Item/PrintUsageByPrinterRequestBuilder.cs index 245604a5f92..18cfb7d28da 100644 --- a/src/generated/Reports/DailyPrintUsageByPrinter/Item/PrintUsageByPrinterRequestBuilder.cs +++ b/src/generated/Reports/DailyPrintUsageByPrinter/Item/PrintUsageByPrinterRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property dailyPrintUsageByPrinter for reports"; // Create options for all the parameters - var printUsageByPrinterIdOption = new Option("--printusagebyprinter-id", description: "key: id of printUsageByPrinter") { + var printUsageByPrinterIdOption = new Option("--print-usage-by-printer-id", description: "key: id of printUsageByPrinter") { }; printUsageByPrinterIdOption.IsRequired = true; command.AddOption(printUsageByPrinterIdOption); - command.SetHandler(async (string printUsageByPrinterId) => { + command.SetHandler(async (string printUsageByPrinterId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printUsageByPrinterIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get dailyPrintUsageByPrinter from reports"; // Create options for all the parameters - var printUsageByPrinterIdOption = new Option("--printusagebyprinter-id", description: "key: id of printUsageByPrinter") { + var printUsageByPrinterIdOption = new Option("--print-usage-by-printer-id", description: "key: id of printUsageByPrinter") { }; printUsageByPrinterIdOption.IsRequired = true; command.AddOption(printUsageByPrinterIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string printUsageByPrinterId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printUsageByPrinterId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printUsageByPrinterIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printUsageByPrinterIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property dailyPrintUsageByPrinter in reports"; // Create options for all the parameters - var printUsageByPrinterIdOption = new Option("--printusagebyprinter-id", description: "key: id of printUsageByPrinter") { + var printUsageByPrinterIdOption = new Option("--print-usage-by-printer-id", description: "key: id of printUsageByPrinter") { }; printUsageByPrinterIdOption.IsRequired = true; command.AddOption(printUsageByPrinterIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string printUsageByPrinterId, string body) => { + command.SetHandler(async (string printUsageByPrinterId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printUsageByPrinterIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(PrintUsageByPrinter body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property dailyPrintUsageByPrinter for reports - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get dailyPrintUsageByPrinter from reports - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property dailyPrintUsageByPrinter in reports - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PrintUsageByPrinter model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get dailyPrintUsageByPrinter from reports public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Reports/DailyPrintUsageByUser/DailyPrintUsageByUserRequestBuilder.cs b/src/generated/Reports/DailyPrintUsageByUser/DailyPrintUsageByUserRequestBuilder.cs index 1adcaf93dbc..40481e05198 100644 --- a/src/generated/Reports/DailyPrintUsageByUser/DailyPrintUsageByUserRequestBuilder.cs +++ b/src/generated/Reports/DailyPrintUsageByUser/DailyPrintUsageByUserRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Reports.DailyPrintUsageByUser.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DailyPrintUsageByUserRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PrintUsageByUserRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(PrintUsageByUser body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get dailyPrintUsageByUser from reports - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to dailyPrintUsageByUser for reports - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PrintUsageByUser model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get dailyPrintUsageByUser from reports public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Reports/DailyPrintUsageByUser/Item/PrintUsageByUserRequestBuilder.cs b/src/generated/Reports/DailyPrintUsageByUser/Item/PrintUsageByUserRequestBuilder.cs index 43ddcf1e997..47c02fc2e48 100644 --- a/src/generated/Reports/DailyPrintUsageByUser/Item/PrintUsageByUserRequestBuilder.cs +++ b/src/generated/Reports/DailyPrintUsageByUser/Item/PrintUsageByUserRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property dailyPrintUsageByUser for reports"; // Create options for all the parameters - var printUsageByUserIdOption = new Option("--printusagebyuser-id", description: "key: id of printUsageByUser") { + var printUsageByUserIdOption = new Option("--print-usage-by-user-id", description: "key: id of printUsageByUser") { }; printUsageByUserIdOption.IsRequired = true; command.AddOption(printUsageByUserIdOption); - command.SetHandler(async (string printUsageByUserId) => { + command.SetHandler(async (string printUsageByUserId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printUsageByUserIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get dailyPrintUsageByUser from reports"; // Create options for all the parameters - var printUsageByUserIdOption = new Option("--printusagebyuser-id", description: "key: id of printUsageByUser") { + var printUsageByUserIdOption = new Option("--print-usage-by-user-id", description: "key: id of printUsageByUser") { }; printUsageByUserIdOption.IsRequired = true; command.AddOption(printUsageByUserIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string printUsageByUserId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printUsageByUserId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printUsageByUserIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printUsageByUserIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property dailyPrintUsageByUser in reports"; // Create options for all the parameters - var printUsageByUserIdOption = new Option("--printusagebyuser-id", description: "key: id of printUsageByUser") { + var printUsageByUserIdOption = new Option("--print-usage-by-user-id", description: "key: id of printUsageByUser") { }; printUsageByUserIdOption.IsRequired = true; command.AddOption(printUsageByUserIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string printUsageByUserId, string body) => { + command.SetHandler(async (string printUsageByUserId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printUsageByUserIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(PrintUsageByUser body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property dailyPrintUsageByUser for reports - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get dailyPrintUsageByUser from reports - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property dailyPrintUsageByUser in reports - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PrintUsageByUser model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get dailyPrintUsageByUser from reports public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Reports/DeviceConfigurationDeviceActivity/DeviceConfigurationDeviceActivityRequestBuilder.cs b/src/generated/Reports/DeviceConfigurationDeviceActivity/DeviceConfigurationDeviceActivityRequestBuilder.cs index 39bdbbfc4a1..5c200e6e456 100644 --- a/src/generated/Reports/DeviceConfigurationDeviceActivity/DeviceConfigurationDeviceActivityRequestBuilder.cs +++ b/src/generated/Reports/DeviceConfigurationDeviceActivity/DeviceConfigurationDeviceActivityRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,18 +26,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Metadata for the device configuration device activity report"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -68,17 +67,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Metadata for the device configuration device activity report - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes report public class DeviceConfigurationDeviceActivityResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Reports/DeviceConfigurationUserActivity/DeviceConfigurationUserActivityRequestBuilder.cs b/src/generated/Reports/DeviceConfigurationUserActivity/DeviceConfigurationUserActivityRequestBuilder.cs index 4f1f0ab738a..b106bf835d9 100644 --- a/src/generated/Reports/DeviceConfigurationUserActivity/DeviceConfigurationUserActivityRequestBuilder.cs +++ b/src/generated/Reports/DeviceConfigurationUserActivity/DeviceConfigurationUserActivityRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,18 +26,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Metadata for the device configuration user activity report"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -68,17 +67,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Metadata for the device configuration user activity report - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes report public class DeviceConfigurationUserActivityResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Reports/GetEmailActivityCountsWithPeriod/GetEmailActivityCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetEmailActivityCountsWithPeriod/GetEmailActivityCountsWithPeriodRequestBuilder.cs index 904e0b29d55..0903223ed98 100644 --- a/src/generated/Reports/GetEmailActivityCountsWithPeriod/GetEmailActivityCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetEmailActivityCountsWithPeriod/GetEmailActivityCountsWithPeriodRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string period, FileInfo output) => { + command.SetHandler(async (string period, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, periodOption, outputOption); + }, periodOption, fileOption, outputOption); return command; } /// @@ -79,16 +81,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getEmailActivityCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetEmailActivityUserCountsWithPeriod/GetEmailActivityUserCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetEmailActivityUserCountsWithPeriod/GetEmailActivityUserCountsWithPeriodRequestBuilder.cs index 87f9b1d4d79..2ec0863a0ab 100644 --- a/src/generated/Reports/GetEmailActivityUserCountsWithPeriod/GetEmailActivityUserCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetEmailActivityUserCountsWithPeriod/GetEmailActivityUserCountsWithPeriodRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string period, FileInfo output) => { + command.SetHandler(async (string period, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, periodOption, outputOption); + }, periodOption, fileOption, outputOption); return command; } /// @@ -79,16 +81,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getEmailActivityUserCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetEmailActivityUserDetailWithDate/GetEmailActivityUserDetailWithDateRequestBuilder.cs b/src/generated/Reports/GetEmailActivityUserDetailWithDate/GetEmailActivityUserDetailWithDateRequestBuilder.cs index da84fb101b5..65bc7008641 100644 --- a/src/generated/Reports/GetEmailActivityUserDetailWithDate/GetEmailActivityUserDetailWithDateRequestBuilder.cs +++ b/src/generated/Reports/GetEmailActivityUserDetailWithDate/GetEmailActivityUserDetailWithDateRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; dateOption.IsRequired = true; command.AddOption(dateOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string date, FileInfo output) => { + command.SetHandler(async (string date, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, dateOption, outputOption); + }, dateOption, fileOption, outputOption); return command; } /// @@ -55,7 +57,7 @@ public Command BuildGetCommand() { /// Path parameters for the request /// The request adapter to use to execute the requests. /// - public GetEmailActivityUserDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, string date = default) { + public GetEmailActivityUserDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, Date? date = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); UrlTemplate = "{+baseurl}/reports/microsoft.graph.getEmailActivityUserDetail(date={date})"; @@ -79,16 +81,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getEmailActivityUserDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetEmailActivityUserDetailWithPeriod/GetEmailActivityUserDetailWithPeriodRequestBuilder.cs b/src/generated/Reports/GetEmailActivityUserDetailWithPeriod/GetEmailActivityUserDetailWithPeriodRequestBuilder.cs index e23e1169328..8d37af7aa15 100644 --- a/src/generated/Reports/GetEmailActivityUserDetailWithPeriod/GetEmailActivityUserDetailWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetEmailActivityUserDetailWithPeriod/GetEmailActivityUserDetailWithPeriodRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string period, FileInfo output) => { + command.SetHandler(async (string period, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, periodOption, outputOption); + }, periodOption, fileOption, outputOption); return command; } /// @@ -79,16 +81,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getEmailActivityUserDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetEmailAppUsageAppsUserCountsWithPeriod/GetEmailAppUsageAppsUserCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetEmailAppUsageAppsUserCountsWithPeriod/GetEmailAppUsageAppsUserCountsWithPeriodRequestBuilder.cs index 3d8feca2304..b2904df0d47 100644 --- a/src/generated/Reports/GetEmailAppUsageAppsUserCountsWithPeriod/GetEmailAppUsageAppsUserCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetEmailAppUsageAppsUserCountsWithPeriod/GetEmailAppUsageAppsUserCountsWithPeriodRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string period, FileInfo output) => { + command.SetHandler(async (string period, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, periodOption, outputOption); + }, periodOption, fileOption, outputOption); return command; } /// @@ -79,16 +81,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getEmailAppUsageAppsUserCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetEmailAppUsageUserCountsWithPeriod/GetEmailAppUsageUserCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetEmailAppUsageUserCountsWithPeriod/GetEmailAppUsageUserCountsWithPeriodRequestBuilder.cs index 92dae393177..40dcb56bac6 100644 --- a/src/generated/Reports/GetEmailAppUsageUserCountsWithPeriod/GetEmailAppUsageUserCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetEmailAppUsageUserCountsWithPeriod/GetEmailAppUsageUserCountsWithPeriodRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string period, FileInfo output) => { + command.SetHandler(async (string period, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, periodOption, outputOption); + }, periodOption, fileOption, outputOption); return command; } /// @@ -79,16 +81,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getEmailAppUsageUserCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetEmailAppUsageUserDetailWithDate/GetEmailAppUsageUserDetailWithDateRequestBuilder.cs b/src/generated/Reports/GetEmailAppUsageUserDetailWithDate/GetEmailAppUsageUserDetailWithDateRequestBuilder.cs index 54de288fb59..0bdba97b0ea 100644 --- a/src/generated/Reports/GetEmailAppUsageUserDetailWithDate/GetEmailAppUsageUserDetailWithDateRequestBuilder.cs +++ b/src/generated/Reports/GetEmailAppUsageUserDetailWithDate/GetEmailAppUsageUserDetailWithDateRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; dateOption.IsRequired = true; command.AddOption(dateOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string date, FileInfo output) => { + command.SetHandler(async (string date, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, dateOption, outputOption); + }, dateOption, fileOption, outputOption); return command; } /// @@ -55,7 +57,7 @@ public Command BuildGetCommand() { /// Path parameters for the request /// The request adapter to use to execute the requests. /// - public GetEmailAppUsageUserDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, string date = default) { + public GetEmailAppUsageUserDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, Date? date = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); UrlTemplate = "{+baseurl}/reports/microsoft.graph.getEmailAppUsageUserDetail(date={date})"; @@ -79,16 +81,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getEmailAppUsageUserDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetEmailAppUsageUserDetailWithPeriod/GetEmailAppUsageUserDetailWithPeriodRequestBuilder.cs b/src/generated/Reports/GetEmailAppUsageUserDetailWithPeriod/GetEmailAppUsageUserDetailWithPeriodRequestBuilder.cs index e526eb82fc8..1f6fc4ff381 100644 --- a/src/generated/Reports/GetEmailAppUsageUserDetailWithPeriod/GetEmailAppUsageUserDetailWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetEmailAppUsageUserDetailWithPeriod/GetEmailAppUsageUserDetailWithPeriodRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string period, FileInfo output) => { + command.SetHandler(async (string period, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, periodOption, outputOption); + }, periodOption, fileOption, outputOption); return command; } /// @@ -79,16 +81,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getEmailAppUsageUserDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetEmailAppUsageVersionsUserCountsWithPeriod/GetEmailAppUsageVersionsUserCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetEmailAppUsageVersionsUserCountsWithPeriod/GetEmailAppUsageVersionsUserCountsWithPeriodRequestBuilder.cs index 4ad7356ddf1..1c1c70e7486 100644 --- a/src/generated/Reports/GetEmailAppUsageVersionsUserCountsWithPeriod/GetEmailAppUsageVersionsUserCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetEmailAppUsageVersionsUserCountsWithPeriod/GetEmailAppUsageVersionsUserCountsWithPeriodRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string period, FileInfo output) => { + command.SetHandler(async (string period, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, periodOption, outputOption); + }, periodOption, fileOption, outputOption); return command; } /// @@ -79,16 +81,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getEmailAppUsageVersionsUserCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetGroupArchivedPrintJobsWithGroupIdWithStartDateTimeWithEndDateTime/GetGroupArchivedPrintJobsWithGroupIdWithStartDateTimeWithEndDateTimeRequestBuilder.cs b/src/generated/Reports/GetGroupArchivedPrintJobsWithGroupIdWithStartDateTimeWithEndDateTime/GetGroupArchivedPrintJobsWithGroupIdWithStartDateTimeWithEndDateTimeRequestBuilder.cs index 45d3c2e763b..42093e222ce 100644 --- a/src/generated/Reports/GetGroupArchivedPrintJobsWithGroupIdWithStartDateTimeWithEndDateTime/GetGroupArchivedPrintJobsWithGroupIdWithStartDateTimeWithEndDateTimeRequestBuilder.cs +++ b/src/generated/Reports/GetGroupArchivedPrintJobsWithGroupIdWithStartDateTimeWithEndDateTime/GetGroupArchivedPrintJobsWithGroupIdWithStartDateTimeWithEndDateTimeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,30 +25,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function getGroupArchivedPrintJobs"; // Create options for all the parameters - var groupIdOption = new Option("--groupid", description: "Usage: groupId={groupId}") { + var groupIdOption = new Option("--group-id", description: "Usage: groupId={groupId}") { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - var startDateTimeOption = new Option("--startdatetime", description: "Usage: startDateTime={startDateTime}") { + var startDateTimeOption = new Option("--start-date-time", description: "Usage: startDateTime={startDateTime}") { }; startDateTimeOption.IsRequired = true; command.AddOption(startDateTimeOption); - var endDateTimeOption = new Option("--enddatetime", description: "Usage: endDateTime={endDateTime}") { + var endDateTimeOption = new Option("--end-date-time", description: "Usage: endDateTime={endDateTime}") { }; endDateTimeOption.IsRequired = true; command.AddOption(endDateTimeOption); - command.SetHandler(async (string groupId, string startDateTime, string endDateTime) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string groupId, string startDateTime, string endDateTime, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, groupIdOption, startDateTimeOption, endDateTimeOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, groupIdOption, startDateTimeOption, endDateTimeOption, outputOption); return command; } /// @@ -85,16 +84,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getGroupArchivedPrintJobs - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetMailboxUsageDetailWithPeriod/GetMailboxUsageDetailWithPeriodRequestBuilder.cs b/src/generated/Reports/GetMailboxUsageDetailWithPeriod/GetMailboxUsageDetailWithPeriodRequestBuilder.cs index 4255a2027a6..b89a99848d7 100644 --- a/src/generated/Reports/GetMailboxUsageDetailWithPeriod/GetMailboxUsageDetailWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetMailboxUsageDetailWithPeriod/GetMailboxUsageDetailWithPeriodRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string period, FileInfo output) => { + command.SetHandler(async (string period, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, periodOption, outputOption); + }, periodOption, fileOption, outputOption); return command; } /// @@ -79,16 +81,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getMailboxUsageDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetMailboxUsageMailboxCountsWithPeriod/GetMailboxUsageMailboxCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetMailboxUsageMailboxCountsWithPeriod/GetMailboxUsageMailboxCountsWithPeriodRequestBuilder.cs index 0adbbb94b8c..c68206028ca 100644 --- a/src/generated/Reports/GetMailboxUsageMailboxCountsWithPeriod/GetMailboxUsageMailboxCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetMailboxUsageMailboxCountsWithPeriod/GetMailboxUsageMailboxCountsWithPeriodRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string period, FileInfo output) => { + command.SetHandler(async (string period, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, periodOption, outputOption); + }, periodOption, fileOption, outputOption); return command; } /// @@ -79,16 +81,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getMailboxUsageMailboxCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetMailboxUsageQuotaStatusMailboxCountsWithPeriod/GetMailboxUsageQuotaStatusMailboxCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetMailboxUsageQuotaStatusMailboxCountsWithPeriod/GetMailboxUsageQuotaStatusMailboxCountsWithPeriodRequestBuilder.cs index aa6bbbeb7c9..60ac86e5620 100644 --- a/src/generated/Reports/GetMailboxUsageQuotaStatusMailboxCountsWithPeriod/GetMailboxUsageQuotaStatusMailboxCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetMailboxUsageQuotaStatusMailboxCountsWithPeriod/GetMailboxUsageQuotaStatusMailboxCountsWithPeriodRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string period, FileInfo output) => { + command.SetHandler(async (string period, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, periodOption, outputOption); + }, periodOption, fileOption, outputOption); return command; } /// @@ -79,16 +81,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getMailboxUsageQuotaStatusMailboxCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetMailboxUsageStorageWithPeriod/GetMailboxUsageStorageWithPeriodRequestBuilder.cs b/src/generated/Reports/GetMailboxUsageStorageWithPeriod/GetMailboxUsageStorageWithPeriodRequestBuilder.cs index 55536765654..e038a58b369 100644 --- a/src/generated/Reports/GetMailboxUsageStorageWithPeriod/GetMailboxUsageStorageWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetMailboxUsageStorageWithPeriod/GetMailboxUsageStorageWithPeriodRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string period, FileInfo output) => { + command.SetHandler(async (string period, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, periodOption, outputOption); + }, periodOption, fileOption, outputOption); return command; } /// @@ -79,16 +81,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getMailboxUsageStorage - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetOffice365ActivationCounts/GetOffice365ActivationCountsRequestBuilder.cs b/src/generated/Reports/GetOffice365ActivationCounts/GetOffice365ActivationCountsRequestBuilder.cs index 27edb69cf7c..fcdfedd51ba 100644 --- a/src/generated/Reports/GetOffice365ActivationCounts/GetOffice365ActivationCountsRequestBuilder.cs +++ b/src/generated/Reports/GetOffice365ActivationCounts/GetOffice365ActivationCountsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,18 +26,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function getOffice365ActivationCounts"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -68,16 +67,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getOffice365ActivationCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetOffice365ActivationsUserCounts/GetOffice365ActivationsUserCountsRequestBuilder.cs b/src/generated/Reports/GetOffice365ActivationsUserCounts/GetOffice365ActivationsUserCountsRequestBuilder.cs index ec7864fd2a7..58eae12500e 100644 --- a/src/generated/Reports/GetOffice365ActivationsUserCounts/GetOffice365ActivationsUserCountsRequestBuilder.cs +++ b/src/generated/Reports/GetOffice365ActivationsUserCounts/GetOffice365ActivationsUserCountsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,18 +26,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function getOffice365ActivationsUserCounts"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -68,16 +67,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getOffice365ActivationsUserCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetOffice365ActivationsUserDetail/GetOffice365ActivationsUserDetailRequestBuilder.cs b/src/generated/Reports/GetOffice365ActivationsUserDetail/GetOffice365ActivationsUserDetailRequestBuilder.cs index 4d5b750e9e2..aac8af10127 100644 --- a/src/generated/Reports/GetOffice365ActivationsUserDetail/GetOffice365ActivationsUserDetailRequestBuilder.cs +++ b/src/generated/Reports/GetOffice365ActivationsUserDetail/GetOffice365ActivationsUserDetailRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,18 +26,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function getOffice365ActivationsUserDetail"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -68,16 +67,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getOffice365ActivationsUserDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetOffice365ActiveUserCountsWithPeriod/GetOffice365ActiveUserCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetOffice365ActiveUserCountsWithPeriod/GetOffice365ActiveUserCountsWithPeriodRequestBuilder.cs index 59e1de22a00..b1af7e70c3d 100644 --- a/src/generated/Reports/GetOffice365ActiveUserCountsWithPeriod/GetOffice365ActiveUserCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetOffice365ActiveUserCountsWithPeriod/GetOffice365ActiveUserCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getOffice365ActiveUserCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetOffice365ActiveUserDetailWithDate/GetOffice365ActiveUserDetailWithDateRequestBuilder.cs b/src/generated/Reports/GetOffice365ActiveUserDetailWithDate/GetOffice365ActiveUserDetailWithDateRequestBuilder.cs index 6fae68d3413..3e18b9bf7f9 100644 --- a/src/generated/Reports/GetOffice365ActiveUserDetailWithDate/GetOffice365ActiveUserDetailWithDateRequestBuilder.cs +++ b/src/generated/Reports/GetOffice365ActiveUserDetailWithDate/GetOffice365ActiveUserDetailWithDateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; dateOption.IsRequired = true; command.AddOption(dateOption); - command.SetHandler(async (string date) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string date, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, dateOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, dateOption, outputOption); return command; } /// @@ -50,7 +49,7 @@ public Command BuildGetCommand() { /// Path parameters for the request /// The request adapter to use to execute the requests. /// - public GetOffice365ActiveUserDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, string date = default) { + public GetOffice365ActiveUserDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, Date? date = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); UrlTemplate = "{+baseurl}/reports/microsoft.graph.getOffice365ActiveUserDetail(date={date})"; @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getOffice365ActiveUserDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetOffice365ActiveUserDetailWithPeriod/GetOffice365ActiveUserDetailWithPeriodRequestBuilder.cs b/src/generated/Reports/GetOffice365ActiveUserDetailWithPeriod/GetOffice365ActiveUserDetailWithPeriodRequestBuilder.cs index 4a02d6c2694..9f4534a7e72 100644 --- a/src/generated/Reports/GetOffice365ActiveUserDetailWithPeriod/GetOffice365ActiveUserDetailWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetOffice365ActiveUserDetailWithPeriod/GetOffice365ActiveUserDetailWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getOffice365ActiveUserDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetOffice365GroupsActivityCountsWithPeriod/GetOffice365GroupsActivityCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetOffice365GroupsActivityCountsWithPeriod/GetOffice365GroupsActivityCountsWithPeriodRequestBuilder.cs index 768a831e660..a75aa3b1106 100644 --- a/src/generated/Reports/GetOffice365GroupsActivityCountsWithPeriod/GetOffice365GroupsActivityCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetOffice365GroupsActivityCountsWithPeriod/GetOffice365GroupsActivityCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getOffice365GroupsActivityCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetOffice365GroupsActivityDetailWithDate/GetOffice365GroupsActivityDetailWithDateRequestBuilder.cs b/src/generated/Reports/GetOffice365GroupsActivityDetailWithDate/GetOffice365GroupsActivityDetailWithDateRequestBuilder.cs index accfe3f3b5d..3faa00c080f 100644 --- a/src/generated/Reports/GetOffice365GroupsActivityDetailWithDate/GetOffice365GroupsActivityDetailWithDateRequestBuilder.cs +++ b/src/generated/Reports/GetOffice365GroupsActivityDetailWithDate/GetOffice365GroupsActivityDetailWithDateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; dateOption.IsRequired = true; command.AddOption(dateOption); - command.SetHandler(async (string date) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string date, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, dateOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, dateOption, outputOption); return command; } /// @@ -50,7 +49,7 @@ public Command BuildGetCommand() { /// Path parameters for the request /// The request adapter to use to execute the requests. /// - public GetOffice365GroupsActivityDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, string date = default) { + public GetOffice365GroupsActivityDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, Date? date = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); UrlTemplate = "{+baseurl}/reports/microsoft.graph.getOffice365GroupsActivityDetail(date={date})"; @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getOffice365GroupsActivityDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetOffice365GroupsActivityDetailWithPeriod/GetOffice365GroupsActivityDetailWithPeriodRequestBuilder.cs b/src/generated/Reports/GetOffice365GroupsActivityDetailWithPeriod/GetOffice365GroupsActivityDetailWithPeriodRequestBuilder.cs index 34221eca821..fed7392ac8d 100644 --- a/src/generated/Reports/GetOffice365GroupsActivityDetailWithPeriod/GetOffice365GroupsActivityDetailWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetOffice365GroupsActivityDetailWithPeriod/GetOffice365GroupsActivityDetailWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getOffice365GroupsActivityDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetOffice365GroupsActivityFileCountsWithPeriod/GetOffice365GroupsActivityFileCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetOffice365GroupsActivityFileCountsWithPeriod/GetOffice365GroupsActivityFileCountsWithPeriodRequestBuilder.cs index df9e28b7221..e3313e37fe6 100644 --- a/src/generated/Reports/GetOffice365GroupsActivityFileCountsWithPeriod/GetOffice365GroupsActivityFileCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetOffice365GroupsActivityFileCountsWithPeriod/GetOffice365GroupsActivityFileCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getOffice365GroupsActivityFileCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetOffice365GroupsActivityGroupCountsWithPeriod/GetOffice365GroupsActivityGroupCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetOffice365GroupsActivityGroupCountsWithPeriod/GetOffice365GroupsActivityGroupCountsWithPeriodRequestBuilder.cs index 4a9ffb8e63e..fbb851c46dc 100644 --- a/src/generated/Reports/GetOffice365GroupsActivityGroupCountsWithPeriod/GetOffice365GroupsActivityGroupCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetOffice365GroupsActivityGroupCountsWithPeriod/GetOffice365GroupsActivityGroupCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getOffice365GroupsActivityGroupCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetOffice365GroupsActivityStorageWithPeriod/GetOffice365GroupsActivityStorageWithPeriodRequestBuilder.cs b/src/generated/Reports/GetOffice365GroupsActivityStorageWithPeriod/GetOffice365GroupsActivityStorageWithPeriodRequestBuilder.cs index 91dc6e760ff..543a610300c 100644 --- a/src/generated/Reports/GetOffice365GroupsActivityStorageWithPeriod/GetOffice365GroupsActivityStorageWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetOffice365GroupsActivityStorageWithPeriod/GetOffice365GroupsActivityStorageWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getOffice365GroupsActivityStorage - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetOffice365ServicesUserCountsWithPeriod/GetOffice365ServicesUserCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetOffice365ServicesUserCountsWithPeriod/GetOffice365ServicesUserCountsWithPeriodRequestBuilder.cs index 3bc1d4b2572..2c3e468598b 100644 --- a/src/generated/Reports/GetOffice365ServicesUserCountsWithPeriod/GetOffice365ServicesUserCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetOffice365ServicesUserCountsWithPeriod/GetOffice365ServicesUserCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getOffice365ServicesUserCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetOneDriveActivityFileCountsWithPeriod/GetOneDriveActivityFileCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetOneDriveActivityFileCountsWithPeriod/GetOneDriveActivityFileCountsWithPeriodRequestBuilder.cs index f8a1ed1bff5..9adb5937135 100644 --- a/src/generated/Reports/GetOneDriveActivityFileCountsWithPeriod/GetOneDriveActivityFileCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetOneDriveActivityFileCountsWithPeriod/GetOneDriveActivityFileCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getOneDriveActivityFileCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetOneDriveActivityUserCountsWithPeriod/GetOneDriveActivityUserCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetOneDriveActivityUserCountsWithPeriod/GetOneDriveActivityUserCountsWithPeriodRequestBuilder.cs index a314e239c01..661c0854855 100644 --- a/src/generated/Reports/GetOneDriveActivityUserCountsWithPeriod/GetOneDriveActivityUserCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetOneDriveActivityUserCountsWithPeriod/GetOneDriveActivityUserCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getOneDriveActivityUserCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetOneDriveActivityUserDetailWithDate/GetOneDriveActivityUserDetailWithDateRequestBuilder.cs b/src/generated/Reports/GetOneDriveActivityUserDetailWithDate/GetOneDriveActivityUserDetailWithDateRequestBuilder.cs index 02af57adf5b..bef8c0b472b 100644 --- a/src/generated/Reports/GetOneDriveActivityUserDetailWithDate/GetOneDriveActivityUserDetailWithDateRequestBuilder.cs +++ b/src/generated/Reports/GetOneDriveActivityUserDetailWithDate/GetOneDriveActivityUserDetailWithDateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; dateOption.IsRequired = true; command.AddOption(dateOption); - command.SetHandler(async (string date) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string date, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, dateOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, dateOption, outputOption); return command; } /// @@ -50,7 +49,7 @@ public Command BuildGetCommand() { /// Path parameters for the request /// The request adapter to use to execute the requests. /// - public GetOneDriveActivityUserDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, string date = default) { + public GetOneDriveActivityUserDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, Date? date = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); UrlTemplate = "{+baseurl}/reports/microsoft.graph.getOneDriveActivityUserDetail(date={date})"; @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getOneDriveActivityUserDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetOneDriveActivityUserDetailWithPeriod/GetOneDriveActivityUserDetailWithPeriodRequestBuilder.cs b/src/generated/Reports/GetOneDriveActivityUserDetailWithPeriod/GetOneDriveActivityUserDetailWithPeriodRequestBuilder.cs index 1cbe7cc1f61..afe901b6d33 100644 --- a/src/generated/Reports/GetOneDriveActivityUserDetailWithPeriod/GetOneDriveActivityUserDetailWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetOneDriveActivityUserDetailWithPeriod/GetOneDriveActivityUserDetailWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getOneDriveActivityUserDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetOneDriveUsageAccountCountsWithPeriod/GetOneDriveUsageAccountCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetOneDriveUsageAccountCountsWithPeriod/GetOneDriveUsageAccountCountsWithPeriodRequestBuilder.cs index ec0997b89a3..fc53c710ab4 100644 --- a/src/generated/Reports/GetOneDriveUsageAccountCountsWithPeriod/GetOneDriveUsageAccountCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetOneDriveUsageAccountCountsWithPeriod/GetOneDriveUsageAccountCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getOneDriveUsageAccountCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetOneDriveUsageAccountDetailWithDate/GetOneDriveUsageAccountDetailWithDateRequestBuilder.cs b/src/generated/Reports/GetOneDriveUsageAccountDetailWithDate/GetOneDriveUsageAccountDetailWithDateRequestBuilder.cs index 4b18f4e36fa..c5d3218e2a2 100644 --- a/src/generated/Reports/GetOneDriveUsageAccountDetailWithDate/GetOneDriveUsageAccountDetailWithDateRequestBuilder.cs +++ b/src/generated/Reports/GetOneDriveUsageAccountDetailWithDate/GetOneDriveUsageAccountDetailWithDateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; dateOption.IsRequired = true; command.AddOption(dateOption); - command.SetHandler(async (string date) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string date, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, dateOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, dateOption, outputOption); return command; } /// @@ -50,7 +49,7 @@ public Command BuildGetCommand() { /// Path parameters for the request /// The request adapter to use to execute the requests. /// - public GetOneDriveUsageAccountDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, string date = default) { + public GetOneDriveUsageAccountDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, Date? date = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); UrlTemplate = "{+baseurl}/reports/microsoft.graph.getOneDriveUsageAccountDetail(date={date})"; @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getOneDriveUsageAccountDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetOneDriveUsageAccountDetailWithPeriod/GetOneDriveUsageAccountDetailWithPeriodRequestBuilder.cs b/src/generated/Reports/GetOneDriveUsageAccountDetailWithPeriod/GetOneDriveUsageAccountDetailWithPeriodRequestBuilder.cs index 5341fbc661a..b47a0a537f8 100644 --- a/src/generated/Reports/GetOneDriveUsageAccountDetailWithPeriod/GetOneDriveUsageAccountDetailWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetOneDriveUsageAccountDetailWithPeriod/GetOneDriveUsageAccountDetailWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getOneDriveUsageAccountDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetOneDriveUsageFileCountsWithPeriod/GetOneDriveUsageFileCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetOneDriveUsageFileCountsWithPeriod/GetOneDriveUsageFileCountsWithPeriodRequestBuilder.cs index a4715290f22..b2973d92715 100644 --- a/src/generated/Reports/GetOneDriveUsageFileCountsWithPeriod/GetOneDriveUsageFileCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetOneDriveUsageFileCountsWithPeriod/GetOneDriveUsageFileCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getOneDriveUsageFileCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetOneDriveUsageStorageWithPeriod/GetOneDriveUsageStorageWithPeriodRequestBuilder.cs b/src/generated/Reports/GetOneDriveUsageStorageWithPeriod/GetOneDriveUsageStorageWithPeriodRequestBuilder.cs index fc47cdcd249..525dc1c6892 100644 --- a/src/generated/Reports/GetOneDriveUsageStorageWithPeriod/GetOneDriveUsageStorageWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetOneDriveUsageStorageWithPeriod/GetOneDriveUsageStorageWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getOneDriveUsageStorage - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetPrinterArchivedPrintJobsWithPrinterIdWithStartDateTimeWithEndDateTime/GetPrinterArchivedPrintJobsWithPrinterIdWithStartDateTimeWithEndDateTimeRequestBuilder.cs b/src/generated/Reports/GetPrinterArchivedPrintJobsWithPrinterIdWithStartDateTimeWithEndDateTime/GetPrinterArchivedPrintJobsWithPrinterIdWithStartDateTimeWithEndDateTimeRequestBuilder.cs index 4f601d52f6f..952cc832ccd 100644 --- a/src/generated/Reports/GetPrinterArchivedPrintJobsWithPrinterIdWithStartDateTimeWithEndDateTime/GetPrinterArchivedPrintJobsWithPrinterIdWithStartDateTimeWithEndDateTimeRequestBuilder.cs +++ b/src/generated/Reports/GetPrinterArchivedPrintJobsWithPrinterIdWithStartDateTimeWithEndDateTime/GetPrinterArchivedPrintJobsWithPrinterIdWithStartDateTimeWithEndDateTimeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,30 +25,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function getPrinterArchivedPrintJobs"; // Create options for all the parameters - var printerIdOption = new Option("--printerid", description: "Usage: printerId={printerId}") { + var printerIdOption = new Option("--printer-id", description: "Usage: printerId={printerId}") { }; printerIdOption.IsRequired = true; command.AddOption(printerIdOption); - var startDateTimeOption = new Option("--startdatetime", description: "Usage: startDateTime={startDateTime}") { + var startDateTimeOption = new Option("--start-date-time", description: "Usage: startDateTime={startDateTime}") { }; startDateTimeOption.IsRequired = true; command.AddOption(startDateTimeOption); - var endDateTimeOption = new Option("--enddatetime", description: "Usage: endDateTime={endDateTime}") { + var endDateTimeOption = new Option("--end-date-time", description: "Usage: endDateTime={endDateTime}") { }; endDateTimeOption.IsRequired = true; command.AddOption(endDateTimeOption); - command.SetHandler(async (string printerId, string startDateTime, string endDateTime) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printerId, string startDateTime, string endDateTime, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printerIdOption, startDateTimeOption, endDateTimeOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printerIdOption, startDateTimeOption, endDateTimeOption, outputOption); return command; } /// @@ -85,16 +84,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getPrinterArchivedPrintJobs - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSharePointActivityFileCountsWithPeriod/GetSharePointActivityFileCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetSharePointActivityFileCountsWithPeriod/GetSharePointActivityFileCountsWithPeriodRequestBuilder.cs index 01dd1747c09..3a08d8c97c4 100644 --- a/src/generated/Reports/GetSharePointActivityFileCountsWithPeriod/GetSharePointActivityFileCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetSharePointActivityFileCountsWithPeriod/GetSharePointActivityFileCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSharePointActivityFileCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSharePointActivityPagesWithPeriod/GetSharePointActivityPagesWithPeriodRequestBuilder.cs b/src/generated/Reports/GetSharePointActivityPagesWithPeriod/GetSharePointActivityPagesWithPeriodRequestBuilder.cs index 2d363b67aa9..714f4cbe94b 100644 --- a/src/generated/Reports/GetSharePointActivityPagesWithPeriod/GetSharePointActivityPagesWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetSharePointActivityPagesWithPeriod/GetSharePointActivityPagesWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSharePointActivityPages - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSharePointActivityUserCountsWithPeriod/GetSharePointActivityUserCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetSharePointActivityUserCountsWithPeriod/GetSharePointActivityUserCountsWithPeriodRequestBuilder.cs index bfdecfd603f..8c2981e512c 100644 --- a/src/generated/Reports/GetSharePointActivityUserCountsWithPeriod/GetSharePointActivityUserCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetSharePointActivityUserCountsWithPeriod/GetSharePointActivityUserCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSharePointActivityUserCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSharePointActivityUserDetailWithDate/GetSharePointActivityUserDetailWithDateRequestBuilder.cs b/src/generated/Reports/GetSharePointActivityUserDetailWithDate/GetSharePointActivityUserDetailWithDateRequestBuilder.cs index 4abf656dd94..b65dae0ee31 100644 --- a/src/generated/Reports/GetSharePointActivityUserDetailWithDate/GetSharePointActivityUserDetailWithDateRequestBuilder.cs +++ b/src/generated/Reports/GetSharePointActivityUserDetailWithDate/GetSharePointActivityUserDetailWithDateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; dateOption.IsRequired = true; command.AddOption(dateOption); - command.SetHandler(async (string date) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string date, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, dateOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, dateOption, outputOption); return command; } /// @@ -50,7 +49,7 @@ public Command BuildGetCommand() { /// Path parameters for the request /// The request adapter to use to execute the requests. /// - public GetSharePointActivityUserDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, string date = default) { + public GetSharePointActivityUserDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, Date? date = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); UrlTemplate = "{+baseurl}/reports/microsoft.graph.getSharePointActivityUserDetail(date={date})"; @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSharePointActivityUserDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSharePointActivityUserDetailWithPeriod/GetSharePointActivityUserDetailWithPeriodRequestBuilder.cs b/src/generated/Reports/GetSharePointActivityUserDetailWithPeriod/GetSharePointActivityUserDetailWithPeriodRequestBuilder.cs index a253c4348ac..fc66005c1fc 100644 --- a/src/generated/Reports/GetSharePointActivityUserDetailWithPeriod/GetSharePointActivityUserDetailWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetSharePointActivityUserDetailWithPeriod/GetSharePointActivityUserDetailWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSharePointActivityUserDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSharePointSiteUsageDetailWithDate/GetSharePointSiteUsageDetailWithDateRequestBuilder.cs b/src/generated/Reports/GetSharePointSiteUsageDetailWithDate/GetSharePointSiteUsageDetailWithDateRequestBuilder.cs index bb5e8d43a70..d8c371ecfa8 100644 --- a/src/generated/Reports/GetSharePointSiteUsageDetailWithDate/GetSharePointSiteUsageDetailWithDateRequestBuilder.cs +++ b/src/generated/Reports/GetSharePointSiteUsageDetailWithDate/GetSharePointSiteUsageDetailWithDateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; dateOption.IsRequired = true; command.AddOption(dateOption); - command.SetHandler(async (string date) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string date, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, dateOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, dateOption, outputOption); return command; } /// @@ -50,7 +49,7 @@ public Command BuildGetCommand() { /// Path parameters for the request /// The request adapter to use to execute the requests. /// - public GetSharePointSiteUsageDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, string date = default) { + public GetSharePointSiteUsageDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, Date? date = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); UrlTemplate = "{+baseurl}/reports/microsoft.graph.getSharePointSiteUsageDetail(date={date})"; @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSharePointSiteUsageDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSharePointSiteUsageDetailWithPeriod/GetSharePointSiteUsageDetailWithPeriodRequestBuilder.cs b/src/generated/Reports/GetSharePointSiteUsageDetailWithPeriod/GetSharePointSiteUsageDetailWithPeriodRequestBuilder.cs index 25745f4f6f1..1e2b9c83241 100644 --- a/src/generated/Reports/GetSharePointSiteUsageDetailWithPeriod/GetSharePointSiteUsageDetailWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetSharePointSiteUsageDetailWithPeriod/GetSharePointSiteUsageDetailWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSharePointSiteUsageDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSharePointSiteUsageFileCountsWithPeriod/GetSharePointSiteUsageFileCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetSharePointSiteUsageFileCountsWithPeriod/GetSharePointSiteUsageFileCountsWithPeriodRequestBuilder.cs index 79d7780bf37..a7dd9cfd830 100644 --- a/src/generated/Reports/GetSharePointSiteUsageFileCountsWithPeriod/GetSharePointSiteUsageFileCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetSharePointSiteUsageFileCountsWithPeriod/GetSharePointSiteUsageFileCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSharePointSiteUsageFileCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSharePointSiteUsagePagesWithPeriod/GetSharePointSiteUsagePagesWithPeriodRequestBuilder.cs b/src/generated/Reports/GetSharePointSiteUsagePagesWithPeriod/GetSharePointSiteUsagePagesWithPeriodRequestBuilder.cs index 00697930397..dcfeb6e5a50 100644 --- a/src/generated/Reports/GetSharePointSiteUsagePagesWithPeriod/GetSharePointSiteUsagePagesWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetSharePointSiteUsagePagesWithPeriod/GetSharePointSiteUsagePagesWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSharePointSiteUsagePages - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSharePointSiteUsageSiteCountsWithPeriod/GetSharePointSiteUsageSiteCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetSharePointSiteUsageSiteCountsWithPeriod/GetSharePointSiteUsageSiteCountsWithPeriodRequestBuilder.cs index a055792d113..3a2b6883c80 100644 --- a/src/generated/Reports/GetSharePointSiteUsageSiteCountsWithPeriod/GetSharePointSiteUsageSiteCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetSharePointSiteUsageSiteCountsWithPeriod/GetSharePointSiteUsageSiteCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSharePointSiteUsageSiteCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSharePointSiteUsageStorageWithPeriod/GetSharePointSiteUsageStorageWithPeriodRequestBuilder.cs b/src/generated/Reports/GetSharePointSiteUsageStorageWithPeriod/GetSharePointSiteUsageStorageWithPeriodRequestBuilder.cs index e3d85b34422..cc56af3499f 100644 --- a/src/generated/Reports/GetSharePointSiteUsageStorageWithPeriod/GetSharePointSiteUsageStorageWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetSharePointSiteUsageStorageWithPeriod/GetSharePointSiteUsageStorageWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSharePointSiteUsageStorage - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSkypeForBusinessActivityCountsWithPeriod/GetSkypeForBusinessActivityCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetSkypeForBusinessActivityCountsWithPeriod/GetSkypeForBusinessActivityCountsWithPeriodRequestBuilder.cs index f2e6cc0005c..ad18bade798 100644 --- a/src/generated/Reports/GetSkypeForBusinessActivityCountsWithPeriod/GetSkypeForBusinessActivityCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetSkypeForBusinessActivityCountsWithPeriod/GetSkypeForBusinessActivityCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSkypeForBusinessActivityCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSkypeForBusinessActivityUserCountsWithPeriod/GetSkypeForBusinessActivityUserCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetSkypeForBusinessActivityUserCountsWithPeriod/GetSkypeForBusinessActivityUserCountsWithPeriodRequestBuilder.cs index 7db94949179..60f4a6ff454 100644 --- a/src/generated/Reports/GetSkypeForBusinessActivityUserCountsWithPeriod/GetSkypeForBusinessActivityUserCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetSkypeForBusinessActivityUserCountsWithPeriod/GetSkypeForBusinessActivityUserCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSkypeForBusinessActivityUserCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSkypeForBusinessActivityUserDetailWithDate/GetSkypeForBusinessActivityUserDetailWithDateRequestBuilder.cs b/src/generated/Reports/GetSkypeForBusinessActivityUserDetailWithDate/GetSkypeForBusinessActivityUserDetailWithDateRequestBuilder.cs index e42ff44a7c0..01cf5ee16c6 100644 --- a/src/generated/Reports/GetSkypeForBusinessActivityUserDetailWithDate/GetSkypeForBusinessActivityUserDetailWithDateRequestBuilder.cs +++ b/src/generated/Reports/GetSkypeForBusinessActivityUserDetailWithDate/GetSkypeForBusinessActivityUserDetailWithDateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; dateOption.IsRequired = true; command.AddOption(dateOption); - command.SetHandler(async (string date) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string date, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, dateOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, dateOption, outputOption); return command; } /// @@ -50,7 +49,7 @@ public Command BuildGetCommand() { /// Path parameters for the request /// The request adapter to use to execute the requests. /// - public GetSkypeForBusinessActivityUserDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, string date = default) { + public GetSkypeForBusinessActivityUserDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, Date? date = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); UrlTemplate = "{+baseurl}/reports/microsoft.graph.getSkypeForBusinessActivityUserDetail(date={date})"; @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSkypeForBusinessActivityUserDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSkypeForBusinessActivityUserDetailWithPeriod/GetSkypeForBusinessActivityUserDetailWithPeriodRequestBuilder.cs b/src/generated/Reports/GetSkypeForBusinessActivityUserDetailWithPeriod/GetSkypeForBusinessActivityUserDetailWithPeriodRequestBuilder.cs index bfe1b33c789..830f2b6b853 100644 --- a/src/generated/Reports/GetSkypeForBusinessActivityUserDetailWithPeriod/GetSkypeForBusinessActivityUserDetailWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetSkypeForBusinessActivityUserDetailWithPeriod/GetSkypeForBusinessActivityUserDetailWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSkypeForBusinessActivityUserDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSkypeForBusinessDeviceUsageDistributionUserCountsWithPeriod/GetSkypeForBusinessDeviceUsageDistributionUserCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetSkypeForBusinessDeviceUsageDistributionUserCountsWithPeriod/GetSkypeForBusinessDeviceUsageDistributionUserCountsWithPeriodRequestBuilder.cs index 8722cfa8281..2daf488e0a3 100644 --- a/src/generated/Reports/GetSkypeForBusinessDeviceUsageDistributionUserCountsWithPeriod/GetSkypeForBusinessDeviceUsageDistributionUserCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetSkypeForBusinessDeviceUsageDistributionUserCountsWithPeriod/GetSkypeForBusinessDeviceUsageDistributionUserCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSkypeForBusinessDeviceUsageDistributionUserCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSkypeForBusinessDeviceUsageUserCountsWithPeriod/GetSkypeForBusinessDeviceUsageUserCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetSkypeForBusinessDeviceUsageUserCountsWithPeriod/GetSkypeForBusinessDeviceUsageUserCountsWithPeriodRequestBuilder.cs index 2ae532ee501..cfe84900230 100644 --- a/src/generated/Reports/GetSkypeForBusinessDeviceUsageUserCountsWithPeriod/GetSkypeForBusinessDeviceUsageUserCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetSkypeForBusinessDeviceUsageUserCountsWithPeriod/GetSkypeForBusinessDeviceUsageUserCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSkypeForBusinessDeviceUsageUserCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSkypeForBusinessDeviceUsageUserDetailWithDate/GetSkypeForBusinessDeviceUsageUserDetailWithDateRequestBuilder.cs b/src/generated/Reports/GetSkypeForBusinessDeviceUsageUserDetailWithDate/GetSkypeForBusinessDeviceUsageUserDetailWithDateRequestBuilder.cs index 7d15e552990..44989ced933 100644 --- a/src/generated/Reports/GetSkypeForBusinessDeviceUsageUserDetailWithDate/GetSkypeForBusinessDeviceUsageUserDetailWithDateRequestBuilder.cs +++ b/src/generated/Reports/GetSkypeForBusinessDeviceUsageUserDetailWithDate/GetSkypeForBusinessDeviceUsageUserDetailWithDateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; dateOption.IsRequired = true; command.AddOption(dateOption); - command.SetHandler(async (string date) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string date, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, dateOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, dateOption, outputOption); return command; } /// @@ -50,7 +49,7 @@ public Command BuildGetCommand() { /// Path parameters for the request /// The request adapter to use to execute the requests. /// - public GetSkypeForBusinessDeviceUsageUserDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, string date = default) { + public GetSkypeForBusinessDeviceUsageUserDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, Date? date = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); UrlTemplate = "{+baseurl}/reports/microsoft.graph.getSkypeForBusinessDeviceUsageUserDetail(date={date})"; @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSkypeForBusinessDeviceUsageUserDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSkypeForBusinessDeviceUsageUserDetailWithPeriod/GetSkypeForBusinessDeviceUsageUserDetailWithPeriodRequestBuilder.cs b/src/generated/Reports/GetSkypeForBusinessDeviceUsageUserDetailWithPeriod/GetSkypeForBusinessDeviceUsageUserDetailWithPeriodRequestBuilder.cs index 8058906cbb3..f2a80b9be5b 100644 --- a/src/generated/Reports/GetSkypeForBusinessDeviceUsageUserDetailWithPeriod/GetSkypeForBusinessDeviceUsageUserDetailWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetSkypeForBusinessDeviceUsageUserDetailWithPeriod/GetSkypeForBusinessDeviceUsageUserDetailWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSkypeForBusinessDeviceUsageUserDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSkypeForBusinessOrganizerActivityCountsWithPeriod/GetSkypeForBusinessOrganizerActivityCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetSkypeForBusinessOrganizerActivityCountsWithPeriod/GetSkypeForBusinessOrganizerActivityCountsWithPeriodRequestBuilder.cs index fbb9f750d4f..a0248ef54e7 100644 --- a/src/generated/Reports/GetSkypeForBusinessOrganizerActivityCountsWithPeriod/GetSkypeForBusinessOrganizerActivityCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetSkypeForBusinessOrganizerActivityCountsWithPeriod/GetSkypeForBusinessOrganizerActivityCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSkypeForBusinessOrganizerActivityCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSkypeForBusinessOrganizerActivityMinuteCountsWithPeriod/GetSkypeForBusinessOrganizerActivityMinuteCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetSkypeForBusinessOrganizerActivityMinuteCountsWithPeriod/GetSkypeForBusinessOrganizerActivityMinuteCountsWithPeriodRequestBuilder.cs index 2feadeb536e..e8d6493b732 100644 --- a/src/generated/Reports/GetSkypeForBusinessOrganizerActivityMinuteCountsWithPeriod/GetSkypeForBusinessOrganizerActivityMinuteCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetSkypeForBusinessOrganizerActivityMinuteCountsWithPeriod/GetSkypeForBusinessOrganizerActivityMinuteCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSkypeForBusinessOrganizerActivityMinuteCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSkypeForBusinessOrganizerActivityUserCountsWithPeriod/GetSkypeForBusinessOrganizerActivityUserCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetSkypeForBusinessOrganizerActivityUserCountsWithPeriod/GetSkypeForBusinessOrganizerActivityUserCountsWithPeriodRequestBuilder.cs index 5a756fed5f3..c5e57c2a9ab 100644 --- a/src/generated/Reports/GetSkypeForBusinessOrganizerActivityUserCountsWithPeriod/GetSkypeForBusinessOrganizerActivityUserCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetSkypeForBusinessOrganizerActivityUserCountsWithPeriod/GetSkypeForBusinessOrganizerActivityUserCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSkypeForBusinessOrganizerActivityUserCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSkypeForBusinessParticipantActivityCountsWithPeriod/GetSkypeForBusinessParticipantActivityCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetSkypeForBusinessParticipantActivityCountsWithPeriod/GetSkypeForBusinessParticipantActivityCountsWithPeriodRequestBuilder.cs index d735c904cd4..aca5f7afc64 100644 --- a/src/generated/Reports/GetSkypeForBusinessParticipantActivityCountsWithPeriod/GetSkypeForBusinessParticipantActivityCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetSkypeForBusinessParticipantActivityCountsWithPeriod/GetSkypeForBusinessParticipantActivityCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSkypeForBusinessParticipantActivityCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSkypeForBusinessParticipantActivityMinuteCountsWithPeriod/GetSkypeForBusinessParticipantActivityMinuteCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetSkypeForBusinessParticipantActivityMinuteCountsWithPeriod/GetSkypeForBusinessParticipantActivityMinuteCountsWithPeriodRequestBuilder.cs index 66728204326..30408a9f942 100644 --- a/src/generated/Reports/GetSkypeForBusinessParticipantActivityMinuteCountsWithPeriod/GetSkypeForBusinessParticipantActivityMinuteCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetSkypeForBusinessParticipantActivityMinuteCountsWithPeriod/GetSkypeForBusinessParticipantActivityMinuteCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSkypeForBusinessParticipantActivityMinuteCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSkypeForBusinessParticipantActivityUserCountsWithPeriod/GetSkypeForBusinessParticipantActivityUserCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetSkypeForBusinessParticipantActivityUserCountsWithPeriod/GetSkypeForBusinessParticipantActivityUserCountsWithPeriodRequestBuilder.cs index 11e066f61a0..571ab52f842 100644 --- a/src/generated/Reports/GetSkypeForBusinessParticipantActivityUserCountsWithPeriod/GetSkypeForBusinessParticipantActivityUserCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetSkypeForBusinessParticipantActivityUserCountsWithPeriod/GetSkypeForBusinessParticipantActivityUserCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSkypeForBusinessParticipantActivityUserCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSkypeForBusinessPeerToPeerActivityCountsWithPeriod/GetSkypeForBusinessPeerToPeerActivityCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetSkypeForBusinessPeerToPeerActivityCountsWithPeriod/GetSkypeForBusinessPeerToPeerActivityCountsWithPeriodRequestBuilder.cs index edf73c190a4..06dbfa939f7 100644 --- a/src/generated/Reports/GetSkypeForBusinessPeerToPeerActivityCountsWithPeriod/GetSkypeForBusinessPeerToPeerActivityCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetSkypeForBusinessPeerToPeerActivityCountsWithPeriod/GetSkypeForBusinessPeerToPeerActivityCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSkypeForBusinessPeerToPeerActivityCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSkypeForBusinessPeerToPeerActivityMinuteCountsWithPeriod/GetSkypeForBusinessPeerToPeerActivityMinuteCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetSkypeForBusinessPeerToPeerActivityMinuteCountsWithPeriod/GetSkypeForBusinessPeerToPeerActivityMinuteCountsWithPeriodRequestBuilder.cs index 776485d7dda..522bed27b36 100644 --- a/src/generated/Reports/GetSkypeForBusinessPeerToPeerActivityMinuteCountsWithPeriod/GetSkypeForBusinessPeerToPeerActivityMinuteCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetSkypeForBusinessPeerToPeerActivityMinuteCountsWithPeriod/GetSkypeForBusinessPeerToPeerActivityMinuteCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSkypeForBusinessPeerToPeerActivityMinuteCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetSkypeForBusinessPeerToPeerActivityUserCountsWithPeriod/GetSkypeForBusinessPeerToPeerActivityUserCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetSkypeForBusinessPeerToPeerActivityUserCountsWithPeriod/GetSkypeForBusinessPeerToPeerActivityUserCountsWithPeriodRequestBuilder.cs index 592ddc94a4c..fbcf0328a9b 100644 --- a/src/generated/Reports/GetSkypeForBusinessPeerToPeerActivityUserCountsWithPeriod/GetSkypeForBusinessPeerToPeerActivityUserCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetSkypeForBusinessPeerToPeerActivityUserCountsWithPeriod/GetSkypeForBusinessPeerToPeerActivityUserCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getSkypeForBusinessPeerToPeerActivityUserCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetTeamsDeviceUsageDistributionUserCountsWithPeriod/GetTeamsDeviceUsageDistributionUserCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetTeamsDeviceUsageDistributionUserCountsWithPeriod/GetTeamsDeviceUsageDistributionUserCountsWithPeriodRequestBuilder.cs index 6c1b886ee4c..780c2f1763f 100644 --- a/src/generated/Reports/GetTeamsDeviceUsageDistributionUserCountsWithPeriod/GetTeamsDeviceUsageDistributionUserCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetTeamsDeviceUsageDistributionUserCountsWithPeriod/GetTeamsDeviceUsageDistributionUserCountsWithPeriodRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string period, FileInfo output) => { + command.SetHandler(async (string period, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, periodOption, outputOption); + }, periodOption, fileOption, outputOption); return command; } /// @@ -79,16 +81,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getTeamsDeviceUsageDistributionUserCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetTeamsDeviceUsageUserCountsWithPeriod/GetTeamsDeviceUsageUserCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetTeamsDeviceUsageUserCountsWithPeriod/GetTeamsDeviceUsageUserCountsWithPeriodRequestBuilder.cs index 0cedfbbb166..0ab1f977a15 100644 --- a/src/generated/Reports/GetTeamsDeviceUsageUserCountsWithPeriod/GetTeamsDeviceUsageUserCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetTeamsDeviceUsageUserCountsWithPeriod/GetTeamsDeviceUsageUserCountsWithPeriodRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string period, FileInfo output) => { + command.SetHandler(async (string period, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, periodOption, outputOption); + }, periodOption, fileOption, outputOption); return command; } /// @@ -79,16 +81,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getTeamsDeviceUsageUserCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetTeamsDeviceUsageUserDetailWithDate/GetTeamsDeviceUsageUserDetailWithDateRequestBuilder.cs b/src/generated/Reports/GetTeamsDeviceUsageUserDetailWithDate/GetTeamsDeviceUsageUserDetailWithDateRequestBuilder.cs index a1bef126a4f..f22c82e6228 100644 --- a/src/generated/Reports/GetTeamsDeviceUsageUserDetailWithDate/GetTeamsDeviceUsageUserDetailWithDateRequestBuilder.cs +++ b/src/generated/Reports/GetTeamsDeviceUsageUserDetailWithDate/GetTeamsDeviceUsageUserDetailWithDateRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; dateOption.IsRequired = true; command.AddOption(dateOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string date, FileInfo output) => { + command.SetHandler(async (string date, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, dateOption, outputOption); + }, dateOption, fileOption, outputOption); return command; } /// @@ -55,7 +57,7 @@ public Command BuildGetCommand() { /// Path parameters for the request /// The request adapter to use to execute the requests. /// - public GetTeamsDeviceUsageUserDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, string date = default) { + public GetTeamsDeviceUsageUserDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, Date? date = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); UrlTemplate = "{+baseurl}/reports/microsoft.graph.getTeamsDeviceUsageUserDetail(date={date})"; @@ -79,16 +81,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getTeamsDeviceUsageUserDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetTeamsDeviceUsageUserDetailWithPeriod/GetTeamsDeviceUsageUserDetailWithPeriodRequestBuilder.cs b/src/generated/Reports/GetTeamsDeviceUsageUserDetailWithPeriod/GetTeamsDeviceUsageUserDetailWithPeriodRequestBuilder.cs index e0608cbdd21..60087bc4534 100644 --- a/src/generated/Reports/GetTeamsDeviceUsageUserDetailWithPeriod/GetTeamsDeviceUsageUserDetailWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetTeamsDeviceUsageUserDetailWithPeriod/GetTeamsDeviceUsageUserDetailWithPeriodRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string period, FileInfo output) => { + command.SetHandler(async (string period, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, periodOption, outputOption); + }, periodOption, fileOption, outputOption); return command; } /// @@ -79,16 +81,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getTeamsDeviceUsageUserDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetTeamsUserActivityCountsWithPeriod/GetTeamsUserActivityCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetTeamsUserActivityCountsWithPeriod/GetTeamsUserActivityCountsWithPeriodRequestBuilder.cs index 46845d108b1..06424624c64 100644 --- a/src/generated/Reports/GetTeamsUserActivityCountsWithPeriod/GetTeamsUserActivityCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetTeamsUserActivityCountsWithPeriod/GetTeamsUserActivityCountsWithPeriodRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string period, FileInfo output) => { + command.SetHandler(async (string period, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, periodOption, outputOption); + }, periodOption, fileOption, outputOption); return command; } /// @@ -79,16 +81,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getTeamsUserActivityCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetTeamsUserActivityUserCountsWithPeriod/GetTeamsUserActivityUserCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetTeamsUserActivityUserCountsWithPeriod/GetTeamsUserActivityUserCountsWithPeriodRequestBuilder.cs index d73abea905d..ac4d30f1093 100644 --- a/src/generated/Reports/GetTeamsUserActivityUserCountsWithPeriod/GetTeamsUserActivityUserCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetTeamsUserActivityUserCountsWithPeriod/GetTeamsUserActivityUserCountsWithPeriodRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string period, FileInfo output) => { + command.SetHandler(async (string period, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, periodOption, outputOption); + }, periodOption, fileOption, outputOption); return command; } /// @@ -79,16 +81,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getTeamsUserActivityUserCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetTeamsUserActivityUserDetailWithDate/GetTeamsUserActivityUserDetailWithDateRequestBuilder.cs b/src/generated/Reports/GetTeamsUserActivityUserDetailWithDate/GetTeamsUserActivityUserDetailWithDateRequestBuilder.cs index 7c360cccdc2..167abf12b48 100644 --- a/src/generated/Reports/GetTeamsUserActivityUserDetailWithDate/GetTeamsUserActivityUserDetailWithDateRequestBuilder.cs +++ b/src/generated/Reports/GetTeamsUserActivityUserDetailWithDate/GetTeamsUserActivityUserDetailWithDateRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; dateOption.IsRequired = true; command.AddOption(dateOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string date, FileInfo output) => { + command.SetHandler(async (string date, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, dateOption, outputOption); + }, dateOption, fileOption, outputOption); return command; } /// @@ -55,7 +57,7 @@ public Command BuildGetCommand() { /// Path parameters for the request /// The request adapter to use to execute the requests. /// - public GetTeamsUserActivityUserDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, string date = default) { + public GetTeamsUserActivityUserDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, Date? date = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); UrlTemplate = "{+baseurl}/reports/microsoft.graph.getTeamsUserActivityUserDetail(date={date})"; @@ -79,16 +81,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getTeamsUserActivityUserDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetTeamsUserActivityUserDetailWithPeriod/GetTeamsUserActivityUserDetailWithPeriodRequestBuilder.cs b/src/generated/Reports/GetTeamsUserActivityUserDetailWithPeriod/GetTeamsUserActivityUserDetailWithPeriodRequestBuilder.cs index f2dc81caf44..091683d4777 100644 --- a/src/generated/Reports/GetTeamsUserActivityUserDetailWithPeriod/GetTeamsUserActivityUserDetailWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetTeamsUserActivityUserDetailWithPeriod/GetTeamsUserActivityUserDetailWithPeriodRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string period, FileInfo output) => { + command.SetHandler(async (string period, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, periodOption, outputOption); + }, periodOption, fileOption, outputOption); return command; } /// @@ -79,16 +81,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getTeamsUserActivityUserDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetUserArchivedPrintJobsWithUserIdWithStartDateTimeWithEndDateTime/GetUserArchivedPrintJobsWithUserIdWithStartDateTimeWithEndDateTimeRequestBuilder.cs b/src/generated/Reports/GetUserArchivedPrintJobsWithUserIdWithStartDateTimeWithEndDateTime/GetUserArchivedPrintJobsWithUserIdWithStartDateTimeWithEndDateTimeRequestBuilder.cs index 5192d55a43c..27278f9b426 100644 --- a/src/generated/Reports/GetUserArchivedPrintJobsWithUserIdWithStartDateTimeWithEndDateTime/GetUserArchivedPrintJobsWithUserIdWithStartDateTimeWithEndDateTimeRequestBuilder.cs +++ b/src/generated/Reports/GetUserArchivedPrintJobsWithUserIdWithStartDateTimeWithEndDateTime/GetUserArchivedPrintJobsWithUserIdWithStartDateTimeWithEndDateTimeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,30 +25,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function getUserArchivedPrintJobs"; // Create options for all the parameters - var userIdOption = new Option("--userid", description: "Usage: userId={userId}") { + var userIdOption = new Option("--user-id", description: "Usage: userId={userId}") { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var startDateTimeOption = new Option("--startdatetime", description: "Usage: startDateTime={startDateTime}") { + var startDateTimeOption = new Option("--start-date-time", description: "Usage: startDateTime={startDateTime}") { }; startDateTimeOption.IsRequired = true; command.AddOption(startDateTimeOption); - var endDateTimeOption = new Option("--enddatetime", description: "Usage: endDateTime={endDateTime}") { + var endDateTimeOption = new Option("--end-date-time", description: "Usage: endDateTime={endDateTime}") { }; endDateTimeOption.IsRequired = true; command.AddOption(endDateTimeOption); - command.SetHandler(async (string userId, string startDateTime, string endDateTime) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string startDateTime, string endDateTime, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, startDateTimeOption, endDateTimeOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, startDateTimeOption, endDateTimeOption, outputOption); return command; } /// @@ -85,16 +84,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getUserArchivedPrintJobs - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetYammerActivityCountsWithPeriod/GetYammerActivityCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetYammerActivityCountsWithPeriod/GetYammerActivityCountsWithPeriodRequestBuilder.cs index d6159da1d1a..0a18b8c7c4c 100644 --- a/src/generated/Reports/GetYammerActivityCountsWithPeriod/GetYammerActivityCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetYammerActivityCountsWithPeriod/GetYammerActivityCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getYammerActivityCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetYammerActivityUserCountsWithPeriod/GetYammerActivityUserCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetYammerActivityUserCountsWithPeriod/GetYammerActivityUserCountsWithPeriodRequestBuilder.cs index 74b9a7601dd..09b09e2d108 100644 --- a/src/generated/Reports/GetYammerActivityUserCountsWithPeriod/GetYammerActivityUserCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetYammerActivityUserCountsWithPeriod/GetYammerActivityUserCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getYammerActivityUserCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetYammerActivityUserDetailWithDate/GetYammerActivityUserDetailWithDateRequestBuilder.cs b/src/generated/Reports/GetYammerActivityUserDetailWithDate/GetYammerActivityUserDetailWithDateRequestBuilder.cs index 8f4d824f07f..94e44813f73 100644 --- a/src/generated/Reports/GetYammerActivityUserDetailWithDate/GetYammerActivityUserDetailWithDateRequestBuilder.cs +++ b/src/generated/Reports/GetYammerActivityUserDetailWithDate/GetYammerActivityUserDetailWithDateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; dateOption.IsRequired = true; command.AddOption(dateOption); - command.SetHandler(async (string date) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string date, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, dateOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, dateOption, outputOption); return command; } /// @@ -50,7 +49,7 @@ public Command BuildGetCommand() { /// Path parameters for the request /// The request adapter to use to execute the requests. /// - public GetYammerActivityUserDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, string date = default) { + public GetYammerActivityUserDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, Date? date = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); UrlTemplate = "{+baseurl}/reports/microsoft.graph.getYammerActivityUserDetail(date={date})"; @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getYammerActivityUserDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetYammerActivityUserDetailWithPeriod/GetYammerActivityUserDetailWithPeriodRequestBuilder.cs b/src/generated/Reports/GetYammerActivityUserDetailWithPeriod/GetYammerActivityUserDetailWithPeriodRequestBuilder.cs index 9fe8bc7f51c..c4f53196f6a 100644 --- a/src/generated/Reports/GetYammerActivityUserDetailWithPeriod/GetYammerActivityUserDetailWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetYammerActivityUserDetailWithPeriod/GetYammerActivityUserDetailWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getYammerActivityUserDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetYammerDeviceUsageDistributionUserCountsWithPeriod/GetYammerDeviceUsageDistributionUserCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetYammerDeviceUsageDistributionUserCountsWithPeriod/GetYammerDeviceUsageDistributionUserCountsWithPeriodRequestBuilder.cs index 087a275c1c4..8cd8ae36923 100644 --- a/src/generated/Reports/GetYammerDeviceUsageDistributionUserCountsWithPeriod/GetYammerDeviceUsageDistributionUserCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetYammerDeviceUsageDistributionUserCountsWithPeriod/GetYammerDeviceUsageDistributionUserCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getYammerDeviceUsageDistributionUserCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetYammerDeviceUsageUserCountsWithPeriod/GetYammerDeviceUsageUserCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetYammerDeviceUsageUserCountsWithPeriod/GetYammerDeviceUsageUserCountsWithPeriodRequestBuilder.cs index 4b349565e41..a732b3525ed 100644 --- a/src/generated/Reports/GetYammerDeviceUsageUserCountsWithPeriod/GetYammerDeviceUsageUserCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetYammerDeviceUsageUserCountsWithPeriod/GetYammerDeviceUsageUserCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getYammerDeviceUsageUserCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetYammerDeviceUsageUserDetailWithDate/GetYammerDeviceUsageUserDetailWithDateRequestBuilder.cs b/src/generated/Reports/GetYammerDeviceUsageUserDetailWithDate/GetYammerDeviceUsageUserDetailWithDateRequestBuilder.cs index 69461d708b9..3dc3ca34126 100644 --- a/src/generated/Reports/GetYammerDeviceUsageUserDetailWithDate/GetYammerDeviceUsageUserDetailWithDateRequestBuilder.cs +++ b/src/generated/Reports/GetYammerDeviceUsageUserDetailWithDate/GetYammerDeviceUsageUserDetailWithDateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; dateOption.IsRequired = true; command.AddOption(dateOption); - command.SetHandler(async (string date) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string date, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, dateOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, dateOption, outputOption); return command; } /// @@ -50,7 +49,7 @@ public Command BuildGetCommand() { /// Path parameters for the request /// The request adapter to use to execute the requests. /// - public GetYammerDeviceUsageUserDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, string date = default) { + public GetYammerDeviceUsageUserDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, Date? date = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); UrlTemplate = "{+baseurl}/reports/microsoft.graph.getYammerDeviceUsageUserDetail(date={date})"; @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getYammerDeviceUsageUserDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetYammerDeviceUsageUserDetailWithPeriod/GetYammerDeviceUsageUserDetailWithPeriodRequestBuilder.cs b/src/generated/Reports/GetYammerDeviceUsageUserDetailWithPeriod/GetYammerDeviceUsageUserDetailWithPeriodRequestBuilder.cs index 6ef1cb76443..0ca1bbda460 100644 --- a/src/generated/Reports/GetYammerDeviceUsageUserDetailWithPeriod/GetYammerDeviceUsageUserDetailWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetYammerDeviceUsageUserDetailWithPeriod/GetYammerDeviceUsageUserDetailWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getYammerDeviceUsageUserDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetYammerGroupsActivityCountsWithPeriod/GetYammerGroupsActivityCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetYammerGroupsActivityCountsWithPeriod/GetYammerGroupsActivityCountsWithPeriodRequestBuilder.cs index 94a9c3901a6..bfe14c27fd8 100644 --- a/src/generated/Reports/GetYammerGroupsActivityCountsWithPeriod/GetYammerGroupsActivityCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetYammerGroupsActivityCountsWithPeriod/GetYammerGroupsActivityCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getYammerGroupsActivityCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetYammerGroupsActivityDetailWithDate/GetYammerGroupsActivityDetailWithDateRequestBuilder.cs b/src/generated/Reports/GetYammerGroupsActivityDetailWithDate/GetYammerGroupsActivityDetailWithDateRequestBuilder.cs index 8223dcde5cb..979236bbb74 100644 --- a/src/generated/Reports/GetYammerGroupsActivityDetailWithDate/GetYammerGroupsActivityDetailWithDateRequestBuilder.cs +++ b/src/generated/Reports/GetYammerGroupsActivityDetailWithDate/GetYammerGroupsActivityDetailWithDateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; dateOption.IsRequired = true; command.AddOption(dateOption); - command.SetHandler(async (string date) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string date, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, dateOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, dateOption, outputOption); return command; } /// @@ -50,7 +49,7 @@ public Command BuildGetCommand() { /// Path parameters for the request /// The request adapter to use to execute the requests. /// - public GetYammerGroupsActivityDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, string date = default) { + public GetYammerGroupsActivityDetailWithDateRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, Date? date = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); UrlTemplate = "{+baseurl}/reports/microsoft.graph.getYammerGroupsActivityDetail(date={date})"; @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getYammerGroupsActivityDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetYammerGroupsActivityDetailWithPeriod/GetYammerGroupsActivityDetailWithPeriodRequestBuilder.cs b/src/generated/Reports/GetYammerGroupsActivityDetailWithPeriod/GetYammerGroupsActivityDetailWithPeriodRequestBuilder.cs index f3de977930e..c00013fde4c 100644 --- a/src/generated/Reports/GetYammerGroupsActivityDetailWithPeriod/GetYammerGroupsActivityDetailWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetYammerGroupsActivityDetailWithPeriod/GetYammerGroupsActivityDetailWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getYammerGroupsActivityDetail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/GetYammerGroupsActivityGroupCountsWithPeriod/GetYammerGroupsActivityGroupCountsWithPeriodRequestBuilder.cs b/src/generated/Reports/GetYammerGroupsActivityGroupCountsWithPeriod/GetYammerGroupsActivityGroupCountsWithPeriodRequestBuilder.cs index 41344849fee..fd7776cfe4a 100644 --- a/src/generated/Reports/GetYammerGroupsActivityGroupCountsWithPeriod/GetYammerGroupsActivityGroupCountsWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/GetYammerGroupsActivityGroupCountsWithPeriod/GetYammerGroupsActivityGroupCountsWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,16 +73,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getYammerGroupsActivityGroupCounts - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Reports/ManagedDeviceEnrollmentFailureDetails/ManagedDeviceEnrollmentFailureDetailsRequestBuilder.cs b/src/generated/Reports/ManagedDeviceEnrollmentFailureDetails/ManagedDeviceEnrollmentFailureDetailsRequestBuilder.cs index 3c71e15ec93..4cbb2be5320 100644 --- a/src/generated/Reports/ManagedDeviceEnrollmentFailureDetails/ManagedDeviceEnrollmentFailureDetailsRequestBuilder.cs +++ b/src/generated/Reports/ManagedDeviceEnrollmentFailureDetails/ManagedDeviceEnrollmentFailureDetailsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,18 +26,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function managedDeviceEnrollmentFailureDetails"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -68,17 +67,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function managedDeviceEnrollmentFailureDetails - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes report public class ManagedDeviceEnrollmentFailureDetailsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Reports/ManagedDeviceEnrollmentFailureDetailsWithSkipWithTopWithFilterWithSkipToken/ManagedDeviceEnrollmentFailureDetailsWithSkipWithTopWithFilterWithSkipTokenRequestBuilder.cs b/src/generated/Reports/ManagedDeviceEnrollmentFailureDetailsWithSkipWithTopWithFilterWithSkipToken/ManagedDeviceEnrollmentFailureDetailsWithSkipWithTopWithFilterWithSkipTokenRequestBuilder.cs index 5d0addec1b4..800a77b039d 100644 --- a/src/generated/Reports/ManagedDeviceEnrollmentFailureDetailsWithSkipWithTopWithFilterWithSkipToken/ManagedDeviceEnrollmentFailureDetailsWithSkipWithTopWithFilterWithSkipTokenRequestBuilder.cs +++ b/src/generated/Reports/ManagedDeviceEnrollmentFailureDetailsWithSkipWithTopWithFilterWithSkipToken/ManagedDeviceEnrollmentFailureDetailsWithSkipWithTopWithFilterWithSkipTokenRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,22 +38,21 @@ public Command BuildGetCommand() { }; filterOption.IsRequired = true; command.AddOption(filterOption); - var skipTokenOption = new Option("--skiptoken", description: "Usage: skipToken={skipToken}") { + var skipTokenOption = new Option("--skip-token", description: "Usage: skipToken={skipToken}") { }; skipTokenOption.IsRequired = true; command.AddOption(skipTokenOption); - command.SetHandler(async (int? skip, int? top, string filter, string skipToken) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? skip, int? top, string filter, string skipToken, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, skipOption, topOption, filterOption, skipTokenOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, skipOption, topOption, filterOption, skipTokenOption, outputOption); return command; } /// @@ -92,17 +91,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function managedDeviceEnrollmentFailureDetails - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes report public class ManagedDeviceEnrollmentFailureDetailsWithSkipWithTopWithFilterWithSkipTokenResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Reports/ManagedDeviceEnrollmentTopFailures/ManagedDeviceEnrollmentTopFailuresRequestBuilder.cs b/src/generated/Reports/ManagedDeviceEnrollmentTopFailures/ManagedDeviceEnrollmentTopFailuresRequestBuilder.cs index 56b353c08e2..47851e48f44 100644 --- a/src/generated/Reports/ManagedDeviceEnrollmentTopFailures/ManagedDeviceEnrollmentTopFailuresRequestBuilder.cs +++ b/src/generated/Reports/ManagedDeviceEnrollmentTopFailures/ManagedDeviceEnrollmentTopFailuresRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,18 +26,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function managedDeviceEnrollmentTopFailures"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -68,17 +67,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function managedDeviceEnrollmentTopFailures - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes report public class ManagedDeviceEnrollmentTopFailuresResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Reports/ManagedDeviceEnrollmentTopFailuresWithPeriod/ManagedDeviceEnrollmentTopFailuresWithPeriodRequestBuilder.cs b/src/generated/Reports/ManagedDeviceEnrollmentTopFailuresWithPeriod/ManagedDeviceEnrollmentTopFailuresWithPeriodRequestBuilder.cs index eb74509b5f6..d5961b2d846 100644 --- a/src/generated/Reports/ManagedDeviceEnrollmentTopFailuresWithPeriod/ManagedDeviceEnrollmentTopFailuresWithPeriodRequestBuilder.cs +++ b/src/generated/Reports/ManagedDeviceEnrollmentTopFailuresWithPeriod/ManagedDeviceEnrollmentTopFailuresWithPeriodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildGetCommand() { }; periodOption.IsRequired = true; command.AddOption(periodOption); - command.SetHandler(async (string period) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string period, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, periodOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, periodOption, outputOption); return command; } /// @@ -74,17 +73,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function managedDeviceEnrollmentTopFailures - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes report public class ManagedDeviceEnrollmentTopFailuresWithPeriodResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Reports/MonthlyPrintUsageByPrinter/Item/PrintUsageByPrinterRequestBuilder.cs b/src/generated/Reports/MonthlyPrintUsageByPrinter/Item/PrintUsageByPrinterRequestBuilder.cs index 849b48e9b33..b705d60eb02 100644 --- a/src/generated/Reports/MonthlyPrintUsageByPrinter/Item/PrintUsageByPrinterRequestBuilder.cs +++ b/src/generated/Reports/MonthlyPrintUsageByPrinter/Item/PrintUsageByPrinterRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property monthlyPrintUsageByPrinter for reports"; // Create options for all the parameters - var printUsageByPrinterIdOption = new Option("--printusagebyprinter-id", description: "key: id of printUsageByPrinter") { + var printUsageByPrinterIdOption = new Option("--print-usage-by-printer-id", description: "key: id of printUsageByPrinter") { }; printUsageByPrinterIdOption.IsRequired = true; command.AddOption(printUsageByPrinterIdOption); - command.SetHandler(async (string printUsageByPrinterId) => { + command.SetHandler(async (string printUsageByPrinterId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printUsageByPrinterIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get monthlyPrintUsageByPrinter from reports"; // Create options for all the parameters - var printUsageByPrinterIdOption = new Option("--printusagebyprinter-id", description: "key: id of printUsageByPrinter") { + var printUsageByPrinterIdOption = new Option("--print-usage-by-printer-id", description: "key: id of printUsageByPrinter") { }; printUsageByPrinterIdOption.IsRequired = true; command.AddOption(printUsageByPrinterIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string printUsageByPrinterId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printUsageByPrinterId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printUsageByPrinterIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printUsageByPrinterIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property monthlyPrintUsageByPrinter in reports"; // Create options for all the parameters - var printUsageByPrinterIdOption = new Option("--printusagebyprinter-id", description: "key: id of printUsageByPrinter") { + var printUsageByPrinterIdOption = new Option("--print-usage-by-printer-id", description: "key: id of printUsageByPrinter") { }; printUsageByPrinterIdOption.IsRequired = true; command.AddOption(printUsageByPrinterIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string printUsageByPrinterId, string body) => { + command.SetHandler(async (string printUsageByPrinterId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printUsageByPrinterIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(PrintUsageByPrinter body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property monthlyPrintUsageByPrinter for reports - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get monthlyPrintUsageByPrinter from reports - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property monthlyPrintUsageByPrinter in reports - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PrintUsageByPrinter model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get monthlyPrintUsageByPrinter from reports public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Reports/MonthlyPrintUsageByPrinter/MonthlyPrintUsageByPrinterRequestBuilder.cs b/src/generated/Reports/MonthlyPrintUsageByPrinter/MonthlyPrintUsageByPrinterRequestBuilder.cs index 819f6890362..ba38219c32b 100644 --- a/src/generated/Reports/MonthlyPrintUsageByPrinter/MonthlyPrintUsageByPrinterRequestBuilder.cs +++ b/src/generated/Reports/MonthlyPrintUsageByPrinter/MonthlyPrintUsageByPrinterRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Reports.MonthlyPrintUsageByPrinter.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MonthlyPrintUsageByPrinterRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PrintUsageByPrinterRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(PrintUsageByPrinter body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get monthlyPrintUsageByPrinter from reports - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to monthlyPrintUsageByPrinter for reports - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PrintUsageByPrinter model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get monthlyPrintUsageByPrinter from reports public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Reports/MonthlyPrintUsageByUser/Item/PrintUsageByUserRequestBuilder.cs b/src/generated/Reports/MonthlyPrintUsageByUser/Item/PrintUsageByUserRequestBuilder.cs index c8f45a7d970..03e1ff9bbbd 100644 --- a/src/generated/Reports/MonthlyPrintUsageByUser/Item/PrintUsageByUserRequestBuilder.cs +++ b/src/generated/Reports/MonthlyPrintUsageByUser/Item/PrintUsageByUserRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property monthlyPrintUsageByUser for reports"; // Create options for all the parameters - var printUsageByUserIdOption = new Option("--printusagebyuser-id", description: "key: id of printUsageByUser") { + var printUsageByUserIdOption = new Option("--print-usage-by-user-id", description: "key: id of printUsageByUser") { }; printUsageByUserIdOption.IsRequired = true; command.AddOption(printUsageByUserIdOption); - command.SetHandler(async (string printUsageByUserId) => { + command.SetHandler(async (string printUsageByUserId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printUsageByUserIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get monthlyPrintUsageByUser from reports"; // Create options for all the parameters - var printUsageByUserIdOption = new Option("--printusagebyuser-id", description: "key: id of printUsageByUser") { + var printUsageByUserIdOption = new Option("--print-usage-by-user-id", description: "key: id of printUsageByUser") { }; printUsageByUserIdOption.IsRequired = true; command.AddOption(printUsageByUserIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string printUsageByUserId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string printUsageByUserId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, printUsageByUserIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, printUsageByUserIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property monthlyPrintUsageByUser in reports"; // Create options for all the parameters - var printUsageByUserIdOption = new Option("--printusagebyuser-id", description: "key: id of printUsageByUser") { + var printUsageByUserIdOption = new Option("--print-usage-by-user-id", description: "key: id of printUsageByUser") { }; printUsageByUserIdOption.IsRequired = true; command.AddOption(printUsageByUserIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string printUsageByUserId, string body) => { + command.SetHandler(async (string printUsageByUserId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, printUsageByUserIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(PrintUsageByUser body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property monthlyPrintUsageByUser for reports - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get monthlyPrintUsageByUser from reports - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property monthlyPrintUsageByUser in reports - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PrintUsageByUser model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get monthlyPrintUsageByUser from reports public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Reports/MonthlyPrintUsageByUser/MonthlyPrintUsageByUserRequestBuilder.cs b/src/generated/Reports/MonthlyPrintUsageByUser/MonthlyPrintUsageByUserRequestBuilder.cs index e22aedd6e2e..e383089f574 100644 --- a/src/generated/Reports/MonthlyPrintUsageByUser/MonthlyPrintUsageByUserRequestBuilder.cs +++ b/src/generated/Reports/MonthlyPrintUsageByUser/MonthlyPrintUsageByUserRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Reports.MonthlyPrintUsageByUser.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MonthlyPrintUsageByUserRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PrintUsageByUserRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(PrintUsageByUser body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get monthlyPrintUsageByUser from reports - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to monthlyPrintUsageByUser for reports - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PrintUsageByUser model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get monthlyPrintUsageByUser from reports public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Reports/ReportsRequestBuilder.cs b/src/generated/Reports/ReportsRequestBuilder.cs index 209acc77aed..feeb53d5c07 100644 --- a/src/generated/Reports/ReportsRequestBuilder.cs +++ b/src/generated/Reports/ReportsRequestBuilder.cs @@ -97,10 +97,10 @@ using ApiSdk.Reports.MonthlyPrintUsageByUser; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -118,6 +118,9 @@ public class ReportsRequestBuilder { public Command BuildDailyPrintUsageByPrinterCommand() { var command = new Command("daily-print-usage-by-printer"); var builder = new ApiSdk.Reports.DailyPrintUsageByPrinter.DailyPrintUsageByPrinterRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -125,6 +128,9 @@ public Command BuildDailyPrintUsageByPrinterCommand() { public Command BuildDailyPrintUsageByUserCommand() { var command = new Command("daily-print-usage-by-user"); var builder = new ApiSdk.Reports.DailyPrintUsageByUser.DailyPrintUsageByUserRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -146,25 +152,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } public Command BuildMonthlyPrintUsageByPrinterCommand() { var command = new Command("monthly-print-usage-by-printer"); var builder = new ApiSdk.Reports.MonthlyPrintUsageByPrinter.MonthlyPrintUsageByPrinterRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -172,6 +180,9 @@ public Command BuildMonthlyPrintUsageByPrinterCommand() { public Command BuildMonthlyPrintUsageByUserCommand() { var command = new Command("monthly-print-usage-by-user"); var builder = new ApiSdk.Reports.MonthlyPrintUsageByUser.MonthlyPrintUsageByUserRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -187,14 +198,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -264,18 +274,6 @@ public DeviceConfigurationUserActivityRequestBuilder DeviceConfigurationUserActi return new DeviceConfigurationUserActivityRequestBuilder(PathParameters, RequestAdapter); } /// - /// Get reports - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \reports\microsoft.graph.getEmailActivityCounts(period='{period}') /// Usage: period={period} /// @@ -295,8 +293,8 @@ public GetEmailActivityUserCountsWithPeriodRequestBuilder GetEmailActivityUserCo /// Builds and executes requests for operations under \reports\microsoft.graph.getEmailActivityUserDetail(date={date}) /// Usage: date={date} /// - public GetEmailActivityUserDetailWithDateRequestBuilder GetEmailActivityUserDetailWithDate(string date) { - if(string.IsNullOrEmpty(date)) throw new ArgumentNullException(nameof(date)); + public GetEmailActivityUserDetailWithDateRequestBuilder GetEmailActivityUserDetailWithDate(Date? date) { + _ = date ?? throw new ArgumentNullException(nameof(date)); return new GetEmailActivityUserDetailWithDateRequestBuilder(PathParameters, RequestAdapter, date); } /// @@ -327,8 +325,8 @@ public GetEmailAppUsageUserCountsWithPeriodRequestBuilder GetEmailAppUsageUserCo /// Builds and executes requests for operations under \reports\microsoft.graph.getEmailAppUsageUserDetail(date={date}) /// Usage: date={date} /// - public GetEmailAppUsageUserDetailWithDateRequestBuilder GetEmailAppUsageUserDetailWithDate(string date) { - if(string.IsNullOrEmpty(date)) throw new ArgumentNullException(nameof(date)); + public GetEmailAppUsageUserDetailWithDateRequestBuilder GetEmailAppUsageUserDetailWithDate(Date? date) { + _ = date ?? throw new ArgumentNullException(nameof(date)); return new GetEmailAppUsageUserDetailWithDateRequestBuilder(PathParameters, RequestAdapter, date); } /// @@ -421,8 +419,8 @@ public GetOffice365ActiveUserCountsWithPeriodRequestBuilder GetOffice365ActiveUs /// Builds and executes requests for operations under \reports\microsoft.graph.getOffice365ActiveUserDetail(date={date}) /// Usage: date={date} /// - public GetOffice365ActiveUserDetailWithDateRequestBuilder GetOffice365ActiveUserDetailWithDate(string date) { - if(string.IsNullOrEmpty(date)) throw new ArgumentNullException(nameof(date)); + public GetOffice365ActiveUserDetailWithDateRequestBuilder GetOffice365ActiveUserDetailWithDate(Date? date) { + _ = date ?? throw new ArgumentNullException(nameof(date)); return new GetOffice365ActiveUserDetailWithDateRequestBuilder(PathParameters, RequestAdapter, date); } /// @@ -445,8 +443,8 @@ public GetOffice365GroupsActivityCountsWithPeriodRequestBuilder GetOffice365Grou /// Builds and executes requests for operations under \reports\microsoft.graph.getOffice365GroupsActivityDetail(date={date}) /// Usage: date={date} /// - public GetOffice365GroupsActivityDetailWithDateRequestBuilder GetOffice365GroupsActivityDetailWithDate(string date) { - if(string.IsNullOrEmpty(date)) throw new ArgumentNullException(nameof(date)); + public GetOffice365GroupsActivityDetailWithDateRequestBuilder GetOffice365GroupsActivityDetailWithDate(Date? date) { + _ = date ?? throw new ArgumentNullException(nameof(date)); return new GetOffice365GroupsActivityDetailWithDateRequestBuilder(PathParameters, RequestAdapter, date); } /// @@ -509,8 +507,8 @@ public GetOneDriveActivityUserCountsWithPeriodRequestBuilder GetOneDriveActivity /// Builds and executes requests for operations under \reports\microsoft.graph.getOneDriveActivityUserDetail(date={date}) /// Usage: date={date} /// - public GetOneDriveActivityUserDetailWithDateRequestBuilder GetOneDriveActivityUserDetailWithDate(string date) { - if(string.IsNullOrEmpty(date)) throw new ArgumentNullException(nameof(date)); + public GetOneDriveActivityUserDetailWithDateRequestBuilder GetOneDriveActivityUserDetailWithDate(Date? date) { + _ = date ?? throw new ArgumentNullException(nameof(date)); return new GetOneDriveActivityUserDetailWithDateRequestBuilder(PathParameters, RequestAdapter, date); } /// @@ -533,8 +531,8 @@ public GetOneDriveUsageAccountCountsWithPeriodRequestBuilder GetOneDriveUsageAcc /// Builds and executes requests for operations under \reports\microsoft.graph.getOneDriveUsageAccountDetail(date={date}) /// Usage: date={date} /// - public GetOneDriveUsageAccountDetailWithDateRequestBuilder GetOneDriveUsageAccountDetailWithDate(string date) { - if(string.IsNullOrEmpty(date)) throw new ArgumentNullException(nameof(date)); + public GetOneDriveUsageAccountDetailWithDateRequestBuilder GetOneDriveUsageAccountDetailWithDate(Date? date) { + _ = date ?? throw new ArgumentNullException(nameof(date)); return new GetOneDriveUsageAccountDetailWithDateRequestBuilder(PathParameters, RequestAdapter, date); } /// @@ -601,8 +599,8 @@ public GetSharePointActivityUserCountsWithPeriodRequestBuilder GetSharePointActi /// Builds and executes requests for operations under \reports\microsoft.graph.getSharePointActivityUserDetail(date={date}) /// Usage: date={date} /// - public GetSharePointActivityUserDetailWithDateRequestBuilder GetSharePointActivityUserDetailWithDate(string date) { - if(string.IsNullOrEmpty(date)) throw new ArgumentNullException(nameof(date)); + public GetSharePointActivityUserDetailWithDateRequestBuilder GetSharePointActivityUserDetailWithDate(Date? date) { + _ = date ?? throw new ArgumentNullException(nameof(date)); return new GetSharePointActivityUserDetailWithDateRequestBuilder(PathParameters, RequestAdapter, date); } /// @@ -617,8 +615,8 @@ public GetSharePointActivityUserDetailWithPeriodRequestBuilder GetSharePointActi /// Builds and executes requests for operations under \reports\microsoft.graph.getSharePointSiteUsageDetail(date={date}) /// Usage: date={date} /// - public GetSharePointSiteUsageDetailWithDateRequestBuilder GetSharePointSiteUsageDetailWithDate(string date) { - if(string.IsNullOrEmpty(date)) throw new ArgumentNullException(nameof(date)); + public GetSharePointSiteUsageDetailWithDateRequestBuilder GetSharePointSiteUsageDetailWithDate(Date? date) { + _ = date ?? throw new ArgumentNullException(nameof(date)); return new GetSharePointSiteUsageDetailWithDateRequestBuilder(PathParameters, RequestAdapter, date); } /// @@ -681,8 +679,8 @@ public GetSkypeForBusinessActivityUserCountsWithPeriodRequestBuilder GetSkypeFor /// Builds and executes requests for operations under \reports\microsoft.graph.getSkypeForBusinessActivityUserDetail(date={date}) /// Usage: date={date} /// - public GetSkypeForBusinessActivityUserDetailWithDateRequestBuilder GetSkypeForBusinessActivityUserDetailWithDate(string date) { - if(string.IsNullOrEmpty(date)) throw new ArgumentNullException(nameof(date)); + public GetSkypeForBusinessActivityUserDetailWithDateRequestBuilder GetSkypeForBusinessActivityUserDetailWithDate(Date? date) { + _ = date ?? throw new ArgumentNullException(nameof(date)); return new GetSkypeForBusinessActivityUserDetailWithDateRequestBuilder(PathParameters, RequestAdapter, date); } /// @@ -713,8 +711,8 @@ public GetSkypeForBusinessDeviceUsageUserCountsWithPeriodRequestBuilder GetSkype /// Builds and executes requests for operations under \reports\microsoft.graph.getSkypeForBusinessDeviceUsageUserDetail(date={date}) /// Usage: date={date} /// - public GetSkypeForBusinessDeviceUsageUserDetailWithDateRequestBuilder GetSkypeForBusinessDeviceUsageUserDetailWithDate(string date) { - if(string.IsNullOrEmpty(date)) throw new ArgumentNullException(nameof(date)); + public GetSkypeForBusinessDeviceUsageUserDetailWithDateRequestBuilder GetSkypeForBusinessDeviceUsageUserDetailWithDate(Date? date) { + _ = date ?? throw new ArgumentNullException(nameof(date)); return new GetSkypeForBusinessDeviceUsageUserDetailWithDateRequestBuilder(PathParameters, RequestAdapter, date); } /// @@ -817,8 +815,8 @@ public GetTeamsDeviceUsageUserCountsWithPeriodRequestBuilder GetTeamsDeviceUsage /// Builds and executes requests for operations under \reports\microsoft.graph.getTeamsDeviceUsageUserDetail(date={date}) /// Usage: date={date} /// - public GetTeamsDeviceUsageUserDetailWithDateRequestBuilder GetTeamsDeviceUsageUserDetailWithDate(string date) { - if(string.IsNullOrEmpty(date)) throw new ArgumentNullException(nameof(date)); + public GetTeamsDeviceUsageUserDetailWithDateRequestBuilder GetTeamsDeviceUsageUserDetailWithDate(Date? date) { + _ = date ?? throw new ArgumentNullException(nameof(date)); return new GetTeamsDeviceUsageUserDetailWithDateRequestBuilder(PathParameters, RequestAdapter, date); } /// @@ -849,8 +847,8 @@ public GetTeamsUserActivityUserCountsWithPeriodRequestBuilder GetTeamsUserActivi /// Builds and executes requests for operations under \reports\microsoft.graph.getTeamsUserActivityUserDetail(date={date}) /// Usage: date={date} /// - public GetTeamsUserActivityUserDetailWithDateRequestBuilder GetTeamsUserActivityUserDetailWithDate(string date) { - if(string.IsNullOrEmpty(date)) throw new ArgumentNullException(nameof(date)); + public GetTeamsUserActivityUserDetailWithDateRequestBuilder GetTeamsUserActivityUserDetailWithDate(Date? date) { + _ = date ?? throw new ArgumentNullException(nameof(date)); return new GetTeamsUserActivityUserDetailWithDateRequestBuilder(PathParameters, RequestAdapter, date); } /// @@ -893,8 +891,8 @@ public GetYammerActivityUserCountsWithPeriodRequestBuilder GetYammerActivityUser /// Builds and executes requests for operations under \reports\microsoft.graph.getYammerActivityUserDetail(date={date}) /// Usage: date={date} /// - public GetYammerActivityUserDetailWithDateRequestBuilder GetYammerActivityUserDetailWithDate(string date) { - if(string.IsNullOrEmpty(date)) throw new ArgumentNullException(nameof(date)); + public GetYammerActivityUserDetailWithDateRequestBuilder GetYammerActivityUserDetailWithDate(Date? date) { + _ = date ?? throw new ArgumentNullException(nameof(date)); return new GetYammerActivityUserDetailWithDateRequestBuilder(PathParameters, RequestAdapter, date); } /// @@ -925,8 +923,8 @@ public GetYammerDeviceUsageUserCountsWithPeriodRequestBuilder GetYammerDeviceUsa /// Builds and executes requests for operations under \reports\microsoft.graph.getYammerDeviceUsageUserDetail(date={date}) /// Usage: date={date} /// - public GetYammerDeviceUsageUserDetailWithDateRequestBuilder GetYammerDeviceUsageUserDetailWithDate(string date) { - if(string.IsNullOrEmpty(date)) throw new ArgumentNullException(nameof(date)); + public GetYammerDeviceUsageUserDetailWithDateRequestBuilder GetYammerDeviceUsageUserDetailWithDate(Date? date) { + _ = date ?? throw new ArgumentNullException(nameof(date)); return new GetYammerDeviceUsageUserDetailWithDateRequestBuilder(PathParameters, RequestAdapter, date); } /// @@ -949,8 +947,8 @@ public GetYammerGroupsActivityCountsWithPeriodRequestBuilder GetYammerGroupsActi /// Builds and executes requests for operations under \reports\microsoft.graph.getYammerGroupsActivityDetail(date={date}) /// Usage: date={date} /// - public GetYammerGroupsActivityDetailWithDateRequestBuilder GetYammerGroupsActivityDetailWithDate(string date) { - if(string.IsNullOrEmpty(date)) throw new ArgumentNullException(nameof(date)); + public GetYammerGroupsActivityDetailWithDateRequestBuilder GetYammerGroupsActivityDetailWithDate(Date? date) { + _ = date ?? throw new ArgumentNullException(nameof(date)); return new GetYammerGroupsActivityDetailWithDateRequestBuilder(PathParameters, RequestAdapter, date); } /// @@ -1003,19 +1001,6 @@ public ManagedDeviceEnrollmentTopFailuresWithPeriodRequestBuilder ManagedDeviceE if(string.IsNullOrEmpty(period)) throw new ArgumentNullException(nameof(period)); return new ManagedDeviceEnrollmentTopFailuresWithPeriodRequestBuilder(PathParameters, RequestAdapter, period); } - /// - /// Update reports - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ReportRoot model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get reports public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/RoleManagement/Directory/DirectoryRequestBuilder.cs b/src/generated/RoleManagement/Directory/DirectoryRequestBuilder.cs index 9e51ee5eb95..17db0e78c8f 100644 --- a/src/generated/RoleManagement/Directory/DirectoryRequestBuilder.cs +++ b/src/generated/RoleManagement/Directory/DirectoryRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.RoleManagement.Directory.RoleDefinitions; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,11 +28,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -54,20 +53,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -81,14 +79,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -96,6 +93,9 @@ public Command BuildPatchCommand() { public Command BuildRoleAssignmentsCommand() { var command = new Command("role-assignments"); var builder = new ApiSdk.RoleManagement.Directory.RoleAssignments.RoleAssignmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -103,6 +103,9 @@ public Command BuildRoleAssignmentsCommand() { public Command BuildRoleDefinitionsCommand() { var command = new Command("role-definitions"); var builder = new ApiSdk.RoleManagement.Directory.RoleDefinitions.RoleDefinitionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -174,42 +177,6 @@ public RequestInformation CreatePatchRequestInformation(RbacApplication body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(RbacApplication model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/RoleManagement/Directory/RoleAssignments/Item/AppScope/AppScopeRequestBuilder.cs b/src/generated/RoleManagement/Directory/RoleAssignments/Item/AppScope/AppScopeRequestBuilder.cs index 405faca386f..864f6d0d9e5 100644 --- a/src/generated/RoleManagement/Directory/RoleAssignments/Item/AppScope/AppScopeRequestBuilder.cs +++ b/src/generated/RoleManagement/Directory/RoleAssignments/Item/AppScope/AppScopeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Details of the app specific scope when the assignment scope is app specific. Containment entity."; // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { }; unifiedRoleAssignmentIdOption.IsRequired = true; command.AddOption(unifiedRoleAssignmentIdOption); - command.SetHandler(async (string unifiedRoleAssignmentId) => { + command.SetHandler(async (string unifiedRoleAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, unifiedRoleAssignmentIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Details of the app specific scope when the assignment scope is app specific. Containment entity."; // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { }; unifiedRoleAssignmentIdOption.IsRequired = true; command.AddOption(unifiedRoleAssignmentIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string unifiedRoleAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string unifiedRoleAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, unifiedRoleAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, unifiedRoleAssignmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Details of the app specific scope when the assignment scope is app specific. Containment entity."; // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { }; unifiedRoleAssignmentIdOption.IsRequired = true; command.AddOption(unifiedRoleAssignmentIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string unifiedRoleAssignmentId, string body) => { + command.SetHandler(async (string unifiedRoleAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, unifiedRoleAssignmentIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Details of the app specific scope when the assignment scope is app specific. Containment entity. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Details of the app specific scope when the assignment scope is app specific. Containment entity. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Details of the app specific scope when the assignment scope is app specific. Containment entity. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.AppScope model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Details of the app specific scope when the assignment scope is app specific. Containment entity. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/RoleManagement/Directory/RoleAssignments/Item/DirectoryScope/@Ref/@Ref.cs b/src/generated/RoleManagement/Directory/RoleAssignments/Item/DirectoryScope/@Ref/@Ref.cs deleted file mode 100644 index a442c9b656e..00000000000 --- a/src/generated/RoleManagement/Directory/RoleAssignments/Item/DirectoryScope/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.RoleManagement.Directory.RoleAssignments.Item.DirectoryScope.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/RoleManagement/Directory/RoleAssignments/Item/DirectoryScope/@Ref/RefRequestBuilder.cs b/src/generated/RoleManagement/Directory/RoleAssignments/Item/DirectoryScope/@Ref/RefRequestBuilder.cs deleted file mode 100644 index f655ec161de..00000000000 --- a/src/generated/RoleManagement/Directory/RoleAssignments/Item/DirectoryScope/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.RoleManagement.Directory.RoleAssignments.Item.DirectoryScope.@Ref { - /// Builds and executes requests for operations under \roleManagement\directory\roleAssignments\{unifiedRoleAssignment-id}\directoryScope\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; - // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { - }; - unifiedRoleAssignmentIdOption.IsRequired = true; - command.AddOption(unifiedRoleAssignmentIdOption); - command.SetHandler(async (string unifiedRoleAssignmentId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, unifiedRoleAssignmentIdOption); - return command; - } - /// - /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; - // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { - }; - unifiedRoleAssignmentIdOption.IsRequired = true; - command.AddOption(unifiedRoleAssignmentIdOption); - command.SetHandler(async (string unifiedRoleAssignmentId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, unifiedRoleAssignmentIdOption); - return command; - } - /// - /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; - // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { - }; - unifiedRoleAssignmentIdOption.IsRequired = true; - command.AddOption(unifiedRoleAssignmentIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string unifiedRoleAssignmentId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, unifiedRoleAssignmentIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/roleManagement/directory/roleAssignments/{unifiedRoleAssignment_id}/directoryScope/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.RoleManagement.Directory.RoleAssignments.Item.DirectoryScope.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.RoleManagement.Directory.RoleAssignments.Item.DirectoryScope.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/RoleManagement/Directory/RoleAssignments/Item/DirectoryScope/DirectoryScopeRequestBuilder.cs b/src/generated/RoleManagement/Directory/RoleAssignments/Item/DirectoryScope/DirectoryScopeRequestBuilder.cs index 1b3318c67d8..33b54a453bf 100644 --- a/src/generated/RoleManagement/Directory/RoleAssignments/Item/DirectoryScope/DirectoryScopeRequestBuilder.cs +++ b/src/generated/RoleManagement/Directory/RoleAssignments/Item/DirectoryScope/DirectoryScopeRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.RoleManagement.Directory.RoleAssignments.Item.DirectoryScope.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { }; unifiedRoleAssignmentIdOption.IsRequired = true; command.AddOption(unifiedRoleAssignmentIdOption); @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string unifiedRoleAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string unifiedRoleAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, unifiedRoleAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, unifiedRoleAssignmentIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.RoleManagement.Directory.RoleAssignments.Item.DirectoryScope.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.RoleManagement.Directory.RoleAssignments.Item.DirectoryScope.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/RoleManagement/Directory/RoleAssignments/Item/DirectoryScope/Ref/Ref.cs b/src/generated/RoleManagement/Directory/RoleAssignments/Item/DirectoryScope/Ref/Ref.cs new file mode 100644 index 00000000000..8089205cf03 --- /dev/null +++ b/src/generated/RoleManagement/Directory/RoleAssignments/Item/DirectoryScope/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.RoleManagement.Directory.RoleAssignments.Item.DirectoryScope.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/RoleManagement/Directory/RoleAssignments/Item/DirectoryScope/Ref/RefRequestBuilder.cs b/src/generated/RoleManagement/Directory/RoleAssignments/Item/DirectoryScope/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..3167a20c350 --- /dev/null +++ b/src/generated/RoleManagement/Directory/RoleAssignments/Item/DirectoryScope/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.RoleManagement.Directory.RoleAssignments.Item.DirectoryScope.Ref { + /// Builds and executes requests for operations under \roleManagement\directory\roleAssignments\{unifiedRoleAssignment-id}\directoryScope\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; + // Create options for all the parameters + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { + }; + unifiedRoleAssignmentIdOption.IsRequired = true; + command.AddOption(unifiedRoleAssignmentIdOption); + command.SetHandler(async (string unifiedRoleAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, unifiedRoleAssignmentIdOption); + return command; + } + /// + /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; + // Create options for all the parameters + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { + }; + unifiedRoleAssignmentIdOption.IsRequired = true; + command.AddOption(unifiedRoleAssignmentIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string unifiedRoleAssignmentId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, unifiedRoleAssignmentIdOption, outputOption); + return command; + } + /// + /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; + // Create options for all the parameters + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { + }; + unifiedRoleAssignmentIdOption.IsRequired = true; + command.AddOption(unifiedRoleAssignmentIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string unifiedRoleAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, unifiedRoleAssignmentIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/roleManagement/directory/roleAssignments/{unifiedRoleAssignment_id}/directoryScope/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.RoleManagement.Directory.RoleAssignments.Item.DirectoryScope.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/RoleManagement/Directory/RoleAssignments/Item/Principal/@Ref/@Ref.cs b/src/generated/RoleManagement/Directory/RoleAssignments/Item/Principal/@Ref/@Ref.cs deleted file mode 100644 index 63d95cad3a3..00000000000 --- a/src/generated/RoleManagement/Directory/RoleAssignments/Item/Principal/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.RoleManagement.Directory.RoleAssignments.Item.Principal.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/RoleManagement/Directory/RoleAssignments/Item/Principal/@Ref/RefRequestBuilder.cs b/src/generated/RoleManagement/Directory/RoleAssignments/Item/Principal/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 35e685c443e..00000000000 --- a/src/generated/RoleManagement/Directory/RoleAssignments/Item/Principal/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.RoleManagement.Directory.RoleAssignments.Item.Principal.@Ref { - /// Builds and executes requests for operations under \roleManagement\directory\roleAssignments\{unifiedRoleAssignment-id}\principal\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; - // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { - }; - unifiedRoleAssignmentIdOption.IsRequired = true; - command.AddOption(unifiedRoleAssignmentIdOption); - command.SetHandler(async (string unifiedRoleAssignmentId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, unifiedRoleAssignmentIdOption); - return command; - } - /// - /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; - // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { - }; - unifiedRoleAssignmentIdOption.IsRequired = true; - command.AddOption(unifiedRoleAssignmentIdOption); - command.SetHandler(async (string unifiedRoleAssignmentId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, unifiedRoleAssignmentIdOption); - return command; - } - /// - /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; - // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { - }; - unifiedRoleAssignmentIdOption.IsRequired = true; - command.AddOption(unifiedRoleAssignmentIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string unifiedRoleAssignmentId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, unifiedRoleAssignmentIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/roleManagement/directory/roleAssignments/{unifiedRoleAssignment_id}/principal/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.RoleManagement.Directory.RoleAssignments.Item.Principal.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.RoleManagement.Directory.RoleAssignments.Item.Principal.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/RoleManagement/Directory/RoleAssignments/Item/Principal/PrincipalRequestBuilder.cs b/src/generated/RoleManagement/Directory/RoleAssignments/Item/Principal/PrincipalRequestBuilder.cs index 75e7367ba66..cb9127c9fa1 100644 --- a/src/generated/RoleManagement/Directory/RoleAssignments/Item/Principal/PrincipalRequestBuilder.cs +++ b/src/generated/RoleManagement/Directory/RoleAssignments/Item/Principal/PrincipalRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.RoleManagement.Directory.RoleAssignments.Item.Principal.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { }; unifiedRoleAssignmentIdOption.IsRequired = true; command.AddOption(unifiedRoleAssignmentIdOption); @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string unifiedRoleAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string unifiedRoleAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, unifiedRoleAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, unifiedRoleAssignmentIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.RoleManagement.Directory.RoleAssignments.Item.Principal.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.RoleManagement.Directory.RoleAssignments.Item.Principal.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/RoleManagement/Directory/RoleAssignments/Item/Principal/Ref/Ref.cs b/src/generated/RoleManagement/Directory/RoleAssignments/Item/Principal/Ref/Ref.cs new file mode 100644 index 00000000000..4c64919ead5 --- /dev/null +++ b/src/generated/RoleManagement/Directory/RoleAssignments/Item/Principal/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.RoleManagement.Directory.RoleAssignments.Item.Principal.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/RoleManagement/Directory/RoleAssignments/Item/Principal/Ref/RefRequestBuilder.cs b/src/generated/RoleManagement/Directory/RoleAssignments/Item/Principal/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..5690ce44da9 --- /dev/null +++ b/src/generated/RoleManagement/Directory/RoleAssignments/Item/Principal/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.RoleManagement.Directory.RoleAssignments.Item.Principal.Ref { + /// Builds and executes requests for operations under \roleManagement\directory\roleAssignments\{unifiedRoleAssignment-id}\principal\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; + // Create options for all the parameters + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { + }; + unifiedRoleAssignmentIdOption.IsRequired = true; + command.AddOption(unifiedRoleAssignmentIdOption); + command.SetHandler(async (string unifiedRoleAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, unifiedRoleAssignmentIdOption); + return command; + } + /// + /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; + // Create options for all the parameters + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { + }; + unifiedRoleAssignmentIdOption.IsRequired = true; + command.AddOption(unifiedRoleAssignmentIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string unifiedRoleAssignmentId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, unifiedRoleAssignmentIdOption, outputOption); + return command; + } + /// + /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; + // Create options for all the parameters + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { + }; + unifiedRoleAssignmentIdOption.IsRequired = true; + command.AddOption(unifiedRoleAssignmentIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string unifiedRoleAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, unifiedRoleAssignmentIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/roleManagement/directory/roleAssignments/{unifiedRoleAssignment_id}/principal/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.RoleManagement.Directory.RoleAssignments.Item.Principal.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/RoleManagement/Directory/RoleAssignments/Item/RoleDefinition/@Ref/@Ref.cs b/src/generated/RoleManagement/Directory/RoleAssignments/Item/RoleDefinition/@Ref/@Ref.cs deleted file mode 100644 index 595d71676af..00000000000 --- a/src/generated/RoleManagement/Directory/RoleAssignments/Item/RoleDefinition/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.RoleManagement.Directory.RoleAssignments.Item.RoleDefinition.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/RoleManagement/Directory/RoleAssignments/Item/RoleDefinition/@Ref/RefRequestBuilder.cs b/src/generated/RoleManagement/Directory/RoleAssignments/Item/RoleDefinition/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 13f16202ae1..00000000000 --- a/src/generated/RoleManagement/Directory/RoleAssignments/Item/RoleDefinition/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.RoleManagement.Directory.RoleAssignments.Item.RoleDefinition.@Ref { - /// Builds and executes requests for operations under \roleManagement\directory\roleAssignments\{unifiedRoleAssignment-id}\roleDefinition\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand."; - // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { - }; - unifiedRoleAssignmentIdOption.IsRequired = true; - command.AddOption(unifiedRoleAssignmentIdOption); - command.SetHandler(async (string unifiedRoleAssignmentId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, unifiedRoleAssignmentIdOption); - return command; - } - /// - /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand."; - // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { - }; - unifiedRoleAssignmentIdOption.IsRequired = true; - command.AddOption(unifiedRoleAssignmentIdOption); - command.SetHandler(async (string unifiedRoleAssignmentId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, unifiedRoleAssignmentIdOption); - return command; - } - /// - /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand."; - // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { - }; - unifiedRoleAssignmentIdOption.IsRequired = true; - command.AddOption(unifiedRoleAssignmentIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string unifiedRoleAssignmentId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, unifiedRoleAssignmentIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/roleManagement/directory/roleAssignments/{unifiedRoleAssignment_id}/roleDefinition/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.RoleManagement.Directory.RoleAssignments.Item.RoleDefinition.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.RoleManagement.Directory.RoleAssignments.Item.RoleDefinition.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/RoleManagement/Directory/RoleAssignments/Item/RoleDefinition/Ref/Ref.cs b/src/generated/RoleManagement/Directory/RoleAssignments/Item/RoleDefinition/Ref/Ref.cs new file mode 100644 index 00000000000..80fa51bfde0 --- /dev/null +++ b/src/generated/RoleManagement/Directory/RoleAssignments/Item/RoleDefinition/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.RoleManagement.Directory.RoleAssignments.Item.RoleDefinition.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/RoleManagement/Directory/RoleAssignments/Item/RoleDefinition/Ref/RefRequestBuilder.cs b/src/generated/RoleManagement/Directory/RoleAssignments/Item/RoleDefinition/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..fc917b50b15 --- /dev/null +++ b/src/generated/RoleManagement/Directory/RoleAssignments/Item/RoleDefinition/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.RoleManagement.Directory.RoleAssignments.Item.RoleDefinition.Ref { + /// Builds and executes requests for operations under \roleManagement\directory\roleAssignments\{unifiedRoleAssignment-id}\roleDefinition\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand."; + // Create options for all the parameters + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { + }; + unifiedRoleAssignmentIdOption.IsRequired = true; + command.AddOption(unifiedRoleAssignmentIdOption); + command.SetHandler(async (string unifiedRoleAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, unifiedRoleAssignmentIdOption); + return command; + } + /// + /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand."; + // Create options for all the parameters + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { + }; + unifiedRoleAssignmentIdOption.IsRequired = true; + command.AddOption(unifiedRoleAssignmentIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string unifiedRoleAssignmentId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, unifiedRoleAssignmentIdOption, outputOption); + return command; + } + /// + /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand."; + // Create options for all the parameters + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { + }; + unifiedRoleAssignmentIdOption.IsRequired = true; + command.AddOption(unifiedRoleAssignmentIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string unifiedRoleAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, unifiedRoleAssignmentIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/roleManagement/directory/roleAssignments/{unifiedRoleAssignment_id}/roleDefinition/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.RoleManagement.Directory.RoleAssignments.Item.RoleDefinition.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/RoleManagement/Directory/RoleAssignments/Item/RoleDefinition/RoleDefinitionRequestBuilder.cs b/src/generated/RoleManagement/Directory/RoleAssignments/Item/RoleDefinition/RoleDefinitionRequestBuilder.cs index 57060f988fc..fcfb700a453 100644 --- a/src/generated/RoleManagement/Directory/RoleAssignments/Item/RoleDefinition/RoleDefinitionRequestBuilder.cs +++ b/src/generated/RoleManagement/Directory/RoleAssignments/Item/RoleDefinition/RoleDefinitionRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.RoleManagement.Directory.RoleAssignments.Item.RoleDefinition.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand."; // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { }; unifiedRoleAssignmentIdOption.IsRequired = true; command.AddOption(unifiedRoleAssignmentIdOption); @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string unifiedRoleAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string unifiedRoleAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, unifiedRoleAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, unifiedRoleAssignmentIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.RoleManagement.Directory.RoleAssignments.Item.RoleDefinition.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.RoleManagement.Directory.RoleAssignments.Item.RoleDefinition.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/RoleManagement/Directory/RoleAssignments/Item/UnifiedRoleAssignmentRequestBuilder.cs b/src/generated/RoleManagement/Directory/RoleAssignments/Item/UnifiedRoleAssignmentRequestBuilder.cs index 8e1e982944f..cdff043e8c9 100644 --- a/src/generated/RoleManagement/Directory/RoleAssignments/Item/UnifiedRoleAssignmentRequestBuilder.cs +++ b/src/generated/RoleManagement/Directory/RoleAssignments/Item/UnifiedRoleAssignmentRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.RoleManagement.Directory.RoleAssignments.Item.RoleDefinition; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Resource to grant access to users or groups."; // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { }; unifiedRoleAssignmentIdOption.IsRequired = true; command.AddOption(unifiedRoleAssignmentIdOption); - command.SetHandler(async (string unifiedRoleAssignmentId) => { + command.SetHandler(async (string unifiedRoleAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, unifiedRoleAssignmentIdOption); return command; @@ -65,7 +64,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Resource to grant access to users or groups."; // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { }; unifiedRoleAssignmentIdOption.IsRequired = true; command.AddOption(unifiedRoleAssignmentIdOption); @@ -79,20 +78,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string unifiedRoleAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string unifiedRoleAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, unifiedRoleAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, unifiedRoleAssignmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -102,7 +100,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Resource to grant access to users or groups."; // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { }; unifiedRoleAssignmentIdOption.IsRequired = true; command.AddOption(unifiedRoleAssignmentIdOption); @@ -110,14 +108,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string unifiedRoleAssignmentId, string body) => { + command.SetHandler(async (string unifiedRoleAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, unifiedRoleAssignmentIdOption, bodyOption); return command; @@ -203,42 +200,6 @@ public RequestInformation CreatePatchRequestInformation(UnifiedRoleAssignment bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Resource to grant access to users or groups. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Resource to grant access to users or groups. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Resource to grant access to users or groups. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(UnifiedRoleAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Resource to grant access to users or groups. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/RoleManagement/Directory/RoleAssignments/RoleAssignmentsRequestBuilder.cs b/src/generated/RoleManagement/Directory/RoleAssignments/RoleAssignmentsRequestBuilder.cs index dc04fb2daec..368fa520406 100644 --- a/src/generated/RoleManagement/Directory/RoleAssignments/RoleAssignmentsRequestBuilder.cs +++ b/src/generated/RoleManagement/Directory/RoleAssignments/RoleAssignmentsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.RoleManagement.Directory.RoleAssignments.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class RoleAssignmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new UnifiedRoleAssignmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAppScopeCommand(), - builder.BuildDeleteCommand(), - builder.BuildDirectoryScopeCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildPrincipalCommand(), - builder.BuildRoleDefinitionCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAppScopeCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDirectoryScopeCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPrincipalCommand()); + commands.Add(builder.BuildRoleDefinitionCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -103,7 +101,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -114,15 +116,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -177,31 +174,6 @@ public RequestInformation CreatePostRequestInformation(UnifiedRoleAssignment bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Resource to grant access to users or groups. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Resource to grant access to users or groups. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UnifiedRoleAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Resource to grant access to users or groups. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/RoleManagement/Directory/RoleDefinitions/Item/InheritsPermissionsFrom/InheritsPermissionsFromRequestBuilder.cs b/src/generated/RoleManagement/Directory/RoleDefinitions/Item/InheritsPermissionsFrom/InheritsPermissionsFromRequestBuilder.cs index bd5f75c8f0d..7e7b2e14526 100644 --- a/src/generated/RoleManagement/Directory/RoleDefinitions/Item/InheritsPermissionsFrom/InheritsPermissionsFromRequestBuilder.cs +++ b/src/generated/RoleManagement/Directory/RoleDefinitions/Item/InheritsPermissionsFrom/InheritsPermissionsFromRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.RoleManagement.Directory.RoleDefinitions.Item.InheritsPermissionsFrom.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class InheritsPermissionsFromRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new UnifiedRoleDefinitionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Read-only collection of role definitions that the given role definition inherits from. Only Azure AD built-in roles support this attribute."; // Create options for all the parameters - var unifiedRoleDefinitionIdOption = new Option("--unifiedroledefinition-id", description: "key: id of unifiedRoleDefinition") { + var unifiedRoleDefinitionIdOption = new Option("--unified-role-definition-id", description: "key: id of unifiedRoleDefinition") { }; unifiedRoleDefinitionIdOption.IsRequired = true; command.AddOption(unifiedRoleDefinitionIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string unifiedRoleDefinitionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string unifiedRoleDefinitionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, unifiedRoleDefinitionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, unifiedRoleDefinitionIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Read-only collection of role definitions that the given role definition inherits from. Only Azure AD built-in roles support this attribute."; // Create options for all the parameters - var unifiedRoleDefinitionIdOption = new Option("--unifiedroledefinition-id", description: "key: id of unifiedRoleDefinition") { + var unifiedRoleDefinitionIdOption = new Option("--unified-role-definition-id", description: "key: id of unifiedRoleDefinition") { }; unifiedRoleDefinitionIdOption.IsRequired = true; command.AddOption(unifiedRoleDefinitionIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string unifiedRoleDefinitionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string unifiedRoleDefinitionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, unifiedRoleDefinitionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, unifiedRoleDefinitionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(UnifiedRoleDefinition bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only collection of role definitions that the given role definition inherits from. Only Azure AD built-in roles support this attribute. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only collection of role definitions that the given role definition inherits from. Only Azure AD built-in roles support this attribute. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UnifiedRoleDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only collection of role definitions that the given role definition inherits from. Only Azure AD built-in roles support this attribute. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/RoleManagement/Directory/RoleDefinitions/Item/InheritsPermissionsFrom/Item/UnifiedRoleDefinitionRequestBuilder.cs b/src/generated/RoleManagement/Directory/RoleDefinitions/Item/InheritsPermissionsFrom/Item/UnifiedRoleDefinitionRequestBuilder.cs index 6e79508dc52..4a55529d26e 100644 --- a/src/generated/RoleManagement/Directory/RoleDefinitions/Item/InheritsPermissionsFrom/Item/UnifiedRoleDefinitionRequestBuilder.cs +++ b/src/generated/RoleManagement/Directory/RoleDefinitions/Item/InheritsPermissionsFrom/Item/UnifiedRoleDefinitionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only collection of role definitions that the given role definition inherits from. Only Azure AD built-in roles support this attribute."; // Create options for all the parameters - var unifiedRoleDefinitionIdOption = new Option("--unifiedroledefinition-id", description: "key: id of unifiedRoleDefinition") { + var unifiedRoleDefinitionIdOption = new Option("--unified-role-definition-id", description: "key: id of unifiedRoleDefinition") { }; unifiedRoleDefinitionIdOption.IsRequired = true; command.AddOption(unifiedRoleDefinitionIdOption); - var unifiedRoleDefinitionId1Option = new Option("--unifiedroledefinition-id1", description: "key: id of unifiedRoleDefinition") { + var unifiedRoleDefinitionId1Option = new Option("--unified-role-definition-id1", description: "key: id of unifiedRoleDefinition") { }; unifiedRoleDefinitionId1Option.IsRequired = true; command.AddOption(unifiedRoleDefinitionId1Option); - command.SetHandler(async (string unifiedRoleDefinitionId, string unifiedRoleDefinitionId1) => { + command.SetHandler(async (string unifiedRoleDefinitionId, string unifiedRoleDefinitionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, unifiedRoleDefinitionIdOption, unifiedRoleDefinitionId1Option); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only collection of role definitions that the given role definition inherits from. Only Azure AD built-in roles support this attribute."; // Create options for all the parameters - var unifiedRoleDefinitionIdOption = new Option("--unifiedroledefinition-id", description: "key: id of unifiedRoleDefinition") { + var unifiedRoleDefinitionIdOption = new Option("--unified-role-definition-id", description: "key: id of unifiedRoleDefinition") { }; unifiedRoleDefinitionIdOption.IsRequired = true; command.AddOption(unifiedRoleDefinitionIdOption); - var unifiedRoleDefinitionId1Option = new Option("--unifiedroledefinition-id1", description: "key: id of unifiedRoleDefinition") { + var unifiedRoleDefinitionId1Option = new Option("--unified-role-definition-id1", description: "key: id of unifiedRoleDefinition") { }; unifiedRoleDefinitionId1Option.IsRequired = true; command.AddOption(unifiedRoleDefinitionId1Option); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string unifiedRoleDefinitionId, string unifiedRoleDefinitionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string unifiedRoleDefinitionId, string unifiedRoleDefinitionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, unifiedRoleDefinitionIdOption, unifiedRoleDefinitionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, unifiedRoleDefinitionIdOption, unifiedRoleDefinitionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only collection of role definitions that the given role definition inherits from. Only Azure AD built-in roles support this attribute."; // Create options for all the parameters - var unifiedRoleDefinitionIdOption = new Option("--unifiedroledefinition-id", description: "key: id of unifiedRoleDefinition") { + var unifiedRoleDefinitionIdOption = new Option("--unified-role-definition-id", description: "key: id of unifiedRoleDefinition") { }; unifiedRoleDefinitionIdOption.IsRequired = true; command.AddOption(unifiedRoleDefinitionIdOption); - var unifiedRoleDefinitionId1Option = new Option("--unifiedroledefinition-id1", description: "key: id of unifiedRoleDefinition") { + var unifiedRoleDefinitionId1Option = new Option("--unified-role-definition-id1", description: "key: id of unifiedRoleDefinition") { }; unifiedRoleDefinitionId1Option.IsRequired = true; command.AddOption(unifiedRoleDefinitionId1Option); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string unifiedRoleDefinitionId, string unifiedRoleDefinitionId1, string body) => { + command.SetHandler(async (string unifiedRoleDefinitionId, string unifiedRoleDefinitionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, unifiedRoleDefinitionIdOption, unifiedRoleDefinitionId1Option, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(UnifiedRoleDefinition bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only collection of role definitions that the given role definition inherits from. Only Azure AD built-in roles support this attribute. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only collection of role definitions that the given role definition inherits from. Only Azure AD built-in roles support this attribute. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only collection of role definitions that the given role definition inherits from. Only Azure AD built-in roles support this attribute. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(UnifiedRoleDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only collection of role definitions that the given role definition inherits from. Only Azure AD built-in roles support this attribute. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/RoleManagement/Directory/RoleDefinitions/Item/UnifiedRoleDefinitionRequestBuilder.cs b/src/generated/RoleManagement/Directory/RoleDefinitions/Item/UnifiedRoleDefinitionRequestBuilder.cs index 39a1dcaa517..63b09ebca04 100644 --- a/src/generated/RoleManagement/Directory/RoleDefinitions/Item/UnifiedRoleDefinitionRequestBuilder.cs +++ b/src/generated/RoleManagement/Directory/RoleDefinitions/Item/UnifiedRoleDefinitionRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.RoleManagement.Directory.RoleDefinitions.Item.InheritsPermissionsFrom; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,15 +27,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Resource representing the roles allowed by RBAC providers and the permissions assigned to the roles."; // Create options for all the parameters - var unifiedRoleDefinitionIdOption = new Option("--unifiedroledefinition-id", description: "key: id of unifiedRoleDefinition") { + var unifiedRoleDefinitionIdOption = new Option("--unified-role-definition-id", description: "key: id of unifiedRoleDefinition") { }; unifiedRoleDefinitionIdOption.IsRequired = true; command.AddOption(unifiedRoleDefinitionIdOption); - command.SetHandler(async (string unifiedRoleDefinitionId) => { + command.SetHandler(async (string unifiedRoleDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, unifiedRoleDefinitionIdOption); return command; @@ -47,7 +46,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Resource representing the roles allowed by RBAC providers and the permissions assigned to the roles."; // Create options for all the parameters - var unifiedRoleDefinitionIdOption = new Option("--unifiedroledefinition-id", description: "key: id of unifiedRoleDefinition") { + var unifiedRoleDefinitionIdOption = new Option("--unified-role-definition-id", description: "key: id of unifiedRoleDefinition") { }; unifiedRoleDefinitionIdOption.IsRequired = true; command.AddOption(unifiedRoleDefinitionIdOption); @@ -61,25 +60,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string unifiedRoleDefinitionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string unifiedRoleDefinitionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, unifiedRoleDefinitionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, unifiedRoleDefinitionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildInheritsPermissionsFromCommand() { var command = new Command("inherits-permissions-from"); var builder = new ApiSdk.RoleManagement.Directory.RoleDefinitions.Item.InheritsPermissionsFrom.InheritsPermissionsFromRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -91,7 +92,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Resource representing the roles allowed by RBAC providers and the permissions assigned to the roles."; // Create options for all the parameters - var unifiedRoleDefinitionIdOption = new Option("--unifiedroledefinition-id", description: "key: id of unifiedRoleDefinition") { + var unifiedRoleDefinitionIdOption = new Option("--unified-role-definition-id", description: "key: id of unifiedRoleDefinition") { }; unifiedRoleDefinitionIdOption.IsRequired = true; command.AddOption(unifiedRoleDefinitionIdOption); @@ -99,14 +100,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string unifiedRoleDefinitionId, string body) => { + command.SetHandler(async (string unifiedRoleDefinitionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, unifiedRoleDefinitionIdOption, bodyOption); return command; @@ -178,42 +178,6 @@ public RequestInformation CreatePatchRequestInformation(UnifiedRoleDefinition bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Resource representing the roles allowed by RBAC providers and the permissions assigned to the roles. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Resource representing the roles allowed by RBAC providers and the permissions assigned to the roles. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Resource representing the roles allowed by RBAC providers and the permissions assigned to the roles. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(UnifiedRoleDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Resource representing the roles allowed by RBAC providers and the permissions assigned to the roles. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/RoleManagement/Directory/RoleDefinitions/RoleDefinitionsRequestBuilder.cs b/src/generated/RoleManagement/Directory/RoleDefinitions/RoleDefinitionsRequestBuilder.cs index da2a641bd50..a2f4eb85a5a 100644 --- a/src/generated/RoleManagement/Directory/RoleDefinitions/RoleDefinitionsRequestBuilder.cs +++ b/src/generated/RoleManagement/Directory/RoleDefinitions/RoleDefinitionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.RoleManagement.Directory.RoleDefinitions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class RoleDefinitionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new UnifiedRoleDefinitionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildInheritsPermissionsFromCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInheritsPermissionsFromCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(UnifiedRoleDefinition bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Resource representing the roles allowed by RBAC providers and the permissions assigned to the roles. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Resource representing the roles allowed by RBAC providers and the permissions assigned to the roles. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UnifiedRoleDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Resource representing the roles allowed by RBAC providers and the permissions assigned to the roles. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/RoleManagement/EntitlementManagement/EntitlementManagementRequestBuilder.cs b/src/generated/RoleManagement/EntitlementManagement/EntitlementManagementRequestBuilder.cs index 4c5bcc1582d..af1044a6478 100644 --- a/src/generated/RoleManagement/EntitlementManagement/EntitlementManagementRequestBuilder.cs +++ b/src/generated/RoleManagement/EntitlementManagement/EntitlementManagementRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.RoleManagement.EntitlementManagement.RoleDefinitions; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,11 +28,10 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Container for all entitlement management resources in Azure AD identity governance."; // Create options for all the parameters - command.SetHandler(async () => { + command.SetHandler(async (IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }); return command; @@ -54,20 +53,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -81,14 +79,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -96,6 +93,9 @@ public Command BuildPatchCommand() { public Command BuildRoleAssignmentsCommand() { var command = new Command("role-assignments"); var builder = new ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.RoleAssignmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -103,6 +103,9 @@ public Command BuildRoleAssignmentsCommand() { public Command BuildRoleDefinitionsCommand() { var command = new Command("role-definitions"); var builder = new ApiSdk.RoleManagement.EntitlementManagement.RoleDefinitions.RoleDefinitionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -174,42 +177,6 @@ public RequestInformation CreatePatchRequestInformation(RbacApplication body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Container for all entitlement management resources in Azure AD identity governance. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Container for all entitlement management resources in Azure AD identity governance. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Container for all entitlement management resources in Azure AD identity governance. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(RbacApplication model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Container for all entitlement management resources in Azure AD identity governance. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/AppScope/AppScopeRequestBuilder.cs b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/AppScope/AppScopeRequestBuilder.cs index 6ac63e0c6ac..e81ac61ed9e 100644 --- a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/AppScope/AppScopeRequestBuilder.cs +++ b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/AppScope/AppScopeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Details of the app specific scope when the assignment scope is app specific. Containment entity."; // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { }; unifiedRoleAssignmentIdOption.IsRequired = true; command.AddOption(unifiedRoleAssignmentIdOption); - command.SetHandler(async (string unifiedRoleAssignmentId) => { + command.SetHandler(async (string unifiedRoleAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, unifiedRoleAssignmentIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Details of the app specific scope when the assignment scope is app specific. Containment entity."; // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { }; unifiedRoleAssignmentIdOption.IsRequired = true; command.AddOption(unifiedRoleAssignmentIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string unifiedRoleAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string unifiedRoleAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, unifiedRoleAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, unifiedRoleAssignmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Details of the app specific scope when the assignment scope is app specific. Containment entity."; // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { }; unifiedRoleAssignmentIdOption.IsRequired = true; command.AddOption(unifiedRoleAssignmentIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string unifiedRoleAssignmentId, string body) => { + command.SetHandler(async (string unifiedRoleAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, unifiedRoleAssignmentIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Details of the app specific scope when the assignment scope is app specific. Containment entity. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Details of the app specific scope when the assignment scope is app specific. Containment entity. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Details of the app specific scope when the assignment scope is app specific. Containment entity. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.AppScope model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Details of the app specific scope when the assignment scope is app specific. Containment entity. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/DirectoryScope/@Ref/@Ref.cs b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/DirectoryScope/@Ref/@Ref.cs deleted file mode 100644 index 1ff378a3f27..00000000000 --- a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/DirectoryScope/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.DirectoryScope.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/DirectoryScope/@Ref/RefRequestBuilder.cs b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/DirectoryScope/@Ref/RefRequestBuilder.cs deleted file mode 100644 index a703ef40f29..00000000000 --- a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/DirectoryScope/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.DirectoryScope.@Ref { - /// Builds and executes requests for operations under \roleManagement\entitlementManagement\roleAssignments\{unifiedRoleAssignment-id}\directoryScope\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; - // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { - }; - unifiedRoleAssignmentIdOption.IsRequired = true; - command.AddOption(unifiedRoleAssignmentIdOption); - command.SetHandler(async (string unifiedRoleAssignmentId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, unifiedRoleAssignmentIdOption); - return command; - } - /// - /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; - // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { - }; - unifiedRoleAssignmentIdOption.IsRequired = true; - command.AddOption(unifiedRoleAssignmentIdOption); - command.SetHandler(async (string unifiedRoleAssignmentId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, unifiedRoleAssignmentIdOption); - return command; - } - /// - /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; - // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { - }; - unifiedRoleAssignmentIdOption.IsRequired = true; - command.AddOption(unifiedRoleAssignmentIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string unifiedRoleAssignmentId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, unifiedRoleAssignmentIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/roleManagement/entitlementManagement/roleAssignments/{unifiedRoleAssignment_id}/directoryScope/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.DirectoryScope.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.DirectoryScope.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/DirectoryScope/DirectoryScopeRequestBuilder.cs b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/DirectoryScope/DirectoryScopeRequestBuilder.cs index 8ce8ed99b0f..160e23d7c0f 100644 --- a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/DirectoryScope/DirectoryScopeRequestBuilder.cs +++ b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/DirectoryScope/DirectoryScopeRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.DirectoryScope.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { }; unifiedRoleAssignmentIdOption.IsRequired = true; command.AddOption(unifiedRoleAssignmentIdOption); @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string unifiedRoleAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string unifiedRoleAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, unifiedRoleAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, unifiedRoleAssignmentIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.DirectoryScope.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.DirectoryScope.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/DirectoryScope/Ref/Ref.cs b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/DirectoryScope/Ref/Ref.cs new file mode 100644 index 00000000000..ca0c578cb89 --- /dev/null +++ b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/DirectoryScope/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.DirectoryScope.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/DirectoryScope/Ref/RefRequestBuilder.cs b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/DirectoryScope/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..e810fd39e47 --- /dev/null +++ b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/DirectoryScope/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.DirectoryScope.Ref { + /// Builds and executes requests for operations under \roleManagement\entitlementManagement\roleAssignments\{unifiedRoleAssignment-id}\directoryScope\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; + // Create options for all the parameters + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { + }; + unifiedRoleAssignmentIdOption.IsRequired = true; + command.AddOption(unifiedRoleAssignmentIdOption); + command.SetHandler(async (string unifiedRoleAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, unifiedRoleAssignmentIdOption); + return command; + } + /// + /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; + // Create options for all the parameters + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { + }; + unifiedRoleAssignmentIdOption.IsRequired = true; + command.AddOption(unifiedRoleAssignmentIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string unifiedRoleAssignmentId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, unifiedRoleAssignmentIdOption, outputOption); + return command; + } + /// + /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; + // Create options for all the parameters + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { + }; + unifiedRoleAssignmentIdOption.IsRequired = true; + command.AddOption(unifiedRoleAssignmentIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string unifiedRoleAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, unifiedRoleAssignmentIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/roleManagement/entitlementManagement/roleAssignments/{unifiedRoleAssignment_id}/directoryScope/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The directory object that is the scope of the assignment. Provided so that callers can get the directory object using $expand at the same time as getting the role assignment. Read-only. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.DirectoryScope.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/Principal/@Ref/@Ref.cs b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/Principal/@Ref/@Ref.cs deleted file mode 100644 index 689d02d5cdf..00000000000 --- a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/Principal/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.Principal.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/Principal/@Ref/RefRequestBuilder.cs b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/Principal/@Ref/RefRequestBuilder.cs deleted file mode 100644 index e39d4f0078f..00000000000 --- a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/Principal/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.Principal.@Ref { - /// Builds and executes requests for operations under \roleManagement\entitlementManagement\roleAssignments\{unifiedRoleAssignment-id}\principal\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; - // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { - }; - unifiedRoleAssignmentIdOption.IsRequired = true; - command.AddOption(unifiedRoleAssignmentIdOption); - command.SetHandler(async (string unifiedRoleAssignmentId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, unifiedRoleAssignmentIdOption); - return command; - } - /// - /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; - // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { - }; - unifiedRoleAssignmentIdOption.IsRequired = true; - command.AddOption(unifiedRoleAssignmentIdOption); - command.SetHandler(async (string unifiedRoleAssignmentId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, unifiedRoleAssignmentIdOption); - return command; - } - /// - /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; - // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { - }; - unifiedRoleAssignmentIdOption.IsRequired = true; - command.AddOption(unifiedRoleAssignmentIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string unifiedRoleAssignmentId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, unifiedRoleAssignmentIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/roleManagement/entitlementManagement/roleAssignments/{unifiedRoleAssignment_id}/principal/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.Principal.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.Principal.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/Principal/PrincipalRequestBuilder.cs b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/Principal/PrincipalRequestBuilder.cs index 1df56cffbe4..9b46431446e 100644 --- a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/Principal/PrincipalRequestBuilder.cs +++ b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/Principal/PrincipalRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.Principal.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { }; unifiedRoleAssignmentIdOption.IsRequired = true; command.AddOption(unifiedRoleAssignmentIdOption); @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string unifiedRoleAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string unifiedRoleAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, unifiedRoleAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, unifiedRoleAssignmentIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.Principal.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.Principal.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/Principal/Ref/Ref.cs b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/Principal/Ref/Ref.cs new file mode 100644 index 00000000000..6874d422f1c --- /dev/null +++ b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/Principal/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.Principal.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/Principal/Ref/RefRequestBuilder.cs b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/Principal/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..069bbe677f9 --- /dev/null +++ b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/Principal/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.Principal.Ref { + /// Builds and executes requests for operations under \roleManagement\entitlementManagement\roleAssignments\{unifiedRoleAssignment-id}\principal\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; + // Create options for all the parameters + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { + }; + unifiedRoleAssignmentIdOption.IsRequired = true; + command.AddOption(unifiedRoleAssignmentIdOption); + command.SetHandler(async (string unifiedRoleAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, unifiedRoleAssignmentIdOption); + return command; + } + /// + /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; + // Create options for all the parameters + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { + }; + unifiedRoleAssignmentIdOption.IsRequired = true; + command.AddOption(unifiedRoleAssignmentIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string unifiedRoleAssignmentId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, unifiedRoleAssignmentIdOption, outputOption); + return command; + } + /// + /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand."; + // Create options for all the parameters + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { + }; + unifiedRoleAssignmentIdOption.IsRequired = true; + command.AddOption(unifiedRoleAssignmentIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string unifiedRoleAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, unifiedRoleAssignmentIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/roleManagement/entitlementManagement/roleAssignments/{unifiedRoleAssignment_id}/principal/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The assigned principal. Provided so that callers can get the principal using $expand at the same time as getting the role assignment. Read-only. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.Principal.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/RoleDefinition/@Ref/@Ref.cs b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/RoleDefinition/@Ref/@Ref.cs deleted file mode 100644 index 9412013da1c..00000000000 --- a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/RoleDefinition/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.RoleDefinition.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/RoleDefinition/@Ref/RefRequestBuilder.cs b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/RoleDefinition/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 28fe087a56e..00000000000 --- a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/RoleDefinition/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.RoleDefinition.@Ref { - /// Builds and executes requests for operations under \roleManagement\entitlementManagement\roleAssignments\{unifiedRoleAssignment-id}\roleDefinition\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand."; - // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { - }; - unifiedRoleAssignmentIdOption.IsRequired = true; - command.AddOption(unifiedRoleAssignmentIdOption); - command.SetHandler(async (string unifiedRoleAssignmentId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, unifiedRoleAssignmentIdOption); - return command; - } - /// - /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand."; - // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { - }; - unifiedRoleAssignmentIdOption.IsRequired = true; - command.AddOption(unifiedRoleAssignmentIdOption); - command.SetHandler(async (string unifiedRoleAssignmentId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, unifiedRoleAssignmentIdOption); - return command; - } - /// - /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand."; - // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { - }; - unifiedRoleAssignmentIdOption.IsRequired = true; - command.AddOption(unifiedRoleAssignmentIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string unifiedRoleAssignmentId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, unifiedRoleAssignmentIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/roleManagement/entitlementManagement/roleAssignments/{unifiedRoleAssignment_id}/roleDefinition/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.RoleDefinition.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.RoleDefinition.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/RoleDefinition/Ref/Ref.cs b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/RoleDefinition/Ref/Ref.cs new file mode 100644 index 00000000000..544c20cf4f3 --- /dev/null +++ b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/RoleDefinition/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.RoleDefinition.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/RoleDefinition/Ref/RefRequestBuilder.cs b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/RoleDefinition/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..548965808ec --- /dev/null +++ b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/RoleDefinition/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.RoleDefinition.Ref { + /// Builds and executes requests for operations under \roleManagement\entitlementManagement\roleAssignments\{unifiedRoleAssignment-id}\roleDefinition\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand."; + // Create options for all the parameters + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { + }; + unifiedRoleAssignmentIdOption.IsRequired = true; + command.AddOption(unifiedRoleAssignmentIdOption); + command.SetHandler(async (string unifiedRoleAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, unifiedRoleAssignmentIdOption); + return command; + } + /// + /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand."; + // Create options for all the parameters + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { + }; + unifiedRoleAssignmentIdOption.IsRequired = true; + command.AddOption(unifiedRoleAssignmentIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string unifiedRoleAssignmentId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, unifiedRoleAssignmentIdOption, outputOption); + return command; + } + /// + /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand."; + // Create options for all the parameters + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { + }; + unifiedRoleAssignmentIdOption.IsRequired = true; + command.AddOption(unifiedRoleAssignmentIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string unifiedRoleAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, unifiedRoleAssignmentIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/roleManagement/entitlementManagement/roleAssignments/{unifiedRoleAssignment_id}/roleDefinition/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.RoleDefinition.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/RoleDefinition/RoleDefinitionRequestBuilder.cs b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/RoleDefinition/RoleDefinitionRequestBuilder.cs index e72f8d5a9c5..2c85eae8f43 100644 --- a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/RoleDefinition/RoleDefinitionRequestBuilder.cs +++ b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/RoleDefinition/RoleDefinitionRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.RoleDefinition.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand."; // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { }; unifiedRoleAssignmentIdOption.IsRequired = true; command.AddOption(unifiedRoleAssignmentIdOption); @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string unifiedRoleAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string unifiedRoleAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, unifiedRoleAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, unifiedRoleAssignmentIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.RoleDefinition.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.RoleDefinition.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The roleDefinition the assignment is for. Provided so that callers can get the role definition using $expand at the same time as getting the role assignment. roleDefinition.id will be auto expanded. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/UnifiedRoleAssignmentRequestBuilder.cs b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/UnifiedRoleAssignmentRequestBuilder.cs index d477a89a681..9531af0ff9c 100644 --- a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/UnifiedRoleAssignmentRequestBuilder.cs +++ b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/Item/UnifiedRoleAssignmentRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item.RoleDefinition; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Resource to grant access to users or groups."; // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { }; unifiedRoleAssignmentIdOption.IsRequired = true; command.AddOption(unifiedRoleAssignmentIdOption); - command.SetHandler(async (string unifiedRoleAssignmentId) => { + command.SetHandler(async (string unifiedRoleAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, unifiedRoleAssignmentIdOption); return command; @@ -65,7 +64,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Resource to grant access to users or groups."; // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { }; unifiedRoleAssignmentIdOption.IsRequired = true; command.AddOption(unifiedRoleAssignmentIdOption); @@ -79,20 +78,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string unifiedRoleAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string unifiedRoleAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, unifiedRoleAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, unifiedRoleAssignmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -102,7 +100,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Resource to grant access to users or groups."; // Create options for all the parameters - var unifiedRoleAssignmentIdOption = new Option("--unifiedroleassignment-id", description: "key: id of unifiedRoleAssignment") { + var unifiedRoleAssignmentIdOption = new Option("--unified-role-assignment-id", description: "key: id of unifiedRoleAssignment") { }; unifiedRoleAssignmentIdOption.IsRequired = true; command.AddOption(unifiedRoleAssignmentIdOption); @@ -110,14 +108,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string unifiedRoleAssignmentId, string body) => { + command.SetHandler(async (string unifiedRoleAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, unifiedRoleAssignmentIdOption, bodyOption); return command; @@ -203,42 +200,6 @@ public RequestInformation CreatePatchRequestInformation(UnifiedRoleAssignment bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Resource to grant access to users or groups. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Resource to grant access to users or groups. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Resource to grant access to users or groups. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(UnifiedRoleAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Resource to grant access to users or groups. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/RoleAssignmentsRequestBuilder.cs b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/RoleAssignmentsRequestBuilder.cs index a3c7ebe74c6..4f50b0c8e24 100644 --- a/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/RoleAssignmentsRequestBuilder.cs +++ b/src/generated/RoleManagement/EntitlementManagement/RoleAssignments/RoleAssignmentsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.RoleManagement.EntitlementManagement.RoleAssignments.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class RoleAssignmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new UnifiedRoleAssignmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAppScopeCommand(), - builder.BuildDeleteCommand(), - builder.BuildDirectoryScopeCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildPrincipalCommand(), - builder.BuildRoleDefinitionCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAppScopeCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDirectoryScopeCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPrincipalCommand()); + commands.Add(builder.BuildRoleDefinitionCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -103,7 +101,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -114,15 +116,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -177,31 +174,6 @@ public RequestInformation CreatePostRequestInformation(UnifiedRoleAssignment bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Resource to grant access to users or groups. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Resource to grant access to users or groups. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UnifiedRoleAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Resource to grant access to users or groups. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/RoleManagement/EntitlementManagement/RoleDefinitions/Item/InheritsPermissionsFrom/InheritsPermissionsFromRequestBuilder.cs b/src/generated/RoleManagement/EntitlementManagement/RoleDefinitions/Item/InheritsPermissionsFrom/InheritsPermissionsFromRequestBuilder.cs index 6a1bf783558..4e558b2ad44 100644 --- a/src/generated/RoleManagement/EntitlementManagement/RoleDefinitions/Item/InheritsPermissionsFrom/InheritsPermissionsFromRequestBuilder.cs +++ b/src/generated/RoleManagement/EntitlementManagement/RoleDefinitions/Item/InheritsPermissionsFrom/InheritsPermissionsFromRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.RoleManagement.EntitlementManagement.RoleDefinitions.Item.InheritsPermissionsFrom.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class InheritsPermissionsFromRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new UnifiedRoleDefinitionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Read-only collection of role definitions that the given role definition inherits from. Only Azure AD built-in roles support this attribute."; // Create options for all the parameters - var unifiedRoleDefinitionIdOption = new Option("--unifiedroledefinition-id", description: "key: id of unifiedRoleDefinition") { + var unifiedRoleDefinitionIdOption = new Option("--unified-role-definition-id", description: "key: id of unifiedRoleDefinition") { }; unifiedRoleDefinitionIdOption.IsRequired = true; command.AddOption(unifiedRoleDefinitionIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string unifiedRoleDefinitionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string unifiedRoleDefinitionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, unifiedRoleDefinitionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, unifiedRoleDefinitionIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Read-only collection of role definitions that the given role definition inherits from. Only Azure AD built-in roles support this attribute."; // Create options for all the parameters - var unifiedRoleDefinitionIdOption = new Option("--unifiedroledefinition-id", description: "key: id of unifiedRoleDefinition") { + var unifiedRoleDefinitionIdOption = new Option("--unified-role-definition-id", description: "key: id of unifiedRoleDefinition") { }; unifiedRoleDefinitionIdOption.IsRequired = true; command.AddOption(unifiedRoleDefinitionIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string unifiedRoleDefinitionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string unifiedRoleDefinitionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, unifiedRoleDefinitionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, unifiedRoleDefinitionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(UnifiedRoleDefinition bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only collection of role definitions that the given role definition inherits from. Only Azure AD built-in roles support this attribute. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only collection of role definitions that the given role definition inherits from. Only Azure AD built-in roles support this attribute. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UnifiedRoleDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only collection of role definitions that the given role definition inherits from. Only Azure AD built-in roles support this attribute. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/RoleManagement/EntitlementManagement/RoleDefinitions/Item/InheritsPermissionsFrom/Item/UnifiedRoleDefinitionRequestBuilder.cs b/src/generated/RoleManagement/EntitlementManagement/RoleDefinitions/Item/InheritsPermissionsFrom/Item/UnifiedRoleDefinitionRequestBuilder.cs index 909552a9319..0975fa56770 100644 --- a/src/generated/RoleManagement/EntitlementManagement/RoleDefinitions/Item/InheritsPermissionsFrom/Item/UnifiedRoleDefinitionRequestBuilder.cs +++ b/src/generated/RoleManagement/EntitlementManagement/RoleDefinitions/Item/InheritsPermissionsFrom/Item/UnifiedRoleDefinitionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only collection of role definitions that the given role definition inherits from. Only Azure AD built-in roles support this attribute."; // Create options for all the parameters - var unifiedRoleDefinitionIdOption = new Option("--unifiedroledefinition-id", description: "key: id of unifiedRoleDefinition") { + var unifiedRoleDefinitionIdOption = new Option("--unified-role-definition-id", description: "key: id of unifiedRoleDefinition") { }; unifiedRoleDefinitionIdOption.IsRequired = true; command.AddOption(unifiedRoleDefinitionIdOption); - var unifiedRoleDefinitionId1Option = new Option("--unifiedroledefinition-id1", description: "key: id of unifiedRoleDefinition") { + var unifiedRoleDefinitionId1Option = new Option("--unified-role-definition-id1", description: "key: id of unifiedRoleDefinition") { }; unifiedRoleDefinitionId1Option.IsRequired = true; command.AddOption(unifiedRoleDefinitionId1Option); - command.SetHandler(async (string unifiedRoleDefinitionId, string unifiedRoleDefinitionId1) => { + command.SetHandler(async (string unifiedRoleDefinitionId, string unifiedRoleDefinitionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, unifiedRoleDefinitionIdOption, unifiedRoleDefinitionId1Option); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only collection of role definitions that the given role definition inherits from. Only Azure AD built-in roles support this attribute."; // Create options for all the parameters - var unifiedRoleDefinitionIdOption = new Option("--unifiedroledefinition-id", description: "key: id of unifiedRoleDefinition") { + var unifiedRoleDefinitionIdOption = new Option("--unified-role-definition-id", description: "key: id of unifiedRoleDefinition") { }; unifiedRoleDefinitionIdOption.IsRequired = true; command.AddOption(unifiedRoleDefinitionIdOption); - var unifiedRoleDefinitionId1Option = new Option("--unifiedroledefinition-id1", description: "key: id of unifiedRoleDefinition") { + var unifiedRoleDefinitionId1Option = new Option("--unified-role-definition-id1", description: "key: id of unifiedRoleDefinition") { }; unifiedRoleDefinitionId1Option.IsRequired = true; command.AddOption(unifiedRoleDefinitionId1Option); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string unifiedRoleDefinitionId, string unifiedRoleDefinitionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string unifiedRoleDefinitionId, string unifiedRoleDefinitionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, unifiedRoleDefinitionIdOption, unifiedRoleDefinitionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, unifiedRoleDefinitionIdOption, unifiedRoleDefinitionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only collection of role definitions that the given role definition inherits from. Only Azure AD built-in roles support this attribute."; // Create options for all the parameters - var unifiedRoleDefinitionIdOption = new Option("--unifiedroledefinition-id", description: "key: id of unifiedRoleDefinition") { + var unifiedRoleDefinitionIdOption = new Option("--unified-role-definition-id", description: "key: id of unifiedRoleDefinition") { }; unifiedRoleDefinitionIdOption.IsRequired = true; command.AddOption(unifiedRoleDefinitionIdOption); - var unifiedRoleDefinitionId1Option = new Option("--unifiedroledefinition-id1", description: "key: id of unifiedRoleDefinition") { + var unifiedRoleDefinitionId1Option = new Option("--unified-role-definition-id1", description: "key: id of unifiedRoleDefinition") { }; unifiedRoleDefinitionId1Option.IsRequired = true; command.AddOption(unifiedRoleDefinitionId1Option); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string unifiedRoleDefinitionId, string unifiedRoleDefinitionId1, string body) => { + command.SetHandler(async (string unifiedRoleDefinitionId, string unifiedRoleDefinitionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, unifiedRoleDefinitionIdOption, unifiedRoleDefinitionId1Option, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(UnifiedRoleDefinition bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only collection of role definitions that the given role definition inherits from. Only Azure AD built-in roles support this attribute. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only collection of role definitions that the given role definition inherits from. Only Azure AD built-in roles support this attribute. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only collection of role definitions that the given role definition inherits from. Only Azure AD built-in roles support this attribute. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(UnifiedRoleDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only collection of role definitions that the given role definition inherits from. Only Azure AD built-in roles support this attribute. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/RoleManagement/EntitlementManagement/RoleDefinitions/Item/UnifiedRoleDefinitionRequestBuilder.cs b/src/generated/RoleManagement/EntitlementManagement/RoleDefinitions/Item/UnifiedRoleDefinitionRequestBuilder.cs index f0f1619f4b1..17d32e2d0ac 100644 --- a/src/generated/RoleManagement/EntitlementManagement/RoleDefinitions/Item/UnifiedRoleDefinitionRequestBuilder.cs +++ b/src/generated/RoleManagement/EntitlementManagement/RoleDefinitions/Item/UnifiedRoleDefinitionRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.RoleManagement.EntitlementManagement.RoleDefinitions.Item.InheritsPermissionsFrom; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,15 +27,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Resource representing the roles allowed by RBAC providers and the permissions assigned to the roles."; // Create options for all the parameters - var unifiedRoleDefinitionIdOption = new Option("--unifiedroledefinition-id", description: "key: id of unifiedRoleDefinition") { + var unifiedRoleDefinitionIdOption = new Option("--unified-role-definition-id", description: "key: id of unifiedRoleDefinition") { }; unifiedRoleDefinitionIdOption.IsRequired = true; command.AddOption(unifiedRoleDefinitionIdOption); - command.SetHandler(async (string unifiedRoleDefinitionId) => { + command.SetHandler(async (string unifiedRoleDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, unifiedRoleDefinitionIdOption); return command; @@ -47,7 +46,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Resource representing the roles allowed by RBAC providers and the permissions assigned to the roles."; // Create options for all the parameters - var unifiedRoleDefinitionIdOption = new Option("--unifiedroledefinition-id", description: "key: id of unifiedRoleDefinition") { + var unifiedRoleDefinitionIdOption = new Option("--unified-role-definition-id", description: "key: id of unifiedRoleDefinition") { }; unifiedRoleDefinitionIdOption.IsRequired = true; command.AddOption(unifiedRoleDefinitionIdOption); @@ -61,25 +60,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string unifiedRoleDefinitionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string unifiedRoleDefinitionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, unifiedRoleDefinitionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, unifiedRoleDefinitionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildInheritsPermissionsFromCommand() { var command = new Command("inherits-permissions-from"); var builder = new ApiSdk.RoleManagement.EntitlementManagement.RoleDefinitions.Item.InheritsPermissionsFrom.InheritsPermissionsFromRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -91,7 +92,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Resource representing the roles allowed by RBAC providers and the permissions assigned to the roles."; // Create options for all the parameters - var unifiedRoleDefinitionIdOption = new Option("--unifiedroledefinition-id", description: "key: id of unifiedRoleDefinition") { + var unifiedRoleDefinitionIdOption = new Option("--unified-role-definition-id", description: "key: id of unifiedRoleDefinition") { }; unifiedRoleDefinitionIdOption.IsRequired = true; command.AddOption(unifiedRoleDefinitionIdOption); @@ -99,14 +100,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string unifiedRoleDefinitionId, string body) => { + command.SetHandler(async (string unifiedRoleDefinitionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, unifiedRoleDefinitionIdOption, bodyOption); return command; @@ -178,42 +178,6 @@ public RequestInformation CreatePatchRequestInformation(UnifiedRoleDefinition bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Resource representing the roles allowed by RBAC providers and the permissions assigned to the roles. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Resource representing the roles allowed by RBAC providers and the permissions assigned to the roles. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Resource representing the roles allowed by RBAC providers and the permissions assigned to the roles. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(UnifiedRoleDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Resource representing the roles allowed by RBAC providers and the permissions assigned to the roles. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/RoleManagement/EntitlementManagement/RoleDefinitions/RoleDefinitionsRequestBuilder.cs b/src/generated/RoleManagement/EntitlementManagement/RoleDefinitions/RoleDefinitionsRequestBuilder.cs index ecdbb070eff..eae8c9bfe71 100644 --- a/src/generated/RoleManagement/EntitlementManagement/RoleDefinitions/RoleDefinitionsRequestBuilder.cs +++ b/src/generated/RoleManagement/EntitlementManagement/RoleDefinitions/RoleDefinitionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.RoleManagement.EntitlementManagement.RoleDefinitions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class RoleDefinitionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new UnifiedRoleDefinitionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildInheritsPermissionsFromCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInheritsPermissionsFromCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,21 +40,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -100,7 +98,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -111,15 +113,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(UnifiedRoleDefinition bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Resource representing the roles allowed by RBAC providers and the permissions assigned to the roles. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Resource representing the roles allowed by RBAC providers and the permissions assigned to the roles. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UnifiedRoleDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Resource representing the roles allowed by RBAC providers and the permissions assigned to the roles. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/RoleManagement/RoleManagementRequestBuilder.cs b/src/generated/RoleManagement/RoleManagementRequestBuilder.cs index 57b1f3ee956..af0bcf91301 100644 --- a/src/generated/RoleManagement/RoleManagementRequestBuilder.cs +++ b/src/generated/RoleManagement/RoleManagementRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.RoleManagement.EntitlementManagement; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -58,20 +58,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -85,14 +84,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -149,31 +147,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get roleManagement - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update roleManagement - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.RoleManagement model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get roleManagement public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/SchemaExtensions/Item/SchemaExtensionRequestBuilder.cs b/src/generated/SchemaExtensions/Item/SchemaExtensionRequestBuilder.cs index 20dcf855444..2678808d937 100644 --- a/src/generated/SchemaExtensions/Item/SchemaExtensionRequestBuilder.cs +++ b/src/generated/SchemaExtensions/Item/SchemaExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete entity from schemaExtensions"; // Create options for all the parameters - var schemaExtensionIdOption = new Option("--schemaextension-id", description: "key: id of schemaExtension") { + var schemaExtensionIdOption = new Option("--schema-extension-id", description: "key: id of schemaExtension") { }; schemaExtensionIdOption.IsRequired = true; command.AddOption(schemaExtensionIdOption); - command.SetHandler(async (string schemaExtensionId) => { + command.SetHandler(async (string schemaExtensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, schemaExtensionIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get entity from schemaExtensions by key"; // Create options for all the parameters - var schemaExtensionIdOption = new Option("--schemaextension-id", description: "key: id of schemaExtension") { + var schemaExtensionIdOption = new Option("--schema-extension-id", description: "key: id of schemaExtension") { }; schemaExtensionIdOption.IsRequired = true; command.AddOption(schemaExtensionIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string schemaExtensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string schemaExtensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, schemaExtensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, schemaExtensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update entity in schemaExtensions"; // Create options for all the parameters - var schemaExtensionIdOption = new Option("--schemaextension-id", description: "key: id of schemaExtension") { + var schemaExtensionIdOption = new Option("--schema-extension-id", description: "key: id of schemaExtension") { }; schemaExtensionIdOption.IsRequired = true; command.AddOption(schemaExtensionIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string schemaExtensionId, string body) => { + command.SetHandler(async (string schemaExtensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, schemaExtensionIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(SchemaExtension body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from schemaExtensions - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from schemaExtensions by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in schemaExtensions - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SchemaExtension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from schemaExtensions by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/SchemaExtensions/SchemaExtensionsRequestBuilder.cs b/src/generated/SchemaExtensions/SchemaExtensionsRequestBuilder.cs index f54bd308c3e..2d79dc047b4 100644 --- a/src/generated/SchemaExtensions/SchemaExtensionsRequestBuilder.cs +++ b/src/generated/SchemaExtensions/SchemaExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.SchemaExtensions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SchemaExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SchemaExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(SchemaExtension body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get entities from schemaExtensions - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to schemaExtensions - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SchemaExtension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from schemaExtensions public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/ScopedRoleMemberships/Item/ScopedRoleMembershipRequestBuilder.cs b/src/generated/ScopedRoleMemberships/Item/ScopedRoleMembershipRequestBuilder.cs index 3102e0f3e1c..389bc411fe6 100644 --- a/src/generated/ScopedRoleMemberships/Item/ScopedRoleMembershipRequestBuilder.cs +++ b/src/generated/ScopedRoleMemberships/Item/ScopedRoleMembershipRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete entity from scopedRoleMemberships"; // Create options for all the parameters - var scopedRoleMembershipIdOption = new Option("--scopedrolemembership-id", description: "key: id of scopedRoleMembership") { + var scopedRoleMembershipIdOption = new Option("--scoped-role-membership-id", description: "key: id of scopedRoleMembership") { }; scopedRoleMembershipIdOption.IsRequired = true; command.AddOption(scopedRoleMembershipIdOption); - command.SetHandler(async (string scopedRoleMembershipId) => { + command.SetHandler(async (string scopedRoleMembershipId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, scopedRoleMembershipIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get entity from scopedRoleMemberships by key"; // Create options for all the parameters - var scopedRoleMembershipIdOption = new Option("--scopedrolemembership-id", description: "key: id of scopedRoleMembership") { + var scopedRoleMembershipIdOption = new Option("--scoped-role-membership-id", description: "key: id of scopedRoleMembership") { }; scopedRoleMembershipIdOption.IsRequired = true; command.AddOption(scopedRoleMembershipIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string scopedRoleMembershipId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string scopedRoleMembershipId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, scopedRoleMembershipIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, scopedRoleMembershipIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update entity in scopedRoleMemberships"; // Create options for all the parameters - var scopedRoleMembershipIdOption = new Option("--scopedrolemembership-id", description: "key: id of scopedRoleMembership") { + var scopedRoleMembershipIdOption = new Option("--scoped-role-membership-id", description: "key: id of scopedRoleMembership") { }; scopedRoleMembershipIdOption.IsRequired = true; command.AddOption(scopedRoleMembershipIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string scopedRoleMembershipId, string body) => { + command.SetHandler(async (string scopedRoleMembershipId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, scopedRoleMembershipIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ScopedRoleMembership bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from scopedRoleMemberships - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from scopedRoleMemberships by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in scopedRoleMemberships - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ScopedRoleMembership model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from scopedRoleMemberships by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/ScopedRoleMemberships/ScopedRoleMembershipsRequestBuilder.cs b/src/generated/ScopedRoleMemberships/ScopedRoleMembershipsRequestBuilder.cs index 341e58bde8c..d74754e47c4 100644 --- a/src/generated/ScopedRoleMemberships/ScopedRoleMembershipsRequestBuilder.cs +++ b/src/generated/ScopedRoleMemberships/ScopedRoleMembershipsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.ScopedRoleMemberships.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ScopedRoleMembershipsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ScopedRoleMembershipRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(ScopedRoleMembership body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get entities from scopedRoleMemberships - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to scopedRoleMemberships - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ScopedRoleMembership model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from scopedRoleMemberships public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Search/Query/Query.cs b/src/generated/Search/Query/Query.cs deleted file mode 100644 index 519801610c4..00000000000 --- a/src/generated/Search/Query/Query.cs +++ /dev/null @@ -1,41 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Search.Query { - public class Query : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// A collection of search results. - public List HitsContainers { get; set; } - /// Contains the search terms sent in the initial search query. - public List SearchTerms { get; set; } - /// - /// Instantiates a new query and sets the default values. - /// - public Query() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"hitsContainers", (o,n) => { (o as Query).HitsContainers = n.GetCollectionOfObjectValues().ToList(); } }, - {"searchTerms", (o,n) => { (o as Query).SearchTerms = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteCollectionOfObjectValues("hitsContainers", HitsContainers); - writer.WriteCollectionOfPrimitiveValues("searchTerms", SearchTerms); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Search/Query/QueryRequestBuilder.cs b/src/generated/Search/Query/QueryRequestBuilder.cs index 652d4460282..89369650f41 100644 --- a/src/generated/Search/Query/QueryRequestBuilder.cs +++ b/src/generated/Search/Query/QueryRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(QueryRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action query - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(QueryRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Search/SearchRequestBuilder.cs b/src/generated/Search/SearchRequestBuilder.cs index c9e9dbe4438..87e4cdc7cbc 100644 --- a/src/generated/Search/SearchRequestBuilder.cs +++ b/src/generated/Search/SearchRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Search.Query; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,20 +37,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -64,14 +63,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -134,31 +132,6 @@ public RequestInformation CreatePatchRequestInformation(SearchEntity body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get search - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update search - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SearchEntity model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get search public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Security/Alerts/AlertsRequestBuilder.cs b/src/generated/Security/Alerts/AlertsRequestBuilder.cs index 944057fd10e..510feb1386d 100644 --- a/src/generated/Security/Alerts/AlertsRequestBuilder.cs +++ b/src/generated/Security/Alerts/AlertsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Security.Alerts.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AlertsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AlertRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(Alert body, Action - /// Notifications for suspicious or potential security issues in a customer’s tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Notifications for suspicious or potential security issues in a customer’s tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Alert model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Notifications for suspicious or potential security issues in a customer’s tenant. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Security/Alerts/Item/AlertRequestBuilder.cs b/src/generated/Security/Alerts/Item/AlertRequestBuilder.cs index 24be91b296f..2d5c40e3e48 100644 --- a/src/generated/Security/Alerts/Item/AlertRequestBuilder.cs +++ b/src/generated/Security/Alerts/Item/AlertRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,10 @@ public Command BuildDeleteCommand() { }; alertIdOption.IsRequired = true; command.AddOption(alertIdOption); - command.SetHandler(async (string alertId) => { + command.SetHandler(async (string alertId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, alertIdOption); return command; @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string alertId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string alertId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, alertIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, alertIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string alertId, string body) => { + command.SetHandler(async (string alertId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, alertIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(Alert body, Action - /// Notifications for suspicious or potential security issues in a customer’s tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Notifications for suspicious or potential security issues in a customer’s tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Notifications for suspicious or potential security issues in a customer’s tenant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Alert model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Notifications for suspicious or potential security issues in a customer’s tenant. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Security/SecureScoreControlProfiles/Item/SecureScoreControlProfileRequestBuilder.cs b/src/generated/Security/SecureScoreControlProfiles/Item/SecureScoreControlProfileRequestBuilder.cs index 6a08c9a478b..28d585270f7 100644 --- a/src/generated/Security/SecureScoreControlProfiles/Item/SecureScoreControlProfileRequestBuilder.cs +++ b/src/generated/Security/SecureScoreControlProfiles/Item/SecureScoreControlProfileRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property secureScoreControlProfiles for security"; // Create options for all the parameters - var secureScoreControlProfileIdOption = new Option("--securescorecontrolprofile-id", description: "key: id of secureScoreControlProfile") { + var secureScoreControlProfileIdOption = new Option("--secure-score-control-profile-id", description: "key: id of secureScoreControlProfile") { }; secureScoreControlProfileIdOption.IsRequired = true; command.AddOption(secureScoreControlProfileIdOption); - command.SetHandler(async (string secureScoreControlProfileId) => { + command.SetHandler(async (string secureScoreControlProfileId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, secureScoreControlProfileIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get secureScoreControlProfiles from security"; // Create options for all the parameters - var secureScoreControlProfileIdOption = new Option("--securescorecontrolprofile-id", description: "key: id of secureScoreControlProfile") { + var secureScoreControlProfileIdOption = new Option("--secure-score-control-profile-id", description: "key: id of secureScoreControlProfile") { }; secureScoreControlProfileIdOption.IsRequired = true; command.AddOption(secureScoreControlProfileIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string secureScoreControlProfileId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string secureScoreControlProfileId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, secureScoreControlProfileIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, secureScoreControlProfileIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property secureScoreControlProfiles in security"; // Create options for all the parameters - var secureScoreControlProfileIdOption = new Option("--securescorecontrolprofile-id", description: "key: id of secureScoreControlProfile") { + var secureScoreControlProfileIdOption = new Option("--secure-score-control-profile-id", description: "key: id of secureScoreControlProfile") { }; secureScoreControlProfileIdOption.IsRequired = true; command.AddOption(secureScoreControlProfileIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string secureScoreControlProfileId, string body) => { + command.SetHandler(async (string secureScoreControlProfileId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, secureScoreControlProfileIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(SecureScoreControlProfil requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property secureScoreControlProfiles for security - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get secureScoreControlProfiles from security - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property secureScoreControlProfiles in security - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SecureScoreControlProfile model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get secureScoreControlProfiles from security public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Security/SecureScoreControlProfiles/SecureScoreControlProfilesRequestBuilder.cs b/src/generated/Security/SecureScoreControlProfiles/SecureScoreControlProfilesRequestBuilder.cs index cd895a9696b..8aabbab86c5 100644 --- a/src/generated/Security/SecureScoreControlProfiles/SecureScoreControlProfilesRequestBuilder.cs +++ b/src/generated/Security/SecureScoreControlProfiles/SecureScoreControlProfilesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Security.SecureScoreControlProfiles.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SecureScoreControlProfilesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SecureScoreControlProfileRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(SecureScoreControlProfile requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get secureScoreControlProfiles from security - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to secureScoreControlProfiles for security - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SecureScoreControlProfile model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get secureScoreControlProfiles from security public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Security/SecureScores/Item/SecureScoreRequestBuilder.cs b/src/generated/Security/SecureScores/Item/SecureScoreRequestBuilder.cs index 55641fe1a7f..157daf77235 100644 --- a/src/generated/Security/SecureScores/Item/SecureScoreRequestBuilder.cs +++ b/src/generated/Security/SecureScores/Item/SecureScoreRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property secureScores for security"; // Create options for all the parameters - var secureScoreIdOption = new Option("--securescore-id", description: "key: id of secureScore") { + var secureScoreIdOption = new Option("--secure-score-id", description: "key: id of secureScore") { }; secureScoreIdOption.IsRequired = true; command.AddOption(secureScoreIdOption); - command.SetHandler(async (string secureScoreId) => { + command.SetHandler(async (string secureScoreId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, secureScoreIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get secureScores from security"; // Create options for all the parameters - var secureScoreIdOption = new Option("--securescore-id", description: "key: id of secureScore") { + var secureScoreIdOption = new Option("--secure-score-id", description: "key: id of secureScore") { }; secureScoreIdOption.IsRequired = true; command.AddOption(secureScoreIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string secureScoreId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string secureScoreId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, secureScoreIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, secureScoreIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property secureScores in security"; // Create options for all the parameters - var secureScoreIdOption = new Option("--securescore-id", description: "key: id of secureScore") { + var secureScoreIdOption = new Option("--secure-score-id", description: "key: id of secureScore") { }; secureScoreIdOption.IsRequired = true; command.AddOption(secureScoreIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string secureScoreId, string body) => { + command.SetHandler(async (string secureScoreId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, secureScoreIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(SecureScore body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property secureScores for security - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get secureScores from security - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property secureScores in security - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SecureScore model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get secureScores from security public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Security/SecureScores/SecureScoresRequestBuilder.cs b/src/generated/Security/SecureScores/SecureScoresRequestBuilder.cs index 3941f3b703f..861a1bb065b 100644 --- a/src/generated/Security/SecureScores/SecureScoresRequestBuilder.cs +++ b/src/generated/Security/SecureScores/SecureScoresRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Security.SecureScores.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SecureScoresRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SecureScoreRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(SecureScore body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get secureScores from security - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to secureScores for security - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SecureScore model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get secureScores from security public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Security/SecurityRequestBuilder.cs b/src/generated/Security/SecurityRequestBuilder.cs index 92a3a90e549..843cfcc0d04 100644 --- a/src/generated/Security/SecurityRequestBuilder.cs +++ b/src/generated/Security/SecurityRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Security.SecureScores; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,6 +25,9 @@ public class SecurityRequestBuilder { public Command BuildAlertsCommand() { var command = new Command("alerts"); var builder = new ApiSdk.Security.Alerts.AlertsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -46,20 +49,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -73,14 +75,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -88,6 +89,9 @@ public Command BuildPatchCommand() { public Command BuildSecureScoreControlProfilesCommand() { var command = new Command("secure-score-control-profiles"); var builder = new ApiSdk.Security.SecureScoreControlProfiles.SecureScoreControlProfilesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -95,6 +99,9 @@ public Command BuildSecureScoreControlProfilesCommand() { public Command BuildSecureScoresCommand() { var command = new Command("secure-scores"); var builder = new ApiSdk.Security.SecureScores.SecureScoresRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -151,31 +158,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get security - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update security - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Security model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get security public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/ServicePrincipals/Delta/DeltaRequestBuilder.cs b/src/generated/ServicePrincipals/Delta/DeltaRequestBuilder.cs index 4392af23675..9343f363123 100644 --- a/src/generated/ServicePrincipals/Delta/DeltaRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/ServicePrincipals/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs b/src/generated/ServicePrincipals/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs deleted file mode 100644 index a1caa612654..00000000000 --- a/src/generated/ServicePrincipals/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs +++ /dev/null @@ -1,45 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.ServicePrincipals.GetAvailableExtensionProperties { - public class GetAvailableExtensionProperties : DirectoryObject, IParsable { - /// Display name of the application object on which this extension property is defined. Read-only. - public string AppDisplayName { get; set; } - /// Specifies the data type of the value the extension property can hold. Following values are supported. Not nullable. Binary - 256 bytes maximumBooleanDateTime - Must be specified in ISO 8601 format. Will be stored in UTC.Integer - 32-bit value.LargeInteger - 64-bit value.String - 256 characters maximum - public string DataType { get; set; } - /// Indicates if this extension property was sycned from onpremises directory using Azure AD Connect. Read-only. - public bool? IsSyncedFromOnPremises { get; set; } - /// Name of the extension property. Not nullable. - public string Name { get; set; } - /// Following values are supported. Not nullable. UserGroupOrganizationDeviceApplication - public List TargetObjects { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"appDisplayName", (o,n) => { (o as GetAvailableExtensionProperties).AppDisplayName = n.GetStringValue(); } }, - {"dataType", (o,n) => { (o as GetAvailableExtensionProperties).DataType = n.GetStringValue(); } }, - {"isSyncedFromOnPremises", (o,n) => { (o as GetAvailableExtensionProperties).IsSyncedFromOnPremises = n.GetBoolValue(); } }, - {"name", (o,n) => { (o as GetAvailableExtensionProperties).Name = n.GetStringValue(); } }, - {"targetObjects", (o,n) => { (o as GetAvailableExtensionProperties).TargetObjects = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteStringValue("appDisplayName", AppDisplayName); - writer.WriteStringValue("dataType", DataType); - writer.WriteBoolValue("isSyncedFromOnPremises", IsSyncedFromOnPremises); - writer.WriteStringValue("name", Name); - writer.WriteCollectionOfPrimitiveValues("targetObjects", TargetObjects); - } - } -} diff --git a/src/generated/ServicePrincipals/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs b/src/generated/ServicePrincipals/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs index 273a8514644..08bac95e3a6 100644 --- a/src/generated/ServicePrincipals/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs +++ b/src/generated/ServicePrincipals/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(GetAvailableExtensionProp requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getAvailableExtensionProperties - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetAvailableExtensionPropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/ServicePrincipals/GetByIds/GetByIds.cs b/src/generated/ServicePrincipals/GetByIds/GetByIds.cs deleted file mode 100644 index c1639244936..00000000000 --- a/src/generated/ServicePrincipals/GetByIds/GetByIds.cs +++ /dev/null @@ -1,28 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.ServicePrincipals.GetByIds { - public class GetByIds : Entity, IParsable { - public DateTimeOffset? DeletedDateTime { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"deletedDateTime", (o,n) => { (o as GetByIds).DeletedDateTime = n.GetDateTimeOffsetValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteDateTimeOffsetValue("deletedDateTime", DeletedDateTime); - } - } -} diff --git a/src/generated/ServicePrincipals/GetByIds/GetByIdsRequestBuilder.cs b/src/generated/ServicePrincipals/GetByIds/GetByIdsRequestBuilder.cs index 5351e8bc5d7..f0a4aa1ebd7 100644 --- a/src/generated/ServicePrincipals/GetByIds/GetByIdsRequestBuilder.cs +++ b/src/generated/ServicePrincipals/GetByIds/GetByIdsRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(GetByIdsRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getByIds - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetByIdsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/ServicePrincipals/Item/AddKey/AddKeyRequestBuilder.cs b/src/generated/ServicePrincipals/Item/AddKey/AddKeyRequestBuilder.cs index 085db2d8211..184dace6404 100644 --- a/src/generated/ServicePrincipals/Item/AddKey/AddKeyRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/AddKey/AddKeyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action addKey"; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string servicePrincipalId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, bodyOption, outputOption); return command; } /// @@ -82,18 +81,5 @@ public RequestInformation CreatePostRequestInformation(KeyCredentialRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action addKey - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(KeyCredentialRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/ServicePrincipals/Item/AddPassword/AddPasswordRequestBuilder.cs b/src/generated/ServicePrincipals/Item/AddPassword/AddPasswordRequestBuilder.cs index 758abe4873e..5eff5f94711 100644 --- a/src/generated/ServicePrincipals/Item/AddPassword/AddPasswordRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/AddPassword/AddPasswordRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action addPassword"; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string servicePrincipalId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, bodyOption, outputOption); return command; } /// @@ -82,18 +81,5 @@ public RequestInformation CreatePostRequestInformation(PasswordCredentialRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action addPassword - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PasswordCredentialRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/ServicePrincipals/Item/AppRoleAssignedTo/AppRoleAssignedToRequestBuilder.cs b/src/generated/ServicePrincipals/Item/AppRoleAssignedTo/AppRoleAssignedToRequestBuilder.cs index 28a6ad8f150..f64f03c3aa3 100644 --- a/src/generated/ServicePrincipals/Item/AppRoleAssignedTo/AppRoleAssignedToRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/AppRoleAssignedTo/AppRoleAssignedToRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.ServicePrincipals.Item.AppRoleAssignedTo.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AppRoleAssignedToRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AppRoleAssignmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "App role assignments for this app or service, granted to users, groups, and other service principals.Supports $expand."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string servicePrincipalId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "App role assignments for this app or service, granted to users, groups, and other service principals.Supports $expand."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(AppRoleAssignment body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// App role assignments for this app or service, granted to users, groups, and other service principals.Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// App role assignments for this app or service, granted to users, groups, and other service principals.Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AppRoleAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// App role assignments for this app or service, granted to users, groups, and other service principals.Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/ServicePrincipals/Item/AppRoleAssignedTo/Item/AppRoleAssignmentRequestBuilder.cs b/src/generated/ServicePrincipals/Item/AppRoleAssignedTo/Item/AppRoleAssignmentRequestBuilder.cs index fbdcba8a19d..9da33bec01b 100644 --- a/src/generated/ServicePrincipals/Item/AppRoleAssignedTo/Item/AppRoleAssignmentRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/AppRoleAssignedTo/Item/AppRoleAssignmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "App role assignments for this app or service, granted to users, groups, and other service principals.Supports $expand."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); - var appRoleAssignmentIdOption = new Option("--approleassignment-id", description: "key: id of appRoleAssignment") { + var appRoleAssignmentIdOption = new Option("--app-role-assignment-id", description: "key: id of appRoleAssignment") { }; appRoleAssignmentIdOption.IsRequired = true; command.AddOption(appRoleAssignmentIdOption); - command.SetHandler(async (string servicePrincipalId, string appRoleAssignmentId) => { + command.SetHandler(async (string servicePrincipalId, string appRoleAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, servicePrincipalIdOption, appRoleAssignmentIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "App role assignments for this app or service, granted to users, groups, and other service principals.Supports $expand."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); - var appRoleAssignmentIdOption = new Option("--approleassignment-id", description: "key: id of appRoleAssignment") { + var appRoleAssignmentIdOption = new Option("--app-role-assignment-id", description: "key: id of appRoleAssignment") { }; appRoleAssignmentIdOption.IsRequired = true; command.AddOption(appRoleAssignmentIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string servicePrincipalId, string appRoleAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, string appRoleAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, appRoleAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, appRoleAssignmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "App role assignments for this app or service, granted to users, groups, and other service principals.Supports $expand."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); - var appRoleAssignmentIdOption = new Option("--approleassignment-id", description: "key: id of appRoleAssignment") { + var appRoleAssignmentIdOption = new Option("--app-role-assignment-id", description: "key: id of appRoleAssignment") { }; appRoleAssignmentIdOption.IsRequired = true; command.AddOption(appRoleAssignmentIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string servicePrincipalId, string appRoleAssignmentId, string body) => { + command.SetHandler(async (string servicePrincipalId, string appRoleAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, servicePrincipalIdOption, appRoleAssignmentIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(AppRoleAssignment body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// App role assignments for this app or service, granted to users, groups, and other service principals.Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// App role assignments for this app or service, granted to users, groups, and other service principals.Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// App role assignments for this app or service, granted to users, groups, and other service principals.Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AppRoleAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// App role assignments for this app or service, granted to users, groups, and other service principals.Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/ServicePrincipals/Item/AppRoleAssignments/AppRoleAssignmentsRequestBuilder.cs b/src/generated/ServicePrincipals/Item/AppRoleAssignments/AppRoleAssignmentsRequestBuilder.cs index 89c1717a9f0..95aef012f88 100644 --- a/src/generated/ServicePrincipals/Item/AppRoleAssignments/AppRoleAssignmentsRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/AppRoleAssignments/AppRoleAssignmentsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.ServicePrincipals.Item.AppRoleAssignments.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AppRoleAssignmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AppRoleAssignmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "App role assignment for another app or service, granted to this service principal. Supports $expand."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string servicePrincipalId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "App role assignment for another app or service, granted to this service principal. Supports $expand."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(AppRoleAssignment body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// App role assignment for another app or service, granted to this service principal. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// App role assignment for another app or service, granted to this service principal. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AppRoleAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// App role assignment for another app or service, granted to this service principal. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/ServicePrincipals/Item/AppRoleAssignments/Item/AppRoleAssignmentRequestBuilder.cs b/src/generated/ServicePrincipals/Item/AppRoleAssignments/Item/AppRoleAssignmentRequestBuilder.cs index 7cc7ed6edab..a111e8d1b80 100644 --- a/src/generated/ServicePrincipals/Item/AppRoleAssignments/Item/AppRoleAssignmentRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/AppRoleAssignments/Item/AppRoleAssignmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "App role assignment for another app or service, granted to this service principal. Supports $expand."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); - var appRoleAssignmentIdOption = new Option("--approleassignment-id", description: "key: id of appRoleAssignment") { + var appRoleAssignmentIdOption = new Option("--app-role-assignment-id", description: "key: id of appRoleAssignment") { }; appRoleAssignmentIdOption.IsRequired = true; command.AddOption(appRoleAssignmentIdOption); - command.SetHandler(async (string servicePrincipalId, string appRoleAssignmentId) => { + command.SetHandler(async (string servicePrincipalId, string appRoleAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, servicePrincipalIdOption, appRoleAssignmentIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "App role assignment for another app or service, granted to this service principal. Supports $expand."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); - var appRoleAssignmentIdOption = new Option("--approleassignment-id", description: "key: id of appRoleAssignment") { + var appRoleAssignmentIdOption = new Option("--app-role-assignment-id", description: "key: id of appRoleAssignment") { }; appRoleAssignmentIdOption.IsRequired = true; command.AddOption(appRoleAssignmentIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string servicePrincipalId, string appRoleAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, string appRoleAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, appRoleAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, appRoleAssignmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "App role assignment for another app or service, granted to this service principal. Supports $expand."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); - var appRoleAssignmentIdOption = new Option("--approleassignment-id", description: "key: id of appRoleAssignment") { + var appRoleAssignmentIdOption = new Option("--app-role-assignment-id", description: "key: id of appRoleAssignment") { }; appRoleAssignmentIdOption.IsRequired = true; command.AddOption(appRoleAssignmentIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string servicePrincipalId, string appRoleAssignmentId, string body) => { + command.SetHandler(async (string servicePrincipalId, string appRoleAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, servicePrincipalIdOption, appRoleAssignmentIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(AppRoleAssignment body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// App role assignment for another app or service, granted to this service principal. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// App role assignment for another app or service, granted to this service principal. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// App role assignment for another app or service, granted to this service principal. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AppRoleAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// App role assignment for another app or service, granted to this service principal. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/ServicePrincipals/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs b/src/generated/ServicePrincipals/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs index 043e6122ee5..208fdd682dd 100644 --- a/src/generated/ServicePrincipals/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action checkMemberGroups"; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string servicePrincipalId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberGroupsRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/ServicePrincipals/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs b/src/generated/ServicePrincipals/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs index 2d4e020a278..4ac7a933e75 100644 --- a/src/generated/ServicePrincipals/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action checkMemberObjects"; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string servicePrincipalId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberObjectsRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/ServicePrincipals/Item/ClaimsMappingPolicies/@Ref/@Ref.cs b/src/generated/ServicePrincipals/Item/ClaimsMappingPolicies/@Ref/@Ref.cs deleted file mode 100644 index b0185e38360..00000000000 --- a/src/generated/ServicePrincipals/Item/ClaimsMappingPolicies/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.ServicePrincipals.Item.ClaimsMappingPolicies.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/ServicePrincipals/Item/ClaimsMappingPolicies/@Ref/RefRequestBuilder.cs b/src/generated/ServicePrincipals/Item/ClaimsMappingPolicies/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 37dbde8f368..00000000000 --- a/src/generated/ServicePrincipals/Item/ClaimsMappingPolicies/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.ServicePrincipals.Item.ClaimsMappingPolicies.@Ref { - /// Builds and executes requests for operations under \servicePrincipals\{servicePrincipal-id}\claimsMappingPolicies\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The claimsMappingPolicies assigned to this service principal. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The claimsMappingPolicies assigned to this service principal. Supports $expand."; - // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { - }; - servicePrincipalIdOption.IsRequired = true; - command.AddOption(servicePrincipalIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The claimsMappingPolicies assigned to this service principal. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The claimsMappingPolicies assigned to this service principal. Supports $expand."; - // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { - }; - servicePrincipalIdOption.IsRequired = true; - command.AddOption(servicePrincipalIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string servicePrincipalId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/servicePrincipals/{servicePrincipal_id}/claimsMappingPolicies/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The claimsMappingPolicies assigned to this service principal. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The claimsMappingPolicies assigned to this service principal. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.ServicePrincipals.Item.ClaimsMappingPolicies.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The claimsMappingPolicies assigned to this service principal. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The claimsMappingPolicies assigned to this service principal. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.ServicePrincipals.Item.ClaimsMappingPolicies.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The claimsMappingPolicies assigned to this service principal. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/ServicePrincipals/Item/ClaimsMappingPolicies/@Ref/RefResponse.cs b/src/generated/ServicePrincipals/Item/ClaimsMappingPolicies/@Ref/RefResponse.cs deleted file mode 100644 index baa0719024c..00000000000 --- a/src/generated/ServicePrincipals/Item/ClaimsMappingPolicies/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.ServicePrincipals.Item.ClaimsMappingPolicies.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/ServicePrincipals/Item/ClaimsMappingPolicies/ClaimsMappingPoliciesRequestBuilder.cs b/src/generated/ServicePrincipals/Item/ClaimsMappingPolicies/ClaimsMappingPoliciesRequestBuilder.cs index 010f7244a1e..ea73d8e1e02 100644 --- a/src/generated/ServicePrincipals/Item/ClaimsMappingPolicies/ClaimsMappingPoliciesRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/ClaimsMappingPolicies/ClaimsMappingPoliciesRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.ServicePrincipals.Item.ClaimsMappingPolicies.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The claimsMappingPolicies assigned to this service principal. Supports $expand."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.ServicePrincipals.Item.ClaimsMappingPolicies.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.ServicePrincipals.Item.ClaimsMappingPolicies.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The claimsMappingPolicies assigned to this service principal. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The claimsMappingPolicies assigned to this service principal. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/ServicePrincipals/Item/ClaimsMappingPolicies/Ref/Ref.cs b/src/generated/ServicePrincipals/Item/ClaimsMappingPolicies/Ref/Ref.cs new file mode 100644 index 00000000000..fb440b9a4e0 --- /dev/null +++ b/src/generated/ServicePrincipals/Item/ClaimsMappingPolicies/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.ServicePrincipals.Item.ClaimsMappingPolicies.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/ServicePrincipals/Item/ClaimsMappingPolicies/Ref/RefRequestBuilder.cs b/src/generated/ServicePrincipals/Item/ClaimsMappingPolicies/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..32ee4383e8f --- /dev/null +++ b/src/generated/ServicePrincipals/Item/ClaimsMappingPolicies/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.ServicePrincipals.Item.ClaimsMappingPolicies.Ref { + /// Builds and executes requests for operations under \servicePrincipals\{servicePrincipal-id}\claimsMappingPolicies\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The claimsMappingPolicies assigned to this service principal. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The claimsMappingPolicies assigned to this service principal. Supports $expand."; + // Create options for all the parameters + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { + }; + servicePrincipalIdOption.IsRequired = true; + command.AddOption(servicePrincipalIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The claimsMappingPolicies assigned to this service principal. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The claimsMappingPolicies assigned to this service principal. Supports $expand."; + // Create options for all the parameters + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { + }; + servicePrincipalIdOption.IsRequired = true; + command.AddOption(servicePrincipalIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/servicePrincipals/{servicePrincipal_id}/claimsMappingPolicies/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The claimsMappingPolicies assigned to this service principal. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The claimsMappingPolicies assigned to this service principal. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.ServicePrincipals.Item.ClaimsMappingPolicies.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The claimsMappingPolicies assigned to this service principal. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/ServicePrincipals/Item/ClaimsMappingPolicies/Ref/RefResponse.cs b/src/generated/ServicePrincipals/Item/ClaimsMappingPolicies/Ref/RefResponse.cs new file mode 100644 index 00000000000..0b959d8686b --- /dev/null +++ b/src/generated/ServicePrincipals/Item/ClaimsMappingPolicies/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.ServicePrincipals.Item.ClaimsMappingPolicies.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/ServicePrincipals/Item/CreatedObjects/@Ref/@Ref.cs b/src/generated/ServicePrincipals/Item/CreatedObjects/@Ref/@Ref.cs deleted file mode 100644 index a0d57bba67c..00000000000 --- a/src/generated/ServicePrincipals/Item/CreatedObjects/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.ServicePrincipals.Item.CreatedObjects.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/ServicePrincipals/Item/CreatedObjects/@Ref/RefRequestBuilder.cs b/src/generated/ServicePrincipals/Item/CreatedObjects/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 4b00f708272..00000000000 --- a/src/generated/ServicePrincipals/Item/CreatedObjects/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.ServicePrincipals.Item.CreatedObjects.@Ref { - /// Builds and executes requests for operations under \servicePrincipals\{servicePrincipal-id}\createdObjects\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Directory objects created by this service principal. Read-only. Nullable. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Directory objects created by this service principal. Read-only. Nullable."; - // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { - }; - servicePrincipalIdOption.IsRequired = true; - command.AddOption(servicePrincipalIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Directory objects created by this service principal. Read-only. Nullable. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Directory objects created by this service principal. Read-only. Nullable."; - // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { - }; - servicePrincipalIdOption.IsRequired = true; - command.AddOption(servicePrincipalIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string servicePrincipalId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/servicePrincipals/{servicePrincipal_id}/createdObjects/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Directory objects created by this service principal. Read-only. Nullable. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Directory objects created by this service principal. Read-only. Nullable. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.ServicePrincipals.Item.CreatedObjects.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Directory objects created by this service principal. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Directory objects created by this service principal. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.ServicePrincipals.Item.CreatedObjects.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Directory objects created by this service principal. Read-only. Nullable. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/ServicePrincipals/Item/CreatedObjects/@Ref/RefResponse.cs b/src/generated/ServicePrincipals/Item/CreatedObjects/@Ref/RefResponse.cs deleted file mode 100644 index 3cba57ad4c6..00000000000 --- a/src/generated/ServicePrincipals/Item/CreatedObjects/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.ServicePrincipals.Item.CreatedObjects.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/ServicePrincipals/Item/CreatedObjects/CreatedObjectsRequestBuilder.cs b/src/generated/ServicePrincipals/Item/CreatedObjects/CreatedObjectsRequestBuilder.cs index 17726ceff49..6c8c7837905 100644 --- a/src/generated/ServicePrincipals/Item/CreatedObjects/CreatedObjectsRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/CreatedObjects/CreatedObjectsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.ServicePrincipals.Item.CreatedObjects.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Directory objects created by this service principal. Read-only. Nullable."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.ServicePrincipals.Item.CreatedObjects.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.ServicePrincipals.Item.CreatedObjects.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Directory objects created by this service principal. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Directory objects created by this service principal. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/ServicePrincipals/Item/CreatedObjects/Ref/Ref.cs b/src/generated/ServicePrincipals/Item/CreatedObjects/Ref/Ref.cs new file mode 100644 index 00000000000..6627a2c662d --- /dev/null +++ b/src/generated/ServicePrincipals/Item/CreatedObjects/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.ServicePrincipals.Item.CreatedObjects.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/ServicePrincipals/Item/CreatedObjects/Ref/RefRequestBuilder.cs b/src/generated/ServicePrincipals/Item/CreatedObjects/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..e3910a1ce68 --- /dev/null +++ b/src/generated/ServicePrincipals/Item/CreatedObjects/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.ServicePrincipals.Item.CreatedObjects.Ref { + /// Builds and executes requests for operations under \servicePrincipals\{servicePrincipal-id}\createdObjects\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Directory objects created by this service principal. Read-only. Nullable. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Directory objects created by this service principal. Read-only. Nullable."; + // Create options for all the parameters + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { + }; + servicePrincipalIdOption.IsRequired = true; + command.AddOption(servicePrincipalIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Directory objects created by this service principal. Read-only. Nullable. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Directory objects created by this service principal. Read-only. Nullable."; + // Create options for all the parameters + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { + }; + servicePrincipalIdOption.IsRequired = true; + command.AddOption(servicePrincipalIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/servicePrincipals/{servicePrincipal_id}/createdObjects/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Directory objects created by this service principal. Read-only. Nullable. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Directory objects created by this service principal. Read-only. Nullable. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.ServicePrincipals.Item.CreatedObjects.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Directory objects created by this service principal. Read-only. Nullable. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/ServicePrincipals/Item/CreatedObjects/Ref/RefResponse.cs b/src/generated/ServicePrincipals/Item/CreatedObjects/Ref/RefResponse.cs new file mode 100644 index 00000000000..4c4a2053091 --- /dev/null +++ b/src/generated/ServicePrincipals/Item/CreatedObjects/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.ServicePrincipals.Item.CreatedObjects.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/ServicePrincipals/Item/DelegatedPermissionClassifications/DelegatedPermissionClassificationsRequestBuilder.cs b/src/generated/ServicePrincipals/Item/DelegatedPermissionClassifications/DelegatedPermissionClassificationsRequestBuilder.cs index 778c90f9209..2494cddc8ab 100644 --- a/src/generated/ServicePrincipals/Item/DelegatedPermissionClassifications/DelegatedPermissionClassificationsRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/DelegatedPermissionClassifications/DelegatedPermissionClassificationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.ServicePrincipals.Item.DelegatedPermissionClassifications.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DelegatedPermissionClassificationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DelegatedPermissionClassificationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The permission classifications for delegated permissions exposed by the app that this service principal represents. Supports $expand."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string servicePrincipalId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The permission classifications for delegated permissions exposed by the app that this service principal represents. Supports $expand."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(DelegatedPermissionClassi requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permission classifications for delegated permissions exposed by the app that this service principal represents. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permission classifications for delegated permissions exposed by the app that this service principal represents. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DelegatedPermissionClassification model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The permission classifications for delegated permissions exposed by the app that this service principal represents. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/ServicePrincipals/Item/DelegatedPermissionClassifications/Item/DelegatedPermissionClassificationRequestBuilder.cs b/src/generated/ServicePrincipals/Item/DelegatedPermissionClassifications/Item/DelegatedPermissionClassificationRequestBuilder.cs index 5a61b80d19e..076ea58293e 100644 --- a/src/generated/ServicePrincipals/Item/DelegatedPermissionClassifications/Item/DelegatedPermissionClassificationRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/DelegatedPermissionClassifications/Item/DelegatedPermissionClassificationRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The permission classifications for delegated permissions exposed by the app that this service principal represents. Supports $expand."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); - var delegatedPermissionClassificationIdOption = new Option("--delegatedpermissionclassification-id", description: "key: id of delegatedPermissionClassification") { + var delegatedPermissionClassificationIdOption = new Option("--delegated-permission-classification-id", description: "key: id of delegatedPermissionClassification") { }; delegatedPermissionClassificationIdOption.IsRequired = true; command.AddOption(delegatedPermissionClassificationIdOption); - command.SetHandler(async (string servicePrincipalId, string delegatedPermissionClassificationId) => { + command.SetHandler(async (string servicePrincipalId, string delegatedPermissionClassificationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, servicePrincipalIdOption, delegatedPermissionClassificationIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The permission classifications for delegated permissions exposed by the app that this service principal represents. Supports $expand."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); - var delegatedPermissionClassificationIdOption = new Option("--delegatedpermissionclassification-id", description: "key: id of delegatedPermissionClassification") { + var delegatedPermissionClassificationIdOption = new Option("--delegated-permission-classification-id", description: "key: id of delegatedPermissionClassification") { }; delegatedPermissionClassificationIdOption.IsRequired = true; command.AddOption(delegatedPermissionClassificationIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string servicePrincipalId, string delegatedPermissionClassificationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, string delegatedPermissionClassificationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, delegatedPermissionClassificationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, delegatedPermissionClassificationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The permission classifications for delegated permissions exposed by the app that this service principal represents. Supports $expand."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); - var delegatedPermissionClassificationIdOption = new Option("--delegatedpermissionclassification-id", description: "key: id of delegatedPermissionClassification") { + var delegatedPermissionClassificationIdOption = new Option("--delegated-permission-classification-id", description: "key: id of delegatedPermissionClassification") { }; delegatedPermissionClassificationIdOption.IsRequired = true; command.AddOption(delegatedPermissionClassificationIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string servicePrincipalId, string delegatedPermissionClassificationId, string body) => { + command.SetHandler(async (string servicePrincipalId, string delegatedPermissionClassificationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, servicePrincipalIdOption, delegatedPermissionClassificationIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(DelegatedPermissionClass requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permission classifications for delegated permissions exposed by the app that this service principal represents. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permission classifications for delegated permissions exposed by the app that this service principal represents. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permission classifications for delegated permissions exposed by the app that this service principal represents. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DelegatedPermissionClassification model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The permission classifications for delegated permissions exposed by the app that this service principal represents. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/ServicePrincipals/Item/Endpoints/EndpointsRequestBuilder.cs b/src/generated/ServicePrincipals/Item/Endpoints/EndpointsRequestBuilder.cs index ef811673fc0..c3d0fac1490 100644 --- a/src/generated/ServicePrincipals/Item/Endpoints/EndpointsRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/Endpoints/EndpointsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.ServicePrincipals.Item.Endpoints.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class EndpointsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EndpointRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Endpoints available for discovery. Services like Sharepoint populate this property with a tenant specific SharePoint endpoints that other applications can discover and use in their experiences."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string servicePrincipalId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Endpoints available for discovery. Services like Sharepoint populate this property with a tenant specific SharePoint endpoints that other applications can discover and use in their experiences."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(Endpoint body, Action - /// Endpoints available for discovery. Services like Sharepoint populate this property with a tenant specific SharePoint endpoints that other applications can discover and use in their experiences. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Endpoints available for discovery. Services like Sharepoint populate this property with a tenant specific SharePoint endpoints that other applications can discover and use in their experiences. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Endpoint model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Endpoints available for discovery. Services like Sharepoint populate this property with a tenant specific SharePoint endpoints that other applications can discover and use in their experiences. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/ServicePrincipals/Item/Endpoints/Item/EndpointRequestBuilder.cs b/src/generated/ServicePrincipals/Item/Endpoints/Item/EndpointRequestBuilder.cs index 6dd26483d94..68e383bc0bd 100644 --- a/src/generated/ServicePrincipals/Item/Endpoints/Item/EndpointRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/Endpoints/Item/EndpointRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Endpoints available for discovery. Services like Sharepoint populate this property with a tenant specific SharePoint endpoints that other applications can discover and use in their experiences."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; endpointIdOption.IsRequired = true; command.AddOption(endpointIdOption); - command.SetHandler(async (string servicePrincipalId, string endpointId) => { + command.SetHandler(async (string servicePrincipalId, string endpointId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, servicePrincipalIdOption, endpointIdOption); return command; @@ -50,7 +49,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Endpoints available for discovery. Services like Sharepoint populate this property with a tenant specific SharePoint endpoints that other applications can discover and use in their experiences."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string servicePrincipalId, string endpointId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, string endpointId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, endpointIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, endpointIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,7 +89,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Endpoints available for discovery. Services like Sharepoint populate this property with a tenant specific SharePoint endpoints that other applications can discover and use in their experiences."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string servicePrincipalId, string endpointId, string body) => { + command.SetHandler(async (string servicePrincipalId, string endpointId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, servicePrincipalIdOption, endpointIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(Endpoint body, Action - /// Endpoints available for discovery. Services like Sharepoint populate this property with a tenant specific SharePoint endpoints that other applications can discover and use in their experiences. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Endpoints available for discovery. Services like Sharepoint populate this property with a tenant specific SharePoint endpoints that other applications can discover and use in their experiences. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Endpoints available for discovery. Services like Sharepoint populate this property with a tenant specific SharePoint endpoints that other applications can discover and use in their experiences. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Endpoint model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Endpoints available for discovery. Services like Sharepoint populate this property with a tenant specific SharePoint endpoints that other applications can discover and use in their experiences. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/ServicePrincipals/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs b/src/generated/ServicePrincipals/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs index 1a5bde46ea3..9b0a222baba 100644 --- a/src/generated/ServicePrincipals/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action getMemberGroups"; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string servicePrincipalId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberGroupsRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/ServicePrincipals/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs b/src/generated/ServicePrincipals/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs index 09b874489f6..22ffce5f564 100644 --- a/src/generated/ServicePrincipals/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action getMemberObjects"; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string servicePrincipalId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberObjectsRequestBo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/ServicePrincipals/Item/HomeRealmDiscoveryPolicies/@Ref/@Ref.cs b/src/generated/ServicePrincipals/Item/HomeRealmDiscoveryPolicies/@Ref/@Ref.cs deleted file mode 100644 index 1fd5ae3dbe8..00000000000 --- a/src/generated/ServicePrincipals/Item/HomeRealmDiscoveryPolicies/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.ServicePrincipals.Item.HomeRealmDiscoveryPolicies.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/ServicePrincipals/Item/HomeRealmDiscoveryPolicies/@Ref/RefRequestBuilder.cs b/src/generated/ServicePrincipals/Item/HomeRealmDiscoveryPolicies/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 9af501127f0..00000000000 --- a/src/generated/ServicePrincipals/Item/HomeRealmDiscoveryPolicies/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.ServicePrincipals.Item.HomeRealmDiscoveryPolicies.@Ref { - /// Builds and executes requests for operations under \servicePrincipals\{servicePrincipal-id}\homeRealmDiscoveryPolicies\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The homeRealmDiscoveryPolicies assigned to this service principal. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The homeRealmDiscoveryPolicies assigned to this service principal. Supports $expand."; - // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { - }; - servicePrincipalIdOption.IsRequired = true; - command.AddOption(servicePrincipalIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The homeRealmDiscoveryPolicies assigned to this service principal. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The homeRealmDiscoveryPolicies assigned to this service principal. Supports $expand."; - // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { - }; - servicePrincipalIdOption.IsRequired = true; - command.AddOption(servicePrincipalIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string servicePrincipalId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/servicePrincipals/{servicePrincipal_id}/homeRealmDiscoveryPolicies/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The homeRealmDiscoveryPolicies assigned to this service principal. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The homeRealmDiscoveryPolicies assigned to this service principal. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.ServicePrincipals.Item.HomeRealmDiscoveryPolicies.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The homeRealmDiscoveryPolicies assigned to this service principal. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The homeRealmDiscoveryPolicies assigned to this service principal. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.ServicePrincipals.Item.HomeRealmDiscoveryPolicies.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The homeRealmDiscoveryPolicies assigned to this service principal. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/ServicePrincipals/Item/HomeRealmDiscoveryPolicies/@Ref/RefResponse.cs b/src/generated/ServicePrincipals/Item/HomeRealmDiscoveryPolicies/@Ref/RefResponse.cs deleted file mode 100644 index 0be49906801..00000000000 --- a/src/generated/ServicePrincipals/Item/HomeRealmDiscoveryPolicies/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.ServicePrincipals.Item.HomeRealmDiscoveryPolicies.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/ServicePrincipals/Item/HomeRealmDiscoveryPolicies/HomeRealmDiscoveryPoliciesRequestBuilder.cs b/src/generated/ServicePrincipals/Item/HomeRealmDiscoveryPolicies/HomeRealmDiscoveryPoliciesRequestBuilder.cs index 423dfeedc40..7425d197a1f 100644 --- a/src/generated/ServicePrincipals/Item/HomeRealmDiscoveryPolicies/HomeRealmDiscoveryPoliciesRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/HomeRealmDiscoveryPolicies/HomeRealmDiscoveryPoliciesRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.ServicePrincipals.Item.HomeRealmDiscoveryPolicies.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The homeRealmDiscoveryPolicies assigned to this service principal. Supports $expand."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.ServicePrincipals.Item.HomeRealmDiscoveryPolicies.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.ServicePrincipals.Item.HomeRealmDiscoveryPolicies.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The homeRealmDiscoveryPolicies assigned to this service principal. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The homeRealmDiscoveryPolicies assigned to this service principal. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/ServicePrincipals/Item/HomeRealmDiscoveryPolicies/Ref/Ref.cs b/src/generated/ServicePrincipals/Item/HomeRealmDiscoveryPolicies/Ref/Ref.cs new file mode 100644 index 00000000000..76a0d1a0227 --- /dev/null +++ b/src/generated/ServicePrincipals/Item/HomeRealmDiscoveryPolicies/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.ServicePrincipals.Item.HomeRealmDiscoveryPolicies.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/ServicePrincipals/Item/HomeRealmDiscoveryPolicies/Ref/RefRequestBuilder.cs b/src/generated/ServicePrincipals/Item/HomeRealmDiscoveryPolicies/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..dc04309129b --- /dev/null +++ b/src/generated/ServicePrincipals/Item/HomeRealmDiscoveryPolicies/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.ServicePrincipals.Item.HomeRealmDiscoveryPolicies.Ref { + /// Builds and executes requests for operations under \servicePrincipals\{servicePrincipal-id}\homeRealmDiscoveryPolicies\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The homeRealmDiscoveryPolicies assigned to this service principal. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The homeRealmDiscoveryPolicies assigned to this service principal. Supports $expand."; + // Create options for all the parameters + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { + }; + servicePrincipalIdOption.IsRequired = true; + command.AddOption(servicePrincipalIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The homeRealmDiscoveryPolicies assigned to this service principal. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The homeRealmDiscoveryPolicies assigned to this service principal. Supports $expand."; + // Create options for all the parameters + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { + }; + servicePrincipalIdOption.IsRequired = true; + command.AddOption(servicePrincipalIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/servicePrincipals/{servicePrincipal_id}/homeRealmDiscoveryPolicies/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The homeRealmDiscoveryPolicies assigned to this service principal. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The homeRealmDiscoveryPolicies assigned to this service principal. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.ServicePrincipals.Item.HomeRealmDiscoveryPolicies.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The homeRealmDiscoveryPolicies assigned to this service principal. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/ServicePrincipals/Item/HomeRealmDiscoveryPolicies/Ref/RefResponse.cs b/src/generated/ServicePrincipals/Item/HomeRealmDiscoveryPolicies/Ref/RefResponse.cs new file mode 100644 index 00000000000..2ed1f41df01 --- /dev/null +++ b/src/generated/ServicePrincipals/Item/HomeRealmDiscoveryPolicies/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.ServicePrincipals.Item.HomeRealmDiscoveryPolicies.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/ServicePrincipals/Item/MemberOf/@Ref/@Ref.cs b/src/generated/ServicePrincipals/Item/MemberOf/@Ref/@Ref.cs deleted file mode 100644 index 55cfdeaf607..00000000000 --- a/src/generated/ServicePrincipals/Item/MemberOf/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.ServicePrincipals.Item.MemberOf.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/ServicePrincipals/Item/MemberOf/@Ref/RefRequestBuilder.cs b/src/generated/ServicePrincipals/Item/MemberOf/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 776f171a01d..00000000000 --- a/src/generated/ServicePrincipals/Item/MemberOf/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.ServicePrincipals.Item.MemberOf.@Ref { - /// Builds and executes requests for operations under \servicePrincipals\{servicePrincipal-id}\memberOf\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Roles that this service principal is a member of. HTTP Methods: GET Read-only. Nullable. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Roles that this service principal is a member of. HTTP Methods: GET Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { - }; - servicePrincipalIdOption.IsRequired = true; - command.AddOption(servicePrincipalIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Roles that this service principal is a member of. HTTP Methods: GET Read-only. Nullable. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Roles that this service principal is a member of. HTTP Methods: GET Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { - }; - servicePrincipalIdOption.IsRequired = true; - command.AddOption(servicePrincipalIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string servicePrincipalId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/servicePrincipals/{servicePrincipal_id}/memberOf/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Roles that this service principal is a member of. HTTP Methods: GET Read-only. Nullable. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Roles that this service principal is a member of. HTTP Methods: GET Read-only. Nullable. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.ServicePrincipals.Item.MemberOf.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Roles that this service principal is a member of. HTTP Methods: GET Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Roles that this service principal is a member of. HTTP Methods: GET Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.ServicePrincipals.Item.MemberOf.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Roles that this service principal is a member of. HTTP Methods: GET Read-only. Nullable. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/ServicePrincipals/Item/MemberOf/@Ref/RefResponse.cs b/src/generated/ServicePrincipals/Item/MemberOf/@Ref/RefResponse.cs deleted file mode 100644 index 27c20dd7fcb..00000000000 --- a/src/generated/ServicePrincipals/Item/MemberOf/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.ServicePrincipals.Item.MemberOf.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/ServicePrincipals/Item/MemberOf/MemberOfRequestBuilder.cs b/src/generated/ServicePrincipals/Item/MemberOf/MemberOfRequestBuilder.cs index 27f5e4b71c8..2280d70e2cc 100644 --- a/src/generated/ServicePrincipals/Item/MemberOf/MemberOfRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/MemberOf/MemberOfRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.ServicePrincipals.Item.MemberOf.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Roles that this service principal is a member of. HTTP Methods: GET Read-only. Nullable. Supports $expand."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.ServicePrincipals.Item.MemberOf.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.ServicePrincipals.Item.MemberOf.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Roles that this service principal is a member of. HTTP Methods: GET Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Roles that this service principal is a member of. HTTP Methods: GET Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/ServicePrincipals/Item/MemberOf/Ref/Ref.cs b/src/generated/ServicePrincipals/Item/MemberOf/Ref/Ref.cs new file mode 100644 index 00000000000..c9ceabb0a12 --- /dev/null +++ b/src/generated/ServicePrincipals/Item/MemberOf/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.ServicePrincipals.Item.MemberOf.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/ServicePrincipals/Item/MemberOf/Ref/RefRequestBuilder.cs b/src/generated/ServicePrincipals/Item/MemberOf/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..dc05f344450 --- /dev/null +++ b/src/generated/ServicePrincipals/Item/MemberOf/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.ServicePrincipals.Item.MemberOf.Ref { + /// Builds and executes requests for operations under \servicePrincipals\{servicePrincipal-id}\memberOf\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Roles that this service principal is a member of. HTTP Methods: GET Read-only. Nullable. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Roles that this service principal is a member of. HTTP Methods: GET Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { + }; + servicePrincipalIdOption.IsRequired = true; + command.AddOption(servicePrincipalIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Roles that this service principal is a member of. HTTP Methods: GET Read-only. Nullable. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Roles that this service principal is a member of. HTTP Methods: GET Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { + }; + servicePrincipalIdOption.IsRequired = true; + command.AddOption(servicePrincipalIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/servicePrincipals/{servicePrincipal_id}/memberOf/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Roles that this service principal is a member of. HTTP Methods: GET Read-only. Nullable. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Roles that this service principal is a member of. HTTP Methods: GET Read-only. Nullable. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.ServicePrincipals.Item.MemberOf.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Roles that this service principal is a member of. HTTP Methods: GET Read-only. Nullable. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/ServicePrincipals/Item/MemberOf/Ref/RefResponse.cs b/src/generated/ServicePrincipals/Item/MemberOf/Ref/RefResponse.cs new file mode 100644 index 00000000000..9f4e58e232d --- /dev/null +++ b/src/generated/ServicePrincipals/Item/MemberOf/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.ServicePrincipals.Item.MemberOf.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/ServicePrincipals/Item/Oauth2PermissionGrants/@Ref/@Ref.cs b/src/generated/ServicePrincipals/Item/Oauth2PermissionGrants/@Ref/@Ref.cs deleted file mode 100644 index 77bcc17971d..00000000000 --- a/src/generated/ServicePrincipals/Item/Oauth2PermissionGrants/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.ServicePrincipals.Item.Oauth2PermissionGrants.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/ServicePrincipals/Item/Oauth2PermissionGrants/@Ref/RefRequestBuilder.cs b/src/generated/ServicePrincipals/Item/Oauth2PermissionGrants/@Ref/RefRequestBuilder.cs deleted file mode 100644 index e7d337778cc..00000000000 --- a/src/generated/ServicePrincipals/Item/Oauth2PermissionGrants/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.ServicePrincipals.Item.Oauth2PermissionGrants.@Ref { - /// Builds and executes requests for operations under \servicePrincipals\{servicePrincipal-id}\oauth2PermissionGrants\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Delegated permission grants authorizing this service principal to access an API on behalf of a signed-in user. Read-only. Nullable. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Delegated permission grants authorizing this service principal to access an API on behalf of a signed-in user. Read-only. Nullable."; - // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { - }; - servicePrincipalIdOption.IsRequired = true; - command.AddOption(servicePrincipalIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Delegated permission grants authorizing this service principal to access an API on behalf of a signed-in user. Read-only. Nullable. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Delegated permission grants authorizing this service principal to access an API on behalf of a signed-in user. Read-only. Nullable."; - // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { - }; - servicePrincipalIdOption.IsRequired = true; - command.AddOption(servicePrincipalIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string servicePrincipalId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/servicePrincipals/{servicePrincipal_id}/oauth2PermissionGrants/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Delegated permission grants authorizing this service principal to access an API on behalf of a signed-in user. Read-only. Nullable. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Delegated permission grants authorizing this service principal to access an API on behalf of a signed-in user. Read-only. Nullable. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.ServicePrincipals.Item.Oauth2PermissionGrants.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Delegated permission grants authorizing this service principal to access an API on behalf of a signed-in user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Delegated permission grants authorizing this service principal to access an API on behalf of a signed-in user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.ServicePrincipals.Item.Oauth2PermissionGrants.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Delegated permission grants authorizing this service principal to access an API on behalf of a signed-in user. Read-only. Nullable. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/ServicePrincipals/Item/Oauth2PermissionGrants/@Ref/RefResponse.cs b/src/generated/ServicePrincipals/Item/Oauth2PermissionGrants/@Ref/RefResponse.cs deleted file mode 100644 index bc77bf508b7..00000000000 --- a/src/generated/ServicePrincipals/Item/Oauth2PermissionGrants/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.ServicePrincipals.Item.Oauth2PermissionGrants.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/ServicePrincipals/Item/Oauth2PermissionGrants/Oauth2PermissionGrantsRequestBuilder.cs b/src/generated/ServicePrincipals/Item/Oauth2PermissionGrants/Oauth2PermissionGrantsRequestBuilder.cs index 2be928e6d96..f1d6cbc33dc 100644 --- a/src/generated/ServicePrincipals/Item/Oauth2PermissionGrants/Oauth2PermissionGrantsRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/Oauth2PermissionGrants/Oauth2PermissionGrantsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.ServicePrincipals.Item.Oauth2PermissionGrants.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Delegated permission grants authorizing this service principal to access an API on behalf of a signed-in user. Read-only. Nullable."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.ServicePrincipals.Item.Oauth2PermissionGrants.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.ServicePrincipals.Item.Oauth2PermissionGrants.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delegated permission grants authorizing this service principal to access an API on behalf of a signed-in user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Delegated permission grants authorizing this service principal to access an API on behalf of a signed-in user. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/ServicePrincipals/Item/Oauth2PermissionGrants/Ref/Ref.cs b/src/generated/ServicePrincipals/Item/Oauth2PermissionGrants/Ref/Ref.cs new file mode 100644 index 00000000000..27f2279bec3 --- /dev/null +++ b/src/generated/ServicePrincipals/Item/Oauth2PermissionGrants/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.ServicePrincipals.Item.Oauth2PermissionGrants.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/ServicePrincipals/Item/Oauth2PermissionGrants/Ref/RefRequestBuilder.cs b/src/generated/ServicePrincipals/Item/Oauth2PermissionGrants/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..2259a530fea --- /dev/null +++ b/src/generated/ServicePrincipals/Item/Oauth2PermissionGrants/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.ServicePrincipals.Item.Oauth2PermissionGrants.Ref { + /// Builds and executes requests for operations under \servicePrincipals\{servicePrincipal-id}\oauth2PermissionGrants\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Delegated permission grants authorizing this service principal to access an API on behalf of a signed-in user. Read-only. Nullable. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Delegated permission grants authorizing this service principal to access an API on behalf of a signed-in user. Read-only. Nullable."; + // Create options for all the parameters + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { + }; + servicePrincipalIdOption.IsRequired = true; + command.AddOption(servicePrincipalIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Delegated permission grants authorizing this service principal to access an API on behalf of a signed-in user. Read-only. Nullable. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Delegated permission grants authorizing this service principal to access an API on behalf of a signed-in user. Read-only. Nullable."; + // Create options for all the parameters + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { + }; + servicePrincipalIdOption.IsRequired = true; + command.AddOption(servicePrincipalIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/servicePrincipals/{servicePrincipal_id}/oauth2PermissionGrants/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Delegated permission grants authorizing this service principal to access an API on behalf of a signed-in user. Read-only. Nullable. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Delegated permission grants authorizing this service principal to access an API on behalf of a signed-in user. Read-only. Nullable. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.ServicePrincipals.Item.Oauth2PermissionGrants.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Delegated permission grants authorizing this service principal to access an API on behalf of a signed-in user. Read-only. Nullable. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/ServicePrincipals/Item/Oauth2PermissionGrants/Ref/RefResponse.cs b/src/generated/ServicePrincipals/Item/Oauth2PermissionGrants/Ref/RefResponse.cs new file mode 100644 index 00000000000..0b27d2ed7ae --- /dev/null +++ b/src/generated/ServicePrincipals/Item/Oauth2PermissionGrants/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.ServicePrincipals.Item.Oauth2PermissionGrants.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/ServicePrincipals/Item/OwnedObjects/@Ref/@Ref.cs b/src/generated/ServicePrincipals/Item/OwnedObjects/@Ref/@Ref.cs deleted file mode 100644 index 79d798b80a4..00000000000 --- a/src/generated/ServicePrincipals/Item/OwnedObjects/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.ServicePrincipals.Item.OwnedObjects.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/ServicePrincipals/Item/OwnedObjects/@Ref/RefRequestBuilder.cs b/src/generated/ServicePrincipals/Item/OwnedObjects/@Ref/RefRequestBuilder.cs deleted file mode 100644 index bc1350a3a11..00000000000 --- a/src/generated/ServicePrincipals/Item/OwnedObjects/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.ServicePrincipals.Item.OwnedObjects.@Ref { - /// Builds and executes requests for operations under \servicePrincipals\{servicePrincipal-id}\ownedObjects\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Directory objects that are owned by this service principal. Read-only. Nullable. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Directory objects that are owned by this service principal. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { - }; - servicePrincipalIdOption.IsRequired = true; - command.AddOption(servicePrincipalIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Directory objects that are owned by this service principal. Read-only. Nullable. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Directory objects that are owned by this service principal. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { - }; - servicePrincipalIdOption.IsRequired = true; - command.AddOption(servicePrincipalIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string servicePrincipalId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/servicePrincipals/{servicePrincipal_id}/ownedObjects/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Directory objects that are owned by this service principal. Read-only. Nullable. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Directory objects that are owned by this service principal. Read-only. Nullable. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.ServicePrincipals.Item.OwnedObjects.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Directory objects that are owned by this service principal. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Directory objects that are owned by this service principal. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.ServicePrincipals.Item.OwnedObjects.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Directory objects that are owned by this service principal. Read-only. Nullable. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/ServicePrincipals/Item/OwnedObjects/@Ref/RefResponse.cs b/src/generated/ServicePrincipals/Item/OwnedObjects/@Ref/RefResponse.cs deleted file mode 100644 index c1a34c43c3f..00000000000 --- a/src/generated/ServicePrincipals/Item/OwnedObjects/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.ServicePrincipals.Item.OwnedObjects.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/ServicePrincipals/Item/OwnedObjects/OwnedObjectsRequestBuilder.cs b/src/generated/ServicePrincipals/Item/OwnedObjects/OwnedObjectsRequestBuilder.cs index 6789d75718f..b8f96defcb6 100644 --- a/src/generated/ServicePrincipals/Item/OwnedObjects/OwnedObjectsRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/OwnedObjects/OwnedObjectsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.ServicePrincipals.Item.OwnedObjects.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Directory objects that are owned by this service principal. Read-only. Nullable. Supports $expand."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.ServicePrincipals.Item.OwnedObjects.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.ServicePrincipals.Item.OwnedObjects.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Directory objects that are owned by this service principal. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Directory objects that are owned by this service principal. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/ServicePrincipals/Item/OwnedObjects/Ref/Ref.cs b/src/generated/ServicePrincipals/Item/OwnedObjects/Ref/Ref.cs new file mode 100644 index 00000000000..09b75285b84 --- /dev/null +++ b/src/generated/ServicePrincipals/Item/OwnedObjects/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.ServicePrincipals.Item.OwnedObjects.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/ServicePrincipals/Item/OwnedObjects/Ref/RefRequestBuilder.cs b/src/generated/ServicePrincipals/Item/OwnedObjects/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..2a157c21043 --- /dev/null +++ b/src/generated/ServicePrincipals/Item/OwnedObjects/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.ServicePrincipals.Item.OwnedObjects.Ref { + /// Builds and executes requests for operations under \servicePrincipals\{servicePrincipal-id}\ownedObjects\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Directory objects that are owned by this service principal. Read-only. Nullable. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Directory objects that are owned by this service principal. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { + }; + servicePrincipalIdOption.IsRequired = true; + command.AddOption(servicePrincipalIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Directory objects that are owned by this service principal. Read-only. Nullable. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Directory objects that are owned by this service principal. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { + }; + servicePrincipalIdOption.IsRequired = true; + command.AddOption(servicePrincipalIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/servicePrincipals/{servicePrincipal_id}/ownedObjects/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Directory objects that are owned by this service principal. Read-only. Nullable. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Directory objects that are owned by this service principal. Read-only. Nullable. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.ServicePrincipals.Item.OwnedObjects.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Directory objects that are owned by this service principal. Read-only. Nullable. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/ServicePrincipals/Item/OwnedObjects/Ref/RefResponse.cs b/src/generated/ServicePrincipals/Item/OwnedObjects/Ref/RefResponse.cs new file mode 100644 index 00000000000..b6677e073d8 --- /dev/null +++ b/src/generated/ServicePrincipals/Item/OwnedObjects/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.ServicePrincipals.Item.OwnedObjects.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/ServicePrincipals/Item/Owners/@Ref/@Ref.cs b/src/generated/ServicePrincipals/Item/Owners/@Ref/@Ref.cs deleted file mode 100644 index b43ad8334f7..00000000000 --- a/src/generated/ServicePrincipals/Item/Owners/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.ServicePrincipals.Item.Owners.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/ServicePrincipals/Item/Owners/@Ref/RefRequestBuilder.cs b/src/generated/ServicePrincipals/Item/Owners/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 021339f25c2..00000000000 --- a/src/generated/ServicePrincipals/Item/Owners/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.ServicePrincipals.Item.Owners.@Ref { - /// Builds and executes requests for operations under \servicePrincipals\{servicePrincipal-id}\owners\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Directory objects that are owners of this servicePrincipal. The owners are a set of non-admin users or servicePrincipals who are allowed to modify this object. Read-only. Nullable. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Directory objects that are owners of this servicePrincipal. The owners are a set of non-admin users or servicePrincipals who are allowed to modify this object. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { - }; - servicePrincipalIdOption.IsRequired = true; - command.AddOption(servicePrincipalIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Directory objects that are owners of this servicePrincipal. The owners are a set of non-admin users or servicePrincipals who are allowed to modify this object. Read-only. Nullable. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Directory objects that are owners of this servicePrincipal. The owners are a set of non-admin users or servicePrincipals who are allowed to modify this object. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { - }; - servicePrincipalIdOption.IsRequired = true; - command.AddOption(servicePrincipalIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string servicePrincipalId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/servicePrincipals/{servicePrincipal_id}/owners/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Directory objects that are owners of this servicePrincipal. The owners are a set of non-admin users or servicePrincipals who are allowed to modify this object. Read-only. Nullable. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Directory objects that are owners of this servicePrincipal. The owners are a set of non-admin users or servicePrincipals who are allowed to modify this object. Read-only. Nullable. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.ServicePrincipals.Item.Owners.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Directory objects that are owners of this servicePrincipal. The owners are a set of non-admin users or servicePrincipals who are allowed to modify this object. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Directory objects that are owners of this servicePrincipal. The owners are a set of non-admin users or servicePrincipals who are allowed to modify this object. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.ServicePrincipals.Item.Owners.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Directory objects that are owners of this servicePrincipal. The owners are a set of non-admin users or servicePrincipals who are allowed to modify this object. Read-only. Nullable. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/ServicePrincipals/Item/Owners/@Ref/RefResponse.cs b/src/generated/ServicePrincipals/Item/Owners/@Ref/RefResponse.cs deleted file mode 100644 index f36d974b6dd..00000000000 --- a/src/generated/ServicePrincipals/Item/Owners/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.ServicePrincipals.Item.Owners.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/ServicePrincipals/Item/Owners/OwnersRequestBuilder.cs b/src/generated/ServicePrincipals/Item/Owners/OwnersRequestBuilder.cs index 85dee35f135..f017a1a353c 100644 --- a/src/generated/ServicePrincipals/Item/Owners/OwnersRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/Owners/OwnersRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.ServicePrincipals.Item.Owners.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Directory objects that are owners of this servicePrincipal. The owners are a set of non-admin users or servicePrincipals who are allowed to modify this object. Read-only. Nullable. Supports $expand."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.ServicePrincipals.Item.Owners.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.ServicePrincipals.Item.Owners.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Directory objects that are owners of this servicePrincipal. The owners are a set of non-admin users or servicePrincipals who are allowed to modify this object. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Directory objects that are owners of this servicePrincipal. The owners are a set of non-admin users or servicePrincipals who are allowed to modify this object. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/ServicePrincipals/Item/Owners/Ref/Ref.cs b/src/generated/ServicePrincipals/Item/Owners/Ref/Ref.cs new file mode 100644 index 00000000000..1598440cf1d --- /dev/null +++ b/src/generated/ServicePrincipals/Item/Owners/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.ServicePrincipals.Item.Owners.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/ServicePrincipals/Item/Owners/Ref/RefRequestBuilder.cs b/src/generated/ServicePrincipals/Item/Owners/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..470d99dc750 --- /dev/null +++ b/src/generated/ServicePrincipals/Item/Owners/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.ServicePrincipals.Item.Owners.Ref { + /// Builds and executes requests for operations under \servicePrincipals\{servicePrincipal-id}\owners\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Directory objects that are owners of this servicePrincipal. The owners are a set of non-admin users or servicePrincipals who are allowed to modify this object. Read-only. Nullable. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Directory objects that are owners of this servicePrincipal. The owners are a set of non-admin users or servicePrincipals who are allowed to modify this object. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { + }; + servicePrincipalIdOption.IsRequired = true; + command.AddOption(servicePrincipalIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Directory objects that are owners of this servicePrincipal. The owners are a set of non-admin users or servicePrincipals who are allowed to modify this object. Read-only. Nullable. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Directory objects that are owners of this servicePrincipal. The owners are a set of non-admin users or servicePrincipals who are allowed to modify this object. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { + }; + servicePrincipalIdOption.IsRequired = true; + command.AddOption(servicePrincipalIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/servicePrincipals/{servicePrincipal_id}/owners/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Directory objects that are owners of this servicePrincipal. The owners are a set of non-admin users or servicePrincipals who are allowed to modify this object. Read-only. Nullable. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Directory objects that are owners of this servicePrincipal. The owners are a set of non-admin users or servicePrincipals who are allowed to modify this object. Read-only. Nullable. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.ServicePrincipals.Item.Owners.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Directory objects that are owners of this servicePrincipal. The owners are a set of non-admin users or servicePrincipals who are allowed to modify this object. Read-only. Nullable. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/ServicePrincipals/Item/Owners/Ref/RefResponse.cs b/src/generated/ServicePrincipals/Item/Owners/Ref/RefResponse.cs new file mode 100644 index 00000000000..e685a70b4c4 --- /dev/null +++ b/src/generated/ServicePrincipals/Item/Owners/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.ServicePrincipals.Item.Owners.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/ServicePrincipals/Item/RemoveKey/RemoveKeyRequestBuilder.cs b/src/generated/ServicePrincipals/Item/RemoveKey/RemoveKeyRequestBuilder.cs index 56d14928d93..03ebba5fdd5 100644 --- a/src/generated/ServicePrincipals/Item/RemoveKey/RemoveKeyRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/RemoveKey/RemoveKeyRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action removeKey"; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string servicePrincipalId, string body) => { + command.SetHandler(async (string servicePrincipalId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, servicePrincipalIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(RemoveKeyRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action removeKey - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RemoveKeyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/ServicePrincipals/Item/RemovePassword/RemovePasswordRequestBuilder.cs b/src/generated/ServicePrincipals/Item/RemovePassword/RemovePasswordRequestBuilder.cs index a07eead1225..e8c4501fd0e 100644 --- a/src/generated/ServicePrincipals/Item/RemovePassword/RemovePasswordRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/RemovePassword/RemovePasswordRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action removePassword"; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string servicePrincipalId, string body) => { + command.SetHandler(async (string servicePrincipalId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, servicePrincipalIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(RemovePasswordRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action removePassword - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RemovePasswordRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/ServicePrincipals/Item/Restore/RestoreRequestBuilder.cs b/src/generated/ServicePrincipals/Item/Restore/RestoreRequestBuilder.cs index a29f066e000..5244079bf73 100644 --- a/src/generated/ServicePrincipals/Item/Restore/RestoreRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/Restore/RestoreRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action restore"; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); - command.SetHandler(async (string servicePrincipalId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action restore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes directoryObject public class RestoreResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/ServicePrincipals/Item/ServicePrincipalRequestBuilder.cs b/src/generated/ServicePrincipals/Item/ServicePrincipalRequestBuilder.cs index 527cd5d9c13..9aa2420dc7b 100644 --- a/src/generated/ServicePrincipals/Item/ServicePrincipalRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/ServicePrincipalRequestBuilder.cs @@ -24,10 +24,10 @@ using ApiSdk.ServicePrincipals.Item.TransitiveMemberOf; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -57,6 +57,9 @@ public Command BuildAddPasswordCommand() { public Command BuildAppRoleAssignedToCommand() { var command = new Command("app-role-assigned-to"); var builder = new ApiSdk.ServicePrincipals.Item.AppRoleAssignedTo.AppRoleAssignedToRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -64,6 +67,9 @@ public Command BuildAppRoleAssignedToCommand() { public Command BuildAppRoleAssignmentsCommand() { var command = new Command("app-role-assignments"); var builder = new ApiSdk.ServicePrincipals.Item.AppRoleAssignments.AppRoleAssignmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -97,6 +103,9 @@ public Command BuildCreatedObjectsCommand() { public Command BuildDelegatedPermissionClassificationsCommand() { var command = new Command("delegated-permission-classifications"); var builder = new ApiSdk.ServicePrincipals.Item.DelegatedPermissionClassifications.DelegatedPermissionClassificationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -108,15 +117,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete entity from servicePrincipals"; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); - command.SetHandler(async (string servicePrincipalId) => { + command.SetHandler(async (string servicePrincipalId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, servicePrincipalIdOption); return command; @@ -124,6 +132,9 @@ public Command BuildDeleteCommand() { public Command BuildEndpointsCommand() { var command = new Command("endpoints"); var builder = new ApiSdk.ServicePrincipals.Item.Endpoints.EndpointsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -135,7 +146,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get entity from servicePrincipals by key"; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -149,20 +160,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string servicePrincipalId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildGetMemberGroupsCommand() { @@ -219,7 +229,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update entity in servicePrincipals"; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -227,14 +237,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string servicePrincipalId, string body) => { + command.SetHandler(async (string servicePrincipalId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, servicePrincipalIdOption, bodyOption); return command; @@ -345,42 +354,6 @@ public RequestInformation CreatePatchRequestInformation(ServicePrincipal body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from servicePrincipals - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from servicePrincipals by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in servicePrincipals - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ServicePrincipal model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from servicePrincipals by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/ServicePrincipals/Item/TokenIssuancePolicies/@Ref/@Ref.cs b/src/generated/ServicePrincipals/Item/TokenIssuancePolicies/@Ref/@Ref.cs deleted file mode 100644 index 789e74f8112..00000000000 --- a/src/generated/ServicePrincipals/Item/TokenIssuancePolicies/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.ServicePrincipals.Item.TokenIssuancePolicies.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/ServicePrincipals/Item/TokenIssuancePolicies/@Ref/RefRequestBuilder.cs b/src/generated/ServicePrincipals/Item/TokenIssuancePolicies/@Ref/RefRequestBuilder.cs deleted file mode 100644 index b51f9196ca9..00000000000 --- a/src/generated/ServicePrincipals/Item/TokenIssuancePolicies/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.ServicePrincipals.Item.TokenIssuancePolicies.@Ref { - /// Builds and executes requests for operations under \servicePrincipals\{servicePrincipal-id}\tokenIssuancePolicies\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The tokenIssuancePolicies assigned to this service principal. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The tokenIssuancePolicies assigned to this service principal. Supports $expand."; - // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { - }; - servicePrincipalIdOption.IsRequired = true; - command.AddOption(servicePrincipalIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The tokenIssuancePolicies assigned to this service principal. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The tokenIssuancePolicies assigned to this service principal. Supports $expand."; - // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { - }; - servicePrincipalIdOption.IsRequired = true; - command.AddOption(servicePrincipalIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string servicePrincipalId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/servicePrincipals/{servicePrincipal_id}/tokenIssuancePolicies/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The tokenIssuancePolicies assigned to this service principal. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The tokenIssuancePolicies assigned to this service principal. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.ServicePrincipals.Item.TokenIssuancePolicies.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The tokenIssuancePolicies assigned to this service principal. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The tokenIssuancePolicies assigned to this service principal. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.ServicePrincipals.Item.TokenIssuancePolicies.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The tokenIssuancePolicies assigned to this service principal. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/ServicePrincipals/Item/TokenIssuancePolicies/@Ref/RefResponse.cs b/src/generated/ServicePrincipals/Item/TokenIssuancePolicies/@Ref/RefResponse.cs deleted file mode 100644 index 30cc0152ba0..00000000000 --- a/src/generated/ServicePrincipals/Item/TokenIssuancePolicies/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.ServicePrincipals.Item.TokenIssuancePolicies.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/ServicePrincipals/Item/TokenIssuancePolicies/Ref/Ref.cs b/src/generated/ServicePrincipals/Item/TokenIssuancePolicies/Ref/Ref.cs new file mode 100644 index 00000000000..b27fd2d7f1a --- /dev/null +++ b/src/generated/ServicePrincipals/Item/TokenIssuancePolicies/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.ServicePrincipals.Item.TokenIssuancePolicies.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/ServicePrincipals/Item/TokenIssuancePolicies/Ref/RefRequestBuilder.cs b/src/generated/ServicePrincipals/Item/TokenIssuancePolicies/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..c8507100cdf --- /dev/null +++ b/src/generated/ServicePrincipals/Item/TokenIssuancePolicies/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.ServicePrincipals.Item.TokenIssuancePolicies.Ref { + /// Builds and executes requests for operations under \servicePrincipals\{servicePrincipal-id}\tokenIssuancePolicies\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The tokenIssuancePolicies assigned to this service principal. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The tokenIssuancePolicies assigned to this service principal. Supports $expand."; + // Create options for all the parameters + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { + }; + servicePrincipalIdOption.IsRequired = true; + command.AddOption(servicePrincipalIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The tokenIssuancePolicies assigned to this service principal. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The tokenIssuancePolicies assigned to this service principal. Supports $expand."; + // Create options for all the parameters + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { + }; + servicePrincipalIdOption.IsRequired = true; + command.AddOption(servicePrincipalIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/servicePrincipals/{servicePrincipal_id}/tokenIssuancePolicies/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The tokenIssuancePolicies assigned to this service principal. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The tokenIssuancePolicies assigned to this service principal. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.ServicePrincipals.Item.TokenIssuancePolicies.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The tokenIssuancePolicies assigned to this service principal. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/ServicePrincipals/Item/TokenIssuancePolicies/Ref/RefResponse.cs b/src/generated/ServicePrincipals/Item/TokenIssuancePolicies/Ref/RefResponse.cs new file mode 100644 index 00000000000..2ae94650b95 --- /dev/null +++ b/src/generated/ServicePrincipals/Item/TokenIssuancePolicies/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.ServicePrincipals.Item.TokenIssuancePolicies.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/ServicePrincipals/Item/TokenIssuancePolicies/TokenIssuancePoliciesRequestBuilder.cs b/src/generated/ServicePrincipals/Item/TokenIssuancePolicies/TokenIssuancePoliciesRequestBuilder.cs index d656e901426..68bd21f1da1 100644 --- a/src/generated/ServicePrincipals/Item/TokenIssuancePolicies/TokenIssuancePoliciesRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/TokenIssuancePolicies/TokenIssuancePoliciesRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.ServicePrincipals.Item.TokenIssuancePolicies.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The tokenIssuancePolicies assigned to this service principal. Supports $expand."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.ServicePrincipals.Item.TokenIssuancePolicies.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.ServicePrincipals.Item.TokenIssuancePolicies.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The tokenIssuancePolicies assigned to this service principal. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The tokenIssuancePolicies assigned to this service principal. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/ServicePrincipals/Item/TokenLifetimePolicies/@Ref/@Ref.cs b/src/generated/ServicePrincipals/Item/TokenLifetimePolicies/@Ref/@Ref.cs deleted file mode 100644 index 44a05df0c2d..00000000000 --- a/src/generated/ServicePrincipals/Item/TokenLifetimePolicies/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.ServicePrincipals.Item.TokenLifetimePolicies.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/ServicePrincipals/Item/TokenLifetimePolicies/@Ref/RefRequestBuilder.cs b/src/generated/ServicePrincipals/Item/TokenLifetimePolicies/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 140427031e1..00000000000 --- a/src/generated/ServicePrincipals/Item/TokenLifetimePolicies/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.ServicePrincipals.Item.TokenLifetimePolicies.@Ref { - /// Builds and executes requests for operations under \servicePrincipals\{servicePrincipal-id}\tokenLifetimePolicies\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The tokenLifetimePolicies assigned to this service principal. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The tokenLifetimePolicies assigned to this service principal. Supports $expand."; - // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { - }; - servicePrincipalIdOption.IsRequired = true; - command.AddOption(servicePrincipalIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The tokenLifetimePolicies assigned to this service principal. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The tokenLifetimePolicies assigned to this service principal. Supports $expand."; - // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { - }; - servicePrincipalIdOption.IsRequired = true; - command.AddOption(servicePrincipalIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string servicePrincipalId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/servicePrincipals/{servicePrincipal_id}/tokenLifetimePolicies/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The tokenLifetimePolicies assigned to this service principal. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The tokenLifetimePolicies assigned to this service principal. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.ServicePrincipals.Item.TokenLifetimePolicies.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The tokenLifetimePolicies assigned to this service principal. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The tokenLifetimePolicies assigned to this service principal. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.ServicePrincipals.Item.TokenLifetimePolicies.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The tokenLifetimePolicies assigned to this service principal. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/ServicePrincipals/Item/TokenLifetimePolicies/@Ref/RefResponse.cs b/src/generated/ServicePrincipals/Item/TokenLifetimePolicies/@Ref/RefResponse.cs deleted file mode 100644 index d415c662b37..00000000000 --- a/src/generated/ServicePrincipals/Item/TokenLifetimePolicies/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.ServicePrincipals.Item.TokenLifetimePolicies.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/ServicePrincipals/Item/TokenLifetimePolicies/Ref/Ref.cs b/src/generated/ServicePrincipals/Item/TokenLifetimePolicies/Ref/Ref.cs new file mode 100644 index 00000000000..94416889e51 --- /dev/null +++ b/src/generated/ServicePrincipals/Item/TokenLifetimePolicies/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.ServicePrincipals.Item.TokenLifetimePolicies.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/ServicePrincipals/Item/TokenLifetimePolicies/Ref/RefRequestBuilder.cs b/src/generated/ServicePrincipals/Item/TokenLifetimePolicies/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..099f3c146b9 --- /dev/null +++ b/src/generated/ServicePrincipals/Item/TokenLifetimePolicies/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.ServicePrincipals.Item.TokenLifetimePolicies.Ref { + /// Builds and executes requests for operations under \servicePrincipals\{servicePrincipal-id}\tokenLifetimePolicies\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The tokenLifetimePolicies assigned to this service principal. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The tokenLifetimePolicies assigned to this service principal. Supports $expand."; + // Create options for all the parameters + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { + }; + servicePrincipalIdOption.IsRequired = true; + command.AddOption(servicePrincipalIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The tokenLifetimePolicies assigned to this service principal. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The tokenLifetimePolicies assigned to this service principal. Supports $expand."; + // Create options for all the parameters + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { + }; + servicePrincipalIdOption.IsRequired = true; + command.AddOption(servicePrincipalIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/servicePrincipals/{servicePrincipal_id}/tokenLifetimePolicies/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The tokenLifetimePolicies assigned to this service principal. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The tokenLifetimePolicies assigned to this service principal. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.ServicePrincipals.Item.TokenLifetimePolicies.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The tokenLifetimePolicies assigned to this service principal. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/ServicePrincipals/Item/TokenLifetimePolicies/Ref/RefResponse.cs b/src/generated/ServicePrincipals/Item/TokenLifetimePolicies/Ref/RefResponse.cs new file mode 100644 index 00000000000..9fa87625ce0 --- /dev/null +++ b/src/generated/ServicePrincipals/Item/TokenLifetimePolicies/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.ServicePrincipals.Item.TokenLifetimePolicies.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/ServicePrincipals/Item/TokenLifetimePolicies/TokenLifetimePoliciesRequestBuilder.cs b/src/generated/ServicePrincipals/Item/TokenLifetimePolicies/TokenLifetimePoliciesRequestBuilder.cs index cdd0eda88d9..cc73c9a3f88 100644 --- a/src/generated/ServicePrincipals/Item/TokenLifetimePolicies/TokenLifetimePoliciesRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/TokenLifetimePolicies/TokenLifetimePoliciesRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.ServicePrincipals.Item.TokenLifetimePolicies.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The tokenLifetimePolicies assigned to this service principal. Supports $expand."; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.ServicePrincipals.Item.TokenLifetimePolicies.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.ServicePrincipals.Item.TokenLifetimePolicies.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The tokenLifetimePolicies assigned to this service principal. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The tokenLifetimePolicies assigned to this service principal. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/ServicePrincipals/Item/TransitiveMemberOf/@Ref/@Ref.cs b/src/generated/ServicePrincipals/Item/TransitiveMemberOf/@Ref/@Ref.cs deleted file mode 100644 index c958bf9d3d4..00000000000 --- a/src/generated/ServicePrincipals/Item/TransitiveMemberOf/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.ServicePrincipals.Item.TransitiveMemberOf.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/ServicePrincipals/Item/TransitiveMemberOf/@Ref/RefRequestBuilder.cs b/src/generated/ServicePrincipals/Item/TransitiveMemberOf/@Ref/RefRequestBuilder.cs deleted file mode 100644 index bdaf602c73c..00000000000 --- a/src/generated/ServicePrincipals/Item/TransitiveMemberOf/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.ServicePrincipals.Item.TransitiveMemberOf.@Ref { - /// Builds and executes requests for operations under \servicePrincipals\{servicePrincipal-id}\transitiveMemberOf\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Get ref of transitiveMemberOf from servicePrincipals - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Get ref of transitiveMemberOf from servicePrincipals"; - // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { - }; - servicePrincipalIdOption.IsRequired = true; - command.AddOption(servicePrincipalIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Create new navigation property ref to transitiveMemberOf for servicePrincipals - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Create new navigation property ref to transitiveMemberOf for servicePrincipals"; - // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { - }; - servicePrincipalIdOption.IsRequired = true; - command.AddOption(servicePrincipalIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string servicePrincipalId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/servicePrincipals/{servicePrincipal_id}/transitiveMemberOf/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Get ref of transitiveMemberOf from servicePrincipals - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Create new navigation property ref to transitiveMemberOf for servicePrincipals - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.ServicePrincipals.Item.TransitiveMemberOf.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Get ref of transitiveMemberOf from servicePrincipals - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property ref to transitiveMemberOf for servicePrincipals - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.ServicePrincipals.Item.TransitiveMemberOf.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Get ref of transitiveMemberOf from servicePrincipals - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/ServicePrincipals/Item/TransitiveMemberOf/@Ref/RefResponse.cs b/src/generated/ServicePrincipals/Item/TransitiveMemberOf/@Ref/RefResponse.cs deleted file mode 100644 index e530598d953..00000000000 --- a/src/generated/ServicePrincipals/Item/TransitiveMemberOf/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.ServicePrincipals.Item.TransitiveMemberOf.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/ServicePrincipals/Item/TransitiveMemberOf/Ref/Ref.cs b/src/generated/ServicePrincipals/Item/TransitiveMemberOf/Ref/Ref.cs new file mode 100644 index 00000000000..296b17f4ce0 --- /dev/null +++ b/src/generated/ServicePrincipals/Item/TransitiveMemberOf/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.ServicePrincipals.Item.TransitiveMemberOf.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/ServicePrincipals/Item/TransitiveMemberOf/Ref/RefRequestBuilder.cs b/src/generated/ServicePrincipals/Item/TransitiveMemberOf/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..139eb4d0cff --- /dev/null +++ b/src/generated/ServicePrincipals/Item/TransitiveMemberOf/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.ServicePrincipals.Item.TransitiveMemberOf.Ref { + /// Builds and executes requests for operations under \servicePrincipals\{servicePrincipal-id}\transitiveMemberOf\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Get ref of transitiveMemberOf from servicePrincipals + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Get ref of transitiveMemberOf from servicePrincipals"; + // Create options for all the parameters + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { + }; + servicePrincipalIdOption.IsRequired = true; + command.AddOption(servicePrincipalIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Create new navigation property ref to transitiveMemberOf for servicePrincipals + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Create new navigation property ref to transitiveMemberOf for servicePrincipals"; + // Create options for all the parameters + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { + }; + servicePrincipalIdOption.IsRequired = true; + command.AddOption(servicePrincipalIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/servicePrincipals/{servicePrincipal_id}/transitiveMemberOf/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Get ref of transitiveMemberOf from servicePrincipals + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Create new navigation property ref to transitiveMemberOf for servicePrincipals + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.ServicePrincipals.Item.TransitiveMemberOf.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Get ref of transitiveMemberOf from servicePrincipals + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/ServicePrincipals/Item/TransitiveMemberOf/Ref/RefResponse.cs b/src/generated/ServicePrincipals/Item/TransitiveMemberOf/Ref/RefResponse.cs new file mode 100644 index 00000000000..b6a234a62ad --- /dev/null +++ b/src/generated/ServicePrincipals/Item/TransitiveMemberOf/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.ServicePrincipals.Item.TransitiveMemberOf.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/ServicePrincipals/Item/TransitiveMemberOf/TransitiveMemberOfRequestBuilder.cs b/src/generated/ServicePrincipals/Item/TransitiveMemberOf/TransitiveMemberOfRequestBuilder.cs index 0515c46300a..64313250ec1 100644 --- a/src/generated/ServicePrincipals/Item/TransitiveMemberOf/TransitiveMemberOfRequestBuilder.cs +++ b/src/generated/ServicePrincipals/Item/TransitiveMemberOf/TransitiveMemberOfRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.ServicePrincipals.Item.TransitiveMemberOf.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get transitiveMemberOf from servicePrincipals"; // Create options for all the parameters - var servicePrincipalIdOption = new Option("--serviceprincipal-id", description: "key: id of servicePrincipal") { + var servicePrincipalIdOption = new Option("--service-principal-id", description: "key: id of servicePrincipal") { }; servicePrincipalIdOption.IsRequired = true; command.AddOption(servicePrincipalIdOption); @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string servicePrincipalId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, servicePrincipalIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.ServicePrincipals.Item.TransitiveMemberOf.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.ServicePrincipals.Item.TransitiveMemberOf.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get transitiveMemberOf from servicePrincipals - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get transitiveMemberOf from servicePrincipals public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/ServicePrincipals/ServicePrincipalsRequestBuilder.cs b/src/generated/ServicePrincipals/ServicePrincipalsRequestBuilder.cs index aee2b2ea21c..93daf8e10f0 100644 --- a/src/generated/ServicePrincipals/ServicePrincipalsRequestBuilder.cs +++ b/src/generated/ServicePrincipals/ServicePrincipalsRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.ServicePrincipals.ValidateProperties; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,34 +26,33 @@ public class ServicePrincipalsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ServicePrincipalRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAddKeyCommand(), - builder.BuildAddPasswordCommand(), - builder.BuildAppRoleAssignedToCommand(), - builder.BuildAppRoleAssignmentsCommand(), - builder.BuildCheckMemberGroupsCommand(), - builder.BuildCheckMemberObjectsCommand(), - builder.BuildClaimsMappingPoliciesCommand(), - builder.BuildCreatedObjectsCommand(), - builder.BuildDelegatedPermissionClassificationsCommand(), - builder.BuildDeleteCommand(), - builder.BuildEndpointsCommand(), - builder.BuildGetCommand(), - builder.BuildGetMemberGroupsCommand(), - builder.BuildGetMemberObjectsCommand(), - builder.BuildHomeRealmDiscoveryPoliciesCommand(), - builder.BuildMemberOfCommand(), - builder.BuildOauth2PermissionGrantsCommand(), - builder.BuildOwnedObjectsCommand(), - builder.BuildOwnersCommand(), - builder.BuildPatchCommand(), - builder.BuildRemoveKeyCommand(), - builder.BuildRemovePasswordCommand(), - builder.BuildRestoreCommand(), - builder.BuildTokenIssuancePoliciesCommand(), - builder.BuildTokenLifetimePoliciesCommand(), - builder.BuildTransitiveMemberOfCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAddKeyCommand()); + commands.Add(builder.BuildAddPasswordCommand()); + commands.Add(builder.BuildAppRoleAssignedToCommand()); + commands.Add(builder.BuildAppRoleAssignmentsCommand()); + commands.Add(builder.BuildCheckMemberGroupsCommand()); + commands.Add(builder.BuildCheckMemberObjectsCommand()); + commands.Add(builder.BuildClaimsMappingPoliciesCommand()); + commands.Add(builder.BuildCreatedObjectsCommand()); + commands.Add(builder.BuildDelegatedPermissionClassificationsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildEndpointsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildGetMemberGroupsCommand()); + commands.Add(builder.BuildGetMemberObjectsCommand()); + commands.Add(builder.BuildHomeRealmDiscoveryPoliciesCommand()); + commands.Add(builder.BuildMemberOfCommand()); + commands.Add(builder.BuildOauth2PermissionGrantsCommand()); + commands.Add(builder.BuildOwnedObjectsCommand()); + commands.Add(builder.BuildOwnersCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRemoveKeyCommand()); + commands.Add(builder.BuildRemovePasswordCommand()); + commands.Add(builder.BuildRestoreCommand()); + commands.Add(builder.BuildTokenIssuancePoliciesCommand()); + commands.Add(builder.BuildTokenLifetimePoliciesCommand()); + commands.Add(builder.BuildTransitiveMemberOfCommand()); return commands; } /// @@ -67,21 +66,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } public Command BuildGetAvailableExtensionPropertiesCommand() { @@ -138,7 +136,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -149,15 +151,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildValidatePropertiesCommand() { @@ -224,31 +221,6 @@ public RequestInformation CreatePostRequestInformation(ServicePrincipal body, Ac public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// Get entities from servicePrincipals - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to servicePrincipals - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ServicePrincipal model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from servicePrincipals public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/ServicePrincipals/ValidateProperties/ValidatePropertiesRequestBuilder.cs b/src/generated/ServicePrincipals/ValidateProperties/ValidatePropertiesRequestBuilder.cs index 32e3d59d93f..c4312f2037d 100644 --- a/src/generated/ServicePrincipals/ValidateProperties/ValidatePropertiesRequestBuilder.cs +++ b/src/generated/ServicePrincipals/ValidateProperties/ValidatePropertiesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,14 +29,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -72,18 +71,5 @@ public RequestInformation CreatePostRequestInformation(ValidatePropertiesRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action validateProperties - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ValidatePropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Shares/Item/DriveItem/Content/ContentRequestBuilder.cs b/src/generated/Shares/Item/DriveItem/Content/ContentRequestBuilder.cs index 2a7c4b9ac41..f420f20ce1c 100644 --- a/src/generated/Shares/Item/DriveItem/Content/ContentRequestBuilder.cs +++ b/src/generated/Shares/Item/DriveItem/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,28 +25,30 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get media content for the navigation property driveItem from shares"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string sharedDriveItemId, FileInfo output) => { + command.SetHandler(async (string sharedDriveItemId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, sharedDriveItemIdOption, outputOption); + }, sharedDriveItemIdOption, fileOption, outputOption); return command; } /// @@ -56,7 +58,7 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "Update media content for the navigation property driveItem in shares"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -64,12 +66,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, FileInfo file) => { + command.SetHandler(async (string sharedDriveItemId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, bodyOption); return command; @@ -120,29 +121,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property driveItem from shares - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property driveItem in shares - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Shares/Item/DriveItem/DriveItemRequestBuilder.cs b/src/generated/Shares/Item/DriveItem/DriveItemRequestBuilder.cs index 56aff6681f1..1f34282e03c 100644 --- a/src/generated/Shares/Item/DriveItem/DriveItemRequestBuilder.cs +++ b/src/generated/Shares/Item/DriveItem/DriveItemRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Shares.Item.DriveItem.Content; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Used to access the underlying driveItem"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - command.SetHandler(async (string sharedDriveItemId) => { + command.SetHandler(async (string sharedDriveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Used to access the underlying driveItem"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,7 +89,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Used to access the underlying driveItem"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -99,14 +97,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string body) => { + command.SetHandler(async (string sharedDriveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, bodyOption); return command; @@ -178,42 +175,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Used to access the underlying driveItem - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used to access the underlying driveItem - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used to access the underlying driveItem - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Used to access the underlying driveItem public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Shares/Item/Items/Item/Content/ContentRequestBuilder.cs b/src/generated/Shares/Item/Items/Item/Content/ContentRequestBuilder.cs index aeb0ee41171..ceae9d68c16 100644 --- a/src/generated/Shares/Item/Items/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Shares/Item/Items/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,32 +25,34 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get media content for the navigation property items from shares"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string sharedDriveItemId, string driveItemId, FileInfo output) => { + command.SetHandler(async (string sharedDriveItemId, string driveItemId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, sharedDriveItemIdOption, driveItemIdOption, outputOption); + }, sharedDriveItemIdOption, driveItemIdOption, fileOption, outputOption); return command; } /// @@ -60,11 +62,11 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "Update media content for the navigation property items in shares"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -72,12 +74,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string driveItemId, FileInfo file) => { + command.SetHandler(async (string sharedDriveItemId, string driveItemId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, driveItemIdOption, bodyOption); return command; @@ -128,29 +129,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property items from shares - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property items in shares - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Shares/Item/Items/Item/DriveItemRequestBuilder.cs b/src/generated/Shares/Item/Items/Item/DriveItemRequestBuilder.cs index f183a3a3b4a..7a9ea93d240 100644 --- a/src/generated/Shares/Item/Items/Item/DriveItemRequestBuilder.cs +++ b/src/generated/Shares/Item/Items/Item/DriveItemRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Shares.Item.Items.Item.Content; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "All driveItems contained in the sharing root. This collection cannot be enumerated."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string sharedDriveItemId, string driveItemId) => { + command.SetHandler(async (string sharedDriveItemId, string driveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, driveItemIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "All driveItems contained in the sharing root. This collection cannot be enumerated."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string driveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string driveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, driveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, driveItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,11 +97,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "All driveItems contained in the sharing root. This collection cannot be enumerated."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -111,14 +109,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string driveItemId, string body) => { + command.SetHandler(async (string sharedDriveItemId, string driveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, driveItemIdOption, bodyOption); return command; @@ -190,42 +187,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All driveItems contained in the sharing root. This collection cannot be enumerated. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All driveItems contained in the sharing root. This collection cannot be enumerated. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All driveItems contained in the sharing root. This collection cannot be enumerated. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// All driveItems contained in the sharing root. This collection cannot be enumerated. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Shares/Item/Items/ItemsRequestBuilder.cs b/src/generated/Shares/Item/Items/ItemsRequestBuilder.cs index dacf77811f7..67cf02f92ff 100644 --- a/src/generated/Shares/Item/Items/ItemsRequestBuilder.cs +++ b/src/generated/Shares/Item/Items/ItemsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Shares.Item.Items.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class ItemsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DriveItemRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -37,7 +36,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "All driveItems contained in the sharing root. This collection cannot be enumerated."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, bodyOption, outputOption); return command; } /// @@ -69,7 +67,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "All driveItems contained in the sharing root. This collection cannot be enumerated."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All driveItems contained in the sharing root. This collection cannot be enumerated. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All driveItems contained in the sharing root. This collection cannot be enumerated. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// All driveItems contained in the sharing root. This collection cannot be enumerated. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Shares/Item/List/Columns/ColumnsRequestBuilder.cs b/src/generated/Shares/Item/List/Columns/ColumnsRequestBuilder.cs index eb3a75412ec..8bc7fc89295 100644 --- a/src/generated/Shares/Item/List/Columns/ColumnsRequestBuilder.cs +++ b/src/generated/Shares/Item/List/Columns/ColumnsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Shares.Item.List.Columns.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class ColumnsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ColumnDefinitionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSourceColumnCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSourceColumnCommand()); return commands; } /// @@ -37,7 +36,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of field definitions for this list."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, bodyOption, outputOption); return command; } /// @@ -69,7 +67,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of field definitions for this list."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(ColumnDefinition body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of field definitions for this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of field definitions for this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ColumnDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of field definitions for this list. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Shares/Item/List/Columns/Item/ColumnDefinitionRequestBuilder.cs b/src/generated/Shares/Item/List/Columns/Item/ColumnDefinitionRequestBuilder.cs index 76bef14e1ac..e404dba6e87 100644 --- a/src/generated/Shares/Item/List/Columns/Item/ColumnDefinitionRequestBuilder.cs +++ b/src/generated/Shares/Item/List/Columns/Item/ColumnDefinitionRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Shares.Item.List.Columns.Item.SourceColumn; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,19 +27,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of field definitions for this list."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string sharedDriveItemId, string columnDefinitionId) => { + command.SetHandler(async (string sharedDriveItemId, string columnDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, columnDefinitionIdOption); return command; @@ -51,11 +50,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of field definitions for this list."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string columnDefinitionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string columnDefinitionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, columnDefinitionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, columnDefinitionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -92,11 +90,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of field definitions for this list."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -104,14 +102,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string columnDefinitionId, string body) => { + command.SetHandler(async (string sharedDriveItemId, string columnDefinitionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, columnDefinitionIdOption, bodyOption); return command; @@ -190,42 +187,6 @@ public RequestInformation CreatePatchRequestInformation(ColumnDefinition body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of field definitions for this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of field definitions for this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of field definitions for this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ColumnDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of field definitions for this list. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Shares/Item/List/Columns/Item/SourceColumn/@Ref/@Ref.cs b/src/generated/Shares/Item/List/Columns/Item/SourceColumn/@Ref/@Ref.cs deleted file mode 100644 index 9ff7538a953..00000000000 --- a/src/generated/Shares/Item/List/Columns/Item/SourceColumn/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Shares.Item.List.Columns.Item.SourceColumn.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Shares/Item/List/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs b/src/generated/Shares/Item/List/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 8d1bed7774f..00000000000 --- a/src/generated/Shares/Item/List/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Shares.Item.List.Columns.Item.SourceColumn.@Ref { - /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\columns\{columnDefinition-id}\sourceColumn\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The source column for content type column. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { - }; - sharedDriveItemIdOption.IsRequired = true; - command.AddOption(sharedDriveItemIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string sharedDriveItemId, string columnDefinitionId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, sharedDriveItemIdOption, columnDefinitionIdOption); - return command; - } - /// - /// The source column for content type column. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { - }; - sharedDriveItemIdOption.IsRequired = true; - command.AddOption(sharedDriveItemIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string sharedDriveItemId, string columnDefinitionId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, columnDefinitionIdOption); - return command; - } - /// - /// The source column for content type column. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { - }; - sharedDriveItemIdOption.IsRequired = true; - command.AddOption(sharedDriveItemIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string columnDefinitionId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, sharedDriveItemIdOption, columnDefinitionIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/shares/{sharedDriveItem_id}/list/columns/{columnDefinition_id}/sourceColumn/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The source column for content type column. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Shares.Item.List.Columns.Item.SourceColumn.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Shares.Item.List.Columns.Item.SourceColumn.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Shares/Item/List/Columns/Item/SourceColumn/Ref/Ref.cs b/src/generated/Shares/Item/List/Columns/Item/SourceColumn/Ref/Ref.cs new file mode 100644 index 00000000000..f5326ad4258 --- /dev/null +++ b/src/generated/Shares/Item/List/Columns/Item/SourceColumn/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Shares.Item.List.Columns.Item.SourceColumn.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Shares/Item/List/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs b/src/generated/Shares/Item/List/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..e031879691c --- /dev/null +++ b/src/generated/Shares/Item/List/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Shares.Item.List.Columns.Item.SourceColumn.Ref { + /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\columns\{columnDefinition-id}\sourceColumn\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The source column for content type column. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { + }; + sharedDriveItemIdOption.IsRequired = true; + command.AddOption(sharedDriveItemIdOption); + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + command.SetHandler(async (string sharedDriveItemId, string columnDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, sharedDriveItemIdOption, columnDefinitionIdOption); + return command; + } + /// + /// The source column for content type column. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { + }; + sharedDriveItemIdOption.IsRequired = true; + command.AddOption(sharedDriveItemIdOption); + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string columnDefinitionId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, columnDefinitionIdOption, outputOption); + return command; + } + /// + /// The source column for content type column. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { + }; + sharedDriveItemIdOption.IsRequired = true; + command.AddOption(sharedDriveItemIdOption); + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string sharedDriveItemId, string columnDefinitionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, sharedDriveItemIdOption, columnDefinitionIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/shares/{sharedDriveItem_id}/list/columns/{columnDefinition_id}/sourceColumn/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The source column for content type column. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The source column for content type column. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The source column for content type column. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Shares.Item.List.Columns.Item.SourceColumn.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Shares/Item/List/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs b/src/generated/Shares/Item/List/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs index a01d0dc5310..9c5af699aba 100644 --- a/src/generated/Shares/Item/List/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs +++ b/src/generated/Shares/Item/List/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Shares.Item.List.Columns.Item.SourceColumn.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,11 +27,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The source column for content type column."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -45,25 +45,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string columnDefinitionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string columnDefinitionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, columnDefinitionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, columnDefinitionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Shares.Item.List.Columns.Item.SourceColumn.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Shares.Item.List.Columns.Item.SourceColumn.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -103,18 +102,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The source column for content type column. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Shares/Item/List/ContentTypes/AddCopy/AddCopyRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/AddCopy/AddCopyRequestBuilder.cs index 7007f19fd92..0e7f2356219 100644 --- a/src/generated/Shares/Item/List/ContentTypes/AddCopy/AddCopyRequestBuilder.cs +++ b/src/generated/Shares/Item/List/ContentTypes/AddCopy/AddCopyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action addCopy"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(AddCopyRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action addCopy - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddCopyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes contentType public class AddCopyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Shares/Item/List/ContentTypes/ContentTypesRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/ContentTypesRequestBuilder.cs index 673bc5ae2a2..e393e74e6cd 100644 --- a/src/generated/Shares/Item/List/ContentTypes/ContentTypesRequestBuilder.cs +++ b/src/generated/Shares/Item/List/ContentTypes/ContentTypesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Shares.Item.List.ContentTypes.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,20 +29,19 @@ public Command BuildAddCopyCommand() { } public List BuildCommand() { var builder = new ContentTypeRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAssociateWithHubSitesCommand(), - builder.BuildBaseCommand(), - builder.BuildBaseTypesCommand(), - builder.BuildColumnLinksCommand(), - builder.BuildColumnPositionsCommand(), - builder.BuildColumnsCommand(), - builder.BuildCopyToDefaultContentLocationCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildPublishCommand(), - builder.BuildUnpublishCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAssociateWithHubSitesCommand()); + commands.Add(builder.BuildBaseCommand()); + commands.Add(builder.BuildBaseTypesCommand()); + commands.Add(builder.BuildColumnLinksCommand()); + commands.Add(builder.BuildColumnPositionsCommand()); + commands.Add(builder.BuildColumnsCommand()); + commands.Add(builder.BuildCopyToDefaultContentLocationCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPublishCommand()); + commands.Add(builder.BuildUnpublishCommand()); return commands; } /// @@ -52,7 +51,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of content types present in this list."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -60,21 +59,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, bodyOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of content types present in this list."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(ContentType body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of content types present in this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of content types present in this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ContentType model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of content types present in this list. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/@Base/@Ref/@Ref.cs b/src/generated/Shares/Item/List/ContentTypes/Item/@Base/@Ref/@Ref.cs deleted file mode 100644 index cbb7070229d..00000000000 --- a/src/generated/Shares/Item/List/ContentTypes/Item/@Base/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Shares.Item.List.ContentTypes.Item.@Base.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/@Base/@Ref/RefRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/@Base/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 348a8bdaa83..00000000000 --- a/src/generated/Shares/Item/List/ContentTypes/Item/@Base/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Shares.Item.List.ContentTypes.Item.@Base.@Ref { - /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\contentTypes\{contentType-id}\base\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Parent contentType from which this content type is derived. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Parent contentType from which this content type is derived."; - // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { - }; - sharedDriveItemIdOption.IsRequired = true; - command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, sharedDriveItemIdOption, contentTypeIdOption); - return command; - } - /// - /// Parent contentType from which this content type is derived. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Parent contentType from which this content type is derived."; - // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { - }; - sharedDriveItemIdOption.IsRequired = true; - command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, contentTypeIdOption); - return command; - } - /// - /// Parent contentType from which this content type is derived. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Parent contentType from which this content type is derived."; - // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { - }; - sharedDriveItemIdOption.IsRequired = true; - command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, sharedDriveItemIdOption, contentTypeIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/shares/{sharedDriveItem_id}/list/contentTypes/{contentType_id}/base/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Parent contentType from which this content type is derived. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Parent contentType from which this content type is derived. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Parent contentType from which this content type is derived. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Shares.Item.List.ContentTypes.Item.@Base.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Parent contentType from which this content type is derived. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Parent contentType from which this content type is derived. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Parent contentType from which this content type is derived. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Shares.Item.List.ContentTypes.Item.@Base.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs b/src/generated/Shares/Item/List/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs deleted file mode 100644 index b4021218257..00000000000 --- a/src/generated/Shares/Item/List/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Shares.Item.List.ContentTypes.Item.@Base.AssociateWithHubSites { - public class AssociateWithHubSitesRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public List HubSiteUrls { get; set; } - public bool? PropagateToExistingLists { get; set; } - /// - /// Instantiates a new associateWithHubSitesRequestBody and sets the default values. - /// - public AssociateWithHubSitesRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"hubSiteUrls", (o,n) => { (o as AssociateWithHubSitesRequestBody).HubSiteUrls = n.GetCollectionOfPrimitiveValues().ToList(); } }, - {"propagateToExistingLists", (o,n) => { (o as AssociateWithHubSitesRequestBody).PropagateToExistingLists = n.GetBoolValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteCollectionOfPrimitiveValues("hubSiteUrls", HubSiteUrls); - writer.WriteBoolValue("propagateToExistingLists", PropagateToExistingLists); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs deleted file mode 100644 index ad638948db4..00000000000 --- a/src/generated/Shares/Item/List/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs +++ /dev/null @@ -1,97 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Shares.Item.List.ContentTypes.Item.@Base.AssociateWithHubSites { - /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\contentTypes\{contentType-id}\base\microsoft.graph.associateWithHubSites - public class AssociateWithHubSitesRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action associateWithHubSites - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action associateWithHubSites"; - // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { - }; - sharedDriveItemIdOption.IsRequired = true; - command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, sharedDriveItemIdOption, contentTypeIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AssociateWithHubSitesRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AssociateWithHubSitesRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/shares/{sharedDriveItem_id}/list/contentTypes/{contentType_id}/base/microsoft.graph.associateWithHubSites"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action associateWithHubSites - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AssociateWithHubSitesRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action associateWithHubSites - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssociateWithHubSitesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/@Base/BaseRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/@Base/BaseRequestBuilder.cs deleted file mode 100644 index afebe73b60f..00000000000 --- a/src/generated/Shares/Item/List/ContentTypes/Item/@Base/BaseRequestBuilder.cs +++ /dev/null @@ -1,161 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using ApiSdk.Shares.Item.List.ContentTypes.Item.Base.AssociateWithHubSites; -using ApiSdk.Shares.Item.List.ContentTypes.Item.Base.CopyToDefaultContentLocation; -using ApiSdk.Shares.Item.List.ContentTypes.Item.Base.IsPublished; -using ApiSdk.Shares.Item.List.ContentTypes.Item.Base.Publish; -using ApiSdk.Shares.Item.List.ContentTypes.Item.Base.Ref; -using ApiSdk.Shares.Item.List.ContentTypes.Item.Base.Unpublish; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Shares.Item.List.ContentTypes.Item.@Base { - /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\contentTypes\{contentType-id}\base - public class BaseRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - public Command BuildAssociateWithHubSitesCommand() { - var command = new Command("associate-with-hub-sites"); - var builder = new ApiSdk.Shares.Item.List.ContentTypes.Item.@Base.AssociateWithHubSites.AssociateWithHubSitesRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildPostCommand()); - return command; - } - public Command BuildCopyToDefaultContentLocationCommand() { - var command = new Command("copy-to-default-content-location"); - var builder = new ApiSdk.Shares.Item.List.ContentTypes.Item.@Base.CopyToDefaultContentLocation.CopyToDefaultContentLocationRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildPostCommand()); - return command; - } - /// - /// Parent contentType from which this content type is derived. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Parent contentType from which this content type is derived."; - // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { - }; - sharedDriveItemIdOption.IsRequired = true; - command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, contentTypeIdOption, selectOption, expandOption); - return command; - } - public Command BuildPublishCommand() { - var command = new Command("publish"); - var builder = new ApiSdk.Shares.Item.List.ContentTypes.Item.@Base.Publish.PublishRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildPostCommand()); - return command; - } - public Command BuildRefCommand() { - var command = new Command("ref"); - var builder = new ApiSdk.Shares.Item.List.ContentTypes.Item.@Base.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildDeleteCommand()); - command.AddCommand(builder.BuildGetCommand()); - command.AddCommand(builder.BuildPutCommand()); - return command; - } - public Command BuildUnpublishCommand() { - var command = new Command("unpublish"); - var builder = new ApiSdk.Shares.Item.List.ContentTypes.Item.@Base.Unpublish.UnpublishRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildPostCommand()); - return command; - } - /// - /// Instantiates a new BaseRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public BaseRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/shares/{sharedDriveItem_id}/list/contentTypes/{contentType_id}/base{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Parent contentType from which this content type is derived. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Parent contentType from which this content type is derived. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\contentTypes\{contentType-id}\base\microsoft.graph.isPublished() - /// - public IsPublishedRequestBuilder IsPublished() { - return new IsPublishedRequestBuilder(PathParameters, RequestAdapter); - } - /// Parent contentType from which this content type is derived. - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs b/src/generated/Shares/Item/List/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs deleted file mode 100644 index 2e4adbab0f4..00000000000 --- a/src/generated/Shares/Item/List/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs +++ /dev/null @@ -1,39 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Shares.Item.List.ContentTypes.Item.@Base.CopyToDefaultContentLocation { - public class CopyToDefaultContentLocationRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string DestinationFileName { get; set; } - public ItemReference SourceFile { get; set; } - /// - /// Instantiates a new copyToDefaultContentLocationRequestBody and sets the default values. - /// - public CopyToDefaultContentLocationRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"destinationFileName", (o,n) => { (o as CopyToDefaultContentLocationRequestBody).DestinationFileName = n.GetStringValue(); } }, - {"sourceFile", (o,n) => { (o as CopyToDefaultContentLocationRequestBody).SourceFile = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("destinationFileName", DestinationFileName); - writer.WriteObjectValue("sourceFile", SourceFile); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs deleted file mode 100644 index 810abd7a689..00000000000 --- a/src/generated/Shares/Item/List/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs +++ /dev/null @@ -1,97 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Shares.Item.List.ContentTypes.Item.@Base.CopyToDefaultContentLocation { - /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\contentTypes\{contentType-id}\base\microsoft.graph.copyToDefaultContentLocation - public class CopyToDefaultContentLocationRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action copyToDefaultContentLocation - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action copyToDefaultContentLocation"; - // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { - }; - sharedDriveItemIdOption.IsRequired = true; - command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, sharedDriveItemIdOption, contentTypeIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new CopyToDefaultContentLocationRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public CopyToDefaultContentLocationRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/shares/{sharedDriveItem_id}/list/contentTypes/{contentType_id}/base/microsoft.graph.copyToDefaultContentLocation"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action copyToDefaultContentLocation - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(CopyToDefaultContentLocationRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action copyToDefaultContentLocation - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToDefaultContentLocationRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/@Base/IsPublished/IsPublishedRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/@Base/IsPublished/IsPublishedRequestBuilder.cs deleted file mode 100644 index bf39d6a69ee..00000000000 --- a/src/generated/Shares/Item/List/ContentTypes/Item/@Base/IsPublished/IsPublishedRequestBuilder.cs +++ /dev/null @@ -1,90 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Shares.Item.List.ContentTypes.Item.@Base.IsPublished { - /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\contentTypes\{contentType-id}\base\microsoft.graph.isPublished() - public class IsPublishedRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke function isPublished - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Invoke function isPublished"; - // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { - }; - sharedDriveItemIdOption.IsRequired = true; - command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteBoolValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, contentTypeIdOption); - return command; - } - /// - /// Instantiates a new IsPublishedRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public IsPublishedRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/shares/{sharedDriveItem_id}/list/contentTypes/{contentType_id}/base/microsoft.graph.isPublished()"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke function isPublished - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke function isPublished - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/@Base/Publish/PublishRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/@Base/Publish/PublishRequestBuilder.cs deleted file mode 100644 index 044c74344a1..00000000000 --- a/src/generated/Shares/Item/List/ContentTypes/Item/@Base/Publish/PublishRequestBuilder.cs +++ /dev/null @@ -1,85 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Shares.Item.List.ContentTypes.Item.@Base.Publish { - /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\contentTypes\{contentType-id}\base\microsoft.graph.publish - public class PublishRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action publish - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action publish"; - // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { - }; - sharedDriveItemIdOption.IsRequired = true; - command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId) => { - var requestInfo = CreatePostRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, sharedDriveItemIdOption, contentTypeIdOption); - return command; - } - /// - /// Instantiates a new PublishRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public PublishRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/shares/{sharedDriveItem_id}/list/contentTypes/{contentType_id}/base/microsoft.graph.publish"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action publish - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action publish - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/@Base/Unpublish/UnpublishRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/@Base/Unpublish/UnpublishRequestBuilder.cs deleted file mode 100644 index 4c25df1198f..00000000000 --- a/src/generated/Shares/Item/List/ContentTypes/Item/@Base/Unpublish/UnpublishRequestBuilder.cs +++ /dev/null @@ -1,85 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Shares.Item.List.ContentTypes.Item.@Base.Unpublish { - /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\contentTypes\{contentType-id}\base\microsoft.graph.unpublish - public class UnpublishRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action unpublish - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action unpublish"; - // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { - }; - sharedDriveItemIdOption.IsRequired = true; - command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId) => { - var requestInfo = CreatePostRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, sharedDriveItemIdOption, contentTypeIdOption); - return command; - } - /// - /// Instantiates a new UnpublishRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public UnpublishRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/shares/{sharedDriveItem_id}/list/contentTypes/{contentType_id}/base/microsoft.graph.unpublish"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action unpublish - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action unpublish - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs index 84ffca268ec..d8ea5c4a753 100644 --- a/src/generated/Shares/Item/List/ContentTypes/Item/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs +++ b/src/generated/Shares/Item/List/ContentTypes/Item/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,11 +25,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action associateWithHubSites"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string body) => { + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, contentTypeIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AssociateWithHubSitesRequ requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action associateWithHubSites - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssociateWithHubSitesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs b/src/generated/Shares/Item/List/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs new file mode 100644 index 00000000000..1f7e48ba8e5 --- /dev/null +++ b/src/generated/Shares/Item/List/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Shares.Item.List.ContentTypes.Item.Base.AssociateWithHubSites { + public class AssociateWithHubSitesRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public List HubSiteUrls { get; set; } + public bool? PropagateToExistingLists { get; set; } + /// + /// Instantiates a new associateWithHubSitesRequestBody and sets the default values. + /// + public AssociateWithHubSitesRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"hubSiteUrls", (o,n) => { (o as AssociateWithHubSitesRequestBody).HubSiteUrls = n.GetCollectionOfPrimitiveValues().ToList(); } }, + {"propagateToExistingLists", (o,n) => { (o as AssociateWithHubSitesRequestBody).PropagateToExistingLists = n.GetBoolValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfPrimitiveValues("hubSiteUrls", HubSiteUrls); + writer.WriteBoolValue("propagateToExistingLists", PropagateToExistingLists); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs new file mode 100644 index 00000000000..53e2517dae6 --- /dev/null +++ b/src/generated/Shares/Item/List/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs @@ -0,0 +1,83 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Shares.Item.List.ContentTypes.Item.Base.AssociateWithHubSites { + /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\contentTypes\{contentType-id}\base\microsoft.graph.associateWithHubSites + public class AssociateWithHubSitesRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action associateWithHubSites + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action associateWithHubSites"; + // Create options for all the parameters + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { + }; + sharedDriveItemIdOption.IsRequired = true; + command.AddOption(sharedDriveItemIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, sharedDriveItemIdOption, contentTypeIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new AssociateWithHubSitesRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AssociateWithHubSitesRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/shares/{sharedDriveItem_id}/list/contentTypes/{contentType_id}/base/microsoft.graph.associateWithHubSites"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action associateWithHubSites + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AssociateWithHubSitesRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/Base/BaseRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/Base/BaseRequestBuilder.cs new file mode 100644 index 00000000000..75651fc8455 --- /dev/null +++ b/src/generated/Shares/Item/List/ContentTypes/Item/Base/BaseRequestBuilder.cs @@ -0,0 +1,148 @@ +using ApiSdk.Models.Microsoft.Graph; +using ApiSdk.Shares.Item.List.ContentTypes.Item.Base.AssociateWithHubSites; +using ApiSdk.Shares.Item.List.ContentTypes.Item.Base.CopyToDefaultContentLocation; +using ApiSdk.Shares.Item.List.ContentTypes.Item.Base.IsPublished; +using ApiSdk.Shares.Item.List.ContentTypes.Item.Base.Publish; +using ApiSdk.Shares.Item.List.ContentTypes.Item.Base.Ref; +using ApiSdk.Shares.Item.List.ContentTypes.Item.Base.Unpublish; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Shares.Item.List.ContentTypes.Item.Base { + /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\contentTypes\{contentType-id}\base + public class BaseRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + public Command BuildAssociateWithHubSitesCommand() { + var command = new Command("associate-with-hub-sites"); + var builder = new ApiSdk.Shares.Item.List.ContentTypes.Item.Base.AssociateWithHubSites.AssociateWithHubSitesRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildPostCommand()); + return command; + } + public Command BuildCopyToDefaultContentLocationCommand() { + var command = new Command("copy-to-default-content-location"); + var builder = new ApiSdk.Shares.Item.List.ContentTypes.Item.Base.CopyToDefaultContentLocation.CopyToDefaultContentLocationRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildPostCommand()); + return command; + } + /// + /// Parent contentType from which this content type is derived. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Parent contentType from which this content type is derived."; + // Create options for all the parameters + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { + }; + sharedDriveItemIdOption.IsRequired = true; + command.AddOption(sharedDriveItemIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var selectOption = new Option("--select", description: "Select properties to be returned") { + Arity = ArgumentArity.ZeroOrMore + }; + selectOption.IsRequired = false; + command.AddOption(selectOption); + var expandOption = new Option("--expand", description: "Expand related entities") { + Arity = ArgumentArity.ZeroOrMore + }; + expandOption.IsRequired = false; + command.AddOption(expandOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Select = select; + q.Expand = expand; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, contentTypeIdOption, selectOption, expandOption, outputOption); + return command; + } + public Command BuildPublishCommand() { + var command = new Command("publish"); + var builder = new ApiSdk.Shares.Item.List.ContentTypes.Item.Base.Publish.PublishRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildPostCommand()); + return command; + } + public Command BuildRefCommand() { + var command = new Command("ref"); + var builder = new ApiSdk.Shares.Item.List.ContentTypes.Item.Base.Ref.RefRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildDeleteCommand()); + command.AddCommand(builder.BuildGetCommand()); + command.AddCommand(builder.BuildPutCommand()); + return command; + } + public Command BuildUnpublishCommand() { + var command = new Command("unpublish"); + var builder = new ApiSdk.Shares.Item.List.ContentTypes.Item.Base.Unpublish.UnpublishRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildPostCommand()); + return command; + } + /// + /// Instantiates a new BaseRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public BaseRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/shares/{sharedDriveItem_id}/list/contentTypes/{contentType_id}/base{?select,expand}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Parent contentType from which this content type is derived. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\contentTypes\{contentType-id}\base\microsoft.graph.isPublished() + /// + public IsPublishedRequestBuilder IsPublished() { + return new IsPublishedRequestBuilder(PathParameters, RequestAdapter); + } + /// Parent contentType from which this content type is derived. + public class GetQueryParameters : QueryParametersBase { + /// Expand related entities + public string[] Expand { get; set; } + /// Select properties to be returned + public string[] Select { get; set; } + } + } +} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs b/src/generated/Shares/Item/List/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs new file mode 100644 index 00000000000..b1b8ae53ba9 --- /dev/null +++ b/src/generated/Shares/Item/List/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs @@ -0,0 +1,39 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Shares.Item.List.ContentTypes.Item.Base.CopyToDefaultContentLocation { + public class CopyToDefaultContentLocationRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string DestinationFileName { get; set; } + public ItemReference SourceFile { get; set; } + /// + /// Instantiates a new copyToDefaultContentLocationRequestBody and sets the default values. + /// + public CopyToDefaultContentLocationRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"destinationFileName", (o,n) => { (o as CopyToDefaultContentLocationRequestBody).DestinationFileName = n.GetStringValue(); } }, + {"sourceFile", (o,n) => { (o as CopyToDefaultContentLocationRequestBody).SourceFile = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("destinationFileName", DestinationFileName); + writer.WriteObjectValue("sourceFile", SourceFile); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs new file mode 100644 index 00000000000..104b73fb98f --- /dev/null +++ b/src/generated/Shares/Item/List/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs @@ -0,0 +1,83 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Shares.Item.List.ContentTypes.Item.Base.CopyToDefaultContentLocation { + /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\contentTypes\{contentType-id}\base\microsoft.graph.copyToDefaultContentLocation + public class CopyToDefaultContentLocationRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action copyToDefaultContentLocation + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action copyToDefaultContentLocation"; + // Create options for all the parameters + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { + }; + sharedDriveItemIdOption.IsRequired = true; + command.AddOption(sharedDriveItemIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, sharedDriveItemIdOption, contentTypeIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new CopyToDefaultContentLocationRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public CopyToDefaultContentLocationRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/shares/{sharedDriveItem_id}/list/contentTypes/{contentType_id}/base/microsoft.graph.copyToDefaultContentLocation"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action copyToDefaultContentLocation + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(CopyToDefaultContentLocationRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/Base/IsPublished/IsPublishedRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/Base/IsPublished/IsPublishedRequestBuilder.cs new file mode 100644 index 00000000000..6818f0ce8fe --- /dev/null +++ b/src/generated/Shares/Item/List/ContentTypes/Item/Base/IsPublished/IsPublishedRequestBuilder.cs @@ -0,0 +1,78 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Shares.Item.List.ContentTypes.Item.Base.IsPublished { + /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\contentTypes\{contentType-id}\base\microsoft.graph.isPublished() + public class IsPublishedRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke function isPublished + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Invoke function isPublished"; + // Create options for all the parameters + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { + }; + sharedDriveItemIdOption.IsRequired = true; + command.AddOption(sharedDriveItemIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, contentTypeIdOption, outputOption); + return command; + } + /// + /// Instantiates a new IsPublishedRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public IsPublishedRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/shares/{sharedDriveItem_id}/list/contentTypes/{contentType_id}/base/microsoft.graph.isPublished()"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke function isPublished + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/Base/Publish/PublishRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/Base/Publish/PublishRequestBuilder.cs new file mode 100644 index 00000000000..943fe0b37a5 --- /dev/null +++ b/src/generated/Shares/Item/List/ContentTypes/Item/Base/Publish/PublishRequestBuilder.cs @@ -0,0 +1,73 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Shares.Item.List.ContentTypes.Item.Base.Publish { + /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\contentTypes\{contentType-id}\base\microsoft.graph.publish + public class PublishRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action publish + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action publish"; + // Create options for all the parameters + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { + }; + sharedDriveItemIdOption.IsRequired = true; + command.AddOption(sharedDriveItemIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreatePostRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, sharedDriveItemIdOption, contentTypeIdOption); + return command; + } + /// + /// Instantiates a new PublishRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public PublishRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/shares/{sharedDriveItem_id}/list/contentTypes/{contentType_id}/base/microsoft.graph.publish"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action publish + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/Base/Ref/Ref.cs b/src/generated/Shares/Item/List/ContentTypes/Item/Base/Ref/Ref.cs new file mode 100644 index 00000000000..e0d9460b056 --- /dev/null +++ b/src/generated/Shares/Item/List/ContentTypes/Item/Base/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Shares.Item.List.ContentTypes.Item.Base.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/Base/Ref/RefRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/Base/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..f640178e97a --- /dev/null +++ b/src/generated/Shares/Item/List/ContentTypes/Item/Base/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Shares.Item.List.ContentTypes.Item.Base.Ref { + /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\contentTypes\{contentType-id}\base\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Parent contentType from which this content type is derived. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Parent contentType from which this content type is derived."; + // Create options for all the parameters + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { + }; + sharedDriveItemIdOption.IsRequired = true; + command.AddOption(sharedDriveItemIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, sharedDriveItemIdOption, contentTypeIdOption); + return command; + } + /// + /// Parent contentType from which this content type is derived. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Parent contentType from which this content type is derived."; + // Create options for all the parameters + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { + }; + sharedDriveItemIdOption.IsRequired = true; + command.AddOption(sharedDriveItemIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, contentTypeIdOption, outputOption); + return command; + } + /// + /// Parent contentType from which this content type is derived. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Parent contentType from which this content type is derived."; + // Create options for all the parameters + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { + }; + sharedDriveItemIdOption.IsRequired = true; + command.AddOption(sharedDriveItemIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, sharedDriveItemIdOption, contentTypeIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/shares/{sharedDriveItem_id}/list/contentTypes/{contentType_id}/base/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Parent contentType from which this content type is derived. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Parent contentType from which this content type is derived. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Parent contentType from which this content type is derived. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Shares.Item.List.ContentTypes.Item.Base.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/Base/Unpublish/UnpublishRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/Base/Unpublish/UnpublishRequestBuilder.cs new file mode 100644 index 00000000000..54fc06733d0 --- /dev/null +++ b/src/generated/Shares/Item/List/ContentTypes/Item/Base/Unpublish/UnpublishRequestBuilder.cs @@ -0,0 +1,73 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Shares.Item.List.ContentTypes.Item.Base.Unpublish { + /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\contentTypes\{contentType-id}\base\microsoft.graph.unpublish + public class UnpublishRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action unpublish + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action unpublish"; + // Create options for all the parameters + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { + }; + sharedDriveItemIdOption.IsRequired = true; + command.AddOption(sharedDriveItemIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreatePostRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, sharedDriveItemIdOption, contentTypeIdOption); + return command; + } + /// + /// Instantiates a new UnpublishRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public UnpublishRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/shares/{sharedDriveItem_id}/list/contentTypes/{contentType_id}/base/microsoft.graph.unpublish"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action unpublish + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/BaseTypes/@Ref/@Ref.cs b/src/generated/Shares/Item/List/ContentTypes/Item/BaseTypes/@Ref/@Ref.cs deleted file mode 100644 index 161ca235428..00000000000 --- a/src/generated/Shares/Item/List/ContentTypes/Item/BaseTypes/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Shares.Item.List.ContentTypes.Item.BaseTypes.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/BaseTypes/@Ref/RefRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/BaseTypes/@Ref/RefRequestBuilder.cs deleted file mode 100644 index aca7ca58a5d..00000000000 --- a/src/generated/Shares/Item/List/ContentTypes/Item/BaseTypes/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,210 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Shares.Item.List.ContentTypes.Item.BaseTypes.@Ref { - /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\contentTypes\{contentType-id}\baseTypes\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The collection of content types that are ancestors of this content type. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The collection of content types that are ancestors of this content type."; - // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { - }; - sharedDriveItemIdOption.IsRequired = true; - command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The collection of content types that are ancestors of this content type. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The collection of content types that are ancestors of this content type."; - // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { - }; - sharedDriveItemIdOption.IsRequired = true; - command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, contentTypeIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/shares/{sharedDriveItem_id}/list/contentTypes/{contentType_id}/baseTypes/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The collection of content types that are ancestors of this content type. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The collection of content types that are ancestors of this content type. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Shares.Item.List.ContentTypes.Item.BaseTypes.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The collection of content types that are ancestors of this content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of content types that are ancestors of this content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Shares.Item.List.ContentTypes.Item.BaseTypes.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The collection of content types that are ancestors of this content type. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/BaseTypes/@Ref/RefResponse.cs b/src/generated/Shares/Item/List/ContentTypes/Item/BaseTypes/@Ref/RefResponse.cs deleted file mode 100644 index f499adc1686..00000000000 --- a/src/generated/Shares/Item/List/ContentTypes/Item/BaseTypes/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Shares.Item.List.ContentTypes.Item.BaseTypes.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/BaseTypes/AddCopy/AddCopyRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/BaseTypes/AddCopy/AddCopyRequestBuilder.cs index 978a7558000..0437a5e15e4 100644 --- a/src/generated/Shares/Item/List/ContentTypes/Item/BaseTypes/AddCopy/AddCopyRequestBuilder.cs +++ b/src/generated/Shares/Item/List/ContentTypes/Item/BaseTypes/AddCopy/AddCopyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action addCopy"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, contentTypeIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, contentTypeIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(AddCopyRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action addCopy - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddCopyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes contentType public class AddCopyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/BaseTypes/BaseTypesRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/BaseTypes/BaseTypesRequestBuilder.cs index 244ea6c4f18..3700988b9d9 100644 --- a/src/generated/Shares/Item/List/ContentTypes/Item/BaseTypes/BaseTypesRequestBuilder.cs +++ b/src/generated/Shares/Item/List/ContentTypes/Item/BaseTypes/BaseTypesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Shares.Item.List.ContentTypes.Item.BaseTypes.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,11 +33,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of content types that are ancestors of this content type."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -76,7 +76,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -87,20 +91,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Shares.Item.List.ContentTypes.Item.BaseTypes.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Shares.Item.List.ContentTypes.Item.BaseTypes.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -139,18 +138,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of content types that are ancestors of this content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of content types that are ancestors of this content type. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/BaseTypes/Ref/Ref.cs b/src/generated/Shares/Item/List/ContentTypes/Item/BaseTypes/Ref/Ref.cs new file mode 100644 index 00000000000..0fd5ad1ba0a --- /dev/null +++ b/src/generated/Shares/Item/List/ContentTypes/Item/BaseTypes/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Shares.Item.List.ContentTypes.Item.BaseTypes.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/BaseTypes/Ref/RefRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/BaseTypes/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..0b52ec6dd62 --- /dev/null +++ b/src/generated/Shares/Item/List/ContentTypes/Item/BaseTypes/Ref/RefRequestBuilder.cs @@ -0,0 +1,183 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Shares.Item.List.ContentTypes.Item.BaseTypes.Ref { + /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\contentTypes\{contentType-id}\baseTypes\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The collection of content types that are ancestors of this content type. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The collection of content types that are ancestors of this content type."; + // Create options for all the parameters + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { + }; + sharedDriveItemIdOption.IsRequired = true; + command.AddOption(sharedDriveItemIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The collection of content types that are ancestors of this content type. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The collection of content types that are ancestors of this content type."; + // Create options for all the parameters + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { + }; + sharedDriveItemIdOption.IsRequired = true; + command.AddOption(sharedDriveItemIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, contentTypeIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/shares/{sharedDriveItem_id}/list/contentTypes/{contentType_id}/baseTypes/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The collection of content types that are ancestors of this content type. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The collection of content types that are ancestors of this content type. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Shares.Item.List.ContentTypes.Item.BaseTypes.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The collection of content types that are ancestors of this content type. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/BaseTypes/Ref/RefResponse.cs b/src/generated/Shares/Item/List/ContentTypes/Item/BaseTypes/Ref/RefResponse.cs new file mode 100644 index 00000000000..00f7c39eca7 --- /dev/null +++ b/src/generated/Shares/Item/List/ContentTypes/Item/BaseTypes/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Shares.Item.List.ContentTypes.Item.BaseTypes.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/ColumnLinks/ColumnLinksRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/ColumnLinks/ColumnLinksRequestBuilder.cs index 4857b6c0b01..ad39c586e6c 100644 --- a/src/generated/Shares/Item/List/ContentTypes/Item/ColumnLinks/ColumnLinksRequestBuilder.cs +++ b/src/generated/Shares/Item/List/ContentTypes/Item/ColumnLinks/ColumnLinksRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Shares.Item.List.ContentTypes.Item.ColumnLinks.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ColumnLinksRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ColumnLinkRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,11 +35,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of columns that are required by this content type"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, contentTypeIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, contentTypeIdOption, bodyOption, outputOption); return command; } /// @@ -72,11 +70,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of columns that are required by this content type"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(ColumnLink body, Action - /// The collection of columns that are required by this content type - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of columns that are required by this content type - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ColumnLink model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of columns that are required by this content type public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/ColumnLinks/Item/ColumnLinkRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/ColumnLinks/Item/ColumnLinkRequestBuilder.cs index 0c9584c6ccb..30ec5624786 100644 --- a/src/generated/Shares/Item/List/ContentTypes/Item/ColumnLinks/Item/ColumnLinkRequestBuilder.cs +++ b/src/generated/Shares/Item/List/ContentTypes/Item/ColumnLinks/Item/ColumnLinkRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of columns that are required by this content type"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnLinkIdOption = new Option("--columnlink-id", description: "key: id of columnLink") { + var columnLinkIdOption = new Option("--column-link-id", description: "key: id of columnLink") { }; columnLinkIdOption.IsRequired = true; command.AddOption(columnLinkIdOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string columnLinkId) => { + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string columnLinkId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, contentTypeIdOption, columnLinkIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of columns that are required by this content type"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnLinkIdOption = new Option("--columnlink-id", description: "key: id of columnLink") { + var columnLinkIdOption = new Option("--column-link-id", description: "key: id of columnLink") { }; columnLinkIdOption.IsRequired = true; command.AddOption(columnLinkIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string columnLinkId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string columnLinkId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, contentTypeIdOption, columnLinkIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, contentTypeIdOption, columnLinkIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of columns that are required by this content type"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnLinkIdOption = new Option("--columnlink-id", description: "key: id of columnLink") { + var columnLinkIdOption = new Option("--column-link-id", description: "key: id of columnLink") { }; columnLinkIdOption.IsRequired = true; command.AddOption(columnLinkIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string columnLinkId, string body) => { + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string columnLinkId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, contentTypeIdOption, columnLinkIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(ColumnLink body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of columns that are required by this content type - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of columns that are required by this content type - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of columns that are required by this content type - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ColumnLink model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of columns that are required by this content type public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/ColumnPositions/@Ref/@Ref.cs b/src/generated/Shares/Item/List/ContentTypes/Item/ColumnPositions/@Ref/@Ref.cs deleted file mode 100644 index 13d698c3d85..00000000000 --- a/src/generated/Shares/Item/List/ContentTypes/Item/ColumnPositions/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Shares.Item.List.ContentTypes.Item.ColumnPositions.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/ColumnPositions/@Ref/RefRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/ColumnPositions/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 1cbc1796560..00000000000 --- a/src/generated/Shares/Item/List/ContentTypes/Item/ColumnPositions/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,210 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Shares.Item.List.ContentTypes.Item.ColumnPositions.@Ref { - /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\contentTypes\{contentType-id}\columnPositions\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Column order information in a content type. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Column order information in a content type."; - // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { - }; - sharedDriveItemIdOption.IsRequired = true; - command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Column order information in a content type. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Column order information in a content type."; - // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { - }; - sharedDriveItemIdOption.IsRequired = true; - command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, contentTypeIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/shares/{sharedDriveItem_id}/list/contentTypes/{contentType_id}/columnPositions/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Column order information in a content type. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Column order information in a content type. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Shares.Item.List.ContentTypes.Item.ColumnPositions.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Column order information in a content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Column order information in a content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Shares.Item.List.ContentTypes.Item.ColumnPositions.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Column order information in a content type. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/ColumnPositions/@Ref/RefResponse.cs b/src/generated/Shares/Item/List/ContentTypes/Item/ColumnPositions/@Ref/RefResponse.cs deleted file mode 100644 index 941122f5a5d..00000000000 --- a/src/generated/Shares/Item/List/ContentTypes/Item/ColumnPositions/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Shares.Item.List.ContentTypes.Item.ColumnPositions.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/ColumnPositions/ColumnPositionsRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/ColumnPositions/ColumnPositionsRequestBuilder.cs index a1515dc9d45..7bb0e686b46 100644 --- a/src/generated/Shares/Item/List/ContentTypes/Item/ColumnPositions/ColumnPositionsRequestBuilder.cs +++ b/src/generated/Shares/Item/List/ContentTypes/Item/ColumnPositions/ColumnPositionsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Shares.Item.List.ContentTypes.Item.ColumnPositions.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Column order information in a content type."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -69,7 +69,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -80,20 +84,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Shares.Item.List.ContentTypes.Item.ColumnPositions.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Shares.Item.List.ContentTypes.Item.ColumnPositions.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -132,18 +131,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Column order information in a content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Column order information in a content type. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/ColumnPositions/Ref/Ref.cs b/src/generated/Shares/Item/List/ContentTypes/Item/ColumnPositions/Ref/Ref.cs new file mode 100644 index 00000000000..d1ffa70cc97 --- /dev/null +++ b/src/generated/Shares/Item/List/ContentTypes/Item/ColumnPositions/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Shares.Item.List.ContentTypes.Item.ColumnPositions.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/ColumnPositions/Ref/RefRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/ColumnPositions/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..97f393d5153 --- /dev/null +++ b/src/generated/Shares/Item/List/ContentTypes/Item/ColumnPositions/Ref/RefRequestBuilder.cs @@ -0,0 +1,183 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Shares.Item.List.ContentTypes.Item.ColumnPositions.Ref { + /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\contentTypes\{contentType-id}\columnPositions\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Column order information in a content type. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Column order information in a content type."; + // Create options for all the parameters + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { + }; + sharedDriveItemIdOption.IsRequired = true; + command.AddOption(sharedDriveItemIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Column order information in a content type. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Column order information in a content type."; + // Create options for all the parameters + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { + }; + sharedDriveItemIdOption.IsRequired = true; + command.AddOption(sharedDriveItemIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, contentTypeIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/shares/{sharedDriveItem_id}/list/contentTypes/{contentType_id}/columnPositions/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Column order information in a content type. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Column order information in a content type. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Shares.Item.List.ContentTypes.Item.ColumnPositions.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Column order information in a content type. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/ColumnPositions/Ref/RefResponse.cs b/src/generated/Shares/Item/List/ContentTypes/Item/ColumnPositions/Ref/RefResponse.cs new file mode 100644 index 00000000000..2c9e1a3cd01 --- /dev/null +++ b/src/generated/Shares/Item/List/ContentTypes/Item/ColumnPositions/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Shares.Item.List.ContentTypes.Item.ColumnPositions.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/Columns/ColumnsRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/Columns/ColumnsRequestBuilder.cs index bb29e6517d3..98bcf7e351b 100644 --- a/src/generated/Shares/Item/List/ContentTypes/Item/Columns/ColumnsRequestBuilder.cs +++ b/src/generated/Shares/Item/List/ContentTypes/Item/Columns/ColumnsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Shares.Item.List.ContentTypes.Item.Columns.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class ColumnsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ColumnDefinitionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSourceColumnCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSourceColumnCommand()); return commands; } /// @@ -37,11 +36,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The collection of column definitions for this contentType."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, contentTypeIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, contentTypeIdOption, bodyOption, outputOption); return command; } /// @@ -73,11 +71,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The collection of column definitions for this contentType."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -116,7 +114,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -127,15 +129,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -190,31 +187,6 @@ public RequestInformation CreatePostRequestInformation(ColumnDefinition body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of column definitions for this contentType. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of column definitions for this contentType. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ColumnDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of column definitions for this contentType. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs index ce615811d96..1ac7d45ca80 100644 --- a/src/generated/Shares/Item/List/ContentTypes/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs +++ b/src/generated/Shares/Item/List/ContentTypes/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Shares.Item.List.ContentTypes.Item.Columns.Item.SourceColumn; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of column definitions for this contentType."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string columnDefinitionId) => { + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string columnDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, contentTypeIdOption, columnDefinitionIdOption); return command; @@ -55,15 +54,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of column definitions for this contentType."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string columnDefinitionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string columnDefinitionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, contentTypeIdOption, columnDefinitionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, contentTypeIdOption, columnDefinitionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -100,15 +98,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of column definitions for this contentType."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -116,14 +114,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string columnDefinitionId, string body) => { + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string columnDefinitionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, contentTypeIdOption, columnDefinitionIdOption, bodyOption); return command; @@ -202,42 +199,6 @@ public RequestInformation CreatePatchRequestInformation(ColumnDefinition body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of column definitions for this contentType. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of column definitions for this contentType. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of column definitions for this contentType. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ColumnDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of column definitions for this contentType. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/@Ref.cs b/src/generated/Shares/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/@Ref.cs deleted file mode 100644 index 14ded8dc408..00000000000 --- a/src/generated/Shares/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Shares.Item.List.ContentTypes.Item.Columns.Item.SourceColumn.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 842272fe489..00000000000 --- a/src/generated/Shares/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,214 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Shares.Item.List.ContentTypes.Item.Columns.Item.SourceColumn.@Ref { - /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\contentTypes\{contentType-id}\columns\{columnDefinition-id}\sourceColumn\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The source column for content type column. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { - }; - sharedDriveItemIdOption.IsRequired = true; - command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string columnDefinitionId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, sharedDriveItemIdOption, contentTypeIdOption, columnDefinitionIdOption); - return command; - } - /// - /// The source column for content type column. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { - }; - sharedDriveItemIdOption.IsRequired = true; - command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string columnDefinitionId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, contentTypeIdOption, columnDefinitionIdOption); - return command; - } - /// - /// The source column for content type column. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { - }; - sharedDriveItemIdOption.IsRequired = true; - command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string columnDefinitionId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, sharedDriveItemIdOption, contentTypeIdOption, columnDefinitionIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/shares/{sharedDriveItem_id}/list/contentTypes/{contentType_id}/columns/{columnDefinition_id}/sourceColumn/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The source column for content type column. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Shares.Item.List.ContentTypes.Item.Columns.Item.SourceColumn.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Shares.Item.List.ContentTypes.Item.Columns.Item.SourceColumn.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/Ref/Ref.cs b/src/generated/Shares/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/Ref/Ref.cs new file mode 100644 index 00000000000..a2eefd999e2 --- /dev/null +++ b/src/generated/Shares/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Shares.Item.List.ContentTypes.Item.Columns.Item.SourceColumn.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..e6ce5f9b8cd --- /dev/null +++ b/src/generated/Shares/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs @@ -0,0 +1,176 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Shares.Item.List.ContentTypes.Item.Columns.Item.SourceColumn.Ref { + /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\contentTypes\{contentType-id}\columns\{columnDefinition-id}\sourceColumn\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The source column for content type column. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { + }; + sharedDriveItemIdOption.IsRequired = true; + command.AddOption(sharedDriveItemIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string columnDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, sharedDriveItemIdOption, contentTypeIdOption, columnDefinitionIdOption); + return command; + } + /// + /// The source column for content type column. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { + }; + sharedDriveItemIdOption.IsRequired = true; + command.AddOption(sharedDriveItemIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string columnDefinitionId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, contentTypeIdOption, columnDefinitionIdOption, outputOption); + return command; + } + /// + /// The source column for content type column. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { + }; + sharedDriveItemIdOption.IsRequired = true; + command.AddOption(sharedDriveItemIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string columnDefinitionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, sharedDriveItemIdOption, contentTypeIdOption, columnDefinitionIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/shares/{sharedDriveItem_id}/list/contentTypes/{contentType_id}/columns/{columnDefinition_id}/sourceColumn/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The source column for content type column. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The source column for content type column. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The source column for content type column. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Shares.Item.List.ContentTypes.Item.Columns.Item.SourceColumn.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs index 85b2b993055..2bc2068de05 100644 --- a/src/generated/Shares/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs +++ b/src/generated/Shares/Item/List/ContentTypes/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Shares.Item.List.ContentTypes.Item.Columns.Item.SourceColumn.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,15 +27,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The source column for content type column."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -49,25 +49,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string columnDefinitionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string columnDefinitionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, contentTypeIdOption, columnDefinitionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, contentTypeIdOption, columnDefinitionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Shares.Item.List.ContentTypes.Item.Columns.Item.SourceColumn.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Shares.Item.List.ContentTypes.Item.Columns.Item.SourceColumn.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -107,18 +106,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The source column for content type column. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/ContentTypeRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/ContentTypeRequestBuilder.cs index 6c92dfeb830..c49ff2026a2 100644 --- a/src/generated/Shares/Item/List/ContentTypes/Item/ContentTypeRequestBuilder.cs +++ b/src/generated/Shares/Item/List/ContentTypes/Item/ContentTypeRequestBuilder.cs @@ -11,10 +11,10 @@ using ApiSdk.Shares.Item.List.ContentTypes.Item.Unpublish; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,7 +37,7 @@ public Command BuildAssociateWithHubSitesCommand() { } public Command BuildBaseCommand() { var command = new Command("base"); - var builder = new ApiSdk.Shares.Item.List.ContentTypes.Item.@Base.BaseRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Shares.Item.List.ContentTypes.Item.Base.BaseRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAssociateWithHubSitesCommand()); command.AddCommand(builder.BuildCopyToDefaultContentLocationCommand()); command.AddCommand(builder.BuildGetCommand()); @@ -57,6 +57,9 @@ public Command BuildBaseTypesCommand() { public Command BuildColumnLinksCommand() { var command = new Command("column-links"); var builder = new ApiSdk.Shares.Item.List.ContentTypes.Item.ColumnLinks.ColumnLinksRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -71,6 +74,9 @@ public Command BuildColumnPositionsCommand() { public Command BuildColumnsCommand() { var command = new Command("columns"); var builder = new ApiSdk.Shares.Item.List.ContentTypes.Item.Columns.ColumnsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -88,19 +94,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The collection of content types present in this list."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId) => { + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, contentTypeIdOption); return command; @@ -112,11 +117,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The collection of content types present in this list."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -130,20 +135,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, contentTypeIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, contentTypeIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -153,11 +157,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The collection of content types present in this list."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -165,14 +169,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string body) => { + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, contentTypeIdOption, bodyOption); return command; @@ -257,47 +260,11 @@ public RequestInformation CreatePatchRequestInformation(ContentType body, Action return requestInfo; } /// - /// The collection of content types present in this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of content types present in this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\contentTypes\{contentType-id}\microsoft.graph.isPublished() /// public IsPublishedRequestBuilder IsPublished() { return new IsPublishedRequestBuilder(PathParameters, RequestAdapter); } - /// - /// The collection of content types present in this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ContentType model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of content types present in this list. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs index e58f7ec97cb..cb4407bdfbf 100644 --- a/src/generated/Shares/Item/List/ContentTypes/Item/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs +++ b/src/generated/Shares/Item/List/ContentTypes/Item/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,11 +25,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copyToDefaultContentLocation"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string body) => { + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, contentTypeIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CopyToDefaultContentLocat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToDefaultContentLocation - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToDefaultContentLocationRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/IsPublished/IsPublishedRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/IsPublished/IsPublishedRequestBuilder.cs index 3283c3a7e7a..06aa920f3fd 100644 --- a/src/generated/Shares/Item/List/ContentTypes/Item/IsPublished/IsPublishedRequestBuilder.cs +++ b/src/generated/Shares/Item/List/ContentTypes/Item/IsPublished/IsPublishedRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,26 +25,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function isPublished"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteBoolValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, contentTypeIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, contentTypeIdOption, outputOption); return command; } /// @@ -75,16 +74,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function isPublished - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/Publish/PublishRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/Publish/PublishRequestBuilder.cs index c0d832fe2a5..344ff9c3348 100644 --- a/src/generated/Shares/Item/List/ContentTypes/Item/Publish/PublishRequestBuilder.cs +++ b/src/generated/Shares/Item/List/ContentTypes/Item/Publish/PublishRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,18 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action publish"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId) => { + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, contentTypeIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action publish - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Shares/Item/List/ContentTypes/Item/Unpublish/UnpublishRequestBuilder.cs b/src/generated/Shares/Item/List/ContentTypes/Item/Unpublish/UnpublishRequestBuilder.cs index 91009fe26c4..3831be6a638 100644 --- a/src/generated/Shares/Item/List/ContentTypes/Item/Unpublish/UnpublishRequestBuilder.cs +++ b/src/generated/Shares/Item/List/ContentTypes/Item/Unpublish/UnpublishRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,18 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action unpublish"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - command.SetHandler(async (string sharedDriveItemId, string contentTypeId) => { + command.SetHandler(async (string sharedDriveItemId, string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, contentTypeIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action unpublish - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Shares/Item/List/Drive/DriveRequestBuilder.cs b/src/generated/Shares/Item/List/Drive/DriveRequestBuilder.cs index 08ac6cff754..7cdd3ecf625 100644 --- a/src/generated/Shares/Item/List/Drive/DriveRequestBuilder.cs +++ b/src/generated/Shares/Item/List/Drive/DriveRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Only present on document libraries. Allows access to the list as a [drive][] resource with [driveItems][driveItem]."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - command.SetHandler(async (string sharedDriveItemId) => { + command.SetHandler(async (string sharedDriveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Only present on document libraries. Allows access to the list as a [drive][] resource with [driveItems][driveItem]."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Only present on document libraries. Allows access to the list as a [drive][] resource with [driveItems][driveItem]."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string body) => { + command.SetHandler(async (string sharedDriveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Only present on document libraries. Allows access to the list as a [drive][] resource with [driveItems][driveItem]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Only present on document libraries. Allows access to the list as a [drive][] resource with [driveItems][driveItem]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Only present on document libraries. Allows access to the list as a [drive][] resource with [driveItems][driveItem]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Drive model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Only present on document libraries. Allows access to the list as a [drive][] resource with [driveItems][driveItem]. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Shares/Item/List/Items/Item/Analytics/@Ref/@Ref.cs b/src/generated/Shares/Item/List/Items/Item/Analytics/@Ref/@Ref.cs deleted file mode 100644 index 7e75451981e..00000000000 --- a/src/generated/Shares/Item/List/Items/Item/Analytics/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Shares.Item.List.Items.Item.Analytics.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Shares/Item/List/Items/Item/Analytics/@Ref/RefRequestBuilder.cs b/src/generated/Shares/Item/List/Items/Item/Analytics/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 3eda847a6a6..00000000000 --- a/src/generated/Shares/Item/List/Items/Item/Analytics/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Shares.Item.List.Items.Item.Analytics.@Ref { - /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\items\{listItem-id}\analytics\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Analytics about the view activities that took place on this item. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Analytics about the view activities that took place on this item."; - // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { - }; - sharedDriveItemIdOption.IsRequired = true; - command.AddOption(sharedDriveItemIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { - }; - listItemIdOption.IsRequired = true; - command.AddOption(listItemIdOption); - command.SetHandler(async (string sharedDriveItemId, string listItemId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, sharedDriveItemIdOption, listItemIdOption); - return command; - } - /// - /// Analytics about the view activities that took place on this item. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Analytics about the view activities that took place on this item."; - // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { - }; - sharedDriveItemIdOption.IsRequired = true; - command.AddOption(sharedDriveItemIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { - }; - listItemIdOption.IsRequired = true; - command.AddOption(listItemIdOption); - command.SetHandler(async (string sharedDriveItemId, string listItemId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, listItemIdOption); - return command; - } - /// - /// Analytics about the view activities that took place on this item. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Analytics about the view activities that took place on this item."; - // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { - }; - sharedDriveItemIdOption.IsRequired = true; - command.AddOption(sharedDriveItemIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { - }; - listItemIdOption.IsRequired = true; - command.AddOption(listItemIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string listItemId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, sharedDriveItemIdOption, listItemIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/shares/{sharedDriveItem_id}/list/items/{listItem_id}/analytics/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Analytics about the view activities that took place on this item. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Analytics about the view activities that took place on this item. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Analytics about the view activities that took place on this item. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Shares.Item.List.Items.Item.Analytics.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Shares.Item.List.Items.Item.Analytics.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Shares/Item/List/Items/Item/Analytics/AnalyticsRequestBuilder.cs b/src/generated/Shares/Item/List/Items/Item/Analytics/AnalyticsRequestBuilder.cs index f003ba26336..08f9ff8b35f 100644 --- a/src/generated/Shares/Item/List/Items/Item/Analytics/AnalyticsRequestBuilder.cs +++ b/src/generated/Shares/Item/List/Items/Item/Analytics/AnalyticsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Shares.Item.List.Items.Item.Analytics.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,11 +27,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Analytics about the view activities that took place on this item."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -45,25 +45,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string listItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string listItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, listItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, listItemIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Shares.Item.List.Items.Item.Analytics.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Shares.Item.List.Items.Item.Analytics.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -103,18 +102,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Analytics about the view activities that took place on this item. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Shares/Item/List/Items/Item/Analytics/Ref/Ref.cs b/src/generated/Shares/Item/List/Items/Item/Analytics/Ref/Ref.cs new file mode 100644 index 00000000000..2a7fea69f07 --- /dev/null +++ b/src/generated/Shares/Item/List/Items/Item/Analytics/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Shares.Item.List.Items.Item.Analytics.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Shares/Item/List/Items/Item/Analytics/Ref/RefRequestBuilder.cs b/src/generated/Shares/Item/List/Items/Item/Analytics/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..775af9cf8c9 --- /dev/null +++ b/src/generated/Shares/Item/List/Items/Item/Analytics/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Shares.Item.List.Items.Item.Analytics.Ref { + /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\items\{listItem-id}\analytics\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Analytics about the view activities that took place on this item. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Analytics about the view activities that took place on this item."; + // Create options for all the parameters + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { + }; + sharedDriveItemIdOption.IsRequired = true; + command.AddOption(sharedDriveItemIdOption); + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { + }; + listItemIdOption.IsRequired = true; + command.AddOption(listItemIdOption); + command.SetHandler(async (string sharedDriveItemId, string listItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, sharedDriveItemIdOption, listItemIdOption); + return command; + } + /// + /// Analytics about the view activities that took place on this item. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Analytics about the view activities that took place on this item."; + // Create options for all the parameters + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { + }; + sharedDriveItemIdOption.IsRequired = true; + command.AddOption(sharedDriveItemIdOption); + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { + }; + listItemIdOption.IsRequired = true; + command.AddOption(listItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string listItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, listItemIdOption, outputOption); + return command; + } + /// + /// Analytics about the view activities that took place on this item. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Analytics about the view activities that took place on this item."; + // Create options for all the parameters + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { + }; + sharedDriveItemIdOption.IsRequired = true; + command.AddOption(sharedDriveItemIdOption); + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { + }; + listItemIdOption.IsRequired = true; + command.AddOption(listItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string sharedDriveItemId, string listItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, sharedDriveItemIdOption, listItemIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/shares/{sharedDriveItem_id}/list/items/{listItem_id}/analytics/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Analytics about the view activities that took place on this item. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Analytics about the view activities that took place on this item. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Analytics about the view activities that took place on this item. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Shares.Item.List.Items.Item.Analytics.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Shares/Item/List/Items/Item/DriveItem/Content/ContentRequestBuilder.cs b/src/generated/Shares/Item/List/Items/Item/DriveItem/Content/ContentRequestBuilder.cs index 7c2f17e4d71..a55ba4ac207 100644 --- a/src/generated/Shares/Item/List/Items/Item/DriveItem/Content/ContentRequestBuilder.cs +++ b/src/generated/Shares/Item/List/Items/Item/DriveItem/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,32 +25,34 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get media content for the navigation property driveItem from shares"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string sharedDriveItemId, string listItemId, FileInfo output) => { + command.SetHandler(async (string sharedDriveItemId, string listItemId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, sharedDriveItemIdOption, listItemIdOption, outputOption); + }, sharedDriveItemIdOption, listItemIdOption, fileOption, outputOption); return command; } /// @@ -60,11 +62,11 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "Update media content for the navigation property driveItem in shares"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -72,12 +74,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string listItemId, FileInfo file) => { + command.SetHandler(async (string sharedDriveItemId, string listItemId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, listItemIdOption, bodyOption); return command; @@ -128,29 +129,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property driveItem from shares - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property driveItem in shares - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Shares/Item/List/Items/Item/DriveItem/DriveItemRequestBuilder.cs b/src/generated/Shares/Item/List/Items/Item/DriveItem/DriveItemRequestBuilder.cs index 26fad4ca9b3..3d936a3244f 100644 --- a/src/generated/Shares/Item/List/Items/Item/DriveItem/DriveItemRequestBuilder.cs +++ b/src/generated/Shares/Item/List/Items/Item/DriveItem/DriveItemRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Shares.Item.List.Items.Item.DriveItem.Content; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "For document libraries, the driveItem relationship exposes the listItem as a [driveItem][]"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - command.SetHandler(async (string sharedDriveItemId, string listItemId) => { + command.SetHandler(async (string sharedDriveItemId, string listItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, listItemIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "For document libraries, the driveItem relationship exposes the listItem as a [driveItem][]"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string listItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string listItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, listItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, listItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,11 +97,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "For document libraries, the driveItem relationship exposes the listItem as a [driveItem][]"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -111,14 +109,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string listItemId, string body) => { + command.SetHandler(async (string sharedDriveItemId, string listItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, listItemIdOption, bodyOption); return command; @@ -190,42 +187,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// For document libraries, the driveItem relationship exposes the listItem as a [driveItem][] - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// For document libraries, the driveItem relationship exposes the listItem as a [driveItem][] - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// For document libraries, the driveItem relationship exposes the listItem as a [driveItem][] - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// For document libraries, the driveItem relationship exposes the listItem as a [driveItem][] public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Shares/Item/List/Items/Item/Fields/FieldsRequestBuilder.cs b/src/generated/Shares/Item/List/Items/Item/Fields/FieldsRequestBuilder.cs index 8fc0851a5e8..14f5d432026 100644 --- a/src/generated/Shares/Item/List/Items/Item/Fields/FieldsRequestBuilder.cs +++ b/src/generated/Shares/Item/List/Items/Item/Fields/FieldsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The values of the columns set on this list item."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - command.SetHandler(async (string sharedDriveItemId, string listItemId) => { + command.SetHandler(async (string sharedDriveItemId, string listItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, listItemIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The values of the columns set on this list item."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string listItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string listItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, listItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, listItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The values of the columns set on this list item."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string listItemId, string body) => { + command.SetHandler(async (string sharedDriveItemId, string listItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, listItemIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(FieldValueSet body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The values of the columns set on this list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The values of the columns set on this list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The values of the columns set on this list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(FieldValueSet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The values of the columns set on this list item. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Shares/Item/List/Items/Item/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs b/src/generated/Shares/Item/List/Items/Item/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs index c62d5dad976..59534c354f1 100644 --- a/src/generated/Shares/Item/List/Items/Item/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs +++ b/src/generated/Shares/Item/List/Items/Item/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,26 +25,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function getActivitiesByInterval"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - command.SetHandler(async (string sharedDriveItemId, string listItemId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string listItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, listItemIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, listItemIdOption, outputOption); return command; } /// @@ -75,16 +74,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getActivitiesByInterval - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Shares/Item/List/Items/Item/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs b/src/generated/Shares/Item/List/Items/Item/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs index 00ee5306f19..c0ec9521934 100644 --- a/src/generated/Shares/Item/List/Items/Item/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs +++ b/src/generated/Shares/Item/List/Items/Item/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function getActivitiesByInterval"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var startDateTimeOption = new Option("--startdatetime", description: "Usage: startDateTime={startDateTime}") { + var startDateTimeOption = new Option("--start-date-time", description: "Usage: startDateTime={startDateTime}") { }; startDateTimeOption.IsRequired = true; command.AddOption(startDateTimeOption); - var endDateTimeOption = new Option("--enddatetime", description: "Usage: endDateTime={endDateTime}") { + var endDateTimeOption = new Option("--end-date-time", description: "Usage: endDateTime={endDateTime}") { }; endDateTimeOption.IsRequired = true; command.AddOption(endDateTimeOption); @@ -45,18 +45,17 @@ public Command BuildGetCommand() { }; intervalOption.IsRequired = true; command.AddOption(intervalOption); - command.SetHandler(async (string sharedDriveItemId, string listItemId, string startDateTime, string endDateTime, string interval) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string listItemId, string startDateTime, string endDateTime, string interval, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, listItemIdOption, startDateTimeOption, endDateTimeOption, intervalOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, listItemIdOption, startDateTimeOption, endDateTimeOption, intervalOption, outputOption); return command; } /// @@ -93,16 +92,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getActivitiesByInterval - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Shares/Item/List/Items/Item/ListItemRequestBuilder.cs b/src/generated/Shares/Item/List/Items/Item/ListItemRequestBuilder.cs index d7f9758e342..16455ed94c6 100644 --- a/src/generated/Shares/Item/List/Items/Item/ListItemRequestBuilder.cs +++ b/src/generated/Shares/Item/List/Items/Item/ListItemRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Shares.Item.List.Items.Item.Versions; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,19 +39,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "All items contained in the list."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - command.SetHandler(async (string sharedDriveItemId, string listItemId) => { + command.SetHandler(async (string sharedDriveItemId, string listItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, listItemIdOption); return command; @@ -80,11 +79,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "All items contained in the list."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string listItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string listItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, listItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, listItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -121,11 +119,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "All items contained in the list."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -133,14 +131,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string listItemId, string body) => { + command.SetHandler(async (string sharedDriveItemId, string listItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, listItemIdOption, bodyOption); return command; @@ -148,6 +145,9 @@ public Command BuildPatchCommand() { public Command BuildVersionsCommand() { var command = new Command("versions"); var builder = new ApiSdk.Shares.Item.List.Items.Item.Versions.VersionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -220,17 +220,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. return requestInfo; } /// - /// All items contained in the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\list\items\{listItem-id}\microsoft.graph.getActivitiesByInterval() /// public GetActivitiesByIntervalRequestBuilder GetActivitiesByInterval() { @@ -248,31 +237,6 @@ public GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalReques if(string.IsNullOrEmpty(startDateTime)) throw new ArgumentNullException(nameof(startDateTime)); return new GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder(PathParameters, RequestAdapter, startDateTime, endDateTime, interval); } - /// - /// All items contained in the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All items contained in the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.ListItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// All items contained in the list. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Shares/Item/List/Items/Item/Versions/Item/Fields/FieldsRequestBuilder.cs b/src/generated/Shares/Item/List/Items/Item/Versions/Item/Fields/FieldsRequestBuilder.cs index da86549dcbe..67649085220 100644 --- a/src/generated/Shares/Item/List/Items/Item/Versions/Item/Fields/FieldsRequestBuilder.cs +++ b/src/generated/Shares/Item/List/Items/Item/Versions/Item/Fields/FieldsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "A collection of the fields and values for this version of the list item."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); - command.SetHandler(async (string sharedDriveItemId, string listItemId, string listItemVersionId) => { + command.SetHandler(async (string sharedDriveItemId, string listItemId, string listItemVersionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, listItemIdOption, listItemVersionIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "A collection of the fields and values for this version of the list item."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string listItemId, string listItemVersionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string listItemId, string listItemVersionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, listItemIdOption, listItemVersionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, listItemIdOption, listItemVersionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "A collection of the fields and values for this version of the list item."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string listItemId, string listItemVersionId, string body) => { + command.SetHandler(async (string sharedDriveItemId, string listItemId, string listItemVersionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, listItemIdOption, listItemVersionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(FieldValueSet body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of the fields and values for this version of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of the fields and values for this version of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of the fields and values for this version of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(FieldValueSet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of the fields and values for this version of the list item. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Shares/Item/List/Items/Item/Versions/Item/ListItemVersionRequestBuilder.cs b/src/generated/Shares/Item/List/Items/Item/Versions/Item/ListItemVersionRequestBuilder.cs index 4e24f87a851..7cadbe2df9c 100644 --- a/src/generated/Shares/Item/List/Items/Item/Versions/Item/ListItemVersionRequestBuilder.cs +++ b/src/generated/Shares/Item/List/Items/Item/Versions/Item/ListItemVersionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Shares.Item.List.Items.Item.Versions.Item.RestoreVersion; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,23 +28,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of previous versions of the list item."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); - command.SetHandler(async (string sharedDriveItemId, string listItemId, string listItemVersionId) => { + command.SetHandler(async (string sharedDriveItemId, string listItemId, string listItemVersionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, listItemIdOption, listItemVersionIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of previous versions of the list item."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string listItemId, string listItemVersionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string listItemId, string listItemVersionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, listItemIdOption, listItemVersionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, listItemIdOption, listItemVersionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of previous versions of the list item."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string listItemId, string listItemVersionId, string body) => { + command.SetHandler(async (string sharedDriveItemId, string listItemId, string listItemVersionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, listItemIdOption, listItemVersionIdOption, bodyOption); return command; @@ -210,42 +207,6 @@ public RequestInformation CreatePatchRequestInformation(ListItemVersion body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ListItemVersion model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of previous versions of the list item. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Shares/Item/List/Items/Item/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs b/src/generated/Shares/Item/List/Items/Item/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs index e832de3cc15..15c59cd5c4a 100644 --- a/src/generated/Shares/Item/List/Items/Item/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs +++ b/src/generated/Shares/Item/List/Items/Item/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action restoreVersion"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); - command.SetHandler(async (string sharedDriveItemId, string listItemId, string listItemVersionId) => { + command.SetHandler(async (string sharedDriveItemId, string listItemId, string listItemVersionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, listItemIdOption, listItemVersionIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action restoreVersion - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Shares/Item/List/Items/Item/Versions/VersionsRequestBuilder.cs b/src/generated/Shares/Item/List/Items/Item/Versions/VersionsRequestBuilder.cs index 129a3754c36..b098c4bee21 100644 --- a/src/generated/Shares/Item/List/Items/Item/Versions/VersionsRequestBuilder.cs +++ b/src/generated/Shares/Item/List/Items/Item/Versions/VersionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Shares.Item.List.Items.Item.Versions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class VersionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ListItemVersionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildFieldsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildRestoreVersionCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFieldsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRestoreVersionCommand()); return commands; } /// @@ -38,11 +37,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The list of previous versions of the list item."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string listItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string listItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, listItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, listItemIdOption, bodyOption, outputOption); return command; } /// @@ -74,11 +72,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The list of previous versions of the list item."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -117,7 +115,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string listItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string listItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, listItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, listItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(ListItemVersion body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ListItemVersion model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of previous versions of the list item. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Shares/Item/List/Items/ItemsRequestBuilder.cs b/src/generated/Shares/Item/List/Items/ItemsRequestBuilder.cs index e7e6a692191..49dfa445d9c 100644 --- a/src/generated/Shares/Item/List/Items/ItemsRequestBuilder.cs +++ b/src/generated/Shares/Item/List/Items/ItemsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Shares.Item.List.Items.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class ItemsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ListItemRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAnalyticsCommand(), - builder.BuildDeleteCommand(), - builder.BuildDriveItemCommand(), - builder.BuildFieldsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildVersionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAnalyticsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDriveItemCommand()); + commands.Add(builder.BuildFieldsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildVersionsCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "All items contained in the list."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, bodyOption, outputOption); return command; } /// @@ -72,7 +70,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "All items contained in the list."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -122,15 +124,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -185,31 +182,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All items contained in the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All items contained in the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.ListItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// All items contained in the list. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Shares/Item/List/ListRequestBuilder.cs b/src/generated/Shares/Item/List/ListRequestBuilder.cs index 4bb39764f13..7587371c8aa 100644 --- a/src/generated/Shares/Item/List/ListRequestBuilder.cs +++ b/src/generated/Shares/Item/List/ListRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Shares.Item.List.Subscriptions; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,6 +27,9 @@ public class ListRequestBuilder { public Command BuildColumnsCommand() { var command = new Command("columns"); var builder = new ApiSdk.Shares.Item.List.Columns.ColumnsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -35,6 +38,9 @@ public Command BuildContentTypesCommand() { var command = new Command("content-types"); var builder = new ApiSdk.Shares.Item.List.ContentTypes.ContentTypesRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCopyCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -46,15 +52,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Used to access the underlying list"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - command.SetHandler(async (string sharedDriveItemId) => { + command.SetHandler(async (string sharedDriveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption); return command; @@ -74,7 +79,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Used to access the underlying list"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -88,25 +93,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildItemsCommand() { var command = new Command("items"); var builder = new ApiSdk.Shares.Item.List.Items.ItemsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -118,7 +125,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Used to access the underlying list"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -126,14 +133,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string body) => { + command.SetHandler(async (string sharedDriveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, bodyOption); return command; @@ -141,6 +147,9 @@ public Command BuildPatchCommand() { public Command BuildSubscriptionsCommand() { var command = new Command("subscriptions"); var builder = new ApiSdk.Shares.Item.List.Subscriptions.SubscriptionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -212,42 +221,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Used to access the underlying list - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used to access the underlying list - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used to access the underlying list - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.List model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Used to access the underlying list public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Shares/Item/List/Subscriptions/Item/SubscriptionRequestBuilder.cs b/src/generated/Shares/Item/List/Subscriptions/Item/SubscriptionRequestBuilder.cs index 7d9e43b3031..e7b54e727e1 100644 --- a/src/generated/Shares/Item/List/Subscriptions/Item/SubscriptionRequestBuilder.cs +++ b/src/generated/Shares/Item/List/Subscriptions/Item/SubscriptionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The set of subscriptions on the list."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; subscriptionIdOption.IsRequired = true; command.AddOption(subscriptionIdOption); - command.SetHandler(async (string sharedDriveItemId, string subscriptionId) => { + command.SetHandler(async (string sharedDriveItemId, string subscriptionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, subscriptionIdOption); return command; @@ -50,7 +49,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The set of subscriptions on the list."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string subscriptionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string subscriptionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, subscriptionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, subscriptionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,7 +89,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The set of subscriptions on the list."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string subscriptionId, string body) => { + command.SetHandler(async (string sharedDriveItemId, string subscriptionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, subscriptionIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(Subscription body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The set of subscriptions on the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The set of subscriptions on the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The set of subscriptions on the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Subscription model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The set of subscriptions on the list. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Shares/Item/List/Subscriptions/SubscriptionsRequestBuilder.cs b/src/generated/Shares/Item/List/Subscriptions/SubscriptionsRequestBuilder.cs index 80ffe33ac93..c954f590fad 100644 --- a/src/generated/Shares/Item/List/Subscriptions/SubscriptionsRequestBuilder.cs +++ b/src/generated/Shares/Item/List/Subscriptions/SubscriptionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Shares.Item.List.Subscriptions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SubscriptionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SubscriptionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The set of subscriptions on the list."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The set of subscriptions on the list."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(Subscription body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The set of subscriptions on the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The set of subscriptions on the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Subscription model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The set of subscriptions on the list. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Shares/Item/ListItem/Analytics/@Ref/@Ref.cs b/src/generated/Shares/Item/ListItem/Analytics/@Ref/@Ref.cs deleted file mode 100644 index 90e0cdb7dcb..00000000000 --- a/src/generated/Shares/Item/ListItem/Analytics/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Shares.Item.ListItem.Analytics.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Shares/Item/ListItem/Analytics/@Ref/RefRequestBuilder.cs b/src/generated/Shares/Item/ListItem/Analytics/@Ref/RefRequestBuilder.cs deleted file mode 100644 index cc84b3c5aba..00000000000 --- a/src/generated/Shares/Item/ListItem/Analytics/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Shares.Item.ListItem.Analytics.@Ref { - /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\listItem\analytics\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Analytics about the view activities that took place on this item. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Analytics about the view activities that took place on this item."; - // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { - }; - sharedDriveItemIdOption.IsRequired = true; - command.AddOption(sharedDriveItemIdOption); - command.SetHandler(async (string sharedDriveItemId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, sharedDriveItemIdOption); - return command; - } - /// - /// Analytics about the view activities that took place on this item. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Analytics about the view activities that took place on this item."; - // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { - }; - sharedDriveItemIdOption.IsRequired = true; - command.AddOption(sharedDriveItemIdOption); - command.SetHandler(async (string sharedDriveItemId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption); - return command; - } - /// - /// Analytics about the view activities that took place on this item. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Analytics about the view activities that took place on this item."; - // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { - }; - sharedDriveItemIdOption.IsRequired = true; - command.AddOption(sharedDriveItemIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, sharedDriveItemIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/shares/{sharedDriveItem_id}/listItem/analytics/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Analytics about the view activities that took place on this item. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Analytics about the view activities that took place on this item. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Analytics about the view activities that took place on this item. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Shares.Item.ListItem.Analytics.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Shares.Item.ListItem.Analytics.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Shares/Item/ListItem/Analytics/AnalyticsRequestBuilder.cs b/src/generated/Shares/Item/ListItem/Analytics/AnalyticsRequestBuilder.cs index 62bc0bbe25d..be7e426463c 100644 --- a/src/generated/Shares/Item/ListItem/Analytics/AnalyticsRequestBuilder.cs +++ b/src/generated/Shares/Item/ListItem/Analytics/AnalyticsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Shares.Item.ListItem.Analytics.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Analytics about the view activities that took place on this item."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Shares.Item.ListItem.Analytics.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Shares.Item.ListItem.Analytics.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Analytics about the view activities that took place on this item. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Shares/Item/ListItem/Analytics/Ref/Ref.cs b/src/generated/Shares/Item/ListItem/Analytics/Ref/Ref.cs new file mode 100644 index 00000000000..1bd07a6d7c1 --- /dev/null +++ b/src/generated/Shares/Item/ListItem/Analytics/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Shares.Item.ListItem.Analytics.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Shares/Item/ListItem/Analytics/Ref/RefRequestBuilder.cs b/src/generated/Shares/Item/ListItem/Analytics/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..d30446936b6 --- /dev/null +++ b/src/generated/Shares/Item/ListItem/Analytics/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Shares.Item.ListItem.Analytics.Ref { + /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\listItem\analytics\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Analytics about the view activities that took place on this item. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Analytics about the view activities that took place on this item."; + // Create options for all the parameters + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { + }; + sharedDriveItemIdOption.IsRequired = true; + command.AddOption(sharedDriveItemIdOption); + command.SetHandler(async (string sharedDriveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, sharedDriveItemIdOption); + return command; + } + /// + /// Analytics about the view activities that took place on this item. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Analytics about the view activities that took place on this item."; + // Create options for all the parameters + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { + }; + sharedDriveItemIdOption.IsRequired = true; + command.AddOption(sharedDriveItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, outputOption); + return command; + } + /// + /// Analytics about the view activities that took place on this item. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Analytics about the view activities that took place on this item."; + // Create options for all the parameters + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { + }; + sharedDriveItemIdOption.IsRequired = true; + command.AddOption(sharedDriveItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string sharedDriveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, sharedDriveItemIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/shares/{sharedDriveItem_id}/listItem/analytics/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Analytics about the view activities that took place on this item. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Analytics about the view activities that took place on this item. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Analytics about the view activities that took place on this item. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Shares.Item.ListItem.Analytics.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Shares/Item/ListItem/DriveItem/Content/ContentRequestBuilder.cs b/src/generated/Shares/Item/ListItem/DriveItem/Content/ContentRequestBuilder.cs index 368b98c646c..bf7fb078def 100644 --- a/src/generated/Shares/Item/ListItem/DriveItem/Content/ContentRequestBuilder.cs +++ b/src/generated/Shares/Item/ListItem/DriveItem/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,28 +25,30 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get media content for the navigation property driveItem from shares"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string sharedDriveItemId, FileInfo output) => { + command.SetHandler(async (string sharedDriveItemId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, sharedDriveItemIdOption, outputOption); + }, sharedDriveItemIdOption, fileOption, outputOption); return command; } /// @@ -56,7 +58,7 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "Update media content for the navigation property driveItem in shares"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -64,12 +66,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, FileInfo file) => { + command.SetHandler(async (string sharedDriveItemId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, bodyOption); return command; @@ -120,29 +121,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property driveItem from shares - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property driveItem in shares - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Shares/Item/ListItem/DriveItem/DriveItemRequestBuilder.cs b/src/generated/Shares/Item/ListItem/DriveItem/DriveItemRequestBuilder.cs index 23ec461a05d..b48b5d44f98 100644 --- a/src/generated/Shares/Item/ListItem/DriveItem/DriveItemRequestBuilder.cs +++ b/src/generated/Shares/Item/ListItem/DriveItem/DriveItemRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Shares.Item.ListItem.DriveItem.Content; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "For document libraries, the driveItem relationship exposes the listItem as a [driveItem][]"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - command.SetHandler(async (string sharedDriveItemId) => { + command.SetHandler(async (string sharedDriveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "For document libraries, the driveItem relationship exposes the listItem as a [driveItem][]"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,7 +89,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "For document libraries, the driveItem relationship exposes the listItem as a [driveItem][]"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -99,14 +97,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string body) => { + command.SetHandler(async (string sharedDriveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, bodyOption); return command; @@ -178,42 +175,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// For document libraries, the driveItem relationship exposes the listItem as a [driveItem][] - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// For document libraries, the driveItem relationship exposes the listItem as a [driveItem][] - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// For document libraries, the driveItem relationship exposes the listItem as a [driveItem][] - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// For document libraries, the driveItem relationship exposes the listItem as a [driveItem][] public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Shares/Item/ListItem/Fields/FieldsRequestBuilder.cs b/src/generated/Shares/Item/ListItem/Fields/FieldsRequestBuilder.cs index 0497a3de009..dbdd967073a 100644 --- a/src/generated/Shares/Item/ListItem/Fields/FieldsRequestBuilder.cs +++ b/src/generated/Shares/Item/ListItem/Fields/FieldsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The values of the columns set on this list item."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - command.SetHandler(async (string sharedDriveItemId) => { + command.SetHandler(async (string sharedDriveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The values of the columns set on this list item."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The values of the columns set on this list item."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string body) => { + command.SetHandler(async (string sharedDriveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(FieldValueSet body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The values of the columns set on this list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The values of the columns set on this list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The values of the columns set on this list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(FieldValueSet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The values of the columns set on this list item. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Shares/Item/ListItem/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs b/src/generated/Shares/Item/ListItem/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs index d787bc95743..384ba696bfe 100644 --- a/src/generated/Shares/Item/ListItem/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs +++ b/src/generated/Shares/Item/ListItem/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,22 +25,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function getActivitiesByInterval"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - command.SetHandler(async (string sharedDriveItemId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getActivitiesByInterval - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Shares/Item/ListItem/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs b/src/generated/Shares/Item/ListItem/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs index 8d81f2114d7..3350c0a8ab6 100644 --- a/src/generated/Shares/Item/ListItem/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs +++ b/src/generated/Shares/Item/ListItem/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function getActivitiesByInterval"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var startDateTimeOption = new Option("--startdatetime", description: "Usage: startDateTime={startDateTime}") { + var startDateTimeOption = new Option("--start-date-time", description: "Usage: startDateTime={startDateTime}") { }; startDateTimeOption.IsRequired = true; command.AddOption(startDateTimeOption); - var endDateTimeOption = new Option("--enddatetime", description: "Usage: endDateTime={endDateTime}") { + var endDateTimeOption = new Option("--end-date-time", description: "Usage: endDateTime={endDateTime}") { }; endDateTimeOption.IsRequired = true; command.AddOption(endDateTimeOption); @@ -41,18 +41,17 @@ public Command BuildGetCommand() { }; intervalOption.IsRequired = true; command.AddOption(intervalOption); - command.SetHandler(async (string sharedDriveItemId, string startDateTime, string endDateTime, string interval) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string startDateTime, string endDateTime, string interval, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, startDateTimeOption, endDateTimeOption, intervalOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, startDateTimeOption, endDateTimeOption, intervalOption, outputOption); return command; } /// @@ -89,16 +88,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getActivitiesByInterval - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Shares/Item/ListItem/ListItemRequestBuilder.cs b/src/generated/Shares/Item/ListItem/ListItemRequestBuilder.cs index cd51faf44cb..d31d8734eeb 100644 --- a/src/generated/Shares/Item/ListItem/ListItemRequestBuilder.cs +++ b/src/generated/Shares/Item/ListItem/ListItemRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Shares.Item.ListItem.Versions; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,15 +39,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Used to access the underlying listItem"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - command.SetHandler(async (string sharedDriveItemId) => { + command.SetHandler(async (string sharedDriveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption); return command; @@ -76,7 +75,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Used to access the underlying listItem"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -113,7 +111,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Used to access the underlying listItem"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -121,14 +119,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string body) => { + command.SetHandler(async (string sharedDriveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, bodyOption); return command; @@ -136,6 +133,9 @@ public Command BuildPatchCommand() { public Command BuildVersionsCommand() { var command = new Command("versions"); var builder = new ApiSdk.Shares.Item.ListItem.Versions.VersionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -208,17 +208,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. return requestInfo; } /// - /// Used to access the underlying listItem - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \shares\{sharedDriveItem-id}\listItem\microsoft.graph.getActivitiesByInterval() /// public GetActivitiesByIntervalRequestBuilder GetActivitiesByInterval() { @@ -236,31 +225,6 @@ public GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalReques if(string.IsNullOrEmpty(startDateTime)) throw new ArgumentNullException(nameof(startDateTime)); return new GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder(PathParameters, RequestAdapter, startDateTime, endDateTime, interval); } - /// - /// Used to access the underlying listItem - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used to access the underlying listItem - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.ListItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Used to access the underlying listItem public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Shares/Item/ListItem/Versions/Item/Fields/FieldsRequestBuilder.cs b/src/generated/Shares/Item/ListItem/Versions/Item/Fields/FieldsRequestBuilder.cs index 11a3989b92a..091342f2d7b 100644 --- a/src/generated/Shares/Item/ListItem/Versions/Item/Fields/FieldsRequestBuilder.cs +++ b/src/generated/Shares/Item/ListItem/Versions/Item/Fields/FieldsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "A collection of the fields and values for this version of the list item."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); - command.SetHandler(async (string sharedDriveItemId, string listItemVersionId) => { + command.SetHandler(async (string sharedDriveItemId, string listItemVersionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, listItemVersionIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "A collection of the fields and values for this version of the list item."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string listItemVersionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string listItemVersionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, listItemVersionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, listItemVersionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "A collection of the fields and values for this version of the list item."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string listItemVersionId, string body) => { + command.SetHandler(async (string sharedDriveItemId, string listItemVersionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, listItemVersionIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(FieldValueSet body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of the fields and values for this version of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of the fields and values for this version of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of the fields and values for this version of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(FieldValueSet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of the fields and values for this version of the list item. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Shares/Item/ListItem/Versions/Item/ListItemVersionRequestBuilder.cs b/src/generated/Shares/Item/ListItem/Versions/Item/ListItemVersionRequestBuilder.cs index 2a8da31cd38..fe5134972b2 100644 --- a/src/generated/Shares/Item/ListItem/Versions/Item/ListItemVersionRequestBuilder.cs +++ b/src/generated/Shares/Item/ListItem/Versions/Item/ListItemVersionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Shares.Item.ListItem.Versions.Item.RestoreVersion; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,19 +28,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of previous versions of the list item."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); - command.SetHandler(async (string sharedDriveItemId, string listItemVersionId) => { + command.SetHandler(async (string sharedDriveItemId, string listItemVersionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, listItemVersionIdOption); return command; @@ -60,11 +59,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of previous versions of the list item."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); @@ -78,20 +77,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string listItemVersionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string listItemVersionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, listItemVersionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, listItemVersionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -101,11 +99,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of previous versions of the list item."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); @@ -113,14 +111,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string listItemVersionId, string body) => { + command.SetHandler(async (string sharedDriveItemId, string listItemVersionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, listItemVersionIdOption, bodyOption); return command; @@ -198,42 +195,6 @@ public RequestInformation CreatePatchRequestInformation(ListItemVersion body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ListItemVersion model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of previous versions of the list item. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Shares/Item/ListItem/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs b/src/generated/Shares/Item/ListItem/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs index c3402f0f797..7d442de6533 100644 --- a/src/generated/Shares/Item/ListItem/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs +++ b/src/generated/Shares/Item/ListItem/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,18 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action restoreVersion"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); - command.SetHandler(async (string sharedDriveItemId, string listItemVersionId) => { + command.SetHandler(async (string sharedDriveItemId, string listItemVersionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, listItemVersionIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action restoreVersion - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Shares/Item/ListItem/Versions/VersionsRequestBuilder.cs b/src/generated/Shares/Item/ListItem/Versions/VersionsRequestBuilder.cs index 769a98ebd63..2b6a9ff3550 100644 --- a/src/generated/Shares/Item/ListItem/Versions/VersionsRequestBuilder.cs +++ b/src/generated/Shares/Item/ListItem/Versions/VersionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Shares.Item.ListItem.Versions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class VersionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ListItemVersionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildFieldsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildRestoreVersionCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFieldsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRestoreVersionCommand()); return commands; } /// @@ -38,7 +37,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The list of previous versions of the list item."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -46,21 +45,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, bodyOption, outputOption); return command; } /// @@ -70,7 +68,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The list of previous versions of the list item."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -109,7 +107,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -120,15 +122,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -183,31 +180,6 @@ public RequestInformation CreatePostRequestInformation(ListItemVersion body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ListItemVersion model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of previous versions of the list item. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Shares/Item/Permission/Grant/GrantRequestBuilder.cs b/src/generated/Shares/Item/Permission/Grant/GrantRequestBuilder.cs index 0d069993ae5..8bcdf846537 100644 --- a/src/generated/Shares/Item/Permission/Grant/GrantRequestBuilder.cs +++ b/src/generated/Shares/Item/Permission/Grant/GrantRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action grant"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GrantRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action grant - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GrantRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Shares/Item/Permission/PermissionRequestBuilder.cs b/src/generated/Shares/Item/Permission/PermissionRequestBuilder.cs index 62e11a42165..391d1e42aed 100644 --- a/src/generated/Shares/Item/Permission/PermissionRequestBuilder.cs +++ b/src/generated/Shares/Item/Permission/PermissionRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Shares.Item.Permission.Grant; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,15 +27,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Used to access the permission representing the underlying sharing link"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - command.SetHandler(async (string sharedDriveItemId) => { + command.SetHandler(async (string sharedDriveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption); return command; @@ -47,7 +46,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Used to access the permission representing the underlying sharing link"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -61,20 +60,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildGrantCommand() { @@ -90,7 +88,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Used to access the permission representing the underlying sharing link"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -98,14 +96,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string body) => { + command.SetHandler(async (string sharedDriveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, bodyOption); return command; @@ -177,42 +174,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Used to access the permission representing the underlying sharing link - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used to access the permission representing the underlying sharing link - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used to access the permission representing the underlying sharing link - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Permission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Used to access the permission representing the underlying sharing link public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Shares/Item/Root/Content/ContentRequestBuilder.cs b/src/generated/Shares/Item/Root/Content/ContentRequestBuilder.cs index eecc53a35dd..46986d78ce6 100644 --- a/src/generated/Shares/Item/Root/Content/ContentRequestBuilder.cs +++ b/src/generated/Shares/Item/Root/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,28 +25,30 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get media content for the navigation property root from shares"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string sharedDriveItemId, FileInfo output) => { + command.SetHandler(async (string sharedDriveItemId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, sharedDriveItemIdOption, outputOption); + }, sharedDriveItemIdOption, fileOption, outputOption); return command; } /// @@ -56,7 +58,7 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "Update media content for the navigation property root in shares"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -64,12 +66,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, FileInfo file) => { + command.SetHandler(async (string sharedDriveItemId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, bodyOption); return command; @@ -120,29 +121,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property root from shares - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property root in shares - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Shares/Item/Root/RootRequestBuilder.cs b/src/generated/Shares/Item/Root/RootRequestBuilder.cs index 150af260593..1e611fe56a7 100644 --- a/src/generated/Shares/Item/Root/RootRequestBuilder.cs +++ b/src/generated/Shares/Item/Root/RootRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Shares.Item.Root.Content; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Used to access the underlying driveItem. Deprecated -- use driveItem instead."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - command.SetHandler(async (string sharedDriveItemId) => { + command.SetHandler(async (string sharedDriveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Used to access the underlying driveItem. Deprecated -- use driveItem instead."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,7 +89,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Used to access the underlying driveItem. Deprecated -- use driveItem instead."; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -99,14 +97,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string body) => { + command.SetHandler(async (string sharedDriveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, bodyOption); return command; @@ -178,42 +175,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Used to access the underlying driveItem. Deprecated -- use driveItem instead. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used to access the underlying driveItem. Deprecated -- use driveItem instead. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used to access the underlying driveItem. Deprecated -- use driveItem instead. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Used to access the underlying driveItem. Deprecated -- use driveItem instead. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Shares/Item/SharedDriveItemRequestBuilder.cs b/src/generated/Shares/Item/SharedDriveItemRequestBuilder.cs index 4dfcf2b9694..b4d2f68cf53 100644 --- a/src/generated/Shares/Item/SharedDriveItemRequestBuilder.cs +++ b/src/generated/Shares/Item/SharedDriveItemRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Shares.Item.Site; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,15 +33,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete entity from shares"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - command.SetHandler(async (string sharedDriveItemId) => { + command.SetHandler(async (string sharedDriveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get entity from shares by key"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -76,25 +75,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildItemsCommand() { var command = new Command("items"); var builder = new ApiSdk.Shares.Item.Items.ItemsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -131,7 +132,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update entity in shares"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -139,14 +140,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string body) => { + command.SetHandler(async (string sharedDriveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, bodyOption); return command; @@ -244,42 +244,6 @@ public RequestInformation CreatePatchRequestInformation(SharedDriveItem body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from shares - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from shares by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in shares - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SharedDriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from shares by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Shares/Item/Site/SiteRequestBuilder.cs b/src/generated/Shares/Item/Site/SiteRequestBuilder.cs index f25dc602a69..ef73785a195 100644 --- a/src/generated/Shares/Item/Site/SiteRequestBuilder.cs +++ b/src/generated/Shares/Item/Site/SiteRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Used to access the underlying site"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); - command.SetHandler(async (string sharedDriveItemId) => { + command.SetHandler(async (string sharedDriveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Used to access the underlying site"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string sharedDriveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string sharedDriveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, sharedDriveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, sharedDriveItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Used to access the underlying site"; // Create options for all the parameters - var sharedDriveItemIdOption = new Option("--shareddriveitem-id", description: "key: id of sharedDriveItem") { + var sharedDriveItemIdOption = new Option("--shared-drive-item-id", description: "key: id of sharedDriveItem") { }; sharedDriveItemIdOption.IsRequired = true; command.AddOption(sharedDriveItemIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string sharedDriveItemId, string body) => { + command.SetHandler(async (string sharedDriveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, sharedDriveItemIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Used to access the underlying site - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used to access the underlying site - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used to access the underlying site - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Site model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Used to access the underlying site public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Shares/SharesRequestBuilder.cs b/src/generated/Shares/SharesRequestBuilder.cs index 46466ea72db..36c9d32be14 100644 --- a/src/generated/Shares/SharesRequestBuilder.cs +++ b/src/generated/Shares/SharesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Shares.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,18 +22,17 @@ public class SharesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SharedDriveItemRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildDriveItemCommand(), - builder.BuildGetCommand(), - builder.BuildItemsCommand(), - builder.BuildListCommand(), - builder.BuildListItemCommand(), - builder.BuildPatchCommand(), - builder.BuildPermissionCommand(), - builder.BuildRootCommand(), - builder.BuildSiteCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDriveItemCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildItemsCommand()); + commands.Add(builder.BuildListCommand()); + commands.Add(builder.BuildListItemCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPermissionCommand()); + commands.Add(builder.BuildRootCommand()); + commands.Add(builder.BuildSiteCommand()); return commands; } /// @@ -47,21 +46,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -106,7 +104,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -117,15 +119,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -180,31 +177,6 @@ public RequestInformation CreatePostRequestInformation(SharedDriveItem body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get entities from shares - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to shares - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SharedDriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from shares public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/@Add/@Add.cs b/src/generated/Sites/@Add/@Add.cs deleted file mode 100644 index 56cdd45f48f..00000000000 --- a/src/generated/Sites/@Add/@Add.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.@Add { - public class @Add : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Add and sets the default values. - /// - public @Add() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/@Add/AddRequestBody.cs b/src/generated/Sites/@Add/AddRequestBody.cs deleted file mode 100644 index 2b9c40c5de2..00000000000 --- a/src/generated/Sites/@Add/AddRequestBody.cs +++ /dev/null @@ -1,36 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.@Add { - public class AddRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new addRequestBody and sets the default values. - /// - public AddRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"value", (o,n) => { (o as AddRequestBody).Value = n.GetCollectionOfObjectValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteCollectionOfObjectValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/@Add/AddRequestBuilder.cs b/src/generated/Sites/@Add/AddRequestBuilder.cs deleted file mode 100644 index 941b748b0d9..00000000000 --- a/src/generated/Sites/@Add/AddRequestBuilder.cs +++ /dev/null @@ -1,94 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.@Add { - /// Builds and executes requests for operations under \sites\microsoft.graph.add - public class AddRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action add - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action add"; - // Create options for all the parameters - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); - return command; - } - /// - /// Instantiates a new AddRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/microsoft.graph.add"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action add - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action add - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(AddRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/@Remove/@Remove.cs b/src/generated/Sites/@Remove/@Remove.cs deleted file mode 100644 index ad16040dc2c..00000000000 --- a/src/generated/Sites/@Remove/@Remove.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.@Remove { - public class @Remove : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Remove and sets the default values. - /// - public @Remove() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/@Remove/RemoveRequestBuilder.cs b/src/generated/Sites/@Remove/RemoveRequestBuilder.cs deleted file mode 100644 index acae7b98bcf..00000000000 --- a/src/generated/Sites/@Remove/RemoveRequestBuilder.cs +++ /dev/null @@ -1,94 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.@Remove { - /// Builds and executes requests for operations under \sites\microsoft.graph.remove - public class RemoveRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action remove - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action remove"; - // Create options for all the parameters - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); - return command; - } - /// - /// Instantiates a new RemoveRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RemoveRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/microsoft.graph.remove"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action remove - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(RemoveRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action remove - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(RemoveRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Add/Add.cs b/src/generated/Sites/Add/Add.cs new file mode 100644 index 00000000000..a0cafd776b3 --- /dev/null +++ b/src/generated/Sites/Add/Add.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Add { + public class Add : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new add and sets the default values. + /// + public Add() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Add/AddRequestBody.cs b/src/generated/Sites/Add/AddRequestBody.cs new file mode 100644 index 00000000000..b425c198698 --- /dev/null +++ b/src/generated/Sites/Add/AddRequestBody.cs @@ -0,0 +1,36 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Add { + public class AddRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new addRequestBody and sets the default values. + /// + public AddRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"value", (o,n) => { (o as AddRequestBody).Value = n.GetCollectionOfObjectValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Add/AddRequestBuilder.cs b/src/generated/Sites/Add/AddRequestBuilder.cs new file mode 100644 index 00000000000..2d426a06984 --- /dev/null +++ b/src/generated/Sites/Add/AddRequestBuilder.cs @@ -0,0 +1,80 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Add { + /// Builds and executes requests for operations under \sites\microsoft.graph.add + public class AddRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action add + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action add"; + // Create options for all the parameters + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new AddRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/microsoft.graph.add"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action add + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/Analytics/@Ref/@Ref.cs b/src/generated/Sites/Item/Analytics/@Ref/@Ref.cs deleted file mode 100644 index b5426de1f90..00000000000 --- a/src/generated/Sites/Item/Analytics/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.Analytics.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/Analytics/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/Analytics/@Ref/RefRequestBuilder.cs deleted file mode 100644 index a3cc1d4fe81..00000000000 --- a/src/generated/Sites/Item/Analytics/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.Analytics.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\analytics\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Analytics about the view activities that took place in this site. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Analytics about the view activities that took place in this site."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - command.SetHandler(async (string siteId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption); - return command; - } - /// - /// Analytics about the view activities that took place in this site. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Analytics about the view activities that took place in this site."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - command.SetHandler(async (string siteId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption); - return command; - } - /// - /// Analytics about the view activities that took place in this site. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Analytics about the view activities that took place in this site."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/analytics/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Analytics about the view activities that took place in this site. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Analytics about the view activities that took place in this site. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Analytics about the view activities that took place in this site. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.Analytics.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Analytics about the view activities that took place in this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Analytics about the view activities that took place in this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Analytics about the view activities that took place in this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.Analytics.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/Analytics/AnalyticsRequestBuilder.cs b/src/generated/Sites/Item/Analytics/AnalyticsRequestBuilder.cs index 6257260d29f..ec230369885 100644 --- a/src/generated/Sites/Item/Analytics/AnalyticsRequestBuilder.cs +++ b/src/generated/Sites/Item/Analytics/AnalyticsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Analytics.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.Analytics.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.Analytics.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Analytics about the view activities that took place in this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Analytics about the view activities that took place in this site. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Analytics/Ref/Ref.cs b/src/generated/Sites/Item/Analytics/Ref/Ref.cs new file mode 100644 index 00000000000..18701f0a90e --- /dev/null +++ b/src/generated/Sites/Item/Analytics/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.Analytics.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/Analytics/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/Analytics/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..e9ac24ab5ed --- /dev/null +++ b/src/generated/Sites/Item/Analytics/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.Analytics.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\analytics\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Analytics about the view activities that took place in this site. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Analytics about the view activities that took place in this site."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + command.SetHandler(async (string siteId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption); + return command; + } + /// + /// Analytics about the view activities that took place in this site. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Analytics about the view activities that took place in this site."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, outputOption); + return command; + } + /// + /// Analytics about the view activities that took place in this site. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Analytics about the view activities that took place in this site."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/analytics/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Analytics about the view activities that took place in this site. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Analytics about the view activities that took place in this site. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Analytics about the view activities that took place in this site. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.Analytics.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/Columns/ColumnsRequestBuilder.cs b/src/generated/Sites/Item/Columns/ColumnsRequestBuilder.cs index 153238ad7fb..6a783ad7f92 100644 --- a/src/generated/Sites/Item/Columns/ColumnsRequestBuilder.cs +++ b/src/generated/Sites/Item/Columns/ColumnsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Columns.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class ColumnsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ColumnDefinitionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSourceColumnCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSourceColumnCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, bodyOption, outputOption); return command; } /// @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(ColumnDefinition body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of column definitions reusable across lists under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of column definitions reusable across lists under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ColumnDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of column definitions reusable across lists under this site. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs b/src/generated/Sites/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs index bc4fc10d753..7247dab9a38 100644 --- a/src/generated/Sites/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs +++ b/src/generated/Sites/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Columns.Item.SourceColumn; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,15 +31,14 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string siteId, string columnDefinitionId) => { + command.SetHandler(async (string siteId, string columnDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, columnDefinitionIdOption); return command; @@ -55,7 +54,7 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string columnDefinitionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string columnDefinitionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, columnDefinitionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, columnDefinitionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -96,7 +94,7 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -104,14 +102,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string columnDefinitionId, string body) => { + command.SetHandler(async (string siteId, string columnDefinitionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, columnDefinitionIdOption, bodyOption); return command; @@ -190,42 +187,6 @@ public RequestInformation CreatePatchRequestInformation(ColumnDefinition body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of column definitions reusable across lists under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of column definitions reusable across lists under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of column definitions reusable across lists under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ColumnDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of column definitions reusable across lists under this site. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Columns/Item/SourceColumn/@Ref/@Ref.cs b/src/generated/Sites/Item/Columns/Item/SourceColumn/@Ref/@Ref.cs deleted file mode 100644 index 19a755e68ca..00000000000 --- a/src/generated/Sites/Item/Columns/Item/SourceColumn/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.Columns.Item.SourceColumn.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 3b0d27a3ec4..00000000000 --- a/src/generated/Sites/Item/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.Columns.Item.SourceColumn.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\columns\{columnDefinition-id}\sourceColumn\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The source column for content type column. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string siteId, string columnDefinitionId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, columnDefinitionIdOption); - return command; - } - /// - /// The source column for content type column. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string siteId, string columnDefinitionId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, columnDefinitionIdOption); - return command; - } - /// - /// The source column for content type column. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string columnDefinitionId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, columnDefinitionIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/columns/{columnDefinition_id}/sourceColumn/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The source column for content type column. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.Columns.Item.SourceColumn.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.Columns.Item.SourceColumn.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/Columns/Item/SourceColumn/Ref/Ref.cs b/src/generated/Sites/Item/Columns/Item/SourceColumn/Ref/Ref.cs new file mode 100644 index 00000000000..249321ce4ab --- /dev/null +++ b/src/generated/Sites/Item/Columns/Item/SourceColumn/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.Columns.Item.SourceColumn.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..9057d032cc2 --- /dev/null +++ b/src/generated/Sites/Item/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.Columns.Item.SourceColumn.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\columns\{columnDefinition-id}\sourceColumn\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The source column for content type column. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + command.SetHandler(async (string siteId, string columnDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, columnDefinitionIdOption); + return command; + } + /// + /// The source column for content type column. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string columnDefinitionId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, columnDefinitionIdOption, outputOption); + return command; + } + /// + /// The source column for content type column. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string columnDefinitionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, columnDefinitionIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/columns/{columnDefinition_id}/sourceColumn/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The source column for content type column. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The source column for content type column. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The source column for content type column. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.Columns.Item.SourceColumn.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs b/src/generated/Sites/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs index 3fe37ac7af6..3073723fad1 100644 --- a/src/generated/Sites/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs +++ b/src/generated/Sites/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Columns.Item.SourceColumn.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,7 +31,7 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -45,25 +45,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string columnDefinitionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string columnDefinitionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, columnDefinitionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, columnDefinitionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.Columns.Item.SourceColumn.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.Columns.Item.SourceColumn.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -103,18 +102,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The source column for content type column. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/ContentTypes/AddCopy/AddCopyRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/AddCopy/AddCopyRequestBuilder.cs index 73a162eb684..3c46592cc5e 100644 --- a/src/generated/Sites/Item/ContentTypes/AddCopy/AddCopyRequestBuilder.cs +++ b/src/generated/Sites/Item/ContentTypes/AddCopy/AddCopyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(AddCopyRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action addCopy - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddCopyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes contentType public class AddCopyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/ContentTypes/ContentTypesRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/ContentTypesRequestBuilder.cs index 3f82b637e88..3ec5637c768 100644 --- a/src/generated/Sites/Item/ContentTypes/ContentTypesRequestBuilder.cs +++ b/src/generated/Sites/Item/ContentTypes/ContentTypesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Sites.Item.ContentTypes.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,20 +29,19 @@ public Command BuildAddCopyCommand() { } public List BuildCommand() { var builder = new ContentTypeRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAssociateWithHubSitesCommand(), - builder.BuildBaseCommand(), - builder.BuildBaseTypesCommand(), - builder.BuildColumnLinksCommand(), - builder.BuildColumnPositionsCommand(), - builder.BuildColumnsCommand(), - builder.BuildCopyToDefaultContentLocationCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildPublishCommand(), - builder.BuildUnpublishCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAssociateWithHubSitesCommand()); + commands.Add(builder.BuildBaseCommand()); + commands.Add(builder.BuildBaseTypesCommand()); + commands.Add(builder.BuildColumnLinksCommand()); + commands.Add(builder.BuildColumnPositionsCommand()); + commands.Add(builder.BuildColumnsCommand()); + commands.Add(builder.BuildCopyToDefaultContentLocationCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPublishCommand()); + commands.Add(builder.BuildUnpublishCommand()); return commands; } /// @@ -60,21 +59,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, bodyOption, outputOption); return command; } /// @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(ContentType body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of content types defined for this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of content types defined for this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ContentType model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of content types defined for this site. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/ContentTypes/Item/@Base/@Ref/@Ref.cs b/src/generated/Sites/Item/ContentTypes/Item/@Base/@Ref/@Ref.cs deleted file mode 100644 index bd31af9f864..00000000000 --- a/src/generated/Sites/Item/ContentTypes/Item/@Base/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.ContentTypes.Item.@Base.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/ContentTypes/Item/@Base/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/@Base/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 06a42903487..00000000000 --- a/src/generated/Sites/Item/ContentTypes/Item/@Base/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.ContentTypes.Item.@Base.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\contentTypes\{contentType-id}\base\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Parent contentType from which this content type is derived. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Parent contentType from which this content type is derived."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - command.SetHandler(async (string siteId, string contentTypeId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, contentTypeIdOption); - return command; - } - /// - /// Parent contentType from which this content type is derived. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Parent contentType from which this content type is derived."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - command.SetHandler(async (string siteId, string contentTypeId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, contentTypeIdOption); - return command; - } - /// - /// Parent contentType from which this content type is derived. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Parent contentType from which this content type is derived."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string contentTypeId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, contentTypeIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/contentTypes/{contentType_id}/base/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Parent contentType from which this content type is derived. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Parent contentType from which this content type is derived. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Parent contentType from which this content type is derived. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.ContentTypes.Item.@Base.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Parent contentType from which this content type is derived. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Parent contentType from which this content type is derived. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Parent contentType from which this content type is derived. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.ContentTypes.Item.@Base.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs b/src/generated/Sites/Item/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs deleted file mode 100644 index 877a8b7c1e9..00000000000 --- a/src/generated/Sites/Item/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.ContentTypes.Item.@Base.AssociateWithHubSites { - public class AssociateWithHubSitesRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public List HubSiteUrls { get; set; } - public bool? PropagateToExistingLists { get; set; } - /// - /// Instantiates a new associateWithHubSitesRequestBody and sets the default values. - /// - public AssociateWithHubSitesRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"hubSiteUrls", (o,n) => { (o as AssociateWithHubSitesRequestBody).HubSiteUrls = n.GetCollectionOfPrimitiveValues().ToList(); } }, - {"propagateToExistingLists", (o,n) => { (o as AssociateWithHubSitesRequestBody).PropagateToExistingLists = n.GetBoolValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteCollectionOfPrimitiveValues("hubSiteUrls", HubSiteUrls); - writer.WriteBoolValue("propagateToExistingLists", PropagateToExistingLists); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs deleted file mode 100644 index 18d820c8d45..00000000000 --- a/src/generated/Sites/Item/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs +++ /dev/null @@ -1,97 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.ContentTypes.Item.@Base.AssociateWithHubSites { - /// Builds and executes requests for operations under \sites\{site-id}\contentTypes\{contentType-id}\base\microsoft.graph.associateWithHubSites - public class AssociateWithHubSitesRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action associateWithHubSites - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action associateWithHubSites"; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string contentTypeId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, contentTypeIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AssociateWithHubSitesRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AssociateWithHubSitesRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/contentTypes/{contentType_id}/base/microsoft.graph.associateWithHubSites"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action associateWithHubSites - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AssociateWithHubSitesRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action associateWithHubSites - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssociateWithHubSitesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/ContentTypes/Item/@Base/BaseRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/@Base/BaseRequestBuilder.cs deleted file mode 100644 index b127cc111a8..00000000000 --- a/src/generated/Sites/Item/ContentTypes/Item/@Base/BaseRequestBuilder.cs +++ /dev/null @@ -1,161 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using ApiSdk.Sites.Item.ContentTypes.Item.Base.AssociateWithHubSites; -using ApiSdk.Sites.Item.ContentTypes.Item.Base.CopyToDefaultContentLocation; -using ApiSdk.Sites.Item.ContentTypes.Item.Base.IsPublished; -using ApiSdk.Sites.Item.ContentTypes.Item.Base.Publish; -using ApiSdk.Sites.Item.ContentTypes.Item.Base.Ref; -using ApiSdk.Sites.Item.ContentTypes.Item.Base.Unpublish; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.ContentTypes.Item.@Base { - /// Builds and executes requests for operations under \sites\{site-id}\contentTypes\{contentType-id}\base - public class BaseRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - public Command BuildAssociateWithHubSitesCommand() { - var command = new Command("associate-with-hub-sites"); - var builder = new ApiSdk.Sites.Item.ContentTypes.Item.@Base.AssociateWithHubSites.AssociateWithHubSitesRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildPostCommand()); - return command; - } - public Command BuildCopyToDefaultContentLocationCommand() { - var command = new Command("copy-to-default-content-location"); - var builder = new ApiSdk.Sites.Item.ContentTypes.Item.@Base.CopyToDefaultContentLocation.CopyToDefaultContentLocationRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildPostCommand()); - return command; - } - /// - /// Parent contentType from which this content type is derived. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Parent contentType from which this content type is derived."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string siteId, string contentTypeId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, contentTypeIdOption, selectOption, expandOption); - return command; - } - public Command BuildPublishCommand() { - var command = new Command("publish"); - var builder = new ApiSdk.Sites.Item.ContentTypes.Item.@Base.Publish.PublishRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildPostCommand()); - return command; - } - public Command BuildRefCommand() { - var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.ContentTypes.Item.@Base.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildDeleteCommand()); - command.AddCommand(builder.BuildGetCommand()); - command.AddCommand(builder.BuildPutCommand()); - return command; - } - public Command BuildUnpublishCommand() { - var command = new Command("unpublish"); - var builder = new ApiSdk.Sites.Item.ContentTypes.Item.@Base.Unpublish.UnpublishRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildPostCommand()); - return command; - } - /// - /// Instantiates a new BaseRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public BaseRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/contentTypes/{contentType_id}/base{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Parent contentType from which this content type is derived. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Parent contentType from which this content type is derived. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Builds and executes requests for operations under \sites\{site-id}\contentTypes\{contentType-id}\base\microsoft.graph.isPublished() - /// - public IsPublishedRequestBuilder IsPublished() { - return new IsPublishedRequestBuilder(PathParameters, RequestAdapter); - } - /// Parent contentType from which this content type is derived. - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/Sites/Item/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs b/src/generated/Sites/Item/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs deleted file mode 100644 index bd1a678d1a9..00000000000 --- a/src/generated/Sites/Item/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs +++ /dev/null @@ -1,39 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.ContentTypes.Item.@Base.CopyToDefaultContentLocation { - public class CopyToDefaultContentLocationRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string DestinationFileName { get; set; } - public ItemReference SourceFile { get; set; } - /// - /// Instantiates a new copyToDefaultContentLocationRequestBody and sets the default values. - /// - public CopyToDefaultContentLocationRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"destinationFileName", (o,n) => { (o as CopyToDefaultContentLocationRequestBody).DestinationFileName = n.GetStringValue(); } }, - {"sourceFile", (o,n) => { (o as CopyToDefaultContentLocationRequestBody).SourceFile = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("destinationFileName", DestinationFileName); - writer.WriteObjectValue("sourceFile", SourceFile); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs deleted file mode 100644 index 1d5c24191b0..00000000000 --- a/src/generated/Sites/Item/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs +++ /dev/null @@ -1,97 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.ContentTypes.Item.@Base.CopyToDefaultContentLocation { - /// Builds and executes requests for operations under \sites\{site-id}\contentTypes\{contentType-id}\base\microsoft.graph.copyToDefaultContentLocation - public class CopyToDefaultContentLocationRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action copyToDefaultContentLocation - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action copyToDefaultContentLocation"; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string contentTypeId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, contentTypeIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new CopyToDefaultContentLocationRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public CopyToDefaultContentLocationRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/contentTypes/{contentType_id}/base/microsoft.graph.copyToDefaultContentLocation"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action copyToDefaultContentLocation - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(CopyToDefaultContentLocationRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action copyToDefaultContentLocation - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToDefaultContentLocationRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/ContentTypes/Item/@Base/IsPublished/IsPublishedRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/@Base/IsPublished/IsPublishedRequestBuilder.cs deleted file mode 100644 index 81e311703c6..00000000000 --- a/src/generated/Sites/Item/ContentTypes/Item/@Base/IsPublished/IsPublishedRequestBuilder.cs +++ /dev/null @@ -1,90 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.ContentTypes.Item.@Base.IsPublished { - /// Builds and executes requests for operations under \sites\{site-id}\contentTypes\{contentType-id}\base\microsoft.graph.isPublished() - public class IsPublishedRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke function isPublished - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Invoke function isPublished"; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - command.SetHandler(async (string siteId, string contentTypeId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteBoolValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, contentTypeIdOption); - return command; - } - /// - /// Instantiates a new IsPublishedRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public IsPublishedRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/contentTypes/{contentType_id}/base/microsoft.graph.isPublished()"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke function isPublished - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke function isPublished - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/ContentTypes/Item/@Base/Publish/PublishRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/@Base/Publish/PublishRequestBuilder.cs deleted file mode 100644 index 55f76abe862..00000000000 --- a/src/generated/Sites/Item/ContentTypes/Item/@Base/Publish/PublishRequestBuilder.cs +++ /dev/null @@ -1,85 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.ContentTypes.Item.@Base.Publish { - /// Builds and executes requests for operations under \sites\{site-id}\contentTypes\{contentType-id}\base\microsoft.graph.publish - public class PublishRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action publish - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action publish"; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - command.SetHandler(async (string siteId, string contentTypeId) => { - var requestInfo = CreatePostRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, contentTypeIdOption); - return command; - } - /// - /// Instantiates a new PublishRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public PublishRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/contentTypes/{contentType_id}/base/microsoft.graph.publish"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action publish - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action publish - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/ContentTypes/Item/@Base/Unpublish/UnpublishRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/@Base/Unpublish/UnpublishRequestBuilder.cs deleted file mode 100644 index 7802379e2ed..00000000000 --- a/src/generated/Sites/Item/ContentTypes/Item/@Base/Unpublish/UnpublishRequestBuilder.cs +++ /dev/null @@ -1,85 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.ContentTypes.Item.@Base.Unpublish { - /// Builds and executes requests for operations under \sites\{site-id}\contentTypes\{contentType-id}\base\microsoft.graph.unpublish - public class UnpublishRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action unpublish - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action unpublish"; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - command.SetHandler(async (string siteId, string contentTypeId) => { - var requestInfo = CreatePostRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, contentTypeIdOption); - return command; - } - /// - /// Instantiates a new UnpublishRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public UnpublishRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/contentTypes/{contentType_id}/base/microsoft.graph.unpublish"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action unpublish - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action unpublish - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/ContentTypes/Item/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs index 09a01b7d597..30fdb28dc60 100644 --- a/src/generated/Sites/Item/ContentTypes/Item/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs +++ b/src/generated/Sites/Item/ContentTypes/Item/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string contentTypeId, string body) => { + command.SetHandler(async (string siteId, string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, contentTypeIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AssociateWithHubSitesRequ requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action associateWithHubSites - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssociateWithHubSitesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs b/src/generated/Sites/Item/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs new file mode 100644 index 00000000000..1ff93c6257d --- /dev/null +++ b/src/generated/Sites/Item/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.ContentTypes.Item.Base.AssociateWithHubSites { + public class AssociateWithHubSitesRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public List HubSiteUrls { get; set; } + public bool? PropagateToExistingLists { get; set; } + /// + /// Instantiates a new associateWithHubSitesRequestBody and sets the default values. + /// + public AssociateWithHubSitesRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"hubSiteUrls", (o,n) => { (o as AssociateWithHubSitesRequestBody).HubSiteUrls = n.GetCollectionOfPrimitiveValues().ToList(); } }, + {"propagateToExistingLists", (o,n) => { (o as AssociateWithHubSitesRequestBody).PropagateToExistingLists = n.GetBoolValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfPrimitiveValues("hubSiteUrls", HubSiteUrls); + writer.WriteBoolValue("propagateToExistingLists", PropagateToExistingLists); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs new file mode 100644 index 00000000000..8d369767f7f --- /dev/null +++ b/src/generated/Sites/Item/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs @@ -0,0 +1,83 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.ContentTypes.Item.Base.AssociateWithHubSites { + /// Builds and executes requests for operations under \sites\{site-id}\contentTypes\{contentType-id}\base\microsoft.graph.associateWithHubSites + public class AssociateWithHubSitesRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action associateWithHubSites + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action associateWithHubSites"; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, contentTypeIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new AssociateWithHubSitesRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AssociateWithHubSitesRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/contentTypes/{contentType_id}/base/microsoft.graph.associateWithHubSites"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action associateWithHubSites + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AssociateWithHubSitesRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/ContentTypes/Item/Base/BaseRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/Base/BaseRequestBuilder.cs new file mode 100644 index 00000000000..e7b812aecc2 --- /dev/null +++ b/src/generated/Sites/Item/ContentTypes/Item/Base/BaseRequestBuilder.cs @@ -0,0 +1,148 @@ +using ApiSdk.Models.Microsoft.Graph; +using ApiSdk.Sites.Item.ContentTypes.Item.Base.AssociateWithHubSites; +using ApiSdk.Sites.Item.ContentTypes.Item.Base.CopyToDefaultContentLocation; +using ApiSdk.Sites.Item.ContentTypes.Item.Base.IsPublished; +using ApiSdk.Sites.Item.ContentTypes.Item.Base.Publish; +using ApiSdk.Sites.Item.ContentTypes.Item.Base.Ref; +using ApiSdk.Sites.Item.ContentTypes.Item.Base.Unpublish; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.ContentTypes.Item.Base { + /// Builds and executes requests for operations under \sites\{site-id}\contentTypes\{contentType-id}\base + public class BaseRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + public Command BuildAssociateWithHubSitesCommand() { + var command = new Command("associate-with-hub-sites"); + var builder = new ApiSdk.Sites.Item.ContentTypes.Item.Base.AssociateWithHubSites.AssociateWithHubSitesRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildPostCommand()); + return command; + } + public Command BuildCopyToDefaultContentLocationCommand() { + var command = new Command("copy-to-default-content-location"); + var builder = new ApiSdk.Sites.Item.ContentTypes.Item.Base.CopyToDefaultContentLocation.CopyToDefaultContentLocationRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildPostCommand()); + return command; + } + /// + /// Parent contentType from which this content type is derived. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Parent contentType from which this content type is derived."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var selectOption = new Option("--select", description: "Select properties to be returned") { + Arity = ArgumentArity.ZeroOrMore + }; + selectOption.IsRequired = false; + command.AddOption(selectOption); + var expandOption = new Option("--expand", description: "Expand related entities") { + Arity = ArgumentArity.ZeroOrMore + }; + expandOption.IsRequired = false; + command.AddOption(expandOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string contentTypeId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Select = select; + q.Expand = expand; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, contentTypeIdOption, selectOption, expandOption, outputOption); + return command; + } + public Command BuildPublishCommand() { + var command = new Command("publish"); + var builder = new ApiSdk.Sites.Item.ContentTypes.Item.Base.Publish.PublishRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildPostCommand()); + return command; + } + public Command BuildRefCommand() { + var command = new Command("ref"); + var builder = new ApiSdk.Sites.Item.ContentTypes.Item.Base.Ref.RefRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildDeleteCommand()); + command.AddCommand(builder.BuildGetCommand()); + command.AddCommand(builder.BuildPutCommand()); + return command; + } + public Command BuildUnpublishCommand() { + var command = new Command("unpublish"); + var builder = new ApiSdk.Sites.Item.ContentTypes.Item.Base.Unpublish.UnpublishRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildPostCommand()); + return command; + } + /// + /// Instantiates a new BaseRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public BaseRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/contentTypes/{contentType_id}/base{?select,expand}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Parent contentType from which this content type is derived. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Builds and executes requests for operations under \sites\{site-id}\contentTypes\{contentType-id}\base\microsoft.graph.isPublished() + /// + public IsPublishedRequestBuilder IsPublished() { + return new IsPublishedRequestBuilder(PathParameters, RequestAdapter); + } + /// Parent contentType from which this content type is derived. + public class GetQueryParameters : QueryParametersBase { + /// Expand related entities + public string[] Expand { get; set; } + /// Select properties to be returned + public string[] Select { get; set; } + } + } +} diff --git a/src/generated/Sites/Item/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs b/src/generated/Sites/Item/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs new file mode 100644 index 00000000000..bfca268ec24 --- /dev/null +++ b/src/generated/Sites/Item/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs @@ -0,0 +1,39 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.ContentTypes.Item.Base.CopyToDefaultContentLocation { + public class CopyToDefaultContentLocationRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string DestinationFileName { get; set; } + public ItemReference SourceFile { get; set; } + /// + /// Instantiates a new copyToDefaultContentLocationRequestBody and sets the default values. + /// + public CopyToDefaultContentLocationRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"destinationFileName", (o,n) => { (o as CopyToDefaultContentLocationRequestBody).DestinationFileName = n.GetStringValue(); } }, + {"sourceFile", (o,n) => { (o as CopyToDefaultContentLocationRequestBody).SourceFile = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("destinationFileName", DestinationFileName); + writer.WriteObjectValue("sourceFile", SourceFile); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs new file mode 100644 index 00000000000..43e6b064572 --- /dev/null +++ b/src/generated/Sites/Item/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs @@ -0,0 +1,83 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.ContentTypes.Item.Base.CopyToDefaultContentLocation { + /// Builds and executes requests for operations under \sites\{site-id}\contentTypes\{contentType-id}\base\microsoft.graph.copyToDefaultContentLocation + public class CopyToDefaultContentLocationRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action copyToDefaultContentLocation + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action copyToDefaultContentLocation"; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, contentTypeIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new CopyToDefaultContentLocationRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public CopyToDefaultContentLocationRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/contentTypes/{contentType_id}/base/microsoft.graph.copyToDefaultContentLocation"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action copyToDefaultContentLocation + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(CopyToDefaultContentLocationRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/ContentTypes/Item/Base/IsPublished/IsPublishedRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/Base/IsPublished/IsPublishedRequestBuilder.cs new file mode 100644 index 00000000000..9f1bfff776b --- /dev/null +++ b/src/generated/Sites/Item/ContentTypes/Item/Base/IsPublished/IsPublishedRequestBuilder.cs @@ -0,0 +1,78 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.ContentTypes.Item.Base.IsPublished { + /// Builds and executes requests for operations under \sites\{site-id}\contentTypes\{contentType-id}\base\microsoft.graph.isPublished() + public class IsPublishedRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke function isPublished + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Invoke function isPublished"; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string contentTypeId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, contentTypeIdOption, outputOption); + return command; + } + /// + /// Instantiates a new IsPublishedRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public IsPublishedRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/contentTypes/{contentType_id}/base/microsoft.graph.isPublished()"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke function isPublished + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/ContentTypes/Item/Base/Publish/PublishRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/Base/Publish/PublishRequestBuilder.cs new file mode 100644 index 00000000000..79bf4d498e0 --- /dev/null +++ b/src/generated/Sites/Item/ContentTypes/Item/Base/Publish/PublishRequestBuilder.cs @@ -0,0 +1,73 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.ContentTypes.Item.Base.Publish { + /// Builds and executes requests for operations under \sites\{site-id}\contentTypes\{contentType-id}\base\microsoft.graph.publish + public class PublishRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action publish + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action publish"; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + command.SetHandler(async (string siteId, string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreatePostRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, contentTypeIdOption); + return command; + } + /// + /// Instantiates a new PublishRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public PublishRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/contentTypes/{contentType_id}/base/microsoft.graph.publish"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action publish + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/ContentTypes/Item/Base/Ref/Ref.cs b/src/generated/Sites/Item/ContentTypes/Item/Base/Ref/Ref.cs new file mode 100644 index 00000000000..001cffd426c --- /dev/null +++ b/src/generated/Sites/Item/ContentTypes/Item/Base/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.ContentTypes.Item.Base.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/ContentTypes/Item/Base/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/Base/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..08dda55f7eb --- /dev/null +++ b/src/generated/Sites/Item/ContentTypes/Item/Base/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.ContentTypes.Item.Base.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\contentTypes\{contentType-id}\base\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Parent contentType from which this content type is derived. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Parent contentType from which this content type is derived."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + command.SetHandler(async (string siteId, string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, contentTypeIdOption); + return command; + } + /// + /// Parent contentType from which this content type is derived. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Parent contentType from which this content type is derived."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string contentTypeId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, contentTypeIdOption, outputOption); + return command; + } + /// + /// Parent contentType from which this content type is derived. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Parent contentType from which this content type is derived."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, contentTypeIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/contentTypes/{contentType_id}/base/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Parent contentType from which this content type is derived. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Parent contentType from which this content type is derived. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Parent contentType from which this content type is derived. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.ContentTypes.Item.Base.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/ContentTypes/Item/Base/Unpublish/UnpublishRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/Base/Unpublish/UnpublishRequestBuilder.cs new file mode 100644 index 00000000000..107f10d43c9 --- /dev/null +++ b/src/generated/Sites/Item/ContentTypes/Item/Base/Unpublish/UnpublishRequestBuilder.cs @@ -0,0 +1,73 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.ContentTypes.Item.Base.Unpublish { + /// Builds and executes requests for operations under \sites\{site-id}\contentTypes\{contentType-id}\base\microsoft.graph.unpublish + public class UnpublishRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action unpublish + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action unpublish"; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + command.SetHandler(async (string siteId, string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreatePostRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, contentTypeIdOption); + return command; + } + /// + /// Instantiates a new UnpublishRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public UnpublishRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/contentTypes/{contentType_id}/base/microsoft.graph.unpublish"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action unpublish + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/ContentTypes/Item/BaseTypes/@Ref/@Ref.cs b/src/generated/Sites/Item/ContentTypes/Item/BaseTypes/@Ref/@Ref.cs deleted file mode 100644 index 3bf78285152..00000000000 --- a/src/generated/Sites/Item/ContentTypes/Item/BaseTypes/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.ContentTypes.Item.BaseTypes.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/ContentTypes/Item/BaseTypes/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/BaseTypes/@Ref/RefRequestBuilder.cs deleted file mode 100644 index ace20609180..00000000000 --- a/src/generated/Sites/Item/ContentTypes/Item/BaseTypes/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,210 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.ContentTypes.Item.BaseTypes.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\contentTypes\{contentType-id}\baseTypes\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The collection of content types that are ancestors of this content type. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The collection of content types that are ancestors of this content type."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string siteId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The collection of content types that are ancestors of this content type. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The collection of content types that are ancestors of this content type."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string contentTypeId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, contentTypeIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/contentTypes/{contentType_id}/baseTypes/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The collection of content types that are ancestors of this content type. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The collection of content types that are ancestors of this content type. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Sites.Item.ContentTypes.Item.BaseTypes.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The collection of content types that are ancestors of this content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of content types that are ancestors of this content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Sites.Item.ContentTypes.Item.BaseTypes.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The collection of content types that are ancestors of this content type. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Sites/Item/ContentTypes/Item/BaseTypes/@Ref/RefResponse.cs b/src/generated/Sites/Item/ContentTypes/Item/BaseTypes/@Ref/RefResponse.cs deleted file mode 100644 index 8645d8768fb..00000000000 --- a/src/generated/Sites/Item/ContentTypes/Item/BaseTypes/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.ContentTypes.Item.BaseTypes.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/ContentTypes/Item/BaseTypes/AddCopy/AddCopyRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/BaseTypes/AddCopy/AddCopyRequestBuilder.cs index 14db0dd2e8b..933970e9dfe 100644 --- a/src/generated/Sites/Item/ContentTypes/Item/BaseTypes/AddCopy/AddCopyRequestBuilder.cs +++ b/src/generated/Sites/Item/ContentTypes/Item/BaseTypes/AddCopy/AddCopyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string contentTypeId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string contentTypeId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, contentTypeIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, contentTypeIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(AddCopyRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action addCopy - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddCopyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes contentType public class AddCopyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/ContentTypes/Item/BaseTypes/BaseTypesRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/BaseTypes/BaseTypesRequestBuilder.cs index 75586dfb8cd..a96402dcb45 100644 --- a/src/generated/Sites/Item/ContentTypes/Item/BaseTypes/BaseTypesRequestBuilder.cs +++ b/src/generated/Sites/Item/ContentTypes/Item/BaseTypes/BaseTypesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.ContentTypes.Item.BaseTypes.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,7 +37,7 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -76,7 +76,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -87,20 +91,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.ContentTypes.Item.BaseTypes.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.ContentTypes.Item.BaseTypes.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -139,18 +138,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of content types that are ancestors of this content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of content types that are ancestors of this content type. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/ContentTypes/Item/BaseTypes/Ref/Ref.cs b/src/generated/Sites/Item/ContentTypes/Item/BaseTypes/Ref/Ref.cs new file mode 100644 index 00000000000..01ed57e7553 --- /dev/null +++ b/src/generated/Sites/Item/ContentTypes/Item/BaseTypes/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.ContentTypes.Item.BaseTypes.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/ContentTypes/Item/BaseTypes/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/BaseTypes/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..a3839b08690 --- /dev/null +++ b/src/generated/Sites/Item/ContentTypes/Item/BaseTypes/Ref/RefRequestBuilder.cs @@ -0,0 +1,183 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.ContentTypes.Item.BaseTypes.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\contentTypes\{contentType-id}\baseTypes\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The collection of content types that are ancestors of this content type. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The collection of content types that are ancestors of this content type."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The collection of content types that are ancestors of this content type. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The collection of content types that are ancestors of this content type."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string contentTypeId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, contentTypeIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/contentTypes/{contentType_id}/baseTypes/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The collection of content types that are ancestors of this content type. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The collection of content types that are ancestors of this content type. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Sites.Item.ContentTypes.Item.BaseTypes.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The collection of content types that are ancestors of this content type. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Sites/Item/ContentTypes/Item/BaseTypes/Ref/RefResponse.cs b/src/generated/Sites/Item/ContentTypes/Item/BaseTypes/Ref/RefResponse.cs new file mode 100644 index 00000000000..f9b427fdf8b --- /dev/null +++ b/src/generated/Sites/Item/ContentTypes/Item/BaseTypes/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.ContentTypes.Item.BaseTypes.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/ContentTypes/Item/ColumnLinks/ColumnLinksRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/ColumnLinks/ColumnLinksRequestBuilder.cs index 85c91d5f91e..b652cbad5a1 100644 --- a/src/generated/Sites/Item/ContentTypes/Item/ColumnLinks/ColumnLinksRequestBuilder.cs +++ b/src/generated/Sites/Item/ContentTypes/Item/ColumnLinks/ColumnLinksRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.ContentTypes.Item.ColumnLinks.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ColumnLinksRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ColumnLinkRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string contentTypeId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string contentTypeId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, contentTypeIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, contentTypeIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(ColumnLink body, Action - /// The collection of columns that are required by this content type - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of columns that are required by this content type - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ColumnLink model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of columns that are required by this content type public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/ContentTypes/Item/ColumnLinks/Item/ColumnLinkRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/ColumnLinks/Item/ColumnLinkRequestBuilder.cs index 818a560f0bc..f9dac896485 100644 --- a/src/generated/Sites/Item/ContentTypes/Item/ColumnLinks/Item/ColumnLinkRequestBuilder.cs +++ b/src/generated/Sites/Item/ContentTypes/Item/ColumnLinks/Item/ColumnLinkRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnLinkIdOption = new Option("--columnlink-id", description: "key: id of columnLink") { + var columnLinkIdOption = new Option("--column-link-id", description: "key: id of columnLink") { }; columnLinkIdOption.IsRequired = true; command.AddOption(columnLinkIdOption); - command.SetHandler(async (string siteId, string contentTypeId, string columnLinkId) => { + command.SetHandler(async (string siteId, string contentTypeId, string columnLinkId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, contentTypeIdOption, columnLinkIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnLinkIdOption = new Option("--columnlink-id", description: "key: id of columnLink") { + var columnLinkIdOption = new Option("--column-link-id", description: "key: id of columnLink") { }; columnLinkIdOption.IsRequired = true; command.AddOption(columnLinkIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string contentTypeId, string columnLinkId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string contentTypeId, string columnLinkId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, contentTypeIdOption, columnLinkIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, contentTypeIdOption, columnLinkIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnLinkIdOption = new Option("--columnlink-id", description: "key: id of columnLink") { + var columnLinkIdOption = new Option("--column-link-id", description: "key: id of columnLink") { }; columnLinkIdOption.IsRequired = true; command.AddOption(columnLinkIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string contentTypeId, string columnLinkId, string body) => { + command.SetHandler(async (string siteId, string contentTypeId, string columnLinkId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, contentTypeIdOption, columnLinkIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(ColumnLink body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of columns that are required by this content type - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of columns that are required by this content type - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of columns that are required by this content type - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ColumnLink model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of columns that are required by this content type public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/ContentTypes/Item/ColumnPositions/@Ref/@Ref.cs b/src/generated/Sites/Item/ContentTypes/Item/ColumnPositions/@Ref/@Ref.cs deleted file mode 100644 index 15868ce707a..00000000000 --- a/src/generated/Sites/Item/ContentTypes/Item/ColumnPositions/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.ContentTypes.Item.ColumnPositions.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/ContentTypes/Item/ColumnPositions/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/ColumnPositions/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 37b78eb93d6..00000000000 --- a/src/generated/Sites/Item/ContentTypes/Item/ColumnPositions/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,210 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.ContentTypes.Item.ColumnPositions.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\contentTypes\{contentType-id}\columnPositions\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Column order information in a content type. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Column order information in a content type."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string siteId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Column order information in a content type. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Column order information in a content type."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string contentTypeId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, contentTypeIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/contentTypes/{contentType_id}/columnPositions/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Column order information in a content type. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Column order information in a content type. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Sites.Item.ContentTypes.Item.ColumnPositions.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Column order information in a content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Column order information in a content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Sites.Item.ContentTypes.Item.ColumnPositions.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Column order information in a content type. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Sites/Item/ContentTypes/Item/ColumnPositions/@Ref/RefResponse.cs b/src/generated/Sites/Item/ContentTypes/Item/ColumnPositions/@Ref/RefResponse.cs deleted file mode 100644 index 914c94f304d..00000000000 --- a/src/generated/Sites/Item/ContentTypes/Item/ColumnPositions/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.ContentTypes.Item.ColumnPositions.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/ContentTypes/Item/ColumnPositions/ColumnPositionsRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/ColumnPositions/ColumnPositionsRequestBuilder.cs index ac54e535acd..98988eb5c6a 100644 --- a/src/generated/Sites/Item/ContentTypes/Item/ColumnPositions/ColumnPositionsRequestBuilder.cs +++ b/src/generated/Sites/Item/ContentTypes/Item/ColumnPositions/ColumnPositionsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Sites.Item.ContentTypes.Item.ColumnPositions.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -69,7 +69,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -80,20 +84,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.ContentTypes.Item.ColumnPositions.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.ContentTypes.Item.ColumnPositions.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -132,18 +131,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Column order information in a content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Column order information in a content type. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/ContentTypes/Item/ColumnPositions/Ref/Ref.cs b/src/generated/Sites/Item/ContentTypes/Item/ColumnPositions/Ref/Ref.cs new file mode 100644 index 00000000000..c1caff49593 --- /dev/null +++ b/src/generated/Sites/Item/ContentTypes/Item/ColumnPositions/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.ContentTypes.Item.ColumnPositions.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/ContentTypes/Item/ColumnPositions/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/ColumnPositions/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..24cb6be6f9d --- /dev/null +++ b/src/generated/Sites/Item/ContentTypes/Item/ColumnPositions/Ref/RefRequestBuilder.cs @@ -0,0 +1,183 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.ContentTypes.Item.ColumnPositions.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\contentTypes\{contentType-id}\columnPositions\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Column order information in a content type. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Column order information in a content type."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Column order information in a content type. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Column order information in a content type."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string contentTypeId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, contentTypeIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/contentTypes/{contentType_id}/columnPositions/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Column order information in a content type. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Column order information in a content type. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Sites.Item.ContentTypes.Item.ColumnPositions.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Column order information in a content type. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Sites/Item/ContentTypes/Item/ColumnPositions/Ref/RefResponse.cs b/src/generated/Sites/Item/ContentTypes/Item/ColumnPositions/Ref/RefResponse.cs new file mode 100644 index 00000000000..850fa49b2f0 --- /dev/null +++ b/src/generated/Sites/Item/ContentTypes/Item/ColumnPositions/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.ContentTypes.Item.ColumnPositions.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/ContentTypes/Item/Columns/ColumnsRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/Columns/ColumnsRequestBuilder.cs index 6933fb74f5d..c24a0571365 100644 --- a/src/generated/Sites/Item/ContentTypes/Item/Columns/ColumnsRequestBuilder.cs +++ b/src/generated/Sites/Item/ContentTypes/Item/Columns/ColumnsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.ContentTypes.Item.Columns.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class ColumnsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ColumnDefinitionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSourceColumnCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSourceColumnCommand()); return commands; } /// @@ -41,7 +40,7 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string contentTypeId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string contentTypeId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, contentTypeIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, contentTypeIdOption, bodyOption, outputOption); return command; } /// @@ -77,7 +75,7 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -116,7 +114,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -127,15 +129,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -190,31 +187,6 @@ public RequestInformation CreatePostRequestInformation(ColumnDefinition body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of column definitions for this contentType. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of column definitions for this contentType. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ColumnDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of column definitions for this contentType. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/ContentTypes/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs index be7302b89ec..22cd5ec6062 100644 --- a/src/generated/Sites/Item/ContentTypes/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs +++ b/src/generated/Sites/Item/ContentTypes/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.ContentTypes.Item.Columns.Item.SourceColumn; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,19 +31,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string siteId, string contentTypeId, string columnDefinitionId) => { + command.SetHandler(async (string siteId, string contentTypeId, string columnDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, contentTypeIdOption, columnDefinitionIdOption); return command; @@ -59,11 +58,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string contentTypeId, string columnDefinitionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string contentTypeId, string columnDefinitionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, contentTypeIdOption, columnDefinitionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, contentTypeIdOption, columnDefinitionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,11 +102,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -116,14 +114,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string contentTypeId, string columnDefinitionId, string body) => { + command.SetHandler(async (string siteId, string contentTypeId, string columnDefinitionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, contentTypeIdOption, columnDefinitionIdOption, bodyOption); return command; @@ -202,42 +199,6 @@ public RequestInformation CreatePatchRequestInformation(ColumnDefinition body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of column definitions for this contentType. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of column definitions for this contentType. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of column definitions for this contentType. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ColumnDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of column definitions for this contentType. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/@Ref.cs b/src/generated/Sites/Item/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/@Ref.cs deleted file mode 100644 index 1f356e6b0b8..00000000000 --- a/src/generated/Sites/Item/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.ContentTypes.Item.Columns.Item.SourceColumn.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs deleted file mode 100644 index a7808437f4d..00000000000 --- a/src/generated/Sites/Item/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,214 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.ContentTypes.Item.Columns.Item.SourceColumn.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\contentTypes\{contentType-id}\columns\{columnDefinition-id}\sourceColumn\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The source column for content type column. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string siteId, string contentTypeId, string columnDefinitionId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, contentTypeIdOption, columnDefinitionIdOption); - return command; - } - /// - /// The source column for content type column. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string siteId, string contentTypeId, string columnDefinitionId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, contentTypeIdOption, columnDefinitionIdOption); - return command; - } - /// - /// The source column for content type column. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string contentTypeId, string columnDefinitionId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, contentTypeIdOption, columnDefinitionIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/contentTypes/{contentType_id}/columns/{columnDefinition_id}/sourceColumn/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The source column for content type column. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.ContentTypes.Item.Columns.Item.SourceColumn.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.ContentTypes.Item.Columns.Item.SourceColumn.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/ContentTypes/Item/Columns/Item/SourceColumn/Ref/Ref.cs b/src/generated/Sites/Item/ContentTypes/Item/Columns/Item/SourceColumn/Ref/Ref.cs new file mode 100644 index 00000000000..b84a3200a18 --- /dev/null +++ b/src/generated/Sites/Item/ContentTypes/Item/Columns/Item/SourceColumn/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.ContentTypes.Item.Columns.Item.SourceColumn.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/ContentTypes/Item/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..7c572796a1a --- /dev/null +++ b/src/generated/Sites/Item/ContentTypes/Item/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs @@ -0,0 +1,176 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.ContentTypes.Item.Columns.Item.SourceColumn.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\contentTypes\{contentType-id}\columns\{columnDefinition-id}\sourceColumn\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The source column for content type column. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + command.SetHandler(async (string siteId, string contentTypeId, string columnDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, contentTypeIdOption, columnDefinitionIdOption); + return command; + } + /// + /// The source column for content type column. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string contentTypeId, string columnDefinitionId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, contentTypeIdOption, columnDefinitionIdOption, outputOption); + return command; + } + /// + /// The source column for content type column. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string contentTypeId, string columnDefinitionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, contentTypeIdOption, columnDefinitionIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/contentTypes/{contentType_id}/columns/{columnDefinition_id}/sourceColumn/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The source column for content type column. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The source column for content type column. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The source column for content type column. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.ContentTypes.Item.Columns.Item.SourceColumn.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/ContentTypes/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs index 95844726fff..d3090065774 100644 --- a/src/generated/Sites/Item/ContentTypes/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs +++ b/src/generated/Sites/Item/ContentTypes/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.ContentTypes.Item.Columns.Item.SourceColumn.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,11 +31,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -49,25 +49,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string contentTypeId, string columnDefinitionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string contentTypeId, string columnDefinitionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, contentTypeIdOption, columnDefinitionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, contentTypeIdOption, columnDefinitionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.ContentTypes.Item.Columns.Item.SourceColumn.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.ContentTypes.Item.Columns.Item.SourceColumn.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -107,18 +106,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The source column for content type column. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/ContentTypes/Item/ContentTypeRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/ContentTypeRequestBuilder.cs index ffb85b61801..2e439b2cbb5 100644 --- a/src/generated/Sites/Item/ContentTypes/Item/ContentTypeRequestBuilder.cs +++ b/src/generated/Sites/Item/ContentTypes/Item/ContentTypeRequestBuilder.cs @@ -11,10 +11,10 @@ using ApiSdk.Sites.Item.ContentTypes.Item.Unpublish; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,7 +37,7 @@ public Command BuildAssociateWithHubSitesCommand() { } public Command BuildBaseCommand() { var command = new Command("base"); - var builder = new ApiSdk.Sites.Item.ContentTypes.Item.@Base.BaseRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.ContentTypes.Item.Base.BaseRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAssociateWithHubSitesCommand()); command.AddCommand(builder.BuildCopyToDefaultContentLocationCommand()); command.AddCommand(builder.BuildGetCommand()); @@ -57,6 +57,9 @@ public Command BuildBaseTypesCommand() { public Command BuildColumnLinksCommand() { var command = new Command("column-links"); var builder = new ApiSdk.Sites.Item.ContentTypes.Item.ColumnLinks.ColumnLinksRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -71,6 +74,9 @@ public Command BuildColumnPositionsCommand() { public Command BuildColumnsCommand() { var command = new Command("columns"); var builder = new ApiSdk.Sites.Item.ContentTypes.Item.Columns.ColumnsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -92,15 +98,14 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - command.SetHandler(async (string siteId, string contentTypeId) => { + command.SetHandler(async (string siteId, string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, contentTypeIdOption); return command; @@ -116,7 +121,7 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -130,20 +135,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string contentTypeId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string contentTypeId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, contentTypeIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, contentTypeIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -157,7 +161,7 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -165,14 +169,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string contentTypeId, string body) => { + command.SetHandler(async (string siteId, string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, contentTypeIdOption, bodyOption); return command; @@ -257,47 +260,11 @@ public RequestInformation CreatePatchRequestInformation(ContentType body, Action return requestInfo; } /// - /// The collection of content types defined for this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of content types defined for this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \sites\{site-id}\contentTypes\{contentType-id}\microsoft.graph.isPublished() /// public IsPublishedRequestBuilder IsPublished() { return new IsPublishedRequestBuilder(PathParameters, RequestAdapter); } - /// - /// The collection of content types defined for this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ContentType model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of content types defined for this site. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/ContentTypes/Item/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs index 80ba9e8c962..3ca162f3d7d 100644 --- a/src/generated/Sites/Item/ContentTypes/Item/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs +++ b/src/generated/Sites/Item/ContentTypes/Item/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string contentTypeId, string body) => { + command.SetHandler(async (string siteId, string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, contentTypeIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CopyToDefaultContentLocat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToDefaultContentLocation - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToDefaultContentLocationRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/ContentTypes/Item/IsPublished/IsPublishedRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/IsPublished/IsPublishedRequestBuilder.cs index f0775caac4d..6c46ce53710 100644 --- a/src/generated/Sites/Item/ContentTypes/Item/IsPublished/IsPublishedRequestBuilder.cs +++ b/src/generated/Sites/Item/ContentTypes/Item/IsPublished/IsPublishedRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,22 +29,21 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - command.SetHandler(async (string siteId, string contentTypeId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string contentTypeId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteBoolValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, contentTypeIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, contentTypeIdOption, outputOption); return command; } /// @@ -75,16 +74,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function isPublished - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/ContentTypes/Item/Publish/PublishRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/Publish/PublishRequestBuilder.cs index 06770e9f403..771eb724706 100644 --- a/src/generated/Sites/Item/ContentTypes/Item/Publish/PublishRequestBuilder.cs +++ b/src/generated/Sites/Item/ContentTypes/Item/Publish/PublishRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - command.SetHandler(async (string siteId, string contentTypeId) => { + command.SetHandler(async (string siteId, string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, contentTypeIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action publish - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/ContentTypes/Item/Unpublish/UnpublishRequestBuilder.cs b/src/generated/Sites/Item/ContentTypes/Item/Unpublish/UnpublishRequestBuilder.cs index b0e86c401c9..80cbb339c2d 100644 --- a/src/generated/Sites/Item/ContentTypes/Item/Unpublish/UnpublishRequestBuilder.cs +++ b/src/generated/Sites/Item/ContentTypes/Item/Unpublish/UnpublishRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - command.SetHandler(async (string siteId, string contentTypeId) => { + command.SetHandler(async (string siteId, string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, contentTypeIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action unpublish - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Drive/DriveRequestBuilder.cs b/src/generated/Sites/Item/Drive/DriveRequestBuilder.cs index 88d35a5d2bf..dd99f40ce4e 100644 --- a/src/generated/Sites/Item/Drive/DriveRequestBuilder.cs +++ b/src/generated/Sites/Item/Drive/DriveRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,10 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - command.SetHandler(async (string siteId) => { + command.SetHandler(async (string siteId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption); return command; @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string body) => { + command.SetHandler(async (string siteId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The default drive (document library) for this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The default drive (document library) for this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The default drive (document library) for this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Drive model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The default drive (document library) for this site. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Drives/DrivesRequestBuilder.cs b/src/generated/Sites/Item/Drives/DrivesRequestBuilder.cs index f35d1df8782..27d2dad2458 100644 --- a/src/generated/Sites/Item/Drives/DrivesRequestBuilder.cs +++ b/src/generated/Sites/Item/Drives/DrivesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Drives.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DrivesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DriveRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of drives (document libraries) under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of drives (document libraries) under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Drive model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of drives (document libraries) under this site. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Drives/Item/DriveRequestBuilder.cs b/src/generated/Sites/Item/Drives/Item/DriveRequestBuilder.cs index a7222b53927..2e7f4a60b9b 100644 --- a/src/generated/Sites/Item/Drives/Item/DriveRequestBuilder.cs +++ b/src/generated/Sites/Item/Drives/Item/DriveRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - command.SetHandler(async (string siteId, string driveId) => { + command.SetHandler(async (string siteId, string driveId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, driveIdOption); return command; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string driveId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string driveId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, driveIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, driveIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string driveId, string body) => { + command.SetHandler(async (string siteId, string driveId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, driveIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of drives (document libraries) under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of drives (document libraries) under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of drives (document libraries) under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Drive model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of drives (document libraries) under this site. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/ExternalColumns/@Ref/@Ref.cs b/src/generated/Sites/Item/ExternalColumns/@Ref/@Ref.cs deleted file mode 100644 index e4810ec6eb2..00000000000 --- a/src/generated/Sites/Item/ExternalColumns/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.ExternalColumns.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/ExternalColumns/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/ExternalColumns/@Ref/RefRequestBuilder.cs deleted file mode 100644 index efc5ff454cf..00000000000 --- a/src/generated/Sites/Item/ExternalColumns/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.ExternalColumns.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\externalColumns\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The collection of column definitions available in the site that are referenced from the sites in the parent hierarchy of the current site. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The collection of column definitions available in the site that are referenced from the sites in the parent hierarchy of the current site."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The collection of column definitions available in the site that are referenced from the sites in the parent hierarchy of the current site. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The collection of column definitions available in the site that are referenced from the sites in the parent hierarchy of the current site."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/externalColumns/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The collection of column definitions available in the site that are referenced from the sites in the parent hierarchy of the current site. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The collection of column definitions available in the site that are referenced from the sites in the parent hierarchy of the current site. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Sites.Item.ExternalColumns.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The collection of column definitions available in the site that are referenced from the sites in the parent hierarchy of the current site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of column definitions available in the site that are referenced from the sites in the parent hierarchy of the current site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Sites.Item.ExternalColumns.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The collection of column definitions available in the site that are referenced from the sites in the parent hierarchy of the current site. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Sites/Item/ExternalColumns/@Ref/RefResponse.cs b/src/generated/Sites/Item/ExternalColumns/@Ref/RefResponse.cs deleted file mode 100644 index 40ce8122b00..00000000000 --- a/src/generated/Sites/Item/ExternalColumns/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.ExternalColumns.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/ExternalColumns/ExternalColumnsRequestBuilder.cs b/src/generated/Sites/Item/ExternalColumns/ExternalColumnsRequestBuilder.cs index df8c2199903..5052d6e1a64 100644 --- a/src/generated/Sites/Item/ExternalColumns/ExternalColumnsRequestBuilder.cs +++ b/src/generated/Sites/Item/ExternalColumns/ExternalColumnsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Sites.Item.ExternalColumns.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.ExternalColumns.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.ExternalColumns.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of column definitions available in the site that are referenced from the sites in the parent hierarchy of the current site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of column definitions available in the site that are referenced from the sites in the parent hierarchy of the current site. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/ExternalColumns/Ref/Ref.cs b/src/generated/Sites/Item/ExternalColumns/Ref/Ref.cs new file mode 100644 index 00000000000..701fc9f42b6 --- /dev/null +++ b/src/generated/Sites/Item/ExternalColumns/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.ExternalColumns.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/ExternalColumns/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/ExternalColumns/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..c925d7f11ba --- /dev/null +++ b/src/generated/Sites/Item/ExternalColumns/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.ExternalColumns.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\externalColumns\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The collection of column definitions available in the site that are referenced from the sites in the parent hierarchy of the current site. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The collection of column definitions available in the site that are referenced from the sites in the parent hierarchy of the current site."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The collection of column definitions available in the site that are referenced from the sites in the parent hierarchy of the current site. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The collection of column definitions available in the site that are referenced from the sites in the parent hierarchy of the current site."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/externalColumns/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The collection of column definitions available in the site that are referenced from the sites in the parent hierarchy of the current site. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The collection of column definitions available in the site that are referenced from the sites in the parent hierarchy of the current site. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Sites.Item.ExternalColumns.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The collection of column definitions available in the site that are referenced from the sites in the parent hierarchy of the current site. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Sites/Item/ExternalColumns/Ref/RefResponse.cs b/src/generated/Sites/Item/ExternalColumns/Ref/RefResponse.cs new file mode 100644 index 00000000000..733f5669d9b --- /dev/null +++ b/src/generated/Sites/Item/ExternalColumns/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.ExternalColumns.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs b/src/generated/Sites/Item/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs index 8ce6e9ccae2..7cff56dbcb7 100644 --- a/src/generated/Sites/Item/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs +++ b/src/generated/Sites/Item/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +29,17 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - command.SetHandler(async (string siteId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getActivitiesByInterval - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs b/src/generated/Sites/Item/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs index 36ab131df12..c2f8b9abe0d 100644 --- a/src/generated/Sites/Item/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs +++ b/src/generated/Sites/Item/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var startDateTimeOption = new Option("--startdatetime", description: "Usage: startDateTime={startDateTime}") { + var startDateTimeOption = new Option("--start-date-time", description: "Usage: startDateTime={startDateTime}") { }; startDateTimeOption.IsRequired = true; command.AddOption(startDateTimeOption); - var endDateTimeOption = new Option("--enddatetime", description: "Usage: endDateTime={endDateTime}") { + var endDateTimeOption = new Option("--end-date-time", description: "Usage: endDateTime={endDateTime}") { }; endDateTimeOption.IsRequired = true; command.AddOption(endDateTimeOption); @@ -41,18 +41,17 @@ public Command BuildGetCommand() { }; intervalOption.IsRequired = true; command.AddOption(intervalOption); - command.SetHandler(async (string siteId, string startDateTime, string endDateTime, string interval) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string startDateTime, string endDateTime, string interval, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, startDateTimeOption, endDateTimeOption, intervalOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, startDateTimeOption, endDateTimeOption, intervalOption, outputOption); return command; } /// @@ -89,16 +88,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getActivitiesByInterval - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/GetApplicableContentTypesForListWithListId/GetApplicableContentTypesForListWithListIdRequestBuilder.cs b/src/generated/Sites/Item/GetApplicableContentTypesForListWithListId/GetApplicableContentTypesForListWithListIdRequestBuilder.cs index 3c7b8d194d3..a1eb42458b7 100644 --- a/src/generated/Sites/Item/GetApplicableContentTypesForListWithListId/GetApplicableContentTypesForListWithListIdRequestBuilder.cs +++ b/src/generated/Sites/Item/GetApplicableContentTypesForListWithListId/GetApplicableContentTypesForListWithListIdRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,22 +29,21 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var listIdOption = new Option("--listid", description: "Usage: listId={listId}") { + var listIdOption = new Option("--list-id", description: "Usage: listId={listId}") { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - command.SetHandler(async (string siteId, string listId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, outputOption); return command; } /// @@ -77,16 +76,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getApplicableContentTypesForList - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/GetByPathWithPath/GetByPathWithPathRequestBuilder.cs b/src/generated/Sites/Item/GetByPathWithPath/GetByPathWithPathRequestBuilder.cs index e9ee27bb0f9..558dea35857 100644 --- a/src/generated/Sites/Item/GetByPathWithPath/GetByPathWithPathRequestBuilder.cs +++ b/src/generated/Sites/Item/GetByPathWithPath/GetByPathWithPathRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,18 +34,17 @@ public Command BuildGetCommand() { }; pathOption.IsRequired = true; command.AddOption(pathOption); - command.SetHandler(async (string siteId, string path) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string path, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, pathOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, pathOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getByPath - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes site public class GetByPathWithPathResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Items/Item/BaseItemRequestBuilder.cs b/src/generated/Sites/Item/Items/Item/BaseItemRequestBuilder.cs index 4cc82ddbfe9..07d7b9cd032 100644 --- a/src/generated/Sites/Item/Items/Item/BaseItemRequestBuilder.cs +++ b/src/generated/Sites/Item/Items/Item/BaseItemRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var baseItemIdOption = new Option("--baseitem-id", description: "key: id of baseItem") { + var baseItemIdOption = new Option("--base-item-id", description: "key: id of baseItem") { }; baseItemIdOption.IsRequired = true; command.AddOption(baseItemIdOption); - command.SetHandler(async (string siteId, string baseItemId) => { + command.SetHandler(async (string siteId, string baseItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, baseItemIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var baseItemIdOption = new Option("--baseitem-id", description: "key: id of baseItem") { + var baseItemIdOption = new Option("--base-item-id", description: "key: id of baseItem") { }; baseItemIdOption.IsRequired = true; command.AddOption(baseItemIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string baseItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string baseItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, baseItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, baseItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var baseItemIdOption = new Option("--baseitem-id", description: "key: id of baseItem") { + var baseItemIdOption = new Option("--base-item-id", description: "key: id of baseItem") { }; baseItemIdOption.IsRequired = true; command.AddOption(baseItemIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string baseItemId, string body) => { + command.SetHandler(async (string siteId, string baseItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, baseItemIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(BaseItem body, Action - /// Used to address any item contained in this site. This collection cannot be enumerated. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used to address any item contained in this site. This collection cannot be enumerated. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used to address any item contained in this site. This collection cannot be enumerated. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(BaseItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Used to address any item contained in this site. This collection cannot be enumerated. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Items/ItemsRequestBuilder.cs b/src/generated/Sites/Item/Items/ItemsRequestBuilder.cs index cd33dbad89c..39eac128e25 100644 --- a/src/generated/Sites/Item/Items/ItemsRequestBuilder.cs +++ b/src/generated/Sites/Item/Items/ItemsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Items.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ItemsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new BaseItemRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(BaseItem body, Action - /// Used to address any item contained in this site. This collection cannot be enumerated. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used to address any item contained in this site. This collection cannot be enumerated. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(BaseItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Used to address any item contained in this site. This collection cannot be enumerated. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Lists/Item/Columns/ColumnsRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/Columns/ColumnsRequestBuilder.cs index 7767cea887d..2306f05fc17 100644 --- a/src/generated/Sites/Item/Lists/Item/Columns/ColumnsRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/Columns/ColumnsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Lists.Item.Columns.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class ColumnsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ColumnDefinitionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSourceColumnCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSourceColumnCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, bodyOption, outputOption); return command; } /// @@ -116,7 +114,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string listId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -127,15 +129,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -190,31 +187,6 @@ public RequestInformation CreatePostRequestInformation(ColumnDefinition body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of field definitions for this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of field definitions for this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ColumnDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of field definitions for this list. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Lists/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs index ed81ada3c77..928f3f5dde9 100644 --- a/src/generated/Sites/Item/Lists/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Lists.Item.Columns.Item.SourceColumn; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,15 +35,14 @@ public Command BuildDeleteCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string siteId, string listId, string columnDefinitionId) => { + command.SetHandler(async (string siteId, string listId, string columnDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, columnDefinitionIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string listId, string columnDefinitionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string columnDefinitionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, columnDefinitionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, columnDefinitionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -108,7 +106,7 @@ public Command BuildPatchCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -116,14 +114,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string columnDefinitionId, string body) => { + command.SetHandler(async (string siteId, string listId, string columnDefinitionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, columnDefinitionIdOption, bodyOption); return command; @@ -202,42 +199,6 @@ public RequestInformation CreatePatchRequestInformation(ColumnDefinition body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of field definitions for this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of field definitions for this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of field definitions for this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ColumnDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of field definitions for this list. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Lists/Item/Columns/Item/SourceColumn/@Ref/@Ref.cs b/src/generated/Sites/Item/Lists/Item/Columns/Item/SourceColumn/@Ref/@Ref.cs deleted file mode 100644 index 5c3c0a11598..00000000000 --- a/src/generated/Sites/Item/Lists/Item/Columns/Item/SourceColumn/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.Lists.Item.Columns.Item.SourceColumn.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/Lists/Item/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 75714b7eb20..00000000000 --- a/src/generated/Sites/Item/Lists/Item/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,214 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.Lists.Item.Columns.Item.SourceColumn.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\columns\{columnDefinition-id}\sourceColumn\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The source column for content type column. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var listIdOption = new Option("--list-id", description: "key: id of list") { - }; - listIdOption.IsRequired = true; - command.AddOption(listIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string siteId, string listId, string columnDefinitionId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, listIdOption, columnDefinitionIdOption); - return command; - } - /// - /// The source column for content type column. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var listIdOption = new Option("--list-id", description: "key: id of list") { - }; - listIdOption.IsRequired = true; - command.AddOption(listIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string siteId, string listId, string columnDefinitionId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, columnDefinitionIdOption); - return command; - } - /// - /// The source column for content type column. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var listIdOption = new Option("--list-id", description: "key: id of list") { - }; - listIdOption.IsRequired = true; - command.AddOption(listIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string columnDefinitionId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, listIdOption, columnDefinitionIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/lists/{list_id}/columns/{columnDefinition_id}/sourceColumn/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The source column for content type column. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.Lists.Item.Columns.Item.SourceColumn.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.Lists.Item.Columns.Item.SourceColumn.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/Lists/Item/Columns/Item/SourceColumn/Ref/Ref.cs b/src/generated/Sites/Item/Lists/Item/Columns/Item/SourceColumn/Ref/Ref.cs new file mode 100644 index 00000000000..90989e92766 --- /dev/null +++ b/src/generated/Sites/Item/Lists/Item/Columns/Item/SourceColumn/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.Lists.Item.Columns.Item.SourceColumn.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/Lists/Item/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..fc2e00838f7 --- /dev/null +++ b/src/generated/Sites/Item/Lists/Item/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs @@ -0,0 +1,176 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.Lists.Item.Columns.Item.SourceColumn.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\columns\{columnDefinition-id}\sourceColumn\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The source column for content type column. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var listIdOption = new Option("--list-id", description: "key: id of list") { + }; + listIdOption.IsRequired = true; + command.AddOption(listIdOption); + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + command.SetHandler(async (string siteId, string listId, string columnDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, listIdOption, columnDefinitionIdOption); + return command; + } + /// + /// The source column for content type column. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var listIdOption = new Option("--list-id", description: "key: id of list") { + }; + listIdOption.IsRequired = true; + command.AddOption(listIdOption); + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string columnDefinitionId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, columnDefinitionIdOption, outputOption); + return command; + } + /// + /// The source column for content type column. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var listIdOption = new Option("--list-id", description: "key: id of list") { + }; + listIdOption.IsRequired = true; + command.AddOption(listIdOption); + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string listId, string columnDefinitionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, listIdOption, columnDefinitionIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/lists/{list_id}/columns/{columnDefinition_id}/sourceColumn/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The source column for content type column. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The source column for content type column. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The source column for content type column. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.Lists.Item.Columns.Item.SourceColumn.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/Lists/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs index 374660b05fb..a89e1ed45ba 100644 --- a/src/generated/Sites/Item/Lists/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Lists.Item.Columns.Item.SourceColumn.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,7 +35,7 @@ public Command BuildGetCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -49,25 +49,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string listId, string columnDefinitionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string columnDefinitionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, columnDefinitionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, columnDefinitionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.Lists.Item.Columns.Item.SourceColumn.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.Lists.Item.Columns.Item.SourceColumn.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -107,18 +106,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The source column for content type column. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/AddCopy/AddCopyRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/AddCopy/AddCopyRequestBuilder.cs index 019e0d3af1e..3f843ee127a 100644 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/AddCopy/AddCopyRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/AddCopy/AddCopyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(AddCopyRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action addCopy - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddCopyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes contentType public class AddCopyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/ContentTypesRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/ContentTypesRequestBuilder.cs index ed4f0c746ea..7b2fe550808 100644 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/ContentTypesRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/ContentTypesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,20 +29,19 @@ public Command BuildAddCopyCommand() { } public List BuildCommand() { var builder = new ContentTypeRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAssociateWithHubSitesCommand(), - builder.BuildBaseCommand(), - builder.BuildBaseTypesCommand(), - builder.BuildColumnLinksCommand(), - builder.BuildColumnPositionsCommand(), - builder.BuildColumnsCommand(), - builder.BuildCopyToDefaultContentLocationCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildPublishCommand(), - builder.BuildUnpublishCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAssociateWithHubSitesCommand()); + commands.Add(builder.BuildBaseCommand()); + commands.Add(builder.BuildBaseTypesCommand()); + commands.Add(builder.BuildColumnLinksCommand()); + commands.Add(builder.BuildColumnPositionsCommand()); + commands.Add(builder.BuildColumnsCommand()); + commands.Add(builder.BuildCopyToDefaultContentLocationCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPublishCommand()); + commands.Add(builder.BuildUnpublishCommand()); return commands; } /// @@ -64,21 +63,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, bodyOption, outputOption); return command; } /// @@ -131,7 +129,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string listId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -142,15 +144,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -205,31 +202,6 @@ public RequestInformation CreatePostRequestInformation(ContentType body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of content types present in this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of content types present in this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ContentType model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of content types present in this list. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/@Ref/@Ref.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/@Ref/@Ref.cs deleted file mode 100644 index 8a6b93a055b..00000000000 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.@Base.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/@Ref/RefRequestBuilder.cs deleted file mode 100644 index f1e719a73e5..00000000000 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,214 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.@Base.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\contentTypes\{contentType-id}\base\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Parent contentType from which this content type is derived. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Parent contentType from which this content type is derived."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var listIdOption = new Option("--list-id", description: "key: id of list") { - }; - listIdOption.IsRequired = true; - command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, listIdOption, contentTypeIdOption); - return command; - } - /// - /// Parent contentType from which this content type is derived. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Parent contentType from which this content type is derived."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var listIdOption = new Option("--list-id", description: "key: id of list") { - }; - listIdOption.IsRequired = true; - command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, contentTypeIdOption); - return command; - } - /// - /// Parent contentType from which this content type is derived. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Parent contentType from which this content type is derived."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var listIdOption = new Option("--list-id", description: "key: id of list") { - }; - listIdOption.IsRequired = true; - command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, listIdOption, contentTypeIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/lists/{list_id}/contentTypes/{contentType_id}/base/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Parent contentType from which this content type is derived. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Parent contentType from which this content type is derived. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Parent contentType from which this content type is derived. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.@Base.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Parent contentType from which this content type is derived. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Parent contentType from which this content type is derived. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Parent contentType from which this content type is derived. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.@Base.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs deleted file mode 100644 index 6532b069f83..00000000000 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.@Base.AssociateWithHubSites { - public class AssociateWithHubSitesRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public List HubSiteUrls { get; set; } - public bool? PropagateToExistingLists { get; set; } - /// - /// Instantiates a new associateWithHubSitesRequestBody and sets the default values. - /// - public AssociateWithHubSitesRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"hubSiteUrls", (o,n) => { (o as AssociateWithHubSitesRequestBody).HubSiteUrls = n.GetCollectionOfPrimitiveValues().ToList(); } }, - {"propagateToExistingLists", (o,n) => { (o as AssociateWithHubSitesRequestBody).PropagateToExistingLists = n.GetBoolValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteCollectionOfPrimitiveValues("hubSiteUrls", HubSiteUrls); - writer.WriteBoolValue("propagateToExistingLists", PropagateToExistingLists); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs deleted file mode 100644 index e1bd44d75a9..00000000000 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs +++ /dev/null @@ -1,101 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.@Base.AssociateWithHubSites { - /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\contentTypes\{contentType-id}\base\microsoft.graph.associateWithHubSites - public class AssociateWithHubSitesRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action associateWithHubSites - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action associateWithHubSites"; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var listIdOption = new Option("--list-id", description: "key: id of list") { - }; - listIdOption.IsRequired = true; - command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, listIdOption, contentTypeIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AssociateWithHubSitesRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AssociateWithHubSitesRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/lists/{list_id}/contentTypes/{contentType_id}/base/microsoft.graph.associateWithHubSites"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action associateWithHubSites - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AssociateWithHubSitesRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action associateWithHubSites - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssociateWithHubSitesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/BaseRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/BaseRequestBuilder.cs deleted file mode 100644 index d32d2bcc1e5..00000000000 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/BaseRequestBuilder.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.AssociateWithHubSites; -using ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.CopyToDefaultContentLocation; -using ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.IsPublished; -using ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.Publish; -using ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.Ref; -using ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.Unpublish; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.@Base { - /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\contentTypes\{contentType-id}\base - public class BaseRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - public Command BuildAssociateWithHubSitesCommand() { - var command = new Command("associate-with-hub-sites"); - var builder = new ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.@Base.AssociateWithHubSites.AssociateWithHubSitesRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildPostCommand()); - return command; - } - public Command BuildCopyToDefaultContentLocationCommand() { - var command = new Command("copy-to-default-content-location"); - var builder = new ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.@Base.CopyToDefaultContentLocation.CopyToDefaultContentLocationRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildPostCommand()); - return command; - } - /// - /// Parent contentType from which this content type is derived. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Parent contentType from which this content type is derived."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var listIdOption = new Option("--list-id", description: "key: id of list") { - }; - listIdOption.IsRequired = true; - command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, contentTypeIdOption, selectOption, expandOption); - return command; - } - public Command BuildPublishCommand() { - var command = new Command("publish"); - var builder = new ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.@Base.Publish.PublishRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildPostCommand()); - return command; - } - public Command BuildRefCommand() { - var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.@Base.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildDeleteCommand()); - command.AddCommand(builder.BuildGetCommand()); - command.AddCommand(builder.BuildPutCommand()); - return command; - } - public Command BuildUnpublishCommand() { - var command = new Command("unpublish"); - var builder = new ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.@Base.Unpublish.UnpublishRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildPostCommand()); - return command; - } - /// - /// Instantiates a new BaseRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public BaseRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/lists/{list_id}/contentTypes/{contentType_id}/base{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Parent contentType from which this content type is derived. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Parent contentType from which this content type is derived. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\contentTypes\{contentType-id}\base\microsoft.graph.isPublished() - /// - public IsPublishedRequestBuilder IsPublished() { - return new IsPublishedRequestBuilder(PathParameters, RequestAdapter); - } - /// Parent contentType from which this content type is derived. - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs deleted file mode 100644 index 8a872aa6ca2..00000000000 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs +++ /dev/null @@ -1,39 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.@Base.CopyToDefaultContentLocation { - public class CopyToDefaultContentLocationRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string DestinationFileName { get; set; } - public ItemReference SourceFile { get; set; } - /// - /// Instantiates a new copyToDefaultContentLocationRequestBody and sets the default values. - /// - public CopyToDefaultContentLocationRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"destinationFileName", (o,n) => { (o as CopyToDefaultContentLocationRequestBody).DestinationFileName = n.GetStringValue(); } }, - {"sourceFile", (o,n) => { (o as CopyToDefaultContentLocationRequestBody).SourceFile = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("destinationFileName", DestinationFileName); - writer.WriteObjectValue("sourceFile", SourceFile); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs deleted file mode 100644 index 6d06c8ad40a..00000000000 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs +++ /dev/null @@ -1,101 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.@Base.CopyToDefaultContentLocation { - /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\contentTypes\{contentType-id}\base\microsoft.graph.copyToDefaultContentLocation - public class CopyToDefaultContentLocationRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action copyToDefaultContentLocation - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action copyToDefaultContentLocation"; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var listIdOption = new Option("--list-id", description: "key: id of list") { - }; - listIdOption.IsRequired = true; - command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, listIdOption, contentTypeIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new CopyToDefaultContentLocationRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public CopyToDefaultContentLocationRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/lists/{list_id}/contentTypes/{contentType_id}/base/microsoft.graph.copyToDefaultContentLocation"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action copyToDefaultContentLocation - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(CopyToDefaultContentLocationRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action copyToDefaultContentLocation - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToDefaultContentLocationRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/IsPublished/IsPublishedRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/IsPublished/IsPublishedRequestBuilder.cs deleted file mode 100644 index 00ea08c5e6d..00000000000 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/IsPublished/IsPublishedRequestBuilder.cs +++ /dev/null @@ -1,94 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.@Base.IsPublished { - /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\contentTypes\{contentType-id}\base\microsoft.graph.isPublished() - public class IsPublishedRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke function isPublished - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Invoke function isPublished"; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var listIdOption = new Option("--list-id", description: "key: id of list") { - }; - listIdOption.IsRequired = true; - command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteBoolValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, contentTypeIdOption); - return command; - } - /// - /// Instantiates a new IsPublishedRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public IsPublishedRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/lists/{list_id}/contentTypes/{contentType_id}/base/microsoft.graph.isPublished()"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke function isPublished - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke function isPublished - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/Publish/PublishRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/Publish/PublishRequestBuilder.cs deleted file mode 100644 index 3e11dc28628..00000000000 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/Publish/PublishRequestBuilder.cs +++ /dev/null @@ -1,89 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.@Base.Publish { - /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\contentTypes\{contentType-id}\base\microsoft.graph.publish - public class PublishRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action publish - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action publish"; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var listIdOption = new Option("--list-id", description: "key: id of list") { - }; - listIdOption.IsRequired = true; - command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId) => { - var requestInfo = CreatePostRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, listIdOption, contentTypeIdOption); - return command; - } - /// - /// Instantiates a new PublishRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public PublishRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/lists/{list_id}/contentTypes/{contentType_id}/base/microsoft.graph.publish"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action publish - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action publish - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/Unpublish/UnpublishRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/Unpublish/UnpublishRequestBuilder.cs deleted file mode 100644 index 28cbd9880a0..00000000000 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/@Base/Unpublish/UnpublishRequestBuilder.cs +++ /dev/null @@ -1,89 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.@Base.Unpublish { - /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\contentTypes\{contentType-id}\base\microsoft.graph.unpublish - public class UnpublishRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action unpublish - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action unpublish"; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var listIdOption = new Option("--list-id", description: "key: id of list") { - }; - listIdOption.IsRequired = true; - command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId) => { - var requestInfo = CreatePostRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, listIdOption, contentTypeIdOption); - return command; - } - /// - /// Instantiates a new UnpublishRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public UnpublishRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/lists/{list_id}/contentTypes/{contentType_id}/base/microsoft.graph.unpublish"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action unpublish - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action unpublish - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs index b276b7f803f..9691a467d92 100644 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,7 +33,7 @@ public Command BuildPostCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, string body) => { + command.SetHandler(async (string siteId, string listId, string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, contentTypeIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(AssociateWithHubSitesRequ requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action associateWithHubSites - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssociateWithHubSitesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs new file mode 100644 index 00000000000..738eb25a784 --- /dev/null +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBody.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.AssociateWithHubSites { + public class AssociateWithHubSitesRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public List HubSiteUrls { get; set; } + public bool? PropagateToExistingLists { get; set; } + /// + /// Instantiates a new associateWithHubSitesRequestBody and sets the default values. + /// + public AssociateWithHubSitesRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"hubSiteUrls", (o,n) => { (o as AssociateWithHubSitesRequestBody).HubSiteUrls = n.GetCollectionOfPrimitiveValues().ToList(); } }, + {"propagateToExistingLists", (o,n) => { (o as AssociateWithHubSitesRequestBody).PropagateToExistingLists = n.GetBoolValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfPrimitiveValues("hubSiteUrls", HubSiteUrls); + writer.WriteBoolValue("propagateToExistingLists", PropagateToExistingLists); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs new file mode 100644 index 00000000000..f056202fecd --- /dev/null +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/AssociateWithHubSites/AssociateWithHubSitesRequestBuilder.cs @@ -0,0 +1,87 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.AssociateWithHubSites { + /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\contentTypes\{contentType-id}\base\microsoft.graph.associateWithHubSites + public class AssociateWithHubSitesRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action associateWithHubSites + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action associateWithHubSites"; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var listIdOption = new Option("--list-id", description: "key: id of list") { + }; + listIdOption.IsRequired = true; + command.AddOption(listIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, listIdOption, contentTypeIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new AssociateWithHubSitesRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AssociateWithHubSitesRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/lists/{list_id}/contentTypes/{contentType_id}/base/microsoft.graph.associateWithHubSites"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action associateWithHubSites + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AssociateWithHubSitesRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/BaseRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/BaseRequestBuilder.cs new file mode 100644 index 00000000000..0690e52233a --- /dev/null +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/BaseRequestBuilder.cs @@ -0,0 +1,152 @@ +using ApiSdk.Models.Microsoft.Graph; +using ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.AssociateWithHubSites; +using ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.CopyToDefaultContentLocation; +using ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.IsPublished; +using ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.Publish; +using ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.Ref; +using ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.Unpublish; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base { + /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\contentTypes\{contentType-id}\base + public class BaseRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + public Command BuildAssociateWithHubSitesCommand() { + var command = new Command("associate-with-hub-sites"); + var builder = new ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.AssociateWithHubSites.AssociateWithHubSitesRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildPostCommand()); + return command; + } + public Command BuildCopyToDefaultContentLocationCommand() { + var command = new Command("copy-to-default-content-location"); + var builder = new ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.CopyToDefaultContentLocation.CopyToDefaultContentLocationRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildPostCommand()); + return command; + } + /// + /// Parent contentType from which this content type is derived. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Parent contentType from which this content type is derived."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var listIdOption = new Option("--list-id", description: "key: id of list") { + }; + listIdOption.IsRequired = true; + command.AddOption(listIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var selectOption = new Option("--select", description: "Select properties to be returned") { + Arity = ArgumentArity.ZeroOrMore + }; + selectOption.IsRequired = false; + command.AddOption(selectOption); + var expandOption = new Option("--expand", description: "Expand related entities") { + Arity = ArgumentArity.ZeroOrMore + }; + expandOption.IsRequired = false; + command.AddOption(expandOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Select = select; + q.Expand = expand; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, contentTypeIdOption, selectOption, expandOption, outputOption); + return command; + } + public Command BuildPublishCommand() { + var command = new Command("publish"); + var builder = new ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.Publish.PublishRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildPostCommand()); + return command; + } + public Command BuildRefCommand() { + var command = new Command("ref"); + var builder = new ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.Ref.RefRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildDeleteCommand()); + command.AddCommand(builder.BuildGetCommand()); + command.AddCommand(builder.BuildPutCommand()); + return command; + } + public Command BuildUnpublishCommand() { + var command = new Command("unpublish"); + var builder = new ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.Unpublish.UnpublishRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildPostCommand()); + return command; + } + /// + /// Instantiates a new BaseRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public BaseRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/lists/{list_id}/contentTypes/{contentType_id}/base{?select,expand}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Parent contentType from which this content type is derived. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\contentTypes\{contentType-id}\base\microsoft.graph.isPublished() + /// + public IsPublishedRequestBuilder IsPublished() { + return new IsPublishedRequestBuilder(PathParameters, RequestAdapter); + } + /// Parent contentType from which this content type is derived. + public class GetQueryParameters : QueryParametersBase { + /// Expand related entities + public string[] Expand { get; set; } + /// Select properties to be returned + public string[] Select { get; set; } + } + } +} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs new file mode 100644 index 00000000000..5b1873e2d05 --- /dev/null +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBody.cs @@ -0,0 +1,39 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.CopyToDefaultContentLocation { + public class CopyToDefaultContentLocationRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string DestinationFileName { get; set; } + public ItemReference SourceFile { get; set; } + /// + /// Instantiates a new copyToDefaultContentLocationRequestBody and sets the default values. + /// + public CopyToDefaultContentLocationRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"destinationFileName", (o,n) => { (o as CopyToDefaultContentLocationRequestBody).DestinationFileName = n.GetStringValue(); } }, + {"sourceFile", (o,n) => { (o as CopyToDefaultContentLocationRequestBody).SourceFile = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("destinationFileName", DestinationFileName); + writer.WriteObjectValue("sourceFile", SourceFile); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs new file mode 100644 index 00000000000..8dd874da7db --- /dev/null +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs @@ -0,0 +1,87 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.CopyToDefaultContentLocation { + /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\contentTypes\{contentType-id}\base\microsoft.graph.copyToDefaultContentLocation + public class CopyToDefaultContentLocationRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action copyToDefaultContentLocation + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action copyToDefaultContentLocation"; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var listIdOption = new Option("--list-id", description: "key: id of list") { + }; + listIdOption.IsRequired = true; + command.AddOption(listIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, listIdOption, contentTypeIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new CopyToDefaultContentLocationRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public CopyToDefaultContentLocationRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/lists/{list_id}/contentTypes/{contentType_id}/base/microsoft.graph.copyToDefaultContentLocation"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action copyToDefaultContentLocation + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(CopyToDefaultContentLocationRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/IsPublished/IsPublishedRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/IsPublished/IsPublishedRequestBuilder.cs new file mode 100644 index 00000000000..a5f0d062b7e --- /dev/null +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/IsPublished/IsPublishedRequestBuilder.cs @@ -0,0 +1,82 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.IsPublished { + /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\contentTypes\{contentType-id}\base\microsoft.graph.isPublished() + public class IsPublishedRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke function isPublished + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Invoke function isPublished"; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var listIdOption = new Option("--list-id", description: "key: id of list") { + }; + listIdOption.IsRequired = true; + command.AddOption(listIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, contentTypeIdOption, outputOption); + return command; + } + /// + /// Instantiates a new IsPublishedRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public IsPublishedRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/lists/{list_id}/contentTypes/{contentType_id}/base/microsoft.graph.isPublished()"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke function isPublished + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/Publish/PublishRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/Publish/PublishRequestBuilder.cs new file mode 100644 index 00000000000..e232ef9f434 --- /dev/null +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/Publish/PublishRequestBuilder.cs @@ -0,0 +1,77 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.Publish { + /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\contentTypes\{contentType-id}\base\microsoft.graph.publish + public class PublishRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action publish + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action publish"; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var listIdOption = new Option("--list-id", description: "key: id of list") { + }; + listIdOption.IsRequired = true; + command.AddOption(listIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreatePostRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, listIdOption, contentTypeIdOption); + return command; + } + /// + /// Instantiates a new PublishRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public PublishRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/lists/{list_id}/contentTypes/{contentType_id}/base/microsoft.graph.publish"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action publish + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/Ref/Ref.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/Ref/Ref.cs new file mode 100644 index 00000000000..6126d5f301c --- /dev/null +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..a4494cc66d3 --- /dev/null +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/Ref/RefRequestBuilder.cs @@ -0,0 +1,176 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\contentTypes\{contentType-id}\base\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Parent contentType from which this content type is derived. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Parent contentType from which this content type is derived."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var listIdOption = new Option("--list-id", description: "key: id of list") { + }; + listIdOption.IsRequired = true; + command.AddOption(listIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, listIdOption, contentTypeIdOption); + return command; + } + /// + /// Parent contentType from which this content type is derived. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Parent contentType from which this content type is derived."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var listIdOption = new Option("--list-id", description: "key: id of list") { + }; + listIdOption.IsRequired = true; + command.AddOption(listIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, contentTypeIdOption, outputOption); + return command; + } + /// + /// Parent contentType from which this content type is derived. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Parent contentType from which this content type is derived."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var listIdOption = new Option("--list-id", description: "key: id of list") { + }; + listIdOption.IsRequired = true; + command.AddOption(listIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, listIdOption, contentTypeIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/lists/{list_id}/contentTypes/{contentType_id}/base/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Parent contentType from which this content type is derived. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Parent contentType from which this content type is derived. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Parent contentType from which this content type is derived. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/Unpublish/UnpublishRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/Unpublish/UnpublishRequestBuilder.cs new file mode 100644 index 00000000000..06080ce81a6 --- /dev/null +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Base/Unpublish/UnpublishRequestBuilder.cs @@ -0,0 +1,77 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.Unpublish { + /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\contentTypes\{contentType-id}\base\microsoft.graph.unpublish + public class UnpublishRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action unpublish + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action unpublish"; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var listIdOption = new Option("--list-id", description: "key: id of list") { + }; + listIdOption.IsRequired = true; + command.AddOption(listIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreatePostRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, listIdOption, contentTypeIdOption); + return command; + } + /// + /// Instantiates a new UnpublishRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public UnpublishRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/lists/{list_id}/contentTypes/{contentType_id}/base/microsoft.graph.unpublish"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action unpublish + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/BaseTypes/@Ref/@Ref.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/BaseTypes/@Ref/@Ref.cs deleted file mode 100644 index 046b46802c2..00000000000 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/BaseTypes/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.BaseTypes.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/BaseTypes/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/BaseTypes/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 7b8df7c31c6..00000000000 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/BaseTypes/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,218 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.BaseTypes.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\contentTypes\{contentType-id}\baseTypes\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The collection of content types that are ancestors of this content type. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The collection of content types that are ancestors of this content type."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var listIdOption = new Option("--list-id", description: "key: id of list") { - }; - listIdOption.IsRequired = true; - command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The collection of content types that are ancestors of this content type. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The collection of content types that are ancestors of this content type."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var listIdOption = new Option("--list-id", description: "key: id of list") { - }; - listIdOption.IsRequired = true; - command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, contentTypeIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/lists/{list_id}/contentTypes/{contentType_id}/baseTypes/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The collection of content types that are ancestors of this content type. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The collection of content types that are ancestors of this content type. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.BaseTypes.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The collection of content types that are ancestors of this content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of content types that are ancestors of this content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.BaseTypes.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The collection of content types that are ancestors of this content type. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/BaseTypes/@Ref/RefResponse.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/BaseTypes/@Ref/RefResponse.cs deleted file mode 100644 index 208cf5bda40..00000000000 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/BaseTypes/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.BaseTypes.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/BaseTypes/AddCopy/AddCopyRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/BaseTypes/AddCopy/AddCopyRequestBuilder.cs index af98e95faf4..6166f576adb 100644 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/BaseTypes/AddCopy/AddCopyRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/BaseTypes/AddCopy/AddCopyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,7 +34,7 @@ public Command BuildPostCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, contentTypeIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, contentTypeIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(AddCopyRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action addCopy - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddCopyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes contentType public class AddCopyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/BaseTypes/BaseTypesRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/BaseTypes/BaseTypesRequestBuilder.cs index 4010504a76f..596bd862520 100644 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/BaseTypes/BaseTypesRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/BaseTypes/BaseTypesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.BaseTypes.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,7 +41,7 @@ public Command BuildGetCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -80,7 +80,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -91,20 +95,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.BaseTypes.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.BaseTypes.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -143,18 +142,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of content types that are ancestors of this content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of content types that are ancestors of this content type. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/BaseTypes/Ref/Ref.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/BaseTypes/Ref/Ref.cs new file mode 100644 index 00000000000..69dc77ba989 --- /dev/null +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/BaseTypes/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.BaseTypes.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/BaseTypes/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/BaseTypes/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..8a3b85068d1 --- /dev/null +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/BaseTypes/Ref/RefRequestBuilder.cs @@ -0,0 +1,191 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.BaseTypes.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\contentTypes\{contentType-id}\baseTypes\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The collection of content types that are ancestors of this content type. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The collection of content types that are ancestors of this content type."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var listIdOption = new Option("--list-id", description: "key: id of list") { + }; + listIdOption.IsRequired = true; + command.AddOption(listIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The collection of content types that are ancestors of this content type. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The collection of content types that are ancestors of this content type."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var listIdOption = new Option("--list-id", description: "key: id of list") { + }; + listIdOption.IsRequired = true; + command.AddOption(listIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, contentTypeIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/lists/{list_id}/contentTypes/{contentType_id}/baseTypes/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The collection of content types that are ancestors of this content type. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The collection of content types that are ancestors of this content type. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.BaseTypes.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The collection of content types that are ancestors of this content type. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/BaseTypes/Ref/RefResponse.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/BaseTypes/Ref/RefResponse.cs new file mode 100644 index 00000000000..d9d8b51170c --- /dev/null +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/BaseTypes/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.BaseTypes.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnLinks/ColumnLinksRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnLinks/ColumnLinksRequestBuilder.cs index f005e6694b1..cfe2b4c1e53 100644 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnLinks/ColumnLinksRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnLinks/ColumnLinksRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.ColumnLinks.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ColumnLinksRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ColumnLinkRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,7 +43,7 @@ public Command BuildCreateCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, contentTypeIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, contentTypeIdOption, bodyOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildListCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(ColumnLink body, Action - /// The collection of columns that are required by this content type - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of columns that are required by this content type - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ColumnLink model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of columns that are required by this content type public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnLinks/Item/ColumnLinkRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnLinks/Item/ColumnLinkRequestBuilder.cs index 04b30c0c560..e44034c7c0d 100644 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnLinks/Item/ColumnLinkRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnLinks/Item/ColumnLinkRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnLinkIdOption = new Option("--columnlink-id", description: "key: id of columnLink") { + var columnLinkIdOption = new Option("--column-link-id", description: "key: id of columnLink") { }; columnLinkIdOption.IsRequired = true; command.AddOption(columnLinkIdOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, string columnLinkId) => { + command.SetHandler(async (string siteId, string listId, string contentTypeId, string columnLinkId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, contentTypeIdOption, columnLinkIdOption); return command; @@ -66,11 +65,11 @@ public Command BuildGetCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnLinkIdOption = new Option("--columnlink-id", description: "key: id of columnLink") { + var columnLinkIdOption = new Option("--column-link-id", description: "key: id of columnLink") { }; columnLinkIdOption.IsRequired = true; command.AddOption(columnLinkIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, string columnLinkId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, string columnLinkId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, contentTypeIdOption, columnLinkIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, contentTypeIdOption, columnLinkIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,11 +113,11 @@ public Command BuildPatchCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnLinkIdOption = new Option("--columnlink-id", description: "key: id of columnLink") { + var columnLinkIdOption = new Option("--column-link-id", description: "key: id of columnLink") { }; columnLinkIdOption.IsRequired = true; command.AddOption(columnLinkIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, string columnLinkId, string body) => { + command.SetHandler(async (string siteId, string listId, string contentTypeId, string columnLinkId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, contentTypeIdOption, columnLinkIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(ColumnLink body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of columns that are required by this content type - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of columns that are required by this content type - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of columns that are required by this content type - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ColumnLink model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of columns that are required by this content type public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnPositions/@Ref/@Ref.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnPositions/@Ref/@Ref.cs deleted file mode 100644 index bb5568af91c..00000000000 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnPositions/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.ColumnPositions.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnPositions/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnPositions/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 2cd3a45768b..00000000000 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnPositions/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,218 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.ColumnPositions.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\contentTypes\{contentType-id}\columnPositions\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Column order information in a content type. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Column order information in a content type."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var listIdOption = new Option("--list-id", description: "key: id of list") { - }; - listIdOption.IsRequired = true; - command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Column order information in a content type. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Column order information in a content type."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var listIdOption = new Option("--list-id", description: "key: id of list") { - }; - listIdOption.IsRequired = true; - command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, contentTypeIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/lists/{list_id}/contentTypes/{contentType_id}/columnPositions/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Column order information in a content type. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Column order information in a content type. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.ColumnPositions.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Column order information in a content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Column order information in a content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.ColumnPositions.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Column order information in a content type. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnPositions/@Ref/RefResponse.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnPositions/@Ref/RefResponse.cs deleted file mode 100644 index 8ddd2e82b6c..00000000000 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnPositions/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.ColumnPositions.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnPositions/ColumnPositionsRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnPositions/ColumnPositionsRequestBuilder.cs index f4072822bbd..e0b65944fdb 100644 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnPositions/ColumnPositionsRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnPositions/ColumnPositionsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.ColumnPositions.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,7 +34,7 @@ public Command BuildGetCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -73,7 +73,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -84,20 +88,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.ColumnPositions.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.ColumnPositions.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -136,18 +135,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Column order information in a content type. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Column order information in a content type. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnPositions/Ref/Ref.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnPositions/Ref/Ref.cs new file mode 100644 index 00000000000..b8ac28a89ed --- /dev/null +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnPositions/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.ColumnPositions.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnPositions/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnPositions/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..ebf3e54cead --- /dev/null +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnPositions/Ref/RefRequestBuilder.cs @@ -0,0 +1,191 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.ColumnPositions.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\contentTypes\{contentType-id}\columnPositions\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Column order information in a content type. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Column order information in a content type."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var listIdOption = new Option("--list-id", description: "key: id of list") { + }; + listIdOption.IsRequired = true; + command.AddOption(listIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Column order information in a content type. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Column order information in a content type."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var listIdOption = new Option("--list-id", description: "key: id of list") { + }; + listIdOption.IsRequired = true; + command.AddOption(listIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, contentTypeIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/lists/{list_id}/contentTypes/{contentType_id}/columnPositions/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Column order information in a content type. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Column order information in a content type. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.ColumnPositions.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Column order information in a content type. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnPositions/Ref/RefResponse.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnPositions/Ref/RefResponse.cs new file mode 100644 index 00000000000..e14f164199c --- /dev/null +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ColumnPositions/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.ColumnPositions.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Columns/ColumnsRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Columns/ColumnsRequestBuilder.cs index d3f0f6550a8..8de34badf11 100644 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Columns/ColumnsRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Columns/ColumnsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Columns.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class ColumnsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ColumnDefinitionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSourceColumnCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSourceColumnCommand()); return commands; } /// @@ -45,7 +44,7 @@ public Command BuildCreateCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, contentTypeIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, contentTypeIdOption, bodyOption, outputOption); return command; } /// @@ -85,7 +83,7 @@ public Command BuildListCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -124,7 +122,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -135,15 +137,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, contentTypeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -198,31 +195,6 @@ public RequestInformation CreatePostRequestInformation(ColumnDefinition body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of column definitions for this contentType. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of column definitions for this contentType. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ColumnDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of column definitions for this contentType. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs index c53d84f3bf2..798389fd572 100644 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Columns/Item/ColumnDefinitionRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Columns.Item.SourceColumn; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,19 +35,18 @@ public Command BuildDeleteCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, string columnDefinitionId) => { + command.SetHandler(async (string siteId, string listId, string contentTypeId, string columnDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, contentTypeIdOption, columnDefinitionIdOption); return command; @@ -67,11 +66,11 @@ public Command BuildGetCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -85,20 +84,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, string columnDefinitionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, string columnDefinitionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, contentTypeIdOption, columnDefinitionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, contentTypeIdOption, columnDefinitionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -116,11 +114,11 @@ public Command BuildPatchCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -128,14 +126,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, string columnDefinitionId, string body) => { + command.SetHandler(async (string siteId, string listId, string contentTypeId, string columnDefinitionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, contentTypeIdOption, columnDefinitionIdOption, bodyOption); return command; @@ -214,42 +211,6 @@ public RequestInformation CreatePatchRequestInformation(ColumnDefinition body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of column definitions for this contentType. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of column definitions for this contentType. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of column definitions for this contentType. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ColumnDefinition model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of column definitions for this contentType. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/@Ref.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/@Ref.cs deleted file mode 100644 index 71cc1b6a86b..00000000000 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Columns.Item.SourceColumn.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs deleted file mode 100644 index e76f4d49b8f..00000000000 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Columns/Item/SourceColumn/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,226 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Columns.Item.SourceColumn.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\contentTypes\{contentType-id}\columns\{columnDefinition-id}\sourceColumn\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The source column for content type column. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var listIdOption = new Option("--list-id", description: "key: id of list") { - }; - listIdOption.IsRequired = true; - command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, string columnDefinitionId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, listIdOption, contentTypeIdOption, columnDefinitionIdOption); - return command; - } - /// - /// The source column for content type column. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var listIdOption = new Option("--list-id", description: "key: id of list") { - }; - listIdOption.IsRequired = true; - command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, string columnDefinitionId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, contentTypeIdOption, columnDefinitionIdOption); - return command; - } - /// - /// The source column for content type column. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The source column for content type column."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var listIdOption = new Option("--list-id", description: "key: id of list") { - }; - listIdOption.IsRequired = true; - command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { - }; - contentTypeIdOption.IsRequired = true; - command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { - }; - columnDefinitionIdOption.IsRequired = true; - command.AddOption(columnDefinitionIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, string columnDefinitionId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, listIdOption, contentTypeIdOption, columnDefinitionIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/lists/{list_id}/contentTypes/{contentType_id}/columns/{columnDefinition_id}/sourceColumn/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The source column for content type column. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Columns.Item.SourceColumn.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Columns.Item.SourceColumn.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Columns/Item/SourceColumn/Ref/Ref.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Columns/Item/SourceColumn/Ref/Ref.cs new file mode 100644 index 00000000000..b1fb87758ac --- /dev/null +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Columns/Item/SourceColumn/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Columns.Item.SourceColumn.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..88ddd13c26b --- /dev/null +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Columns/Item/SourceColumn/Ref/RefRequestBuilder.cs @@ -0,0 +1,188 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Columns.Item.SourceColumn.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\contentTypes\{contentType-id}\columns\{columnDefinition-id}\sourceColumn\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The source column for content type column. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var listIdOption = new Option("--list-id", description: "key: id of list") { + }; + listIdOption.IsRequired = true; + command.AddOption(listIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, string columnDefinitionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, listIdOption, contentTypeIdOption, columnDefinitionIdOption); + return command; + } + /// + /// The source column for content type column. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var listIdOption = new Option("--list-id", description: "key: id of list") { + }; + listIdOption.IsRequired = true; + command.AddOption(listIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, string columnDefinitionId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, contentTypeIdOption, columnDefinitionIdOption, outputOption); + return command; + } + /// + /// The source column for content type column. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The source column for content type column."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var listIdOption = new Option("--list-id", description: "key: id of list") { + }; + listIdOption.IsRequired = true; + command.AddOption(listIdOption); + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { + }; + contentTypeIdOption.IsRequired = true; + command.AddOption(contentTypeIdOption); + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { + }; + columnDefinitionIdOption.IsRequired = true; + command.AddOption(columnDefinitionIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, string columnDefinitionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, listIdOption, contentTypeIdOption, columnDefinitionIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/lists/{list_id}/contentTypes/{contentType_id}/columns/{columnDefinition_id}/sourceColumn/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The source column for content type column. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The source column for content type column. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The source column for content type column. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Columns.Item.SourceColumn.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs index 6c903cc669f..bc630294b76 100644 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Columns/Item/SourceColumn/SourceColumnRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Columns.Item.SourceColumn.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,11 +35,11 @@ public Command BuildGetCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - var columnDefinitionIdOption = new Option("--columndefinition-id", description: "key: id of columnDefinition") { + var columnDefinitionIdOption = new Option("--column-definition-id", description: "key: id of columnDefinition") { }; columnDefinitionIdOption.IsRequired = true; command.AddOption(columnDefinitionIdOption); @@ -53,25 +53,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, string columnDefinitionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, string columnDefinitionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, contentTypeIdOption, columnDefinitionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, contentTypeIdOption, columnDefinitionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Columns.Item.SourceColumn.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Columns.Item.SourceColumn.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -111,18 +110,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The source column for content type column. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The source column for content type column. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ContentTypeRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ContentTypeRequestBuilder.cs index ab70cabca64..56221cc9361 100644 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ContentTypeRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/ContentTypeRequestBuilder.cs @@ -11,10 +11,10 @@ using ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Unpublish; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,7 +37,7 @@ public Command BuildAssociateWithHubSitesCommand() { } public Command BuildBaseCommand() { var command = new Command("base"); - var builder = new ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.@Base.BaseRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Base.BaseRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAssociateWithHubSitesCommand()); command.AddCommand(builder.BuildCopyToDefaultContentLocationCommand()); command.AddCommand(builder.BuildGetCommand()); @@ -57,6 +57,9 @@ public Command BuildBaseTypesCommand() { public Command BuildColumnLinksCommand() { var command = new Command("column-links"); var builder = new ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.ColumnLinks.ColumnLinksRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -71,6 +74,9 @@ public Command BuildColumnPositionsCommand() { public Command BuildColumnsCommand() { var command = new Command("columns"); var builder = new ApiSdk.Sites.Item.Lists.Item.ContentTypes.Item.Columns.ColumnsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -96,15 +102,14 @@ public Command BuildDeleteCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId) => { + command.SetHandler(async (string siteId, string listId, string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, contentTypeIdOption); return command; @@ -124,7 +129,7 @@ public Command BuildGetCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -138,20 +143,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, contentTypeIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, contentTypeIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -169,7 +173,7 @@ public Command BuildPatchCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -177,14 +181,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, string body) => { + command.SetHandler(async (string siteId, string listId, string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, contentTypeIdOption, bodyOption); return command; @@ -269,47 +272,11 @@ public RequestInformation CreatePatchRequestInformation(ContentType body, Action return requestInfo; } /// - /// The collection of content types present in this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of content types present in this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\contentTypes\{contentType-id}\microsoft.graph.isPublished() /// public IsPublishedRequestBuilder IsPublished() { return new IsPublishedRequestBuilder(PathParameters, RequestAdapter); } - /// - /// The collection of content types present in this list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ContentType model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of content types present in this list. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs index 299170c76f7..5282f013303 100644 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/CopyToDefaultContentLocation/CopyToDefaultContentLocationRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,7 +33,7 @@ public Command BuildPostCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId, string body) => { + command.SetHandler(async (string siteId, string listId, string contentTypeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, contentTypeIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(CopyToDefaultContentLocat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToDefaultContentLocation - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToDefaultContentLocationRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/IsPublished/IsPublishedRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/IsPublished/IsPublishedRequestBuilder.cs index d0a0661a02a..9deac76cec3 100644 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/IsPublished/IsPublishedRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/IsPublished/IsPublishedRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,22 +33,21 @@ public Command BuildGetCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string contentTypeId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteBoolValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, contentTypeIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, contentTypeIdOption, outputOption); return command; } /// @@ -79,16 +78,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function isPublished - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Publish/PublishRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Publish/PublishRequestBuilder.cs index 16d6e5b3180..912217a5650 100644 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Publish/PublishRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Publish/PublishRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,15 +33,14 @@ public Command BuildPostCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId) => { + command.SetHandler(async (string siteId, string listId, string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, contentTypeIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action publish - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Unpublish/UnpublishRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Unpublish/UnpublishRequestBuilder.cs index 1f907b9c15e..1df11de9f5f 100644 --- a/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Unpublish/UnpublishRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/ContentTypes/Item/Unpublish/UnpublishRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,15 +33,14 @@ public Command BuildPostCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var contentTypeIdOption = new Option("--contenttype-id", description: "key: id of contentType") { + var contentTypeIdOption = new Option("--content-type-id", description: "key: id of contentType") { }; contentTypeIdOption.IsRequired = true; command.AddOption(contentTypeIdOption); - command.SetHandler(async (string siteId, string listId, string contentTypeId) => { + command.SetHandler(async (string siteId, string listId, string contentTypeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, contentTypeIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action unpublish - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Lists/Item/Drive/DriveRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/Drive/DriveRequestBuilder.cs index fa23bb6db0d..96bd07d5961 100644 --- a/src/generated/Sites/Item/Lists/Item/Drive/DriveRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/Drive/DriveRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - command.SetHandler(async (string siteId, string listId) => { + command.SetHandler(async (string siteId, string listId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption); return command; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string listId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string body) => { + command.SetHandler(async (string siteId, string listId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Only present on document libraries. Allows access to the list as a [drive][] resource with [driveItems][driveItem]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Only present on document libraries. Allows access to the list as a [drive][] resource with [driveItems][driveItem]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Only present on document libraries. Allows access to the list as a [drive][] resource with [driveItems][driveItem]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Drive model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Only present on document libraries. Allows access to the list as a [drive][] resource with [driveItems][driveItem]. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Lists/Item/Items/Item/Analytics/@Ref/@Ref.cs b/src/generated/Sites/Item/Lists/Item/Items/Item/Analytics/@Ref/@Ref.cs deleted file mode 100644 index 5450916db43..00000000000 --- a/src/generated/Sites/Item/Lists/Item/Items/Item/Analytics/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.Lists.Item.Items.Item.Analytics.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/Lists/Item/Items/Item/Analytics/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/Items/Item/Analytics/@Ref/RefRequestBuilder.cs deleted file mode 100644 index f7b8c4872ef..00000000000 --- a/src/generated/Sites/Item/Lists/Item/Items/Item/Analytics/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,214 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.Lists.Item.Items.Item.Analytics.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\items\{listItem-id}\analytics\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Analytics about the view activities that took place on this item. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Analytics about the view activities that took place on this item."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var listIdOption = new Option("--list-id", description: "key: id of list") { - }; - listIdOption.IsRequired = true; - command.AddOption(listIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { - }; - listItemIdOption.IsRequired = true; - command.AddOption(listItemIdOption); - command.SetHandler(async (string siteId, string listId, string listItemId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, listIdOption, listItemIdOption); - return command; - } - /// - /// Analytics about the view activities that took place on this item. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Analytics about the view activities that took place on this item."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var listIdOption = new Option("--list-id", description: "key: id of list") { - }; - listIdOption.IsRequired = true; - command.AddOption(listIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { - }; - listItemIdOption.IsRequired = true; - command.AddOption(listItemIdOption); - command.SetHandler(async (string siteId, string listId, string listItemId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, listItemIdOption); - return command; - } - /// - /// Analytics about the view activities that took place on this item. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Analytics about the view activities that took place on this item."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var listIdOption = new Option("--list-id", description: "key: id of list") { - }; - listIdOption.IsRequired = true; - command.AddOption(listIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { - }; - listItemIdOption.IsRequired = true; - command.AddOption(listItemIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string listItemId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, listIdOption, listItemIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/lists/{list_id}/items/{listItem_id}/analytics/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Analytics about the view activities that took place on this item. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Analytics about the view activities that took place on this item. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Analytics about the view activities that took place on this item. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.Lists.Item.Items.Item.Analytics.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.Lists.Item.Items.Item.Analytics.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/Lists/Item/Items/Item/Analytics/AnalyticsRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/Items/Item/Analytics/AnalyticsRequestBuilder.cs index 5254c432938..bd71ee2ade4 100644 --- a/src/generated/Sites/Item/Lists/Item/Items/Item/Analytics/AnalyticsRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/Items/Item/Analytics/AnalyticsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Lists.Item.Items.Item.Analytics.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,7 +35,7 @@ public Command BuildGetCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -49,25 +49,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string listId, string listItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string listItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, listItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, listItemIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.Lists.Item.Items.Item.Analytics.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.Lists.Item.Items.Item.Analytics.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -107,18 +106,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Analytics about the view activities that took place on this item. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Lists/Item/Items/Item/Analytics/Ref/Ref.cs b/src/generated/Sites/Item/Lists/Item/Items/Item/Analytics/Ref/Ref.cs new file mode 100644 index 00000000000..358e1c6b799 --- /dev/null +++ b/src/generated/Sites/Item/Lists/Item/Items/Item/Analytics/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.Lists.Item.Items.Item.Analytics.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/Lists/Item/Items/Item/Analytics/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/Items/Item/Analytics/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..5accbcba4b7 --- /dev/null +++ b/src/generated/Sites/Item/Lists/Item/Items/Item/Analytics/Ref/RefRequestBuilder.cs @@ -0,0 +1,176 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.Lists.Item.Items.Item.Analytics.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\items\{listItem-id}\analytics\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Analytics about the view activities that took place on this item. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Analytics about the view activities that took place on this item."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var listIdOption = new Option("--list-id", description: "key: id of list") { + }; + listIdOption.IsRequired = true; + command.AddOption(listIdOption); + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { + }; + listItemIdOption.IsRequired = true; + command.AddOption(listItemIdOption); + command.SetHandler(async (string siteId, string listId, string listItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, listIdOption, listItemIdOption); + return command; + } + /// + /// Analytics about the view activities that took place on this item. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Analytics about the view activities that took place on this item."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var listIdOption = new Option("--list-id", description: "key: id of list") { + }; + listIdOption.IsRequired = true; + command.AddOption(listIdOption); + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { + }; + listItemIdOption.IsRequired = true; + command.AddOption(listItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string listItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, listItemIdOption, outputOption); + return command; + } + /// + /// Analytics about the view activities that took place on this item. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Analytics about the view activities that took place on this item."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var listIdOption = new Option("--list-id", description: "key: id of list") { + }; + listIdOption.IsRequired = true; + command.AddOption(listIdOption); + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { + }; + listItemIdOption.IsRequired = true; + command.AddOption(listItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string listId, string listItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, listIdOption, listItemIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/lists/{list_id}/items/{listItem_id}/analytics/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Analytics about the view activities that took place on this item. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Analytics about the view activities that took place on this item. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Analytics about the view activities that took place on this item. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.Lists.Item.Items.Item.Analytics.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/Lists/Item/Items/Item/DriveItem/Content/ContentRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/Items/Item/DriveItem/Content/ContentRequestBuilder.cs index 1955379c295..1f4c4fa7134 100644 --- a/src/generated/Sites/Item/Lists/Item/Items/Item/DriveItem/Content/ContentRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/Items/Item/DriveItem/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,28 +33,30 @@ public Command BuildGetCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string siteId, string listId, string listItemId, FileInfo output) => { + command.SetHandler(async (string siteId, string listId, string listItemId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, siteIdOption, listIdOption, listItemIdOption, outputOption); + }, siteIdOption, listIdOption, listItemIdOption, fileOption, outputOption); return command; } /// @@ -72,7 +74,7 @@ public Command BuildPutCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -80,12 +82,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string listItemId, FileInfo file) => { + command.SetHandler(async (string siteId, string listId, string listItemId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, listItemIdOption, bodyOption); return command; @@ -136,29 +137,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property driveItem from sites - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property driveItem in sites - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Lists/Item/Items/Item/DriveItem/DriveItemRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/Items/Item/DriveItem/DriveItemRequestBuilder.cs index ac69c3eb78f..9c552fa9f19 100644 --- a/src/generated/Sites/Item/Lists/Item/Items/Item/DriveItem/DriveItemRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/Items/Item/DriveItem/DriveItemRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Lists.Item.Items.Item.DriveItem.Content; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -42,15 +42,14 @@ public Command BuildDeleteCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - command.SetHandler(async (string siteId, string listId, string listItemId) => { + command.SetHandler(async (string siteId, string listId, string listItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, listItemIdOption); return command; @@ -70,7 +69,7 @@ public Command BuildGetCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string listId, string listItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string listItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, listItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, listItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,7 +113,7 @@ public Command BuildPatchCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -123,14 +121,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string listItemId, string body) => { + command.SetHandler(async (string siteId, string listId, string listItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, listItemIdOption, bodyOption); return command; @@ -202,42 +199,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// For document libraries, the driveItem relationship exposes the listItem as a [driveItem][] - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// For document libraries, the driveItem relationship exposes the listItem as a [driveItem][] - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// For document libraries, the driveItem relationship exposes the listItem as a [driveItem][] - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// For document libraries, the driveItem relationship exposes the listItem as a [driveItem][] public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Lists/Item/Items/Item/Fields/FieldsRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/Items/Item/Fields/FieldsRequestBuilder.cs index fa216b01234..c94ac45ab39 100644 --- a/src/generated/Sites/Item/Lists/Item/Items/Item/Fields/FieldsRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/Items/Item/Fields/FieldsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - command.SetHandler(async (string siteId, string listId, string listItemId) => { + command.SetHandler(async (string siteId, string listId, string listItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, listItemIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string listId, string listItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string listItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, listItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, listItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string listItemId, string body) => { + command.SetHandler(async (string siteId, string listId, string listItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, listItemIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(FieldValueSet body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The values of the columns set on this list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The values of the columns set on this list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The values of the columns set on this list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(FieldValueSet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The values of the columns set on this list item. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Lists/Item/Items/Item/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/Items/Item/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs index 7c974bd6010..6acdaf257f2 100644 --- a/src/generated/Sites/Item/Lists/Item/Items/Item/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/Items/Item/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,22 +33,21 @@ public Command BuildGetCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - command.SetHandler(async (string siteId, string listId, string listItemId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string listItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, listItemIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, listItemIdOption, outputOption); return command; } /// @@ -79,16 +78,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getActivitiesByInterval - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Lists/Item/Items/Item/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/Items/Item/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs index dca38c2e9af..d47c36dd6f5 100644 --- a/src/generated/Sites/Item/Lists/Item/Items/Item/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/Items/Item/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,15 +33,15 @@ public Command BuildGetCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var startDateTimeOption = new Option("--startdatetime", description: "Usage: startDateTime={startDateTime}") { + var startDateTimeOption = new Option("--start-date-time", description: "Usage: startDateTime={startDateTime}") { }; startDateTimeOption.IsRequired = true; command.AddOption(startDateTimeOption); - var endDateTimeOption = new Option("--enddatetime", description: "Usage: endDateTime={endDateTime}") { + var endDateTimeOption = new Option("--end-date-time", description: "Usage: endDateTime={endDateTime}") { }; endDateTimeOption.IsRequired = true; command.AddOption(endDateTimeOption); @@ -49,18 +49,17 @@ public Command BuildGetCommand() { }; intervalOption.IsRequired = true; command.AddOption(intervalOption); - command.SetHandler(async (string siteId, string listId, string listItemId, string startDateTime, string endDateTime, string interval) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string listItemId, string startDateTime, string endDateTime, string interval, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, listItemIdOption, startDateTimeOption, endDateTimeOption, intervalOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, listItemIdOption, startDateTimeOption, endDateTimeOption, intervalOption, outputOption); return command; } /// @@ -97,16 +96,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getActivitiesByInterval - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Lists/Item/Items/Item/ListItemRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/Items/Item/ListItemRequestBuilder.cs index 174d972fd6d..8b12c140f80 100644 --- a/src/generated/Sites/Item/Lists/Item/Items/Item/ListItemRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/Items/Item/ListItemRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Sites.Item.Lists.Item.Items.Item.Versions; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,15 +47,14 @@ public Command BuildDeleteCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - command.SetHandler(async (string siteId, string listId, string listItemId) => { + command.SetHandler(async (string siteId, string listId, string listItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, listItemIdOption); return command; @@ -92,7 +91,7 @@ public Command BuildGetCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -106,20 +105,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string listId, string listItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string listItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, listItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, listItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -137,7 +135,7 @@ public Command BuildPatchCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -145,14 +143,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string listItemId, string body) => { + command.SetHandler(async (string siteId, string listId, string listItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, listItemIdOption, bodyOption); return command; @@ -160,6 +157,9 @@ public Command BuildPatchCommand() { public Command BuildVersionsCommand() { var command = new Command("versions"); var builder = new ApiSdk.Sites.Item.Lists.Item.Items.Item.Versions.VersionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -232,17 +232,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. return requestInfo; } /// - /// All items contained in the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \sites\{site-id}\lists\{list-id}\items\{listItem-id}\microsoft.graph.getActivitiesByInterval() /// public GetActivitiesByIntervalRequestBuilder GetActivitiesByInterval() { @@ -260,31 +249,6 @@ public GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalReques if(string.IsNullOrEmpty(startDateTime)) throw new ArgumentNullException(nameof(startDateTime)); return new GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder(PathParameters, RequestAdapter, startDateTime, endDateTime, interval); } - /// - /// All items contained in the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All items contained in the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.ListItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// All items contained in the list. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Lists/Item/Items/Item/Versions/Item/Fields/FieldsRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/Items/Item/Versions/Item/Fields/FieldsRequestBuilder.cs index fae9922c9d2..be8bfaab8df 100644 --- a/src/generated/Sites/Item/Lists/Item/Items/Item/Versions/Item/Fields/FieldsRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/Items/Item/Versions/Item/Fields/FieldsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); - command.SetHandler(async (string siteId, string listId, string listItemId, string listItemVersionId) => { + command.SetHandler(async (string siteId, string listId, string listItemId, string listItemVersionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, listItemIdOption, listItemVersionIdOption); return command; @@ -66,11 +65,11 @@ public Command BuildGetCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string listId, string listItemId, string listItemVersionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string listItemId, string listItemVersionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, listItemIdOption, listItemVersionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, listItemIdOption, listItemVersionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,11 +113,11 @@ public Command BuildPatchCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string listItemId, string listItemVersionId, string body) => { + command.SetHandler(async (string siteId, string listId, string listItemId, string listItemVersionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, listItemIdOption, listItemVersionIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(FieldValueSet body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of the fields and values for this version of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of the fields and values for this version of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of the fields and values for this version of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(FieldValueSet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of the fields and values for this version of the list item. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Lists/Item/Items/Item/Versions/Item/ListItemVersionRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/Items/Item/Versions/Item/ListItemVersionRequestBuilder.cs index 1934e4c6b1b..c3165211052 100644 --- a/src/generated/Sites/Item/Lists/Item/Items/Item/Versions/Item/ListItemVersionRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/Items/Item/Versions/Item/ListItemVersionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Sites.Item.Lists.Item.Items.Item.Versions.Item.RestoreVersion; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -36,19 +36,18 @@ public Command BuildDeleteCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); - command.SetHandler(async (string siteId, string listId, string listItemId, string listItemVersionId) => { + command.SetHandler(async (string siteId, string listId, string listItemId, string listItemVersionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, listItemIdOption, listItemVersionIdOption); return command; @@ -76,11 +75,11 @@ public Command BuildGetCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); @@ -94,20 +93,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string listId, string listItemId, string listItemVersionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string listItemId, string listItemVersionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, listItemIdOption, listItemVersionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, listItemIdOption, listItemVersionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -125,11 +123,11 @@ public Command BuildPatchCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); @@ -137,14 +135,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string listItemId, string listItemVersionId, string body) => { + command.SetHandler(async (string siteId, string listId, string listItemId, string listItemVersionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, listItemIdOption, listItemVersionIdOption, bodyOption); return command; @@ -222,42 +219,6 @@ public RequestInformation CreatePatchRequestInformation(ListItemVersion body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ListItemVersion model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of previous versions of the list item. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Lists/Item/Items/Item/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/Items/Item/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs index 69fe76d6eb0..91223fcdf06 100644 --- a/src/generated/Sites/Item/Lists/Item/Items/Item/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/Items/Item/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,19 +33,18 @@ public Command BuildPostCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); - command.SetHandler(async (string siteId, string listId, string listItemId, string listItemVersionId) => { + command.SetHandler(async (string siteId, string listId, string listItemId, string listItemVersionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, listItemIdOption, listItemVersionIdOption); return command; @@ -78,16 +77,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action restoreVersion - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Lists/Item/Items/Item/Versions/VersionsRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/Items/Item/Versions/VersionsRequestBuilder.cs index e301f1fb66f..687adb4f59a 100644 --- a/src/generated/Sites/Item/Lists/Item/Items/Item/Versions/VersionsRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/Items/Item/Versions/VersionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Lists.Item.Items.Item.Versions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class VersionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ListItemVersionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildFieldsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildRestoreVersionCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFieldsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRestoreVersionCommand()); return commands; } /// @@ -46,7 +45,7 @@ public Command BuildCreateCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string listItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string listItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, listItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, listItemIdOption, bodyOption, outputOption); return command; } /// @@ -86,7 +84,7 @@ public Command BuildListCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - var listItemIdOption = new Option("--listitem-id", description: "key: id of listItem") { + var listItemIdOption = new Option("--list-item-id", description: "key: id of listItem") { }; listItemIdOption.IsRequired = true; command.AddOption(listItemIdOption); @@ -125,7 +123,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string listId, string listItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string listItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, listItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, listItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(ListItemVersion body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ListItemVersion model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of previous versions of the list item. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Lists/Item/Items/ItemsRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/Items/ItemsRequestBuilder.cs index 6b7cfa45c79..7cec23b92de 100644 --- a/src/generated/Sites/Item/Lists/Item/Items/ItemsRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/Items/ItemsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Lists.Item.Items.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class ItemsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ListItemRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAnalyticsCommand(), - builder.BuildDeleteCommand(), - builder.BuildDriveItemCommand(), - builder.BuildFieldsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildVersionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAnalyticsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDriveItemCommand()); + commands.Add(builder.BuildFieldsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildVersionsCommand()); return commands; } /// @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, bodyOption, outputOption); return command; } /// @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string listId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -130,15 +132,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -193,31 +190,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All items contained in the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All items contained in the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.ListItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// All items contained in the list. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Lists/Item/ListRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/ListRequestBuilder.cs index 36047db24cb..50065f97bb7 100644 --- a/src/generated/Sites/Item/Lists/Item/ListRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/ListRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Sites.Item.Lists.Item.Subscriptions; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,6 +27,9 @@ public class ListRequestBuilder { public Command BuildColumnsCommand() { var command = new Command("columns"); var builder = new ApiSdk.Sites.Item.Lists.Item.Columns.ColumnsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -35,6 +38,9 @@ public Command BuildContentTypesCommand() { var command = new Command("content-types"); var builder = new ApiSdk.Sites.Item.Lists.Item.ContentTypes.ContentTypesRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCopyCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -54,11 +60,10 @@ public Command BuildDeleteCommand() { }; listIdOption.IsRequired = true; command.AddOption(listIdOption); - command.SetHandler(async (string siteId, string listId) => { + command.SetHandler(async (string siteId, string listId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption); return command; @@ -96,25 +101,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string listId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildItemsCommand() { var command = new Command("items"); var builder = new ApiSdk.Sites.Item.Lists.Item.Items.ItemsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -138,14 +145,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string body) => { + command.SetHandler(async (string siteId, string listId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, bodyOption); return command; @@ -153,6 +159,9 @@ public Command BuildPatchCommand() { public Command BuildSubscriptionsCommand() { var command = new Command("subscriptions"); var builder = new ApiSdk.Sites.Item.Lists.Item.Subscriptions.SubscriptionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -224,42 +233,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of lists under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of lists under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of lists under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.List model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of lists under this site. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Lists/Item/Subscriptions/Item/SubscriptionRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/Subscriptions/Item/SubscriptionRequestBuilder.cs index f583c38bbed..6237a985aaf 100644 --- a/src/generated/Sites/Item/Lists/Item/Subscriptions/Item/SubscriptionRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/Subscriptions/Item/SubscriptionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; subscriptionIdOption.IsRequired = true; command.AddOption(subscriptionIdOption); - command.SetHandler(async (string siteId, string listId, string subscriptionId) => { + command.SetHandler(async (string siteId, string listId, string subscriptionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, subscriptionIdOption); return command; @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string listId, string subscriptionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string subscriptionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, subscriptionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, subscriptionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string subscriptionId, string body) => { + command.SetHandler(async (string siteId, string listId, string subscriptionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, listIdOption, subscriptionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Subscription body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The set of subscriptions on the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The set of subscriptions on the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The set of subscriptions on the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Subscription model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The set of subscriptions on the list. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Lists/Item/Subscriptions/SubscriptionsRequestBuilder.cs b/src/generated/Sites/Item/Lists/Item/Subscriptions/SubscriptionsRequestBuilder.cs index f209352cfc1..40b17fbd905 100644 --- a/src/generated/Sites/Item/Lists/Item/Subscriptions/SubscriptionsRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/Item/Subscriptions/SubscriptionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Lists.Item.Subscriptions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SubscriptionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SubscriptionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string listId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string listId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string listId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, listIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, listIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(Subscription body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The set of subscriptions on the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The set of subscriptions on the list. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Subscription model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The set of subscriptions on the list. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Lists/ListsRequestBuilder.cs b/src/generated/Sites/Item/Lists/ListsRequestBuilder.cs index b306ff05b20..32a2f4688e2 100644 --- a/src/generated/Sites/Item/Lists/ListsRequestBuilder.cs +++ b/src/generated/Sites/Item/Lists/ListsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Lists.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class ListsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ListRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildColumnsCommand(), - builder.BuildContentTypesCommand(), - builder.BuildDeleteCommand(), - builder.BuildDriveCommand(), - builder.BuildGetCommand(), - builder.BuildItemsCommand(), - builder.BuildPatchCommand(), - builder.BuildSubscriptionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildColumnsCommand()); + commands.Add(builder.BuildContentTypesCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDriveCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildItemsCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSubscriptionsCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, bodyOption, outputOption); return command; } /// @@ -112,7 +110,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -186,31 +183,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of lists under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of lists under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.List model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of lists under this site. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Notebooks/GetNotebookFromWebUrl/GetNotebookFromWebUrlRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/GetNotebookFromWebUrl/GetNotebookFromWebUrlRequestBuilder.cs index 7658ba745ff..207be6b7482 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/GetNotebookFromWebUrl/GetNotebookFromWebUrlRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/GetNotebookFromWebUrl/GetNotebookFromWebUrlRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(GetNotebookFromWebUrlRequ requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getNotebookFromWebUrl - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GetNotebookFromWebUrlRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes CopyNotebookModel public class GetNotebookFromWebUrlResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Notebooks/GetRecentNotebooksWithIncludePersonalNotebooks/GetRecentNotebooksWithIncludePersonalNotebooksRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/GetRecentNotebooksWithIncludePersonalNotebooks/GetRecentNotebooksWithIncludePersonalNotebooksRequestBuilder.cs index 221316d5176..0d821d44c94 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/GetRecentNotebooksWithIncludePersonalNotebooks/GetRecentNotebooksWithIncludePersonalNotebooksRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/GetRecentNotebooksWithIncludePersonalNotebooks/GetRecentNotebooksWithIncludePersonalNotebooksRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,22 +29,21 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var includePersonalNotebooksOption = new Option("--includepersonalnotebooks", description: "Usage: includePersonalNotebooks={includePersonalNotebooks}") { + var includePersonalNotebooksOption = new Option("--include-personal-notebooks", description: "Usage: includePersonalNotebooks={includePersonalNotebooks}") { }; includePersonalNotebooksOption.IsRequired = true; command.AddOption(includePersonalNotebooksOption); - command.SetHandler(async (string siteId, bool? includePersonalNotebooks) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, bool? includePersonalNotebooks, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, includePersonalNotebooksOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, includePersonalNotebooksOption, outputOption); return command; } /// @@ -77,16 +76,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getRecentNotebooks - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/CopyNotebook/CopyNotebookRequestBuilder.cs index ca9e49983fc..c648b9d1438 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/NotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/NotebookRequestBuilder.cs index 4b3caf27376..3cdd5ac2bdf 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/NotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/NotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.Onenote.Notebooks.Item.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -43,11 +43,10 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - command.SetHandler(async (string siteId, string notebookId) => { + command.SetHandler(async (string siteId, string notebookId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption); return command; @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string body) => { + command.SetHandler(async (string siteId, string notebookId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, bodyOption); return command; @@ -127,6 +124,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Sites.Item.Onenote.Notebooks.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,6 +134,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Sites.Item.Onenote.Notebooks.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -205,42 +208,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 641997d53ee..5d74e6a936f 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,7 +34,7 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index f209100e5f8..a3f5584787e 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Notebooks.Item.SectionGroups.Item.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,15 +41,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId) => { + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, sectionGroupIdOption); return command; @@ -69,7 +68,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -114,7 +112,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string body) => { + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, sectionGroupIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 5632f5af8ec..f5778ab7213 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId) => { + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, sectionGroupIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string body) => { + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, sectionGroupIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index e110e115e7d..5ebc2bd92d8 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Sites.Item.Onenote.Notebooks.Item.SectionGroups.Item.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId) => { + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, sectionGroupIdOption); return command; @@ -66,7 +65,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -80,20 +79,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -128,7 +126,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -136,14 +134,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string body) => { + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, sectionGroupIdOption, bodyOption); return command; @@ -151,6 +148,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Sites.Item.Onenote.Notebooks.Item.SectionGroups.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -158,6 +158,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Sites.Item.Onenote.Notebooks.Item.SectionGroups.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -229,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index cecf05b1240..e0fce17fc12 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -66,11 +65,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -115,11 +113,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs index 20ec58f0a17..93826844812 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Notebooks.Item.SectionGroups.Item.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,7 +43,7 @@ public Command BuildCreateCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildListCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index d8e04e04242..d3be7e0f589 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 9e11c47ea24..854ef57e4c4 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index ed4dd79ed41..2c2dc784d2d 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Sites.Item.Onenote.Notebooks.Item.SectionGroups.Item.Sections.Item.ParentSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -51,19 +51,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -83,11 +82,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -101,25 +100,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Sites.Item.Onenote.Notebooks.Item.SectionGroups.Item.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -156,11 +157,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -168,14 +169,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -247,42 +247,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index 3898c7ea37b..df9dd838158 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,36 +33,38 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo output) => { + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); + }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, fileOption, outputOption); return command; } /// @@ -80,15 +82,15 @@ public Command BuildPutCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -96,12 +98,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file) => { + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -152,29 +153,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from sites - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in sites - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 19156c09dca..a58596c0960 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,15 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -50,21 +50,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -98,19 +97,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index 89e89f48dcc..74ef8e6f4ad 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Sites.Item.Onenote.Notebooks.Item.SectionGroups.Item.Sections.Item.Pages.Item.Preview; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -53,23 +53,22 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -89,15 +88,15 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -111,20 +110,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -167,15 +165,15 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -183,14 +181,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -263,42 +260,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \sites\{site-id}\onenote\notebooks\{notebook-id}\sectionGroups\{sectionGroup-id}\sections\{onenoteSection-id}\pages\{onenotePage-id}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index 4d1790ba7dd..c3afadc5286 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,15 +33,15 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -49,14 +49,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -92,18 +91,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 7e62f93e0a1..7099bf12c99 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,15 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -50,21 +50,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -98,19 +97,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 953c4716ce8..7b7884456ae 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Notebooks.Item.SectionGroups.Item.Sections.Item.Pages.Item.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,23 +41,22 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -77,15 +76,15 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -99,20 +98,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -130,15 +128,15 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -146,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -225,42 +222,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 438c58bed1f..4a7148ebd32 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,15 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -50,21 +50,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -98,19 +97,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 36fa85efed2..3e6f17658c2 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,15 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -50,21 +50,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -98,19 +97,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs index e74aca50b89..cad53f8cba6 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Sites.Item.Onenote.Notebooks.Item.SectionGroups.Item.Sections.Item.Pages.Item.ParentSection.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -48,23 +48,22 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -84,15 +83,15 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -106,20 +105,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -137,15 +135,15 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -153,14 +151,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -232,42 +229,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index 19060810c51..fbdd137c20e 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,30 +34,29 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); return command; } /// @@ -88,17 +87,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs index a2463bf6747..a59de4f8364 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Notebooks.Item.SectionGroups.Item.Sections.Item.Pages.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -49,11 +48,11 @@ public Command BuildCreateCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -61,21 +60,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -93,11 +91,11 @@ public Command BuildListCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -136,7 +134,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -147,15 +149,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -210,31 +207,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 1887d42cd3a..175586cb979 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 3ceeda76ed6..23151319207 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Notebooks.Item.SectionGroups.Item.Sections.Item.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,19 +41,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -73,11 +72,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -91,20 +90,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -122,11 +120,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index ab90243ebc9..90959ef5901 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -66,11 +65,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,11 +113,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/SectionsRequestBuilder.cs index 168f980d5a5..299b88fc926 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Notebooks.Item.SectionGroups.Item.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -49,7 +48,7 @@ public Command BuildCreateCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -57,21 +56,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -89,7 +87,7 @@ public Command BuildListCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -128,7 +126,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -139,15 +141,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -202,31 +199,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/SectionGroupsRequestBuilder.cs index d13edf23a03..3f67d24d135 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Notebooks.Item.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, bodyOption, outputOption); return command; } /// @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -130,15 +132,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -193,31 +190,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index f8723cee604..4522ca4383d 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,7 +34,7 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index fc639358b6b..5ddf2b16e5b 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,7 +34,7 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index d8eededd289..5d6a8e102ff 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Sites.Item.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -51,15 +51,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, onenoteSectionIdOption); return command; @@ -79,7 +78,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -93,25 +92,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Sites.Item.Onenote.Notebooks.Item.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -131,7 +132,6 @@ public Command BuildParentSectionGroupCommand() { command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); command.AddCommand(builder.BuildPatchCommand()); command.AddCommand(builder.BuildSectionGroupsCommand()); command.AddCommand(builder.BuildSectionsCommand()); @@ -152,7 +152,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -160,14 +160,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -239,42 +238,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index ea269bf6f00..d2e9c633738 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,32 +33,34 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, FileInfo output) => { + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); + }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, fileOption, outputOption); return command; } /// @@ -76,11 +78,11 @@ public Command BuildPutCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -88,12 +90,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, FileInfo file) => { + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -144,29 +145,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from sites - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in sites - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 1f68fd8639b..dc58ffc96eb 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index 76f77c7643b..7b34739ebf2 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Sites.Item.Onenote.Notebooks.Item.Sections.Item.Pages.Item.Preview; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -53,19 +53,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -85,11 +84,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -103,20 +102,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -159,11 +157,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -171,14 +169,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -251,42 +248,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \sites\{site-id}\onenote\notebooks\{notebook-id}\sections\{onenoteSection-id}\pages\{onenotePage-id}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index bcbcbec7992..6712576ba9e 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,11 +33,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index fa93e58e07a..53ff6bd34d1 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 5871b6f3f9f..bd9c91e6dac 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Notebooks.Item.Sections.Item.Pages.Item.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,19 +41,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -73,11 +72,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -91,20 +90,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -122,11 +120,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 18ae66b2540..91cebb67556 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 5bdc1b05a22..f8508e834b3 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs index 7046da57a1d..8be517efdf8 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Sites.Item.Onenote.Notebooks.Item.Sections.Item.Pages.Item.ParentSection.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -48,19 +48,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -80,11 +79,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -129,11 +127,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index d19472f06ce..977209935ef 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,26 +34,25 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenotePageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/PagesRequestBuilder.cs index d6e01bd1fc9..15a46c13264 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Notebooks.Item.Sections.Item.Pages.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -49,7 +48,7 @@ public Command BuildCreateCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -57,21 +56,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -89,7 +87,7 @@ public Command BuildListCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -128,7 +126,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -139,15 +141,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -202,31 +199,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index f05c5eac17e..cac91899f4d 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,7 +34,7 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index c8ff78c29e7..74dfa928c71 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Notebooks.Item.Sections.Item.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,15 +41,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, onenoteSectionIdOption); return command; @@ -69,7 +68,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -114,7 +112,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 155ce2c7ac5..48c80b86b95 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,7 +34,7 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs index c13798d398e..87dce706414 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,15 +41,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, onenoteSectionIdOption); return command; @@ -69,7 +68,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -114,7 +112,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs deleted file mode 100644 index 8191e9391d7..00000000000 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ /dev/null @@ -1,241 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup.ParentSectionGroup { - /// Builds and executes requests for operations under \sites\{site-id}\onenote\notebooks\{notebook-id}\sections\{onenoteSection-id}\parentSectionGroup\parentSectionGroup - public class ParentSectionGroupRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var notebookIdOption = new Option("--notebook-id", description: "key: id of notebook") { - }; - notebookIdOption.IsRequired = true; - command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var notebookIdOption = new Option("--notebook-id", description: "key: id of notebook") { - }; - notebookIdOption.IsRequired = true; - command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildPatchCommand() { - var command = new Command("patch"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var notebookIdOption = new Option("--notebook-id", description: "key: id of notebook") { - }; - notebookIdOption.IsRequired = true; - command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePatchRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new ParentSectionGroupRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public ParentSectionGroupRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/onenote/notebooks/{notebook_id}/sections/{onenoteSection_id}/parentSectionGroup/parentSectionGroup{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePatchRequestInformation(SectionGroup body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PATCH, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// The section group that contains the section group. Read-only. - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 00c65f964e6..8bec33f1d31 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,15 +37,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, onenoteSectionIdOption); return command; @@ -65,7 +64,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -79,20 +78,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -104,18 +102,6 @@ public Command BuildParentNotebookCommand() { command.AddCommand(builder.BuildPatchCommand()); return command; } - public Command BuildParentSectionGroupCommand() { - var command = new Command("parent-section-group"); - var builder = new ApiSdk.Sites.Item.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup.ParentSectionGroupRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildDeleteCommand()); - command.AddCommand(builder.BuildGetCommand()); - command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); - command.AddCommand(builder.BuildPatchCommand()); - command.AddCommand(builder.BuildSectionGroupsCommand()); - command.AddCommand(builder.BuildSectionsCommand()); - return command; - } /// /// The section group that contains the section. Read-only. /// @@ -131,7 +117,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -139,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -154,6 +139,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Sites.Item.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -161,6 +149,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Sites.Item.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -232,42 +223,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs index f2b5e5a28d3..70bfb3f18f1 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -66,11 +65,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,11 +113,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs index 33fced9f0f4..fb943860b19 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,7 +43,7 @@ public Command BuildCreateCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildListCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index f105f3b208e..5629b67ba6b 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 829b5d21231..5e92673a9db 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs index 8bc7b8bead5..d6c5c0c6721 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Sites.Item.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -48,19 +48,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenoteSectionId1) => { + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option); return command; @@ -80,11 +79,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -129,11 +127,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs index bf3bdc5a618..a0f627b5160 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -46,7 +45,7 @@ public Command BuildCreateCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,7 +84,7 @@ public Command BuildListCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -125,7 +123,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/SectionsRequestBuilder.cs index e1470fe6f0f..806886f34ec 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Notebooks.Item.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string notebookId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, bodyOption, outputOption); return command; } /// @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string notebookId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string notebookId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, notebookIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, notebookIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -194,31 +191,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Notebooks/NotebooksRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Notebooks/NotebooksRequestBuilder.cs index b42a7663c86..a840114fc74 100644 --- a/src/generated/Sites/Item/Onenote/Notebooks/NotebooksRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Notebooks/NotebooksRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.Onenote.Notebooks.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -24,14 +24,13 @@ public class NotebooksRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new NotebookRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyNotebookCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyNotebookCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, bodyOption, outputOption); return command; } public Command BuildGetNotebookFromWebUrlCommand() { @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -129,15 +131,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -193,18 +190,6 @@ public RequestInformation CreatePostRequestInformation(Notebook body, Action - /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \sites\{site-id}\onenote\notebooks\microsoft.graph.getRecentNotebooks(includePersonalNotebooks={includePersonalNotebooks}) /// Usage: includePersonalNotebooks={includePersonalNotebooks} /// @@ -212,19 +197,6 @@ public GetRecentNotebooksWithIncludePersonalNotebooksRequestBuilder GetRecentNot _ = includePersonalNotebooks ?? throw new ArgumentNullException(nameof(includePersonalNotebooks)); return new GetRecentNotebooksWithIncludePersonalNotebooksRequestBuilder(PathParameters, RequestAdapter, includePersonalNotebooks); } - /// - /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/OnenoteRequestBuilder.cs b/src/generated/Sites/Item/Onenote/OnenoteRequestBuilder.cs index 4a3afa78ba4..f42ed8fcd95 100644 --- a/src/generated/Sites/Item/Onenote/OnenoteRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/OnenoteRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Sites.Item.Onenote.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -36,11 +36,10 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - command.SetHandler(async (string siteId) => { + command.SetHandler(async (string siteId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption); return command; @@ -66,25 +65,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildNotebooksCommand() { var command = new Command("notebooks"); var builder = new ApiSdk.Sites.Item.Onenote.Notebooks.NotebooksRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildGetNotebookFromWebUrlCommand()); command.AddCommand(builder.BuildListCommand()); @@ -93,6 +94,9 @@ public Command BuildNotebooksCommand() { public Command BuildOperationsCommand() { var command = new Command("operations"); var builder = new ApiSdk.Sites.Item.Onenote.Operations.OperationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -100,6 +104,9 @@ public Command BuildOperationsCommand() { public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Sites.Item.Onenote.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -119,14 +126,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string body) => { + command.SetHandler(async (string siteId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, bodyOption); return command; @@ -134,6 +140,9 @@ public Command BuildPatchCommand() { public Command BuildResourcesCommand() { var command = new Command("resources"); var builder = new ApiSdk.Sites.Item.Onenote.Resources.ResourcesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -141,6 +150,9 @@ public Command BuildResourcesCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Sites.Item.Onenote.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -148,6 +160,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Sites.Item.Onenote.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -219,42 +234,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Calls the OneNote service for notebook related operations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Calls the OneNote service for notebook related operations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Calls the OneNote service for notebook related operations. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Onenote model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Calls the OneNote service for notebook related operations. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Operations/Item/OnenoteOperationRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Operations/Item/OnenoteOperationRequestBuilder.cs index 443d3494dd3..fc8e250f633 100644 --- a/src/generated/Sites/Item/Onenote/Operations/Item/OnenoteOperationRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Operations/Item/OnenoteOperationRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteOperationIdOption = new Option("--onenoteoperation-id", description: "key: id of onenoteOperation") { + var onenoteOperationIdOption = new Option("--onenote-operation-id", description: "key: id of onenoteOperation") { }; onenoteOperationIdOption.IsRequired = true; command.AddOption(onenoteOperationIdOption); - command.SetHandler(async (string siteId, string onenoteOperationId) => { + command.SetHandler(async (string siteId, string onenoteOperationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteOperationIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteOperationIdOption = new Option("--onenoteoperation-id", description: "key: id of onenoteOperation") { + var onenoteOperationIdOption = new Option("--onenote-operation-id", description: "key: id of onenoteOperation") { }; onenoteOperationIdOption.IsRequired = true; command.AddOption(onenoteOperationIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteOperationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteOperationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteOperationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteOperationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteOperationIdOption = new Option("--onenoteoperation-id", description: "key: id of onenoteOperation") { + var onenoteOperationIdOption = new Option("--onenote-operation-id", description: "key: id of onenoteOperation") { }; onenoteOperationIdOption.IsRequired = true; command.AddOption(onenoteOperationIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteOperationId, string body) => { + command.SetHandler(async (string siteId, string onenoteOperationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteOperationIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteOperation body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteOperation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Operations/OperationsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Operations/OperationsRequestBuilder.cs index 84c3e1ee8a2..d05600ffaad 100644 --- a/src/generated/Sites/Item/Onenote/Operations/OperationsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Operations/OperationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Operations.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class OperationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteOperationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteOperation body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteOperation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/Content/ContentRequestBuilder.cs index fcef501397f..a20f81586fb 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,28 +29,30 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string siteId, string onenotePageId, FileInfo output) => { + command.SetHandler(async (string siteId, string onenotePageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, siteIdOption, onenotePageIdOption, outputOption); + }, siteIdOption, onenotePageIdOption, fileOption, outputOption); return command; } /// @@ -64,7 +66,7 @@ public Command BuildPutCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -72,12 +74,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, FileInfo file) => { + command.SetHandler(async (string siteId, string onenotePageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, bodyOption); return command; @@ -128,29 +129,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from sites - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in sites - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 54982fe8f73..940f515c64e 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/OnenotePageRequestBuilder.cs index 6bf6b1210a3..2e55aeff26c 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/OnenotePageRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.Preview; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -49,15 +49,14 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string onenotePageId) => { + command.SetHandler(async (string siteId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption); return command; @@ -73,7 +72,7 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -87,20 +86,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -144,7 +142,7 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -152,14 +150,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, bodyOption); return command; @@ -232,42 +229,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The pages in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The pages in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The pages in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \sites\{site-id}\onenote\pages\{onenotePage-id}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index 813321c5875..4d34ecdb4cb 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index cd060f11c9c..a7da30993b3 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index e4cda9bccd2..940e8a2db31 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,15 +39,14 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string onenotePageId) => { + command.SetHandler(async (string siteId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,7 +102,7 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, bodyOption); return command; @@ -127,6 +124,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,6 +134,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -205,42 +208,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index c903698aebf..aed664387a5 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 3e1d8c131af..793780e50f8 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,19 +37,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -65,11 +64,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,11 +108,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 593befb7d3c..aeb5fa2cbaf 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index 02ed2eb54ba..a7784d4651b 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -62,11 +61,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -80,20 +79,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -124,11 +122,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -136,14 +134,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -151,6 +148,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -158,6 +158,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -229,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index f99aa2a8fa4..ee0fa846144 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs index 2da77f1cb5c..ffe15c94cdb 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,11 +39,11 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -80,11 +78,11 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 8927d2870fb..01145543f9d 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 43350dbf962..2562ea281fd 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index 2067f6b4482..6a3fa405e9e 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.Sections.Item.ParentSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,23 +47,22 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -79,15 +78,15 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -101,25 +100,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -152,15 +153,15 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -168,14 +169,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -247,42 +247,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index acae5099056..95c2725ec3b 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,40 +29,42 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, FileInfo output) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, outputOption); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, fileOption, outputOption); return command; } /// @@ -76,19 +78,19 @@ public Command BuildPutCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -96,12 +98,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, FileInfo file) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); return command; @@ -152,29 +153,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from sites - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in sites - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 9632881f7af..35a7a591249 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,19 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -50,21 +50,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption, outputOption); return command; } /// @@ -98,19 +97,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index dfef1b9a6d6..a14b29b02f1 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.Sections.Item.Pages.Item.Preview; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,27 +47,26 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option); return command; @@ -83,19 +82,19 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -109,20 +108,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -142,19 +140,19 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -162,14 +160,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); return command; @@ -242,42 +239,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \sites\{site-id}\onenote\pages\{onenotePage-id}\parentNotebook\sectionGroups\{sectionGroup-id}\sections\{onenoteSection-id}\pages\{onenotePage-id1}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index 19b38fa9ac4..abf56789fea 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,19 +29,19 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -49,14 +49,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); return command; @@ -92,18 +91,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index c62a0cf6f02..d7782051bd7 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,34 +30,33 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, outputOption); return command; } /// @@ -88,17 +87,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs index 32b586f78c1..91b13d934a4 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.Sections.Item.Pages.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -43,15 +42,15 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -59,21 +58,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -87,15 +85,15 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -134,7 +132,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -145,15 +147,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -208,31 +205,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 3cdc448b52d..b56940b2914 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 2817a1a9330..5e87c6a2bfc 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.Sections.Item.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,23 +37,22 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -69,15 +68,15 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -91,20 +90,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -118,15 +116,15 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 6ef895dadfd..96fa49cbb3f 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs index ea9dad0a76f..82e3b98b205 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,11 +44,11 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -57,21 +56,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -85,11 +83,11 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -128,7 +126,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -139,15 +141,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -202,31 +199,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index 2c66babcfb2..04da5a3e450 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -44,7 +43,7 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -80,7 +78,7 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -130,15 +132,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -193,31 +190,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 9e33fc8a573..ac64f7da9ee 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 005cffe3fa8..1a4e9a89fc4 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index 1eb000fe802..89c746267ff 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,19 +47,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -75,11 +74,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -93,25 +92,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -131,7 +132,6 @@ public Command BuildParentSectionGroupCommand() { command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); command.AddCommand(builder.BuildPatchCommand()); command.AddCommand(builder.BuildSectionGroupsCommand()); command.AddCommand(builder.BuildSectionsCommand()); @@ -148,11 +148,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -160,14 +160,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -239,42 +238,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index 21231d467fd..e66256908c9 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,36 +29,38 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string onenotePageId1, FileInfo output) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string onenotePageId1, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, outputOption); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, fileOption, outputOption); return command; } /// @@ -72,15 +74,15 @@ public Command BuildPutCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -88,12 +90,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string onenotePageId1, FileInfo file) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string onenotePageId1, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); return command; @@ -144,29 +145,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from sites - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in sites - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 5c2dc206a34..8f0c89c4d68 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string onenotePageId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string onenotePageId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index e85e9450da1..cac7456e5ae 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.Pages.Item.Preview; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,23 +47,22 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string onenotePageId1) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string onenotePageId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option); return command; @@ -79,15 +78,15 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -101,20 +100,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string onenotePageId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string onenotePageId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -134,15 +132,15 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -150,14 +148,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string onenotePageId1, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string onenotePageId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); return command; @@ -230,42 +227,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \sites\{site-id}\onenote\pages\{onenotePage-id}\parentNotebook\sections\{onenoteSection-id}\pages\{onenotePage-id1}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index fd6922ee4e7..b8307ed7fe8 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,15 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string onenotePageId1, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string onenotePageId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index 76f41e533e1..bea14b9a0bc 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,30 +30,29 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string onenotePageId1) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string onenotePageId1, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs index d880439e49e..14a020806a1 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.Pages.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -43,11 +42,11 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -55,21 +54,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -83,11 +81,11 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -126,7 +124,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -137,15 +139,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -200,31 +197,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 696b16868d0..db92bf004f5 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index c13a9b7bed6..a017bf43431 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,19 +37,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -65,11 +64,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,11 +108,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 4c14927465d..88df3efe658 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs index 74e0e18e890..525d3a1d7f9 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,19 +37,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -65,11 +64,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,11 +108,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs deleted file mode 100644 index 0f1cc7c7c8d..00000000000 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ /dev/null @@ -1,241 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup.ParentSectionGroup { - /// Builds and executes requests for operations under \sites\{site-id}\onenote\pages\{onenotePage-id}\parentNotebook\sections\{onenoteSection-id}\parentSectionGroup\parentSectionGroup - public class ParentSectionGroupRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { - }; - onenotePageIdOption.IsRequired = true; - command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { - }; - onenotePageIdOption.IsRequired = true; - command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildPatchCommand() { - var command = new Command("patch"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { - }; - onenotePageIdOption.IsRequired = true; - command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePatchRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new ParentSectionGroupRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public ParentSectionGroupRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/onenote/pages/{onenotePage_id}/parentNotebook/sections/{onenoteSection_id}/parentSectionGroup/parentSectionGroup{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePatchRequestInformation(SectionGroup body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PATCH, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// The section group that contains the section group. Read-only. - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index ab91d1c2981..2fd333b5245 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,19 +33,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -61,11 +60,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -79,20 +78,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -104,18 +102,6 @@ public Command BuildParentNotebookCommand() { command.AddCommand(builder.BuildPatchCommand()); return command; } - public Command BuildParentSectionGroupCommand() { - var command = new Command("parent-section-group"); - var builder = new ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup.ParentSectionGroupRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildDeleteCommand()); - command.AddCommand(builder.BuildGetCommand()); - command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); - command.AddCommand(builder.BuildPatchCommand()); - command.AddCommand(builder.BuildSectionGroupsCommand()); - command.AddCommand(builder.BuildSectionsCommand()); - return command; - } /// /// The section group that contains the section. Read-only. /// @@ -127,11 +113,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -139,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -154,6 +139,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -161,6 +149,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -232,42 +223,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs index aa057abc8ba..563f89c8ca9 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs index 99f25cbc613..7380d42ffc2 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,11 +39,11 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -80,11 +78,11 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index af2a66aaa72..c2fb5d2012c 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 56364081843..265e62daa8a 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs index 904879b362a..dd994926727 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,23 +44,22 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option); return command; @@ -76,15 +75,15 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -125,15 +123,15 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs index 10f8c321432..accee9cc666 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,11 +41,11 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -82,11 +80,11 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -125,7 +123,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs index d6d18af593b..42c281ad97d 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,7 +44,7 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -81,7 +79,7 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -194,31 +191,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs index fb0859988de..45d7359a7df 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 8664dbdd513..32e211dd8ae 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/Pages/Item/Content/ContentRequestBuilder.cs index 594a7d0820c..3673f767b72 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,32 +29,34 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenotePageId1, FileInfo output) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenotePageId1, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, siteIdOption, onenotePageIdOption, onenotePageId1Option, outputOption); + }, siteIdOption, onenotePageIdOption, onenotePageId1Option, fileOption, outputOption); return command; } /// @@ -68,11 +70,11 @@ public Command BuildPutCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -80,12 +82,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenotePageId1, FileInfo file) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenotePageId1, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, onenotePageId1Option, bodyOption); return command; @@ -136,29 +137,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from sites - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in sites - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index dfb5844c340..e9b4350ae36 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenotePageId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenotePageId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenotePageId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenotePageId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePageRequestBuilder.cs index 98c40ec6205..731ad27e55f 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePageRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.Pages.Item.Preview; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,19 +47,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - command.SetHandler(async (string siteId, string onenotePageId, string onenotePageId1) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenotePageId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, onenotePageId1Option); return command; @@ -75,11 +74,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -93,20 +92,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenotePageId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenotePageId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenotePageId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenotePageId1Option, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -126,11 +124,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -138,14 +136,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenotePageId1, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenotePageId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, onenotePageId1Option, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \sites\{site-id}\onenote\pages\{onenotePage-id}\parentSection\pages\{onenotePage-id1}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index feedd1dd07d..e7ab3012c8e 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenotePageId1, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenotePageId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, onenotePageId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/Pages/Item/Preview/PreviewRequestBuilder.cs index 5855870ebe3..69e7d01597e 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,26 +30,25 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - command.SetHandler(async (string siteId, string onenotePageId, string onenotePageId1) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenotePageId1, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenotePageId1Option); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenotePageId1Option, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/Pages/PagesRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/Pages/PagesRequestBuilder.cs index c69fdff5e93..3ac7ae22673 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/Pages/PagesRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.Pages.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -43,7 +42,7 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -51,21 +50,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -79,7 +77,7 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -129,15 +131,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 058648f7344..e89f43ec1cf 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/ParentNotebookRequestBuilder.cs index 2003cc0cd1f..3e3702f52c0 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,15 +39,14 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string onenotePageId) => { + command.SetHandler(async (string siteId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,7 +102,7 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, bodyOption); return command; @@ -127,6 +124,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,6 +134,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -205,42 +208,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 391a0a8d35a..e0f24facb47 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 147099037aa..e8d0596a8c6 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.SectionGroups.Item.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,19 +37,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -65,11 +64,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,11 +108,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 60301dc3bbc..668ad045192 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index 5d54011a17c..868dbfde9ef 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.SectionGroups.Item.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -62,11 +61,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -80,20 +79,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -124,11 +122,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -136,14 +134,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -151,6 +148,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.SectionGroups.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -158,6 +158,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.SectionGroups.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -229,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index 3f44f959613..d0323be62e2 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs index b1c0ff0fd7d..21c8cd9e338 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.SectionGroups.Item.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,11 +39,11 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -80,11 +78,11 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 0a6f4d2b110..627546a1c19 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 8147f584f75..cff3368ddbd 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index efe51e18d90..d2f4ac91369 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.SectionGroups.Item.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,23 +44,22 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -76,15 +75,15 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -125,15 +123,15 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs index b2e4e782b20..a92e15f5429 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.SectionGroups.Item.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,11 +41,11 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -82,11 +80,11 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -125,7 +123,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index 40d6d60479d..b7d7ebaf6ab 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -44,7 +43,7 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -80,7 +78,7 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -130,15 +132,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -193,31 +190,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 2f55b38a796..a1fee5831b5 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 1f201a2bb39..c674c2732b9 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index 74abc9e5fe6..81dfc9478d1 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,19 +44,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -72,11 +71,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -117,11 +115,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/SectionsRequestBuilder.cs index 2688407e991..4ecf95d8367 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,7 +41,7 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -78,7 +76,7 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -117,7 +115,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 1f0cdc78844..08cbb63b6d0 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs index 88dfc9cba25..aecb75bb572 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.ParentNotebook.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,15 +39,14 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string onenotePageId) => { + command.SetHandler(async (string siteId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,7 +102,7 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, bodyOption); return command; @@ -127,6 +124,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,6 +134,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -205,42 +208,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index cb45bf6a391..cdf6dfc87d0 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index 945e4cdd69b..7b17d3cbb59 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.ParentNotebook.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 904cb403806..deaa3665a70 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 02372c9b8a4..08a8558cbd2 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index f56341a9b94..d9e9fa9768b 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.ParentNotebook.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,19 +44,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -72,11 +71,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -117,11 +115,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs index 6d10b21f4f0..d9e5ad5f971 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.ParentNotebook.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,7 +41,7 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -78,7 +76,7 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -117,7 +115,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs deleted file mode 100644 index 0da545ec3ef..00000000000 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ /dev/null @@ -1,229 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.ParentSectionGroup { - /// Builds and executes requests for operations under \sites\{site-id}\onenote\pages\{onenotePage-id}\parentSection\parentSectionGroup\parentSectionGroup - public class ParentSectionGroupRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { - }; - onenotePageIdOption.IsRequired = true; - command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string onenotePageId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, onenotePageIdOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { - }; - onenotePageIdOption.IsRequired = true; - command.AddOption(onenotePageIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, selectOption, expandOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildPatchCommand() { - var command = new Command("patch"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { - }; - onenotePageIdOption.IsRequired = true; - command.AddOption(onenotePageIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePatchRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, onenotePageIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new ParentSectionGroupRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public ParentSectionGroupRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/onenote/pages/{onenotePage_id}/parentSection/parentSectionGroup/parentSectionGroup{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePatchRequestInformation(SectionGroup body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PATCH, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// The section group that contains the section group. Read-only. - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index d9846389448..54082ec5949 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,15 +33,14 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string onenotePageId) => { + command.SetHandler(async (string siteId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption); return command; @@ -57,7 +56,7 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -71,20 +70,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -98,18 +96,6 @@ public Command BuildParentNotebookCommand() { command.AddCommand(builder.BuildSectionsCommand()); return command; } - public Command BuildParentSectionGroupCommand() { - var command = new Command("parent-section-group"); - var builder = new ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.ParentSectionGroupRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildDeleteCommand()); - command.AddCommand(builder.BuildGetCommand()); - command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); - command.AddCommand(builder.BuildPatchCommand()); - command.AddCommand(builder.BuildSectionGroupsCommand()); - command.AddCommand(builder.BuildSectionsCommand()); - return command; - } /// /// The section group that contains the section. Read-only. /// @@ -121,7 +107,7 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -129,14 +115,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, bodyOption); return command; @@ -144,6 +129,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -151,6 +139,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -222,42 +213,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs index 43baa2690ec..6eb5d44a930 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs index 8b40b456394..41f46f57e4c 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index eed2e51ce03..39a35729fdd 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 6a519c179bd..f5bf87ebb06 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs index 3a1edcc8bd0..804ab5d31dc 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,19 +44,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -72,11 +71,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -117,11 +115,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/SectionsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/SectionsRequestBuilder.cs index b28e40f4376..f919987b0b7 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,7 +41,7 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -78,7 +76,7 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -117,7 +115,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs index 2920c487fbd..d0cf2066c74 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,15 +47,14 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string onenotePageId) => { + command.SetHandler(async (string siteId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption); return command; @@ -71,7 +70,7 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -85,25 +84,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Sites.Item.Onenote.Pages.Item.ParentSection.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -125,7 +126,6 @@ public Command BuildParentSectionGroupCommand() { command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); command.AddCommand(builder.BuildPatchCommand()); command.AddCommand(builder.BuildSectionGroupsCommand()); command.AddCommand(builder.BuildSectionsCommand()); @@ -142,7 +142,7 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -150,14 +150,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenotePageId, string body) => { + command.SetHandler(async (string siteId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenotePageIdOption, bodyOption); return command; @@ -229,42 +228,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/Item/Preview/PreviewRequestBuilder.cs index dec20c71f10..e0eca612149 100644 --- a/src/generated/Sites/Item/Onenote/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string onenotePageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenotePageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenotePageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenotePageIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Pages/PagesRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Pages/PagesRequestBuilder.cs index 08e4e03afaf..d43b1f16853 100644 --- a/src/generated/Sites/Item/Onenote/Pages/PagesRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Pages.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, bodyOption, outputOption); return command; } /// @@ -112,7 +110,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -186,31 +183,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The pages in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The pages in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The pages in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Resources/Item/Content/ContentRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Resources/Item/Content/ContentRequestBuilder.cs index 9d668b29e31..5b2148af161 100644 --- a/src/generated/Sites/Item/Onenote/Resources/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Resources/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,28 +29,30 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteResourceIdOption = new Option("--onenoteresource-id", description: "key: id of onenoteResource") { + var onenoteResourceIdOption = new Option("--onenote-resource-id", description: "key: id of onenoteResource") { }; onenoteResourceIdOption.IsRequired = true; command.AddOption(onenoteResourceIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string siteId, string onenoteResourceId, FileInfo output) => { + command.SetHandler(async (string siteId, string onenoteResourceId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, siteIdOption, onenoteResourceIdOption, outputOption); + }, siteIdOption, onenoteResourceIdOption, fileOption, outputOption); return command; } /// @@ -64,7 +66,7 @@ public Command BuildPutCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteResourceIdOption = new Option("--onenoteresource-id", description: "key: id of onenoteResource") { + var onenoteResourceIdOption = new Option("--onenote-resource-id", description: "key: id of onenoteResource") { }; onenoteResourceIdOption.IsRequired = true; command.AddOption(onenoteResourceIdOption); @@ -72,12 +74,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteResourceId, FileInfo file) => { + command.SetHandler(async (string siteId, string onenoteResourceId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteResourceIdOption, bodyOption); return command; @@ -128,29 +129,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property resources from sites - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property resources in sites - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Onenote/Resources/Item/OnenoteResourceRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Resources/Item/OnenoteResourceRequestBuilder.cs index 2a3c5e98748..60a58763959 100644 --- a/src/generated/Sites/Item/Onenote/Resources/Item/OnenoteResourceRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Resources/Item/OnenoteResourceRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Resources.Item.Content; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteResourceIdOption = new Option("--onenoteresource-id", description: "key: id of onenoteResource") { + var onenoteResourceIdOption = new Option("--onenote-resource-id", description: "key: id of onenoteResource") { }; onenoteResourceIdOption.IsRequired = true; command.AddOption(onenoteResourceIdOption); - command.SetHandler(async (string siteId, string onenoteResourceId) => { + command.SetHandler(async (string siteId, string onenoteResourceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteResourceIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteResourceIdOption = new Option("--onenoteresource-id", description: "key: id of onenoteResource") { + var onenoteResourceIdOption = new Option("--onenote-resource-id", description: "key: id of onenoteResource") { }; onenoteResourceIdOption.IsRequired = true; command.AddOption(onenoteResourceIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteResourceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteResourceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteResourceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteResourceIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,7 +101,7 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteResourceIdOption = new Option("--onenoteresource-id", description: "key: id of onenoteResource") { + var onenoteResourceIdOption = new Option("--onenote-resource-id", description: "key: id of onenoteResource") { }; onenoteResourceIdOption.IsRequired = true; command.AddOption(onenoteResourceIdOption); @@ -111,14 +109,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteResourceId, string body) => { + command.SetHandler(async (string siteId, string onenoteResourceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteResourceIdOption, bodyOption); return command; @@ -190,42 +187,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteResource body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Resources/ResourcesRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Resources/ResourcesRequestBuilder.cs index fd440e18c91..f9695d06356 100644 --- a/src/generated/Sites/Item/Onenote/Resources/ResourcesRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Resources/ResourcesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Resources.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class ResourcesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteResourceRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, bodyOption, outputOption); return command; } /// @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteResource body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 2f63f199bf6..ceea0a1d40e 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 75b4b0834a7..dc2e802d07c 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.Onenote.SectionGroups.Item.ParentNotebook.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,15 +39,14 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string siteId, string sectionGroupId) => { + command.SetHandler(async (string siteId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,7 +102,7 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string body) => { + command.SetHandler(async (string siteId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, bodyOption); return command; @@ -127,6 +124,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Sites.Item.Onenote.SectionGroups.Item.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,6 +134,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Sites.Item.Onenote.SectionGroups.Item.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -205,42 +208,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index 1d7290a71ec..76ab38cffee 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string siteId, string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string siteId, string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string siteId, string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index 6480f7bcf26..04d483ec4a8 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.SectionGroups.Item.ParentNotebook.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index c76996b99e8..6e716bd7ce5 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 190df444fab..61d410ac519 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index a86b69fa993..5f5c6e83335 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Sites.Item.Onenote.SectionGroups.Item.ParentNotebook.Sections.Item.ParentSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,19 +47,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -75,11 +74,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -93,25 +92,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Sites.Item.Onenote.SectionGroups.Item.ParentNotebook.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -144,11 +145,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -156,14 +157,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -235,42 +235,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index ea02a499b73..fd4c4b69abe 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,36 +29,38 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo output) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, fileOption, outputOption); return command; } /// @@ -72,15 +74,15 @@ public Command BuildPutCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -88,12 +90,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -144,29 +145,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from sites - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in sites - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index c15b9fbc191..14b72ac5ac5 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index ecee0e0cd10..855aa42cfc0 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Sites.Item.Onenote.SectionGroups.Item.ParentNotebook.Sections.Item.Pages.Item.Preview; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -49,23 +49,22 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -81,15 +80,15 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -103,20 +102,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -155,15 +153,15 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -171,14 +169,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -251,42 +248,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \sites\{site-id}\onenote\sectionGroups\{sectionGroup-id}\parentNotebook\sections\{onenoteSection-id}\pages\{onenotePage-id}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index d95f507dd1b..ab27c9f0d82 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,15 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index edb76477f19..7cd2d682ffb 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 9562df0b135..8d450f99fec 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.SectionGroups.Item.ParentNotebook.Sections.Item.Pages.Item.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,23 +37,22 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -69,15 +68,15 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -91,20 +90,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -118,15 +116,15 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 14b7d73b5f7..2c9b89488c1 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 89e70c8a8c4..1d7b2be409c 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs index 5c778eff381..e117dcf8683 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Sites.Item.Onenote.SectionGroups.Item.ParentNotebook.Sections.Item.Pages.Item.ParentSection.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,23 +44,22 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -76,15 +75,15 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -125,15 +123,15 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index 8a4c6ba3b48..df722e34a28 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,30 +30,29 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs index 44486b649a6..6461f1b712d 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.SectionGroups.Item.ParentNotebook.Sections.Item.Pages.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,11 +44,11 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -57,21 +56,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -85,11 +83,11 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -128,7 +126,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -139,15 +141,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -202,31 +199,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 9125ef791fa..1b94ff3903f 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 7cff94867c5..8982763377d 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.SectionGroups.Item.ParentNotebook.Sections.Item.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,19 +37,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -65,11 +64,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,11 +108,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 81caa224135..3b88921fa1a 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs index 8a61d9b966b..a513ef5c578 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.SectionGroups.Item.ParentNotebook.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,7 +44,7 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -81,7 +79,7 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -194,31 +191,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 3298d294841..6a90610d2ed 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string siteId, string sectionGroupId) => { + command.SetHandler(async (string siteId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string body) => { + command.SetHandler(async (string siteId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/SectionGroupRequestBuilder.cs index fad2e77574d..1ad10d6ee18 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Sites.Item.Onenote.SectionGroups.Item.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string siteId, string sectionGroupId) => { + command.SetHandler(async (string siteId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption); return command; @@ -58,7 +57,7 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -72,20 +71,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -118,7 +116,7 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -126,14 +124,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string body) => { + command.SetHandler(async (string siteId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, bodyOption); return command; @@ -141,6 +138,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Sites.Item.Onenote.SectionGroups.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -148,6 +148,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Sites.Item.Onenote.SectionGroups.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -219,42 +222,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index 3b7b618016f..09dca41c7c8 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string siteId, string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string siteId, string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string siteId, string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs index 69eb07a93ae..c9593bb57b7 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.SectionGroups.Item.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 913de92d939..53dfc7cf0b2 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 04452f921b9..014ee08a561 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index ce9f7bcbd43..fccbeb80508 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Sites.Item.Onenote.SectionGroups.Item.Sections.Item.ParentSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,19 +47,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -75,11 +74,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -93,25 +92,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Sites.Item.Onenote.SectionGroups.Item.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -146,11 +147,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -158,14 +159,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -237,42 +237,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index 15a7ffe882b..b68bc2593b4 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,36 +29,38 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo output) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, fileOption, outputOption); return command; } /// @@ -72,15 +74,15 @@ public Command BuildPutCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -88,12 +90,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -144,29 +145,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from sites - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in sites - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index ef6ec87193f..48157727337 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index 4df1b6ca985..5fa836cae8a 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Sites.Item.Onenote.SectionGroups.Item.Sections.Item.Pages.Item.Preview; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -49,23 +49,22 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -81,15 +80,15 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -103,20 +102,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -157,15 +155,15 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -173,14 +171,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -253,42 +250,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \sites\{site-id}\onenote\sectionGroups\{sectionGroup-id}\sections\{onenoteSection-id}\pages\{onenotePage-id}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index 3209d2aaf83..77548f639cd 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,15 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 946e7e6b367..700632f3937 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 6f3448115f5..31902b3be7f 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.Onenote.SectionGroups.Item.Sections.Item.Pages.Item.ParentNotebook.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,23 +39,22 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -71,15 +70,15 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -93,20 +92,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -120,15 +118,15 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -136,14 +134,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -151,6 +148,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Sites.Item.Onenote.SectionGroups.Item.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -158,6 +158,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Sites.Item.Onenote.SectionGroups.Item.Sections.Item.Pages.Item.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -229,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index 55cf1ac7e12..90023531898 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,27 +30,26 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string sectionGroupId1) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupId1Option); return command; @@ -66,19 +65,19 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -92,20 +91,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -119,19 +117,19 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -139,14 +137,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string sectionGroupId1, string body) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupId1Option, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index 7195c835799..f4baf1442fe 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.SectionGroups.Item.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,15 +39,15 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -84,15 +82,15 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -131,7 +129,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -142,15 +144,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -205,31 +202,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index e9c2868bd5f..9928ee72f6d 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,19 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -50,21 +50,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -98,19 +97,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index fb135f709fe..987dd5b53f7 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,19 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -50,21 +50,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -98,19 +97,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index d938b1b047a..d9e7c2be29a 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Sites.Item.Onenote.SectionGroups.Item.Sections.Item.Pages.Item.ParentNotebook.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,27 +44,26 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option); return command; @@ -80,19 +79,19 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -106,20 +105,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -133,19 +131,19 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -153,14 +151,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -232,42 +229,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs index aaa92cd5127..2287c22eef8 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.SectionGroups.Item.Sections.Item.Pages.Item.ParentNotebook.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,15 +41,15 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -58,21 +57,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -86,15 +84,15 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -133,7 +131,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -144,15 +146,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -207,31 +204,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs index be4a6c83e52..ed772233552 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 41f95473d84..59942ff78ab 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs index b2c943e8556..5cdbd142647 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Sites.Item.Onenote.SectionGroups.Item.Sections.Item.Pages.Item.ParentSection.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,23 +44,22 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -76,15 +75,15 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -125,15 +123,15 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index 19a22436ea5..a5291c1f994 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,30 +30,29 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs index d6b5599ba45..44c699e36cc 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.SectionGroups.Item.Sections.Item.Pages.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,11 +44,11 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -57,21 +56,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -85,11 +83,11 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -128,7 +126,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -139,15 +141,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -202,31 +199,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index bae2c9c3f10..543df796136 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index aa62ab8fd9a..7cc7d47a075 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.Onenote.SectionGroups.Item.Sections.Item.ParentNotebook.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,19 +39,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -67,11 +66,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -85,20 +84,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -112,11 +110,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -124,14 +122,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -139,6 +136,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Sites.Item.Onenote.SectionGroups.Item.Sections.Item.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -146,6 +146,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Sites.Item.Onenote.SectionGroups.Item.Sections.Item.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -217,42 +220,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index 140a642e972..ec6e63f578f 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string sectionGroupId1) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, sectionGroupId1Option); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string sectionGroupId1, string body) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, sectionGroupId1Option, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index 02f75e314c2..18425fbb95b 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.SectionGroups.Item.Sections.Item.ParentNotebook.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,11 +39,11 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -80,11 +78,11 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 3076a577122..ead3731c24a 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index b5c0540b318..c39b9b81011 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index 1ca9896dfbe..359484770c8 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Sites.Item.Onenote.SectionGroups.Item.Sections.Item.ParentNotebook.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,23 +44,22 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option); return command; @@ -76,15 +75,15 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -125,15 +123,15 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs index 3336eba281c..7ff19df163b 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.SectionGroups.Item.Sections.Item.ParentNotebook.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,11 +41,11 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -82,11 +80,11 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -125,7 +123,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 487b49f0c55..0771bb5ad00 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/SectionsRequestBuilder.cs index c7193654416..e65a687ec0d 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.SectionGroups.Item.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,7 +44,7 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -81,7 +79,7 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -194,31 +191,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/SectionGroups/SectionGroupsRequestBuilder.cs index bbaaedb4486..774d70c046b 100644 --- a/src/generated/Sites/Item/Onenote/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, bodyOption, outputOption); return command; } /// @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -122,15 +124,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -185,31 +182,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index c71ddd8a8bc..9a74fd8ea0b 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 54c955fb9d2..e98dff7c1c1 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/OnenoteSectionRequestBuilder.cs index 1d6985dd4a2..a6626e7930c 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.ParentSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,15 +47,14 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption); return command; @@ -71,7 +70,7 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -85,25 +84,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Sites.Item.Onenote.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -125,7 +126,6 @@ public Command BuildParentSectionGroupCommand() { command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); command.AddCommand(builder.BuildPatchCommand()); command.AddCommand(builder.BuildSectionGroupsCommand()); command.AddCommand(builder.BuildSectionsCommand()); @@ -142,7 +142,7 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -150,14 +150,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -229,42 +228,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index 5395e8975b1..d941fa65b57 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,32 +29,34 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, FileInfo output) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, fileOption, outputOption); return command; } /// @@ -68,11 +70,11 @@ public Command BuildPutCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -80,12 +82,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, FileInfo file) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -136,29 +137,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from sites - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in sites - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 7c3e4d5f256..64468e9c043 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index 06f9a6601a0..2cc57ef2bc8 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.Pages.Item.Preview; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -49,19 +49,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -77,11 +76,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -95,20 +94,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -149,11 +147,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -161,14 +159,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -241,42 +238,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \sites\{site-id}\onenote\sections\{onenoteSection-id}\pages\{onenotePage-id}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index dab05d1816d..2ddf78d0c45 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 77855b1a83b..877503e6624 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index ce4bf6f2009..4b059e8d5d6 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,19 +39,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -67,11 +66,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -85,20 +84,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -112,11 +110,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -124,14 +122,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -139,6 +136,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Sites.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -146,6 +146,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Sites.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -217,42 +220,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 175332cf500..3a8542ad3ed 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 6b8ca8bed82..3620a30b6bc 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.Item.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,23 +37,22 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -69,15 +68,15 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -91,20 +90,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -118,15 +116,15 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 8f9ec9b5fb9..2f067b69547 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index 0d93d32f835..500b37944c5 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.Item.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,23 +34,22 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -66,15 +65,15 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -88,20 +87,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -132,15 +130,15 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -148,14 +146,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -163,6 +160,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Sites.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -170,6 +170,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Sites.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -241,42 +244,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index ee5d1a42a34..995da47890f 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,27 +30,26 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -66,19 +65,19 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -92,20 +91,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -119,19 +117,19 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -139,14 +137,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs index e9dc5dccbfe..fd69a85ca87 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.Item.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,15 +39,15 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -84,15 +82,15 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -131,7 +129,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -142,15 +144,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -205,31 +202,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index a98d70353ad..66b2c355cf6 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,19 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -50,21 +50,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -98,19 +97,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 14ffcbd3a4b..60d79536a32 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,19 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -50,21 +50,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -98,19 +97,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index 84636ff73cb..af4c12671e8 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.Item.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,27 +44,26 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option); return command; @@ -80,19 +79,19 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -106,20 +105,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -133,19 +131,19 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -153,14 +151,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -232,42 +229,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs index 48df693111a..2e19b915323 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.Item.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,15 +41,15 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -58,21 +57,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -86,15 +84,15 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -133,7 +131,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -144,15 +146,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -207,31 +204,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index 610a8866575..6c20891a4c9 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -44,11 +43,11 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -84,11 +82,11 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -127,7 +125,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -138,15 +140,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -201,31 +198,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 1e5d00cf326..bf6b1497843 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 927987a9f9b..cea3a57c08b 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index 8b4c508fe3e..522b5c72428 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,23 +44,22 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option); return command; @@ -76,15 +75,15 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -125,15 +123,15 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs index 0e4ed118878..f8607411f9f 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,11 +41,11 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -82,11 +80,11 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -125,7 +123,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 3f9a42a219d..5831c15e88c 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 6c070bbbe79..080a52c05f4 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs index 4ca1c5444fe..90d6780154b 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.Pages.Item.ParentSection.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,19 +44,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -72,11 +71,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -117,11 +115,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index 799c7d2f1d3..e26cd2450e8 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,26 +30,25 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenotePageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/PagesRequestBuilder.cs index 06a3c74ddf4..07fd697f885 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.Pages.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,7 +44,7 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -81,7 +79,7 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -194,31 +191,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 27d7afdea66..3c459372e2b 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 5420763ed85..b3476561f0f 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.ParentNotebook.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,15 +39,14 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,7 +102,7 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -127,6 +124,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Sites.Item.Onenote.Sections.Item.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,6 +134,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Sites.Item.Onenote.Sections.Item.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -205,42 +208,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index ea98bb53f38..1efe262b680 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 585116d9f0e..6d3f044c363 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.ParentNotebook.SectionGroups.Item.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,19 +37,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -65,11 +64,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,11 +108,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 21a3189fe15..31bcd5e03f1 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index 9182c49391e..aa2953d259e 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.ParentNotebook.SectionGroups.Item.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -62,11 +61,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -80,20 +79,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -124,11 +122,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -136,14 +134,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -151,6 +148,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Sites.Item.Onenote.Sections.Item.ParentNotebook.SectionGroups.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -158,6 +158,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Sites.Item.Onenote.Sections.Item.ParentNotebook.SectionGroups.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -229,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index 2d3b22b084a..1399b0015b6 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs index 6b4207990f2..d80ac6aa1b9 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.ParentNotebook.SectionGroups.Item.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,11 +39,11 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -80,11 +78,11 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index ff3e1448244..a9966195d0a 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 5efff596c08..cc6f8a28a59 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index e6e537add47..7ffde9cf2f3 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.ParentNotebook.SectionGroups.Item.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,23 +44,22 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option); return command; @@ -76,15 +75,15 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -125,15 +123,15 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs index 1eb0863abe4..8b8359760dd 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.ParentNotebook.SectionGroups.Item.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,11 +41,11 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -82,11 +80,11 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -125,7 +123,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index 830097eb346..2050deb4596 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.ParentNotebook.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -44,7 +43,7 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -80,7 +78,7 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -130,15 +132,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -193,31 +190,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 312afa7c046..502ebb1e9d6 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 28c213c2a27..f373efc248d 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index 0f764abf49c..ec14f9eccca 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.ParentNotebook.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,19 +44,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, onenoteSectionId1Option); return command; @@ -72,11 +71,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -117,11 +115,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs index 8a6d7a93176..173e7f1b0bd 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.ParentNotebook.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,7 +41,7 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -78,7 +76,7 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -117,7 +115,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index b819f76147a..f64a4f64aa5 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs index 4e2d214ed62..503c55a7ff7 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.ParentSectionGroup.ParentNotebook.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,15 +39,14 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,7 +102,7 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -127,6 +124,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Sites.Item.Onenote.Sections.Item.ParentSectionGroup.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,6 +134,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Sites.Item.Onenote.Sections.Item.ParentSectionGroup.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -205,42 +208,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index 9c3c1d21f80..532c44c2652 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index a3690237e4a..4309ca1b145 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.ParentSectionGroup.ParentNotebook.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 796e5a28bfc..029da633562 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index b718cd08885..d0258e37ad3 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index 88bb2326229..6b3f2fad877 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.ParentSectionGroup.ParentNotebook.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,19 +44,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, onenoteSectionId1Option); return command; @@ -72,11 +71,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -117,11 +115,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs index 08c87d2d087..5ac520fccd2 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.ParentSectionGroup.ParentNotebook.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,7 +41,7 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -78,7 +76,7 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -117,7 +115,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs deleted file mode 100644 index 4a7fb277c25..00000000000 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ /dev/null @@ -1,229 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.Onenote.Sections.Item.ParentSectionGroup.ParentSectionGroup { - /// Builds and executes requests for operations under \sites\{site-id}\onenote\sections\{onenoteSection-id}\parentSectionGroup\parentSectionGroup - public class ParentSectionGroupRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string onenoteSectionId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, onenoteSectionIdOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, selectOption, expandOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildPatchCommand() { - var command = new Command("patch"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePatchRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, onenoteSectionIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new ParentSectionGroupRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public ParentSectionGroupRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/onenote/sections/{onenoteSection_id}/parentSectionGroup/parentSectionGroup{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePatchRequestInformation(SectionGroup body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PATCH, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// The section group that contains the section group. Read-only. - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 06ddc252d6d..96ad850f1e7 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.ParentSectionGroup.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,15 +33,14 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string siteId, string onenoteSectionId) => { + command.SetHandler(async (string siteId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption); return command; @@ -57,7 +56,7 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -71,20 +70,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -98,18 +96,6 @@ public Command BuildParentNotebookCommand() { command.AddCommand(builder.BuildSectionsCommand()); return command; } - public Command BuildParentSectionGroupCommand() { - var command = new Command("parent-section-group"); - var builder = new ApiSdk.Sites.Item.Onenote.Sections.Item.ParentSectionGroup.ParentSectionGroupRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildDeleteCommand()); - command.AddCommand(builder.BuildGetCommand()); - command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); - command.AddCommand(builder.BuildPatchCommand()); - command.AddCommand(builder.BuildSectionGroupsCommand()); - command.AddCommand(builder.BuildSectionsCommand()); - return command; - } /// /// The section group that contains the section. Read-only. /// @@ -121,7 +107,7 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -129,14 +115,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string body) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -144,6 +129,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Sites.Item.Onenote.Sections.Item.ParentSectionGroup.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -151,6 +139,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Sites.Item.Onenote.Sections.Item.ParentSectionGroup.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -222,42 +213,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs index 42a4b02359f..df412c24216 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs index 84bfbc65fcf..e5bbff40ce9 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.ParentSectionGroup.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 502f8263beb..63ff0957a5b 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 7da167ac1e4..ef738b45e47 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs index d73fbd5477a..e5382488339 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.ParentSectionGroup.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,19 +44,18 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, onenoteSectionId1Option); return command; @@ -72,11 +71,11 @@ public Command BuildGetCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -117,11 +115,11 @@ public Command BuildPatchCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string siteId, string onenoteSectionId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs index 076ceca8c38..246fab38691 100644 --- a/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item.ParentSectionGroup.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,7 +41,7 @@ public Command BuildCreateCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -78,7 +76,7 @@ public Command BuildListCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -117,7 +115,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Onenote/Sections/SectionsRequestBuilder.cs b/src/generated/Sites/Item/Onenote/Sections/SectionsRequestBuilder.cs index 8157ba4f35b..a8232931a67 100644 --- a/src/generated/Sites/Item/Onenote/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Sites/Item/Onenote/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Onenote.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, bodyOption, outputOption); return command; } /// @@ -112,7 +110,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -186,31 +183,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/Permissions/Item/Grant/GrantRequestBuilder.cs b/src/generated/Sites/Item/Permissions/Item/Grant/GrantRequestBuilder.cs index e244c613f9e..3a1012d1bc6 100644 --- a/src/generated/Sites/Item/Permissions/Item/Grant/GrantRequestBuilder.cs +++ b/src/generated/Sites/Item/Permissions/Item/Grant/GrantRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,21 +37,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string permissionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string permissionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, permissionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, permissionIdOption, bodyOption, outputOption); return command; } /// @@ -85,18 +84,5 @@ public RequestInformation CreatePostRequestInformation(GrantRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action grant - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GrantRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Sites/Item/Permissions/Item/PermissionRequestBuilder.cs b/src/generated/Sites/Item/Permissions/Item/PermissionRequestBuilder.cs index c5b9359228d..863fcf883e4 100644 --- a/src/generated/Sites/Item/Permissions/Item/PermissionRequestBuilder.cs +++ b/src/generated/Sites/Item/Permissions/Item/PermissionRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Permissions.Item.Grant; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,11 +35,10 @@ public Command BuildDeleteCommand() { }; permissionIdOption.IsRequired = true; command.AddOption(permissionIdOption); - command.SetHandler(async (string siteId, string permissionId) => { + command.SetHandler(async (string siteId, string permissionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, permissionIdOption); return command; @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string permissionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string permissionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, permissionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, permissionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildGrantCommand() { @@ -110,14 +108,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string permissionId, string body) => { + command.SetHandler(async (string siteId, string permissionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, permissionIdOption, bodyOption); return command; @@ -189,42 +186,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions associated with the site. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions associated with the site. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions associated with the site. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Permission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions associated with the site. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Permissions/PermissionsRequestBuilder.cs b/src/generated/Sites/Item/Permissions/PermissionsRequestBuilder.cs index 2ad148126fb..6a9885bcb40 100644 --- a/src/generated/Sites/Item/Permissions/PermissionsRequestBuilder.cs +++ b/src/generated/Sites/Item/Permissions/PermissionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Permissions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class PermissionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PermissionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildGrantCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildGrantCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, bodyOption, outputOption); return command; } /// @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions associated with the site. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions associated with the site. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Permission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions associated with the site. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/SiteRequestBuilder.cs b/src/generated/Sites/Item/SiteRequestBuilder.cs index 13910bc0980..2b99878d9e6 100644 --- a/src/generated/Sites/Item/SiteRequestBuilder.cs +++ b/src/generated/Sites/Item/SiteRequestBuilder.cs @@ -18,10 +18,10 @@ using ApiSdk.Sites.Item.TermStores; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -46,6 +46,9 @@ public Command BuildAnalyticsCommand() { public Command BuildColumnsCommand() { var command = new Command("columns"); var builder = new ApiSdk.Sites.Item.Columns.ColumnsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -54,6 +57,9 @@ public Command BuildContentTypesCommand() { var command = new Command("content-types"); var builder = new ApiSdk.Sites.Item.ContentTypes.ContentTypesRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCopyCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -69,11 +75,10 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - command.SetHandler(async (string siteId) => { + command.SetHandler(async (string siteId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption); return command; @@ -89,6 +94,9 @@ public Command BuildDriveCommand() { public Command BuildDrivesCommand() { var command = new Command("drives"); var builder = new ApiSdk.Sites.Item.Drives.DrivesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -121,25 +129,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildItemsCommand() { var command = new Command("items"); var builder = new ApiSdk.Sites.Item.Items.ItemsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -147,6 +157,9 @@ public Command BuildItemsCommand() { public Command BuildListsCommand() { var command = new Command("lists"); var builder = new ApiSdk.Sites.Item.Lists.ListsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -180,14 +193,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string body) => { + command.SetHandler(async (string siteId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, bodyOption); return command; @@ -195,6 +207,9 @@ public Command BuildPatchCommand() { public Command BuildPermissionsCommand() { var command = new Command("permissions"); var builder = new ApiSdk.Sites.Item.Permissions.PermissionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -202,6 +217,9 @@ public Command BuildPermissionsCommand() { public Command BuildSitesCommand() { var command = new Command("sites"); var builder = new ApiSdk.Sites.Item.Sites.SitesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -219,6 +237,9 @@ public Command BuildTermStoreCommand() { public Command BuildTermStoresCommand() { var command = new Command("term-stores"); var builder = new ApiSdk.Sites.Item.TermStores.TermStoresRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -291,17 +312,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. return requestInfo; } /// - /// Delete entity from sites - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \sites\{site-id}\microsoft.graph.getActivitiesByInterval() /// public GetActivitiesByIntervalRequestBuilder GetActivitiesByInterval() { @@ -328,18 +338,6 @@ public GetApplicableContentTypesForListWithListIdRequestBuilder GetApplicableCon return new GetApplicableContentTypesForListWithListIdRequestBuilder(PathParameters, RequestAdapter, listId); } /// - /// Get entity from sites by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \sites\{site-id}\microsoft.graph.getByPath(path='{path}') /// Usage: path={path} /// @@ -347,19 +345,6 @@ public GetByPathWithPathRequestBuilder GetByPathWithPath(string path) { if(string.IsNullOrEmpty(path)) throw new ArgumentNullException(nameof(path)); return new GetByPathWithPathRequestBuilder(PathParameters, RequestAdapter, path); } - /// - /// Update entity in sites - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Site model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from sites by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Sites/Item/SiteRequestBuilder.cs b/src/generated/Sites/Item/Sites/Item/SiteRequestBuilder.cs index fef7308bf04..bbb2c9f1358 100644 --- a/src/generated/Sites/Item/Sites/Item/SiteRequestBuilder.cs +++ b/src/generated/Sites/Item/Sites/Item/SiteRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; siteId1Option.IsRequired = true; command.AddOption(siteId1Option); - command.SetHandler(async (string siteId, string siteId1) => { + command.SetHandler(async (string siteId, string siteId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, siteId1Option); return command; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string siteId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string siteId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, siteId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, siteId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string siteId1, string body) => { + command.SetHandler(async (string siteId, string siteId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, siteId1Option, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of the sub-sites under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of the sub-sites under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of the sub-sites under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Site model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of the sub-sites under this site. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/Sites/SitesRequestBuilder.cs b/src/generated/Sites/Item/Sites/SitesRequestBuilder.cs index 407886d8864..4f7a1916813 100644 --- a/src/generated/Sites/Item/Sites/SitesRequestBuilder.cs +++ b/src/generated/Sites/Item/Sites/SitesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.Sites.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SitesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SiteRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of the sub-sites under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of the sub-sites under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Site model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of the sub-sites under this site. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStore/Groups/GroupsRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/GroupsRequestBuilder.cs index c580759af83..0a246e13d4c 100644 --- a/src/generated/Sites/Item/TermStore/Groups/GroupsRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/GroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Groups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class GroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new GroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSetsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSetsCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, bodyOption, outputOption); return command; } /// @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of all groups available in the term store. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of all groups available in the term store. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Group model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of all groups available in the term store. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStore/Groups/GroupsResponse.cs b/src/generated/Sites/Item/TermStore/Groups/GroupsResponse.cs index c17041ea674..7606a5881d7 100644 --- a/src/generated/Sites/Item/TermStore/Groups/GroupsResponse.cs +++ b/src/generated/Sites/Item/TermStore/Groups/GroupsResponse.cs @@ -1,4 +1,4 @@ -using ApiSdk.Models.Microsoft.Graph; +using ApiSdk.Models.Microsoft.Graph.TermStore; using Microsoft.Kiota.Abstractions.Serialization; using System; using System.Collections.Generic; @@ -9,7 +9,7 @@ public class GroupsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new groupsResponse and sets the default values. /// @@ -22,7 +22,7 @@ public GroupsResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as GroupsResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as GroupsResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, + {"value", (o,n) => { (o as GroupsResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/GroupRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/GroupRequestBuilder.cs index 99a77af48f1..fe595633e27 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/GroupRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/GroupRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Groups.Item.Sets; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,11 +35,10 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - command.SetHandler(async (string siteId, string groupId) => { + command.SetHandler(async (string siteId, string groupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, groupIdOption); return command; @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,14 +102,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string body) => { + command.SetHandler(async (string siteId, string groupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, groupIdOption, bodyOption); return command; @@ -119,6 +116,9 @@ public Command BuildPatchCommand() { public Command BuildSetsCommand() { var command = new Command("sets"); var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.SetsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -190,42 +190,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of all groups available in the term store. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of all groups available in the term store. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of all groups available in the term store. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Group model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of all groups available in the term store. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/ChildrenRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/ChildrenRequestBuilder.cs index bad25be00dc..2d7b887719b 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/ChildrenRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/ChildrenRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class ChildrenRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TermRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildChildrenCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildRelationsCommand(), - builder.BuildSetCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildChildrenCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRelationsCommand()); + commands.Add(builder.BuildSetCommand()); return commands; } /// @@ -55,21 +54,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string setId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, bodyOption, outputOption); return command; } /// @@ -126,7 +124,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -137,15 +139,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -200,31 +197,6 @@ public RequestInformation CreatePostRequestInformation(Term body, Action - /// Children terms of set in term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children terms of set in term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Children terms of set in term [store]. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Children/ChildrenRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Children/ChildrenRequestBuilder.cs index b2b861b2533..ac3d49972fa 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Children/ChildrenRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Children/ChildrenRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Children.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ChildrenRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TermRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, bodyOption, outputOption); return command; } /// @@ -131,7 +129,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -142,15 +144,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -205,31 +202,6 @@ public RequestInformation CreatePostRequestInformation(Term body, Action - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Children of current term. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Children/Item/TermRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Children/Item/TermRequestBuilder.cs index f0b2b8315a3..dbe6e58fb90 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Children/Item/TermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Children/Item/TermRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph.TermStore; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -46,11 +46,10 @@ public Command BuildDeleteCommand() { }; termId1Option.IsRequired = true; command.AddOption(termId1Option); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string termId1) => { + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string termId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, groupIdOption, setIdOption, termIdOption, termId1Option); return command; @@ -92,20 +91,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string termId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string termId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, termId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, termId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -139,14 +137,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string termId1, string body) => { + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string termId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, groupIdOption, setIdOption, termIdOption, termId1Option, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(Term body, Action - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Children of current term. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/@Ref/@Ref.cs deleted file mode 100644 index da586aec76c..00000000000 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 5b865ea4b54..00000000000 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,238 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStore\groups\{group-id}\sets\{set-id}\children\{term-id}\relations\{relation-id}\fromTerm\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/groups/{group_id}/sets/{set_id}/children/{term_id}/relations/{relation_id}/fromTerm/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs index 59d6b32a78e..5774ba96f56 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -57,25 +57,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -115,18 +114,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/Ref/Ref.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/Ref/Ref.cs new file mode 100644 index 00000000000..e95d30db1f8 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..b26623f3664 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs @@ -0,0 +1,200 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStore\groups\{group-id}\sets\{set-id}\children\{term-id}\relations\{relation-id}\fromTerm\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); + return command; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/groups/{group_id}/sets/{set_id}/children/{term_id}/relations/{relation_id}/fromTerm/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/RelationRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/RelationRequestBuilder.cs index 28c8464b8c7..12da7a58efb 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/RelationRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/RelationRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.ToTerm; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -49,11 +49,10 @@ public Command BuildDeleteCommand() { }; relationIdOption.IsRequired = true; command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId) => { + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); return command; @@ -102,20 +101,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -149,14 +147,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string body) => { + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); return command; @@ -242,42 +239,6 @@ public RequestInformation CreatePatchRequestInformation(Relation body, Action - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Relation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// To indicate which terms are related to the current term as either pinned or reused. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/@Ref/@Ref.cs deleted file mode 100644 index 48775136199..00000000000 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.Set.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 2fc84dee00c..00000000000 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,238 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.Set.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStore\groups\{group-id}\sets\{set-id}\children\{term-id}\relations\{relation-id}\set\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/groups/{group_id}/sets/{set_id}/children/{term_id}/relations/{relation_id}/set/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The [set] in which the relation is relevant. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.Set.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.Set.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/Ref/Ref.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/Ref/Ref.cs new file mode 100644 index 00000000000..ef9fc27e786 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.Set.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..0128680d996 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs @@ -0,0 +1,200 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.Set.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStore\groups\{group-id}\sets\{set-id}\children\{term-id}\relations\{relation-id}\set\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); + return command; + } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/groups/{group_id}/sets/{set_id}/children/{term_id}/relations/{relation_id}/set/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The [set] in which the relation is relevant. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the relation is relevant. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the relation is relevant. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.Set.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/SetRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/SetRequestBuilder.cs index c2f7c2232a1..d89fef90e86 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/SetRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/SetRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.Set.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -57,25 +57,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.Set.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.Set.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -115,18 +114,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The [set] in which the relation is relevant. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/@Ref/@Ref.cs deleted file mode 100644 index 21c782f501d..00000000000 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 346e8b36375..00000000000 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,238 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStore\groups\{group-id}\sets\{set-id}\children\{term-id}\relations\{relation-id}\toTerm\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/groups/{group_id}/sets/{set_id}/children/{term_id}/relations/{relation_id}/toTerm/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/Ref/Ref.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/Ref/Ref.cs new file mode 100644 index 00000000000..b1fb60e21c2 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..0d94bde90d1 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs @@ -0,0 +1,200 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStore\groups\{group-id}\sets\{set-id}\children\{term-id}\relations\{relation-id}\toTerm\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); + return command; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/groups/{group_id}/sets/{set_id}/children/{term_id}/relations/{relation_id}/toTerm/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs index bbcee63bbf0..1f7cdd5d5a3 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -57,25 +57,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -115,18 +114,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The to [term] of the relation. The term to which the relationship is defined. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/RelationsRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/RelationsRequestBuilder.cs index 97dcd6f39c3..78f578d0728 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/RelationsRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Relations/RelationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class RelationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new RelationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildFromTermCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSetCommand(), - builder.BuildToTermCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFromTermCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSetCommand()); + commands.Add(builder.BuildToTermCommand()); return commands; } /// @@ -59,21 +58,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, bodyOption, outputOption); return command; } /// @@ -134,7 +132,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -145,15 +147,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -208,31 +205,6 @@ public RequestInformation CreatePostRequestInformation(Relation body, Action - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Relation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// To indicate which terms are related to the current term as either pinned or reused. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Set/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Set/@Ref/@Ref.cs deleted file mode 100644 index 71cf9c64022..00000000000 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Set/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Set.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Set/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Set/@Ref/RefRequestBuilder.cs deleted file mode 100644 index f719801abb2..00000000000 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Set/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,226 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Set.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStore\groups\{group-id}\sets\{set-id}\children\{term-id}\set\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The [set] in which the term is created. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The [set] in which the term is created."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption); - return command; - } - /// - /// The [set] in which the term is created. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The [set] in which the term is created."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption); - return command; - } - /// - /// The [set] in which the term is created. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The [set] in which the term is created."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/groups/{group_id}/sets/{set_id}/children/{term_id}/set/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The [set] in which the term is created. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the term is created. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the term is created. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Set.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Set.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Set/Ref/Ref.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Set/Ref/Ref.cs new file mode 100644 index 00000000000..ac02756a1ed --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Set/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Set.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Set/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Set/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..b5212e677cc --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Set/Ref/RefRequestBuilder.cs @@ -0,0 +1,188 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Set.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStore\groups\{group-id}\sets\{set-id}\children\{term-id}\set\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The [set] in which the term is created. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The [set] in which the term is created."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, groupIdOption, setIdOption, termIdOption); + return command; + } + /// + /// The [set] in which the term is created. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The [set] in which the term is created."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, outputOption); + return command; + } + /// + /// The [set] in which the term is created. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The [set] in which the term is created."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/groups/{group_id}/sets/{set_id}/children/{term_id}/set/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The [set] in which the term is created. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the term is created. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the term is created. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Set.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Set/SetRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Set/SetRequestBuilder.cs index 70b25f62d5f..74cf4232b28 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Set/SetRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/Set/SetRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Set.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -53,25 +53,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Set.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Set.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -111,18 +110,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The [set] in which the term is created. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/TermRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/TermRequestBuilder.cs index b748267584f..0ddc4c49b32 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/TermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Children/Item/TermRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Set; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,6 +25,9 @@ public class TermRequestBuilder { public Command BuildChildrenCommand() { var command = new Command("children"); var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Children.ChildrenRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -52,11 +55,10 @@ public Command BuildDeleteCommand() { }; termIdOption.IsRequired = true; command.AddOption(termIdOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId) => { + command.SetHandler(async (string siteId, string groupId, string setId, string termId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, groupIdOption, setIdOption, termIdOption); return command; @@ -94,20 +96,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -137,14 +138,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string body) => { + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, groupIdOption, setIdOption, termIdOption, bodyOption); return command; @@ -152,6 +152,9 @@ public Command BuildPatchCommand() { public Command BuildRelationsCommand() { var command = new Command("relations"); var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.Item.Relations.RelationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -230,42 +233,6 @@ public RequestInformation CreatePatchRequestInformation(Term body, Action - /// Children terms of set in term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children terms of set in term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children terms of set in term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Children terms of set in term [store]. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/ParentGroup/ParentGroupRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/ParentGroup/ParentGroupRequestBuilder.cs index 607c56243b1..50ff3ba7794 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/ParentGroup/ParentGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/ParentGroup/ParentGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; setIdOption.IsRequired = true; command.AddOption(setIdOption); - command.SetHandler(async (string siteId, string groupId, string setId) => { + command.SetHandler(async (string siteId, string groupId, string setId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, groupIdOption, setIdOption); return command; @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string setId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string setId, string body) => { + command.SetHandler(async (string siteId, string groupId, string setId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, groupIdOption, setIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The parent [group] that contains the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The parent [group] that contains the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The parent [group] that contains the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Group model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The parent [group] that contains the set. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/FromTerm/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/FromTerm/@Ref/@Ref.cs deleted file mode 100644 index 54f93b66bc8..00000000000 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/FromTerm/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.FromTerm.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 6a06a1ce2eb..00000000000 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,226 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.FromTerm.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStore\groups\{group-id}\sets\{set-id}\relations\{relation-id}\fromTerm\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string groupId, string setId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, groupIdOption, setIdOption, relationIdOption); - return command; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string groupId, string setId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, relationIdOption); - return command; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string setId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, groupIdOption, setIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/groups/{group_id}/sets/{set_id}/relations/{relation_id}/fromTerm/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.FromTerm.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.FromTerm.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs index d9edc58ffd1..b941c4a35d4 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.FromTerm.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -53,25 +53,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string setId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.FromTerm.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.FromTerm.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -111,18 +110,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/FromTerm/Ref/Ref.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/FromTerm/Ref/Ref.cs new file mode 100644 index 00000000000..003fcdebccf --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/FromTerm/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.FromTerm.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..5f98d749503 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs @@ -0,0 +1,188 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.FromTerm.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStore\groups\{group-id}\sets\{set-id}\relations\{relation-id}\fromTerm\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string groupId, string setId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, groupIdOption, setIdOption, relationIdOption); + return command; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string groupId, string setId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, groupIdOption, setIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/groups/{group_id}/sets/{set_id}/relations/{relation_id}/fromTerm/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.FromTerm.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/RelationRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/RelationRequestBuilder.cs index 396f4966397..cd84d63c3f8 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/RelationRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/RelationRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.ToTerm; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -45,11 +45,10 @@ public Command BuildDeleteCommand() { }; relationIdOption.IsRequired = true; command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string groupId, string setId, string relationId) => { + command.SetHandler(async (string siteId, string groupId, string setId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, groupIdOption, setIdOption, relationIdOption); return command; @@ -94,20 +93,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string setId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -137,14 +135,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string setId, string relationId, string body) => { + command.SetHandler(async (string siteId, string groupId, string setId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, groupIdOption, setIdOption, relationIdOption, bodyOption); return command; @@ -230,42 +227,6 @@ public RequestInformation CreatePatchRequestInformation(Relation body, Action - /// Indicates which terms have been pinned or reused directly under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Indicates which terms have been pinned or reused directly under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Indicates which terms have been pinned or reused directly under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Relation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Indicates which terms have been pinned or reused directly under the set. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/Set/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/Set/@Ref/@Ref.cs deleted file mode 100644 index c78e1a54fe3..00000000000 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/Set/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.Set.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs deleted file mode 100644 index cf434b63e05..00000000000 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,226 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.Set.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStore\groups\{group-id}\sets\{set-id}\relations\{relation-id}\set\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string groupId, string setId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, groupIdOption, setIdOption, relationIdOption); - return command; - } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string groupId, string setId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, relationIdOption); - return command; - } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string setId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, groupIdOption, setIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/groups/{group_id}/sets/{set_id}/relations/{relation_id}/set/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The [set] in which the relation is relevant. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.Set.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.Set.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/Set/Ref/Ref.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/Set/Ref/Ref.cs new file mode 100644 index 00000000000..d8b48e53754 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/Set/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.Set.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..a74752d4f75 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs @@ -0,0 +1,188 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.Set.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStore\groups\{group-id}\sets\{set-id}\relations\{relation-id}\set\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string groupId, string setId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, groupIdOption, setIdOption, relationIdOption); + return command; + } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string groupId, string setId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, groupIdOption, setIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/groups/{group_id}/sets/{set_id}/relations/{relation_id}/set/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The [set] in which the relation is relevant. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the relation is relevant. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the relation is relevant. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.Set.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/Set/SetRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/Set/SetRequestBuilder.cs index fe77a0d1dc8..d91d47858e8 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/Set/SetRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/Set/SetRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.Set.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -53,25 +53,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string setId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.Set.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.Set.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -111,18 +110,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The [set] in which the relation is relevant. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/ToTerm/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/ToTerm/@Ref/@Ref.cs deleted file mode 100644 index 4db04f042ca..00000000000 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/ToTerm/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.ToTerm.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 41de0dd966b..00000000000 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,226 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.ToTerm.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStore\groups\{group-id}\sets\{set-id}\relations\{relation-id}\toTerm\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string groupId, string setId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, groupIdOption, setIdOption, relationIdOption); - return command; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string groupId, string setId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, relationIdOption); - return command; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string setId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, groupIdOption, setIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/groups/{group_id}/sets/{set_id}/relations/{relation_id}/toTerm/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.ToTerm.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.ToTerm.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/ToTerm/Ref/Ref.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/ToTerm/Ref/Ref.cs new file mode 100644 index 00000000000..4f319f3f77a --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/ToTerm/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.ToTerm.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..2278649bf34 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs @@ -0,0 +1,188 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.ToTerm.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStore\groups\{group-id}\sets\{set-id}\relations\{relation-id}\toTerm\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string groupId, string setId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, groupIdOption, setIdOption, relationIdOption); + return command; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string groupId, string setId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, groupIdOption, setIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/groups/{group_id}/sets/{set_id}/relations/{relation_id}/toTerm/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.ToTerm.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs index dac3fdfb3f6..cbac2bd7c47 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.ToTerm.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -53,25 +53,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string setId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.ToTerm.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item.ToTerm.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -111,18 +110,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The to [term] of the relation. The term to which the relationship is defined. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/RelationsRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/RelationsRequestBuilder.cs index cc95c7dc816..1d257df601b 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/RelationsRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Relations/RelationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class RelationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new RelationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildFromTermCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSetCommand(), - builder.BuildToTermCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFromTermCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSetCommand()); + commands.Add(builder.BuildToTermCommand()); return commands; } /// @@ -55,21 +54,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string setId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, bodyOption, outputOption); return command; } /// @@ -126,7 +124,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -137,15 +139,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -200,31 +197,6 @@ public RequestInformation CreatePostRequestInformation(Relation body, Action - /// Indicates which terms have been pinned or reused directly under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Indicates which terms have been pinned or reused directly under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Relation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Indicates which terms have been pinned or reused directly under the set. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/SetRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/SetRequestBuilder.cs index 7c2aff2c70a..63b7dd77d9c 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/SetRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/SetRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,6 +26,9 @@ public class SetRequestBuilder { public Command BuildChildrenCommand() { var command = new Command("children"); var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Children.ChildrenRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -49,11 +52,10 @@ public Command BuildDeleteCommand() { }; setIdOption.IsRequired = true; command.AddOption(setIdOption); - command.SetHandler(async (string siteId, string groupId, string setId) => { + command.SetHandler(async (string siteId, string groupId, string setId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, groupIdOption, setIdOption); return command; @@ -87,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string setId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentGroupCommand() { @@ -134,14 +135,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string setId, string body) => { + command.SetHandler(async (string siteId, string groupId, string setId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, groupIdOption, setIdOption, bodyOption); return command; @@ -149,6 +149,9 @@ public Command BuildPatchCommand() { public Command BuildRelationsCommand() { var command = new Command("relations"); var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Relations.RelationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -156,6 +159,9 @@ public Command BuildRelationsCommand() { public Command BuildTermsCommand() { var command = new Command("terms"); var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.TermsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -227,42 +233,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All sets under the group in a term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All sets under the group in a term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All sets under the group in a term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.TermStore.Set model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// All sets under the group in a term [store]. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Children/ChildrenRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Children/ChildrenRequestBuilder.cs index faa165e0334..8dabcc34667 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Children/ChildrenRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Children/ChildrenRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Children.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ChildrenRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TermRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, bodyOption, outputOption); return command; } /// @@ -131,7 +129,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -142,15 +144,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -205,31 +202,6 @@ public RequestInformation CreatePostRequestInformation(Term body, Action - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Children of current term. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Children/Item/TermRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Children/Item/TermRequestBuilder.cs index 7cf63480344..ca94fdbac6b 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Children/Item/TermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Children/Item/TermRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph.TermStore; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -46,11 +46,10 @@ public Command BuildDeleteCommand() { }; termId1Option.IsRequired = true; command.AddOption(termId1Option); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string termId1) => { + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string termId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, groupIdOption, setIdOption, termIdOption, termId1Option); return command; @@ -92,20 +91,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string termId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string termId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, termId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, termId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -139,14 +137,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string termId1, string body) => { + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string termId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, groupIdOption, setIdOption, termIdOption, termId1Option, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(Term body, Action - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Children of current term. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/@Ref/@Ref.cs deleted file mode 100644 index 0ac579399c1..00000000000 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 1ce400a78a0..00000000000 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,238 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStore\groups\{group-id}\sets\{set-id}\terms\{term-id}\relations\{relation-id}\fromTerm\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/groups/{group_id}/sets/{set_id}/terms/{term_id}/relations/{relation_id}/fromTerm/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs index 86550550b64..03095f3c07b 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -57,25 +57,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -115,18 +114,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/Ref/Ref.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/Ref/Ref.cs new file mode 100644 index 00000000000..7daa9aee82f --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..18b2994f570 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs @@ -0,0 +1,200 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStore\groups\{group-id}\sets\{set-id}\terms\{term-id}\relations\{relation-id}\fromTerm\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); + return command; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/groups/{group_id}/sets/{set_id}/terms/{term_id}/relations/{relation_id}/fromTerm/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/RelationRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/RelationRequestBuilder.cs index 2377a185fb8..023908bccc5 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/RelationRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/RelationRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -49,11 +49,10 @@ public Command BuildDeleteCommand() { }; relationIdOption.IsRequired = true; command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId) => { + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); return command; @@ -102,20 +101,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -149,14 +147,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string body) => { + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); return command; @@ -242,42 +239,6 @@ public RequestInformation CreatePatchRequestInformation(Relation body, Action - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Relation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// To indicate which terms are related to the current term as either pinned or reused. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/@Ref/@Ref.cs deleted file mode 100644 index e4fbeaa1197..00000000000 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.Set.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 65a9c2d0649..00000000000 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,238 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.Set.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStore\groups\{group-id}\sets\{set-id}\terms\{term-id}\relations\{relation-id}\set\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/groups/{group_id}/sets/{set_id}/terms/{term_id}/relations/{relation_id}/set/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The [set] in which the relation is relevant. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.Set.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.Set.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/Ref/Ref.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/Ref/Ref.cs new file mode 100644 index 00000000000..b4a7a62aea3 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.Set.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..543a6c93706 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs @@ -0,0 +1,200 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.Set.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStore\groups\{group-id}\sets\{set-id}\terms\{term-id}\relations\{relation-id}\set\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); + return command; + } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/groups/{group_id}/sets/{set_id}/terms/{term_id}/relations/{relation_id}/set/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The [set] in which the relation is relevant. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the relation is relevant. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the relation is relevant. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.Set.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/SetRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/SetRequestBuilder.cs index d0ba9c493fe..d901480816a 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/SetRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/SetRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.Set.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -57,25 +57,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.Set.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.Set.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -115,18 +114,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The [set] in which the relation is relevant. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/@Ref/@Ref.cs deleted file mode 100644 index 7a81852e63e..00000000000 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs deleted file mode 100644 index c74501504cf..00000000000 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,238 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStore\groups\{group-id}\sets\{set-id}\terms\{term-id}\relations\{relation-id}\toTerm\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/groups/{group_id}/sets/{set_id}/terms/{term_id}/relations/{relation_id}/toTerm/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/Ref/Ref.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/Ref/Ref.cs new file mode 100644 index 00000000000..4567706bb0d --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..aef894e2c09 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs @@ -0,0 +1,200 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStore\groups\{group-id}\sets\{set-id}\terms\{term-id}\relations\{relation-id}\toTerm\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); + return command; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/groups/{group_id}/sets/{set_id}/terms/{term_id}/relations/{relation_id}/toTerm/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs index 00fdee93b5d..f409a18fd5c 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -57,25 +57,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -115,18 +114,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The to [term] of the relation. The term to which the relationship is defined. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/RelationsRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/RelationsRequestBuilder.cs index 483db08c814..ebcbeaa0f98 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/RelationsRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Relations/RelationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class RelationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new RelationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildFromTermCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSetCommand(), - builder.BuildToTermCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFromTermCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSetCommand()); + commands.Add(builder.BuildToTermCommand()); return commands; } /// @@ -59,21 +58,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, bodyOption, outputOption); return command; } /// @@ -134,7 +132,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -145,15 +147,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -208,31 +205,6 @@ public RequestInformation CreatePostRequestInformation(Relation body, Action - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Relation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// To indicate which terms are related to the current term as either pinned or reused. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Set/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Set/@Ref/@Ref.cs deleted file mode 100644 index b9ae4971020..00000000000 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Set/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Set.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Set/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Set/@Ref/RefRequestBuilder.cs deleted file mode 100644 index a2c979d0147..00000000000 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Set/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,226 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Set.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStore\groups\{group-id}\sets\{set-id}\terms\{term-id}\set\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The [set] in which the term is created. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The [set] in which the term is created."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption); - return command; - } - /// - /// The [set] in which the term is created. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The [set] in which the term is created."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption); - return command; - } - /// - /// The [set] in which the term is created. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The [set] in which the term is created."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/groups/{group_id}/sets/{set_id}/terms/{term_id}/set/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The [set] in which the term is created. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the term is created. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the term is created. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Set.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Set.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Set/Ref/Ref.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Set/Ref/Ref.cs new file mode 100644 index 00000000000..90d7b48a8c9 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Set/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Set.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Set/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Set/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..7f21557a480 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Set/Ref/RefRequestBuilder.cs @@ -0,0 +1,188 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Set.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStore\groups\{group-id}\sets\{set-id}\terms\{term-id}\set\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The [set] in which the term is created. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The [set] in which the term is created."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, groupIdOption, setIdOption, termIdOption); + return command; + } + /// + /// The [set] in which the term is created. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The [set] in which the term is created."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, outputOption); + return command; + } + /// + /// The [set] in which the term is created. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The [set] in which the term is created."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/groups/{group_id}/sets/{set_id}/terms/{term_id}/set/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The [set] in which the term is created. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the term is created. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the term is created. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Set.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Set/SetRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Set/SetRequestBuilder.cs index 5cff886368f..f5630c0b329 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Set/SetRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/Set/SetRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Set.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -53,25 +53,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Set.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Set.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -111,18 +110,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The [set] in which the term is created. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/TermRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/TermRequestBuilder.cs index 27518a5a2a6..5347341a9ae 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/TermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/Item/TermRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Set; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,6 +25,9 @@ public class TermRequestBuilder { public Command BuildChildrenCommand() { var command = new Command("children"); var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Children.ChildrenRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -52,11 +55,10 @@ public Command BuildDeleteCommand() { }; termIdOption.IsRequired = true; command.AddOption(termIdOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId) => { + command.SetHandler(async (string siteId, string groupId, string setId, string termId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, groupIdOption, setIdOption, termIdOption); return command; @@ -94,20 +96,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, termIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, termIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -137,14 +138,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string setId, string termId, string body) => { + command.SetHandler(async (string siteId, string groupId, string setId, string termId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, groupIdOption, setIdOption, termIdOption, bodyOption); return command; @@ -152,6 +152,9 @@ public Command BuildPatchCommand() { public Command BuildRelationsCommand() { var command = new Command("relations"); var builder = new ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item.Relations.RelationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -230,42 +233,6 @@ public RequestInformation CreatePatchRequestInformation(Term body, Action - /// All the terms under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All the terms under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All the terms under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// All the terms under the set. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/TermsRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/TermsRequestBuilder.cs index b54205e6a50..1ee0aaf8de3 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/TermsRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/Item/Terms/TermsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item.Terms.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class TermsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TermRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildChildrenCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildRelationsCommand(), - builder.BuildSetCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildChildrenCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRelationsCommand()); + commands.Add(builder.BuildSetCommand()); return commands; } /// @@ -55,21 +54,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string setId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, bodyOption, outputOption); return command; } /// @@ -126,7 +124,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -137,15 +139,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -200,31 +197,6 @@ public RequestInformation CreatePostRequestInformation(Term body, Action - /// All the terms under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All the terms under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// All the terms under the set. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/SetsRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/SetsRequestBuilder.cs index c712809d60d..7785d31d69e 100644 --- a/src/generated/Sites/Item/TermStore/Groups/Item/Sets/SetsRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Groups/Item/Sets/SetsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Groups.Item.Sets.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SetsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SetRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildChildrenCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildRelationsCommand(), - builder.BuildTermsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildChildrenCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRelationsCommand()); + commands.Add(builder.BuildTermsCommand()); return commands; } /// @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, bodyOption, outputOption); return command; } /// @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -130,15 +132,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -193,31 +190,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All sets under the group in a term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All sets under the group in a term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.TermStore.Set model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// All sets under the group in a term [store]. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Children/ChildrenRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Children/ChildrenRequestBuilder.cs index 9280ae112b1..ed2024f5fcb 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Children/ChildrenRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Children/ChildrenRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class ChildrenRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TermRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildChildrenCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildRelationsCommand(), - builder.BuildSetCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildChildrenCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRelationsCommand()); + commands.Add(builder.BuildSetCommand()); return commands; } /// @@ -51,21 +50,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, bodyOption, outputOption); return command; } /// @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -129,15 +131,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(Term body, Action - /// Children terms of set in term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children terms of set in term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Children terms of set in term [store]. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Children/ChildrenRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Children/ChildrenRequestBuilder.cs index 75046e8cee5..fbc10a022e6 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Children/ChildrenRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Children/ChildrenRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Children.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ChildrenRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TermRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string termId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, bodyOption, outputOption); return command; } /// @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(Term body, Action - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Children of current term. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Children/Item/TermRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Children/Item/TermRequestBuilder.cs index e8a8d8139fc..c1e4903d937 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Children/Item/TermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Children/Item/TermRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph.TermStore; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -42,11 +42,10 @@ public Command BuildDeleteCommand() { }; termId1Option.IsRequired = true; command.AddOption(termId1Option); - command.SetHandler(async (string siteId, string setId, string termId, string termId1) => { + command.SetHandler(async (string siteId, string setId, string termId, string termId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, setIdOption, termIdOption, termId1Option); return command; @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, string termId, string termId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, string termId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, termId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, termId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string termId, string termId1, string body) => { + command.SetHandler(async (string siteId, string setId, string termId, string termId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, setIdOption, termIdOption, termId1Option, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(Term body, Action - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Children of current term. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/FromTerm/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/FromTerm/@Ref/@Ref.cs deleted file mode 100644 index 12399beb61d..00000000000 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/FromTerm/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.FromTerm.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs deleted file mode 100644 index c90e38c7f5c..00000000000 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,226 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.FromTerm.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStore\sets\{set-id}\children\{term-id}\relations\{relation-id}\fromTerm\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/sets/{set_id}/children/{term_id}/relations/{relation_id}/fromTerm/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.FromTerm.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.FromTerm.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs index b4c6d9c7f4a..b3149643dec 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.FromTerm.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -53,25 +53,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.FromTerm.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.FromTerm.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -111,18 +110,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/FromTerm/Ref/Ref.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/FromTerm/Ref/Ref.cs new file mode 100644 index 00000000000..0924e898851 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/FromTerm/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.FromTerm.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..cd9ff5bb62a --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs @@ -0,0 +1,188 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.FromTerm.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStore\sets\{set-id}\children\{term-id}\relations\{relation-id}\fromTerm\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, setIdOption, termIdOption, relationIdOption); + return command; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/sets/{set_id}/children/{term_id}/relations/{relation_id}/fromTerm/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.FromTerm.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/RelationRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/RelationRequestBuilder.cs index b2e59b2e6c5..eb2515fc1a0 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/RelationRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/RelationRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.ToTerm; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -45,11 +45,10 @@ public Command BuildDeleteCommand() { }; relationIdOption.IsRequired = true; command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId) => { + command.SetHandler(async (string siteId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, setIdOption, termIdOption, relationIdOption); return command; @@ -94,20 +93,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -137,14 +135,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId, string body) => { + command.SetHandler(async (string siteId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); return command; @@ -230,42 +227,6 @@ public RequestInformation CreatePatchRequestInformation(Relation body, Action - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Relation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// To indicate which terms are related to the current term as either pinned or reused. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/Set/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/Set/@Ref/@Ref.cs deleted file mode 100644 index e5a34369a82..00000000000 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/Set/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.Set.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs deleted file mode 100644 index c944267b381..00000000000 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,226 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.Set.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStore\sets\{set-id}\children\{term-id}\relations\{relation-id}\set\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/sets/{set_id}/children/{term_id}/relations/{relation_id}/set/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The [set] in which the relation is relevant. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.Set.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.Set.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/Set/Ref/Ref.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/Set/Ref/Ref.cs new file mode 100644 index 00000000000..e9abe27259c --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/Set/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.Set.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..c10c0d51440 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs @@ -0,0 +1,188 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.Set.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStore\sets\{set-id}\children\{term-id}\relations\{relation-id}\set\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, setIdOption, termIdOption, relationIdOption); + return command; + } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/sets/{set_id}/children/{term_id}/relations/{relation_id}/set/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The [set] in which the relation is relevant. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the relation is relevant. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the relation is relevant. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.Set.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/Set/SetRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/Set/SetRequestBuilder.cs index 38d23d6a447..c9cff6f746e 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/Set/SetRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/Set/SetRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.Set.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -53,25 +53,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.Set.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.Set.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -111,18 +110,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The [set] in which the relation is relevant. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/ToTerm/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/ToTerm/@Ref/@Ref.cs deleted file mode 100644 index ea0d1e72532..00000000000 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/ToTerm/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.ToTerm.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 57155e1df85..00000000000 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,226 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.ToTerm.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStore\sets\{set-id}\children\{term-id}\relations\{relation-id}\toTerm\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/sets/{set_id}/children/{term_id}/relations/{relation_id}/toTerm/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.ToTerm.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.ToTerm.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/ToTerm/Ref/Ref.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/ToTerm/Ref/Ref.cs new file mode 100644 index 00000000000..858c3b67857 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/ToTerm/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.ToTerm.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..61dfb85fd2b --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs @@ -0,0 +1,188 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.ToTerm.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStore\sets\{set-id}\children\{term-id}\relations\{relation-id}\toTerm\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, setIdOption, termIdOption, relationIdOption); + return command; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/sets/{set_id}/children/{term_id}/relations/{relation_id}/toTerm/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.ToTerm.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs index 0be16674d2c..5ebd615cad9 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.ToTerm.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -53,25 +53,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.ToTerm.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item.ToTerm.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -111,18 +110,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The to [term] of the relation. The term to which the relationship is defined. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/RelationsRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/RelationsRequestBuilder.cs index bf65e721839..08b19161698 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/RelationsRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Relations/RelationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class RelationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new RelationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildFromTermCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSetCommand(), - builder.BuildToTermCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFromTermCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSetCommand()); + commands.Add(builder.BuildToTermCommand()); return commands; } /// @@ -55,21 +54,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string termId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, bodyOption, outputOption); return command; } /// @@ -126,7 +124,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -137,15 +139,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -200,31 +197,6 @@ public RequestInformation CreatePostRequestInformation(Relation body, Action - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Relation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// To indicate which terms are related to the current term as either pinned or reused. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Set/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Set/@Ref/@Ref.cs deleted file mode 100644 index 2ba61d8c4e8..00000000000 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Set/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Set.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Set/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Set/@Ref/RefRequestBuilder.cs deleted file mode 100644 index c5f9a8e20c5..00000000000 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Set/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,214 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Set.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStore\sets\{set-id}\children\{term-id}\set\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The [set] in which the term is created. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The [set] in which the term is created."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - command.SetHandler(async (string siteId, string setId, string termId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, setIdOption, termIdOption); - return command; - } - /// - /// The [set] in which the term is created. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The [set] in which the term is created."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - command.SetHandler(async (string siteId, string setId, string termId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption); - return command; - } - /// - /// The [set] in which the term is created. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The [set] in which the term is created."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string termId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, setIdOption, termIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/sets/{set_id}/children/{term_id}/set/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The [set] in which the term is created. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the term is created. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the term is created. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Set.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Set.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Set/Ref/Ref.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Set/Ref/Ref.cs new file mode 100644 index 00000000000..6a257d528fa --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Set/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Set.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Set/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Set/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..80a3e4179eb --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Set/Ref/RefRequestBuilder.cs @@ -0,0 +1,176 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Set.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStore\sets\{set-id}\children\{term-id}\set\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The [set] in which the term is created. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The [set] in which the term is created."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + command.SetHandler(async (string siteId, string setId, string termId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, setIdOption, termIdOption); + return command; + } + /// + /// The [set] in which the term is created. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The [set] in which the term is created."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, outputOption); + return command; + } + /// + /// The [set] in which the term is created. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The [set] in which the term is created."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string setId, string termId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, setIdOption, termIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/sets/{set_id}/children/{term_id}/set/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The [set] in which the term is created. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the term is created. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the term is created. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Set.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Set/SetRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Set/SetRequestBuilder.cs index 87fcebd23a3..e0318bd8a59 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Set/SetRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/Set/SetRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Set.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -49,25 +49,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, string termId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Set.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Set.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -107,18 +106,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The [set] in which the term is created. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/TermRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/TermRequestBuilder.cs index e4bbb0b9aa5..3759aa618b2 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/TermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Children/Item/TermRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Set; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,6 +25,9 @@ public class TermRequestBuilder { public Command BuildChildrenCommand() { var command = new Command("children"); var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Children.ChildrenRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -48,11 +51,10 @@ public Command BuildDeleteCommand() { }; termIdOption.IsRequired = true; command.AddOption(termIdOption); - command.SetHandler(async (string siteId, string setId, string termId) => { + command.SetHandler(async (string siteId, string setId, string termId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, setIdOption, termIdOption); return command; @@ -86,20 +88,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, string termId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -125,14 +126,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string termId, string body) => { + command.SetHandler(async (string siteId, string setId, string termId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, setIdOption, termIdOption, bodyOption); return command; @@ -140,6 +140,9 @@ public Command BuildPatchCommand() { public Command BuildRelationsCommand() { var command = new Command("relations"); var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Children.Item.Relations.RelationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -218,42 +221,6 @@ public RequestInformation CreatePatchRequestInformation(Term body, Action - /// Children terms of set in term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children terms of set in term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children terms of set in term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Children terms of set in term [store]. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/ParentGroup/ParentGroupRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/ParentGroup/ParentGroupRequestBuilder.cs index 8d2b85c2e68..8d89ae2bda6 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/ParentGroup/ParentGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/ParentGroup/ParentGroupRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Sets.Item.ParentGroup.Sets; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,11 +35,10 @@ public Command BuildDeleteCommand() { }; setIdOption.IsRequired = true; command.AddOption(setIdOption); - command.SetHandler(async (string siteId, string setId) => { + command.SetHandler(async (string siteId, string setId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, setIdOption); return command; @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,14 +102,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string body) => { + command.SetHandler(async (string siteId, string setId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, setIdOption, bodyOption); return command; @@ -119,6 +116,9 @@ public Command BuildPatchCommand() { public Command BuildSetsCommand() { var command = new Command("sets"); var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.ParentGroup.Sets.SetsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -190,42 +190,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The parent [group] that contains the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The parent [group] that contains the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The parent [group] that contains the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Group model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The parent [group] that contains the set. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/ParentGroup/Sets/Item/SetRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/ParentGroup/Sets/Item/SetRequestBuilder.cs index a5050ebab9f..373eb591933 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/ParentGroup/Sets/Item/SetRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/ParentGroup/Sets/Item/SetRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph.TermStore; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; setId1Option.IsRequired = true; command.AddOption(setId1Option); - command.SetHandler(async (string siteId, string setId, string setId1) => { + command.SetHandler(async (string siteId, string setId, string setId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, setIdOption, setId1Option); return command; @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, string setId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string setId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, setId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, setId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string setId1, string body) => { + command.SetHandler(async (string siteId, string setId, string setId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, setIdOption, setId1Option, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All sets under the group in a term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All sets under the group in a term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All sets under the group in a term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.TermStore.Set model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// All sets under the group in a term [store]. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/ParentGroup/Sets/SetsRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/ParentGroup/Sets/SetsRequestBuilder.cs index 17aacc54c5a..41b55cdf9c5 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/ParentGroup/Sets/SetsRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/ParentGroup/Sets/SetsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Sets.Item.ParentGroup.Sets.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SetsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SetRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All sets under the group in a term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All sets under the group in a term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.TermStore.Set model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// All sets under the group in a term [store]. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/FromTerm/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/FromTerm/@Ref/@Ref.cs deleted file mode 100644 index 467625252eb..00000000000 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/FromTerm/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.FromTerm.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 848c8af0558..00000000000 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,214 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.FromTerm.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStore\sets\{set-id}\relations\{relation-id}\fromTerm\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string setId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, setIdOption, relationIdOption); - return command; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string setId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, relationIdOption); - return command; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, setIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/sets/{set_id}/relations/{relation_id}/fromTerm/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.FromTerm.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.FromTerm.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs index 1627d272733..631ac284e47 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.FromTerm.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -49,25 +49,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.FromTerm.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.FromTerm.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -107,18 +106,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/FromTerm/Ref/Ref.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/FromTerm/Ref/Ref.cs new file mode 100644 index 00000000000..fa3f54e22c5 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/FromTerm/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.FromTerm.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..11035efa1d2 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs @@ -0,0 +1,176 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.FromTerm.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStore\sets\{set-id}\relations\{relation-id}\fromTerm\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string setId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, setIdOption, relationIdOption); + return command; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string setId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, setIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/sets/{set_id}/relations/{relation_id}/fromTerm/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.FromTerm.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/RelationRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/RelationRequestBuilder.cs index 2d85a621fd0..32a10c124f9 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/RelationRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/RelationRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.ToTerm; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,11 +41,10 @@ public Command BuildDeleteCommand() { }; relationIdOption.IsRequired = true; command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string setId, string relationId) => { + command.SetHandler(async (string siteId, string setId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, setIdOption, relationIdOption); return command; @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string relationId, string body) => { + command.SetHandler(async (string siteId, string setId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, setIdOption, relationIdOption, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(Relation body, Action - /// Indicates which terms have been pinned or reused directly under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Indicates which terms have been pinned or reused directly under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Indicates which terms have been pinned or reused directly under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Relation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Indicates which terms have been pinned or reused directly under the set. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/Set/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/Set/@Ref/@Ref.cs deleted file mode 100644 index fd9b5f0e8e3..00000000000 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/Set/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.Set.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs deleted file mode 100644 index a038eeb02d7..00000000000 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,214 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.Set.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStore\sets\{set-id}\relations\{relation-id}\set\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string setId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, setIdOption, relationIdOption); - return command; - } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string setId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, relationIdOption); - return command; - } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, setIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/sets/{set_id}/relations/{relation_id}/set/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The [set] in which the relation is relevant. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.Set.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.Set.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/Set/Ref/Ref.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/Set/Ref/Ref.cs new file mode 100644 index 00000000000..40284745505 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/Set/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.Set.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..9e434fbfcb1 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs @@ -0,0 +1,176 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.Set.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStore\sets\{set-id}\relations\{relation-id}\set\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string setId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, setIdOption, relationIdOption); + return command; + } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string setId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, setIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/sets/{set_id}/relations/{relation_id}/set/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The [set] in which the relation is relevant. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the relation is relevant. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the relation is relevant. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.Set.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/Set/SetRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/Set/SetRequestBuilder.cs index 6ebb596de02..501c35d372d 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/Set/SetRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/Set/SetRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.Set.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -49,25 +49,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.Set.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.Set.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -107,18 +106,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The [set] in which the relation is relevant. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/ToTerm/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/ToTerm/@Ref/@Ref.cs deleted file mode 100644 index 1c50c30972d..00000000000 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/ToTerm/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.ToTerm.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 091bb5cbe85..00000000000 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,214 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.ToTerm.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStore\sets\{set-id}\relations\{relation-id}\toTerm\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string setId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, setIdOption, relationIdOption); - return command; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string setId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, relationIdOption); - return command; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, setIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/sets/{set_id}/relations/{relation_id}/toTerm/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.ToTerm.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.ToTerm.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/ToTerm/Ref/Ref.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/ToTerm/Ref/Ref.cs new file mode 100644 index 00000000000..c725631e0c8 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/ToTerm/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.ToTerm.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..3dd8cd9a315 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs @@ -0,0 +1,176 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.ToTerm.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStore\sets\{set-id}\relations\{relation-id}\toTerm\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string setId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, setIdOption, relationIdOption); + return command; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string setId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, setIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/sets/{set_id}/relations/{relation_id}/toTerm/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.ToTerm.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs index e9d75ead029..6f5cb97c9ed 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.ToTerm.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -49,25 +49,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.ToTerm.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item.ToTerm.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -107,18 +106,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The to [term] of the relation. The term to which the relationship is defined. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/RelationsRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/RelationsRequestBuilder.cs index 675178d5fe7..8d6900b4371 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Relations/RelationsRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Relations/RelationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class RelationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new RelationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildFromTermCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSetCommand(), - builder.BuildToTermCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFromTermCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSetCommand()); + commands.Add(builder.BuildToTermCommand()); return commands; } /// @@ -51,21 +50,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, bodyOption, outputOption); return command; } /// @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -129,15 +131,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(Relation body, Action - /// Indicates which terms have been pinned or reused directly under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Indicates which terms have been pinned or reused directly under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Relation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Indicates which terms have been pinned or reused directly under the set. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/SetRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/SetRequestBuilder.cs index b3e4c554bd8..9a7f58ed520 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/SetRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/SetRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Sites.Item.TermStore.Sets.Item.Terms; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,6 +26,9 @@ public class SetRequestBuilder { public Command BuildChildrenCommand() { var command = new Command("children"); var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Children.ChildrenRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -45,11 +48,10 @@ public Command BuildDeleteCommand() { }; setIdOption.IsRequired = true; command.AddOption(setIdOption); - command.SetHandler(async (string siteId, string setId) => { + command.SetHandler(async (string siteId, string setId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, setIdOption); return command; @@ -79,20 +81,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentGroupCommand() { @@ -123,14 +124,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string body) => { + command.SetHandler(async (string siteId, string setId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, setIdOption, bodyOption); return command; @@ -138,6 +138,9 @@ public Command BuildPatchCommand() { public Command BuildRelationsCommand() { var command = new Command("relations"); var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Relations.RelationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -145,6 +148,9 @@ public Command BuildRelationsCommand() { public Command BuildTermsCommand() { var command = new Command("terms"); var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.TermsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -216,42 +222,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of all sets available in the term store. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of all sets available in the term store. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of all sets available in the term store. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.TermStore.Set model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of all sets available in the term store. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Children/ChildrenRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Children/ChildrenRequestBuilder.cs index a08d13026b3..29266b573b7 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Children/ChildrenRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Children/ChildrenRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Children.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ChildrenRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TermRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string termId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, bodyOption, outputOption); return command; } /// @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(Term body, Action - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Children of current term. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Children/Item/TermRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Children/Item/TermRequestBuilder.cs index 80610cc4571..0cb115d3312 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Children/Item/TermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Children/Item/TermRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph.TermStore; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -42,11 +42,10 @@ public Command BuildDeleteCommand() { }; termId1Option.IsRequired = true; command.AddOption(termId1Option); - command.SetHandler(async (string siteId, string setId, string termId, string termId1) => { + command.SetHandler(async (string siteId, string setId, string termId, string termId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, setIdOption, termIdOption, termId1Option); return command; @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, string termId, string termId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, string termId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, termId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, termId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string termId, string termId1, string body) => { + command.SetHandler(async (string siteId, string setId, string termId, string termId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, setIdOption, termIdOption, termId1Option, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(Term body, Action - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Children of current term. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/FromTerm/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/FromTerm/@Ref/@Ref.cs deleted file mode 100644 index 1122f9603b8..00000000000 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/FromTerm/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.FromTerm.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs deleted file mode 100644 index d36b57c96f7..00000000000 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,226 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.FromTerm.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStore\sets\{set-id}\terms\{term-id}\relations\{relation-id}\fromTerm\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/sets/{set_id}/terms/{term_id}/relations/{relation_id}/fromTerm/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.FromTerm.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.FromTerm.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs index bf4464d2120..45b04dffd37 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.FromTerm.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -53,25 +53,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.FromTerm.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.FromTerm.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -111,18 +110,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/FromTerm/Ref/Ref.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/FromTerm/Ref/Ref.cs new file mode 100644 index 00000000000..28f32bbde97 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/FromTerm/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.FromTerm.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..a14a9e541c6 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs @@ -0,0 +1,188 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.FromTerm.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStore\sets\{set-id}\terms\{term-id}\relations\{relation-id}\fromTerm\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, setIdOption, termIdOption, relationIdOption); + return command; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/sets/{set_id}/terms/{term_id}/relations/{relation_id}/fromTerm/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.FromTerm.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/RelationRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/RelationRequestBuilder.cs index 6c99fa0a835..193bac2d6b2 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/RelationRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/RelationRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.ToTerm; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -45,11 +45,10 @@ public Command BuildDeleteCommand() { }; relationIdOption.IsRequired = true; command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId) => { + command.SetHandler(async (string siteId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, setIdOption, termIdOption, relationIdOption); return command; @@ -94,20 +93,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -137,14 +135,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId, string body) => { + command.SetHandler(async (string siteId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); return command; @@ -230,42 +227,6 @@ public RequestInformation CreatePatchRequestInformation(Relation body, Action - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Relation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// To indicate which terms are related to the current term as either pinned or reused. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/Set/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/Set/@Ref/@Ref.cs deleted file mode 100644 index c77f0c308a2..00000000000 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/Set/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.Set.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 6a49b9ebc1c..00000000000 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,226 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.Set.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStore\sets\{set-id}\terms\{term-id}\relations\{relation-id}\set\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/sets/{set_id}/terms/{term_id}/relations/{relation_id}/set/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The [set] in which the relation is relevant. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.Set.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.Set.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/Set/Ref/Ref.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/Set/Ref/Ref.cs new file mode 100644 index 00000000000..3beb6ed642f --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/Set/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.Set.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..079e820f233 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs @@ -0,0 +1,188 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.Set.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStore\sets\{set-id}\terms\{term-id}\relations\{relation-id}\set\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, setIdOption, termIdOption, relationIdOption); + return command; + } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/sets/{set_id}/terms/{term_id}/relations/{relation_id}/set/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The [set] in which the relation is relevant. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the relation is relevant. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the relation is relevant. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.Set.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/Set/SetRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/Set/SetRequestBuilder.cs index 5c282c68916..fc5a74fab73 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/Set/SetRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/Set/SetRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.Set.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -53,25 +53,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.Set.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.Set.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -111,18 +110,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The [set] in which the relation is relevant. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/ToTerm/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/ToTerm/@Ref/@Ref.cs deleted file mode 100644 index 88644beb2cd..00000000000 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/ToTerm/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.ToTerm.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 2c98cfcfa31..00000000000 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,226 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.ToTerm.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStore\sets\{set-id}\terms\{term-id}\relations\{relation-id}\toTerm\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/sets/{set_id}/terms/{term_id}/relations/{relation_id}/toTerm/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.ToTerm.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.ToTerm.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/ToTerm/Ref/Ref.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/ToTerm/Ref/Ref.cs new file mode 100644 index 00000000000..59d6b19a028 --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/ToTerm/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.ToTerm.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..4127e79ec0b --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs @@ -0,0 +1,188 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.ToTerm.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStore\sets\{set-id}\terms\{term-id}\relations\{relation-id}\toTerm\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, setIdOption, termIdOption, relationIdOption); + return command; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/sets/{set_id}/terms/{term_id}/relations/{relation_id}/toTerm/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.ToTerm.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs index 7d78b5fab6f..937596a0e14 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.ToTerm.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -53,25 +53,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.ToTerm.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item.ToTerm.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -111,18 +110,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The to [term] of the relation. The term to which the relationship is defined. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/RelationsRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/RelationsRequestBuilder.cs index 8a21216431e..56668ca651d 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/RelationsRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Relations/RelationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class RelationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new RelationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildFromTermCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSetCommand(), - builder.BuildToTermCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFromTermCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSetCommand()); + commands.Add(builder.BuildToTermCommand()); return commands; } /// @@ -55,21 +54,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string termId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, bodyOption, outputOption); return command; } /// @@ -126,7 +124,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -137,15 +139,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -200,31 +197,6 @@ public RequestInformation CreatePostRequestInformation(Relation body, Action - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Relation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// To indicate which terms are related to the current term as either pinned or reused. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Set/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Set/@Ref/@Ref.cs deleted file mode 100644 index 23456c24db0..00000000000 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Set/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Set.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Set/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Set/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 130062c5e0e..00000000000 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Set/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,214 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Set.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStore\sets\{set-id}\terms\{term-id}\set\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The [set] in which the term is created. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The [set] in which the term is created."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - command.SetHandler(async (string siteId, string setId, string termId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, setIdOption, termIdOption); - return command; - } - /// - /// The [set] in which the term is created. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The [set] in which the term is created."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - command.SetHandler(async (string siteId, string setId, string termId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption); - return command; - } - /// - /// The [set] in which the term is created. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The [set] in which the term is created."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string termId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, setIdOption, termIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/sets/{set_id}/terms/{term_id}/set/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The [set] in which the term is created. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the term is created. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the term is created. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Set.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Set.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Set/Ref/Ref.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Set/Ref/Ref.cs new file mode 100644 index 00000000000..434ac3c054e --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Set/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Set.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Set/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Set/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..d48d6def55a --- /dev/null +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Set/Ref/RefRequestBuilder.cs @@ -0,0 +1,176 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Set.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStore\sets\{set-id}\terms\{term-id}\set\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The [set] in which the term is created. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The [set] in which the term is created."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + command.SetHandler(async (string siteId, string setId, string termId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, setIdOption, termIdOption); + return command; + } + /// + /// The [set] in which the term is created. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The [set] in which the term is created."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, outputOption); + return command; + } + /// + /// The [set] in which the term is created. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The [set] in which the term is created."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string setId, string termId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, setIdOption, termIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStore/sets/{set_id}/terms/{term_id}/set/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The [set] in which the term is created. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the term is created. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the term is created. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Set.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Set/SetRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Set/SetRequestBuilder.cs index cf71c33787a..5e21ae6382c 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Set/SetRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/Set/SetRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Set.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -49,25 +49,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, string termId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Set.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Set.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -107,18 +106,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The [set] in which the term is created. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/TermRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/TermRequestBuilder.cs index c71e718353c..cdb9d9cf7a5 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/TermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/Item/TermRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Set; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,6 +25,9 @@ public class TermRequestBuilder { public Command BuildChildrenCommand() { var command = new Command("children"); var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Children.ChildrenRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -48,11 +51,10 @@ public Command BuildDeleteCommand() { }; termIdOption.IsRequired = true; command.AddOption(termIdOption); - command.SetHandler(async (string siteId, string setId, string termId) => { + command.SetHandler(async (string siteId, string setId, string termId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, setIdOption, termIdOption); return command; @@ -86,20 +88,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, string termId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string termId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, termIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, termIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -125,14 +126,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string termId, string body) => { + command.SetHandler(async (string siteId, string setId, string termId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, setIdOption, termIdOption, bodyOption); return command; @@ -140,6 +140,9 @@ public Command BuildPatchCommand() { public Command BuildRelationsCommand() { var command = new Command("relations"); var builder = new ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item.Relations.RelationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -218,42 +221,6 @@ public RequestInformation CreatePatchRequestInformation(Term body, Action - /// All the terms under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All the terms under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All the terms under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// All the terms under the set. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/TermsRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/TermsRequestBuilder.cs index daceec3e383..ec85b7c2734 100644 --- a/src/generated/Sites/Item/TermStore/Sets/Item/Terms/TermsRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/Item/Terms/TermsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Sets.Item.Terms.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class TermsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TermRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildChildrenCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildRelationsCommand(), - builder.BuildSetCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildChildrenCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRelationsCommand()); + commands.Add(builder.BuildSetCommand()); return commands; } /// @@ -51,21 +50,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string setId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, bodyOption, outputOption); return command; } /// @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -129,15 +131,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(Term body, Action - /// All the terms under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All the terms under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// All the terms under the set. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStore/Sets/SetsRequestBuilder.cs b/src/generated/Sites/Item/TermStore/Sets/SetsRequestBuilder.cs index 8c55783c688..be2c527641d 100644 --- a/src/generated/Sites/Item/TermStore/Sets/SetsRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/Sets/SetsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStore.Sets.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SetsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SetRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildChildrenCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildRelationsCommand(), - builder.BuildTermsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildChildrenCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRelationsCommand()); + commands.Add(builder.BuildTermsCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, bodyOption, outputOption); return command; } /// @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -122,15 +124,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -185,31 +182,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of all sets available in the term store. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of all sets available in the term store. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.TermStore.Set model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of all sets available in the term store. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStore/TermStoreRequestBuilder.cs b/src/generated/Sites/Item/TermStore/TermStoreRequestBuilder.cs index 9095953b914..a2ebe11765e 100644 --- a/src/generated/Sites/Item/TermStore/TermStoreRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStore/TermStoreRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Sites.Item.TermStore.Sets; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -32,11 +32,10 @@ public Command BuildDeleteCommand() { }; siteIdOption.IsRequired = true; command.AddOption(siteIdOption); - command.SetHandler(async (string siteId) => { + command.SetHandler(async (string siteId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption); return command; @@ -62,25 +61,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildGroupsCommand() { var command = new Command("groups"); var builder = new ApiSdk.Sites.Item.TermStore.Groups.GroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -100,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string body) => { + command.SetHandler(async (string siteId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, bodyOption); return command; @@ -115,6 +115,9 @@ public Command BuildPatchCommand() { public Command BuildSetsCommand() { var command = new Command("sets"); var builder = new ApiSdk.Sites.Item.TermStore.Sets.SetsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -186,42 +189,6 @@ public RequestInformation CreatePatchRequestInformation(Store body, Action - /// The termStore under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The termStore under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The termStore under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Store model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The termStore under this site. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/GroupsRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/GroupsRequestBuilder.cs index 096bbc2df31..5a6451027c4 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/GroupsRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/GroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Groups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class GroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new GroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSetsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSetsCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, bodyOption, outputOption); return command; } /// @@ -116,7 +114,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -127,15 +129,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -190,31 +187,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of all groups available in the term store. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of all groups available in the term store. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Group model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of all groups available in the term store. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/GroupsResponse.cs b/src/generated/Sites/Item/TermStores/Item/Groups/GroupsResponse.cs index 9d0daaf749a..079b389e274 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/GroupsResponse.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/GroupsResponse.cs @@ -1,4 +1,4 @@ -using ApiSdk.Models.Microsoft.Graph; +using ApiSdk.Models.Microsoft.Graph.TermStore; using Microsoft.Kiota.Abstractions.Serialization; using System; using System.Collections.Generic; @@ -9,7 +9,7 @@ public class GroupsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new groupsResponse and sets the default values. /// @@ -22,7 +22,7 @@ public GroupsResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as GroupsResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as GroupsResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, + {"value", (o,n) => { (o as GroupsResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/GroupRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/GroupRequestBuilder.cs index a5615a5fb2f..86a4314a2c4 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/GroupRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/GroupRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,11 +39,10 @@ public Command BuildDeleteCommand() { }; groupIdOption.IsRequired = true; command.AddOption(groupIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId) => { + command.SetHandler(async (string siteId, string storeId, string groupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, groupIdOption); return command; @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -116,14 +114,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string body) => { + command.SetHandler(async (string siteId, string storeId, string groupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, groupIdOption, bodyOption); return command; @@ -131,6 +128,9 @@ public Command BuildPatchCommand() { public Command BuildSetsCommand() { var command = new Command("sets"); var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.SetsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -202,42 +202,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of all groups available in the term store. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of all groups available in the term store. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of all groups available in the term store. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Group model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of all groups available in the term store. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/ChildrenRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/ChildrenRequestBuilder.cs index 8c8c1036888..ad56f80d4ef 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/ChildrenRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/ChildrenRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class ChildrenRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TermRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildChildrenCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildRelationsCommand(), - builder.BuildSetCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildChildrenCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRelationsCommand()); + commands.Add(builder.BuildSetCommand()); return commands; } /// @@ -59,21 +58,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, bodyOption, outputOption); return command; } /// @@ -134,7 +132,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -145,15 +147,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -208,31 +205,6 @@ public RequestInformation CreatePostRequestInformation(Term body, Action - /// Children terms of set in term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children terms of set in term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Children terms of set in term [store]. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Children/ChildrenRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Children/ChildrenRequestBuilder.cs index a67d1b652b9..ef4c74a0a44 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Children/ChildrenRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Children/ChildrenRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Children.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ChildrenRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TermRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -60,21 +59,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, bodyOption, outputOption); return command; } /// @@ -139,7 +137,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -150,15 +152,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -213,31 +210,6 @@ public RequestInformation CreatePostRequestInformation(Term body, Action - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Children of current term. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Children/Item/TermRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Children/Item/TermRequestBuilder.cs index a2f22020f31..419db312f4a 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Children/Item/TermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Children/Item/TermRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph.TermStore; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -50,11 +50,10 @@ public Command BuildDeleteCommand() { }; termId1Option.IsRequired = true; command.AddOption(termId1Option); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string termId1) => { + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string termId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, termId1Option); return command; @@ -100,20 +99,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string termId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string termId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, termId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, termId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -151,14 +149,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string termId1, string body) => { + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string termId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, termId1Option, bodyOption); return command; @@ -230,42 +227,6 @@ public RequestInformation CreatePatchRequestInformation(Term body, Action - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Children of current term. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/@Ref/@Ref.cs deleted file mode 100644 index dc705c1dd77..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 099b7dcd08c..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,250 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\groups\{group-id}\sets\{set-id}\children\{term-id}\relations\{relation-id}\fromTerm\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/groups/{group_id}/sets/{set_id}/children/{term_id}/relations/{relation_id}/fromTerm/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs index dce03a27361..3bb15a9364d 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -61,25 +61,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -119,18 +118,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/Ref/Ref.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/Ref/Ref.cs new file mode 100644 index 00000000000..1dc203c9e8d --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..4c12c04b350 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs @@ -0,0 +1,212 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\groups\{group-id}\sets\{set-id}\children\{term-id}\relations\{relation-id}\fromTerm\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); + return command; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/groups/{group_id}/sets/{set_id}/children/{term_id}/relations/{relation_id}/fromTerm/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/RelationRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/RelationRequestBuilder.cs index 27a6e1fcefd..b67c3801516 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/RelationRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/RelationRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.ToTerm; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -53,11 +53,10 @@ public Command BuildDeleteCommand() { }; relationIdOption.IsRequired = true; command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId) => { + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); return command; @@ -110,20 +109,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -161,14 +159,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string body) => { + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); return command; @@ -254,42 +251,6 @@ public RequestInformation CreatePatchRequestInformation(Relation body, Action - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Relation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// To indicate which terms are related to the current term as either pinned or reused. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/@Ref/@Ref.cs deleted file mode 100644 index 740c53d6db1..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.Set.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs deleted file mode 100644 index caee77ca46c..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,250 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.Set.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\groups\{group-id}\sets\{set-id}\children\{term-id}\relations\{relation-id}\set\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/groups/{group_id}/sets/{set_id}/children/{term_id}/relations/{relation_id}/set/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The [set] in which the relation is relevant. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.Set.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.Set.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/Ref/Ref.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/Ref/Ref.cs new file mode 100644 index 00000000000..b5e517512aa --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.Set.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..7552c4ae238 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs @@ -0,0 +1,212 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.Set.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\groups\{group-id}\sets\{set-id}\children\{term-id}\relations\{relation-id}\set\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); + return command; + } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/groups/{group_id}/sets/{set_id}/children/{term_id}/relations/{relation_id}/set/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The [set] in which the relation is relevant. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the relation is relevant. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the relation is relevant. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.Set.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/SetRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/SetRequestBuilder.cs index 1a9777b7113..c6840f369cd 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/SetRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/Set/SetRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.Set.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -61,25 +61,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.Set.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.Set.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -119,18 +118,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The [set] in which the relation is relevant. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/@Ref/@Ref.cs deleted file mode 100644 index 2d3578ae607..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs deleted file mode 100644 index b21a1924136..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,250 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\groups\{group-id}\sets\{set-id}\children\{term-id}\relations\{relation-id}\toTerm\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/groups/{group_id}/sets/{set_id}/children/{term_id}/relations/{relation_id}/toTerm/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/Ref/Ref.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/Ref/Ref.cs new file mode 100644 index 00000000000..faa0ab01318 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..f3f8aabad1d --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs @@ -0,0 +1,212 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\groups\{group-id}\sets\{set-id}\children\{term-id}\relations\{relation-id}\toTerm\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); + return command; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/groups/{group_id}/sets/{set_id}/children/{term_id}/relations/{relation_id}/toTerm/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs index c5270a8a6e1..7f799f154d8 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -61,25 +61,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -119,18 +118,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The to [term] of the relation. The term to which the relationship is defined. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/RelationsRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/RelationsRequestBuilder.cs index 46aef7a84ce..68e8089884c 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/RelationsRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Relations/RelationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class RelationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new RelationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildFromTermCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSetCommand(), - builder.BuildToTermCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFromTermCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSetCommand()); + commands.Add(builder.BuildToTermCommand()); return commands; } /// @@ -63,21 +62,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, bodyOption, outputOption); return command; } /// @@ -142,7 +140,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -153,15 +155,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -216,31 +213,6 @@ public RequestInformation CreatePostRequestInformation(Relation body, Action - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Relation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// To indicate which terms are related to the current term as either pinned or reused. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Set/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Set/@Ref/@Ref.cs deleted file mode 100644 index 1104e0cef9c..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Set/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Set.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Set/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Set/@Ref/RefRequestBuilder.cs deleted file mode 100644 index f5d5db0be74..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Set/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,238 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Set.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\groups\{group-id}\sets\{set-id}\children\{term-id}\set\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The [set] in which the term is created. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The [set] in which the term is created."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption); - return command; - } - /// - /// The [set] in which the term is created. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The [set] in which the term is created."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption); - return command; - } - /// - /// The [set] in which the term is created. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The [set] in which the term is created."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/groups/{group_id}/sets/{set_id}/children/{term_id}/set/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The [set] in which the term is created. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the term is created. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the term is created. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Set.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Set.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Set/Ref/Ref.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Set/Ref/Ref.cs new file mode 100644 index 00000000000..9e24e5e0f04 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Set/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Set.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Set/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Set/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..59e24372503 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Set/Ref/RefRequestBuilder.cs @@ -0,0 +1,200 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Set.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\groups\{group-id}\sets\{set-id}\children\{term-id}\set\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The [set] in which the term is created. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The [set] in which the term is created."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption); + return command; + } + /// + /// The [set] in which the term is created. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The [set] in which the term is created."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, outputOption); + return command; + } + /// + /// The [set] in which the term is created. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The [set] in which the term is created."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/groups/{group_id}/sets/{set_id}/children/{term_id}/set/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The [set] in which the term is created. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the term is created. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the term is created. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Set.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Set/SetRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Set/SetRequestBuilder.cs index 3f54f184f96..a32c5a636ea 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Set/SetRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/Set/SetRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Set.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -57,25 +57,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Set.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Set.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -115,18 +114,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The [set] in which the term is created. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/TermRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/TermRequestBuilder.cs index 30d1e92a51f..7e1f2d20b07 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/TermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Children/Item/TermRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Set; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,6 +25,9 @@ public class TermRequestBuilder { public Command BuildChildrenCommand() { var command = new Command("children"); var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Children.ChildrenRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -56,11 +59,10 @@ public Command BuildDeleteCommand() { }; termIdOption.IsRequired = true; command.AddOption(termIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId) => { + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption); return command; @@ -102,20 +104,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -149,14 +150,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string body) => { + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, bodyOption); return command; @@ -164,6 +164,9 @@ public Command BuildPatchCommand() { public Command BuildRelationsCommand() { var command = new Command("relations"); var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.Item.Relations.RelationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -242,42 +245,6 @@ public RequestInformation CreatePatchRequestInformation(Term body, Action - /// Children terms of set in term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children terms of set in term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children terms of set in term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Children terms of set in term [store]. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/ParentGroup/ParentGroupRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/ParentGroup/ParentGroupRequestBuilder.cs index 01b23054b22..def69a8c1c8 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/ParentGroup/ParentGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/ParentGroup/ParentGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -42,11 +42,10 @@ public Command BuildDeleteCommand() { }; setIdOption.IsRequired = true; command.AddOption(setIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId) => { + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, groupIdOption, setIdOption); return command; @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string body) => { + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, groupIdOption, setIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The parent [group] that contains the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The parent [group] that contains the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The parent [group] that contains the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Group model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The parent [group] that contains the set. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/FromTerm/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/FromTerm/@Ref/@Ref.cs deleted file mode 100644 index a1171faf179..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/FromTerm/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.FromTerm.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 59f75c6a48a..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,238 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.FromTerm.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\groups\{group-id}\sets\{set-id}\relations\{relation-id}\fromTerm\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption); - return command; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption); - return command; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/groups/{group_id}/sets/{set_id}/relations/{relation_id}/fromTerm/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.FromTerm.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.FromTerm.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs index 30027e03420..4ea952180db 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.FromTerm.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -57,25 +57,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.FromTerm.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.FromTerm.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -115,18 +114,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/FromTerm/Ref/Ref.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/FromTerm/Ref/Ref.cs new file mode 100644 index 00000000000..03543b5c25c --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/FromTerm/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.FromTerm.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..16f2bff1be4 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs @@ -0,0 +1,200 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.FromTerm.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\groups\{group-id}\sets\{set-id}\relations\{relation-id}\fromTerm\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption); + return command; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/groups/{group_id}/sets/{set_id}/relations/{relation_id}/fromTerm/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.FromTerm.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/RelationRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/RelationRequestBuilder.cs index d9ccce23900..03a4bf00c77 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/RelationRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/RelationRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.ToTerm; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -49,11 +49,10 @@ public Command BuildDeleteCommand() { }; relationIdOption.IsRequired = true; command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId) => { + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption); return command; @@ -102,20 +101,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -149,14 +147,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId, string body) => { + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption, bodyOption); return command; @@ -242,42 +239,6 @@ public RequestInformation CreatePatchRequestInformation(Relation body, Action - /// Indicates which terms have been pinned or reused directly under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Indicates which terms have been pinned or reused directly under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Indicates which terms have been pinned or reused directly under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Relation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Indicates which terms have been pinned or reused directly under the set. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/Set/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/Set/@Ref/@Ref.cs deleted file mode 100644 index fde11438e90..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/Set/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.Set.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 9dd164979f4..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,238 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.Set.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\groups\{group-id}\sets\{set-id}\relations\{relation-id}\set\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption); - return command; - } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption); - return command; - } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/groups/{group_id}/sets/{set_id}/relations/{relation_id}/set/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The [set] in which the relation is relevant. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.Set.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.Set.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/Set/Ref/Ref.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/Set/Ref/Ref.cs new file mode 100644 index 00000000000..e5cc19b50a5 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/Set/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.Set.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..a4a8a5a49b2 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs @@ -0,0 +1,200 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.Set.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\groups\{group-id}\sets\{set-id}\relations\{relation-id}\set\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption); + return command; + } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/groups/{group_id}/sets/{set_id}/relations/{relation_id}/set/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The [set] in which the relation is relevant. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the relation is relevant. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the relation is relevant. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.Set.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/Set/SetRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/Set/SetRequestBuilder.cs index 594777069d4..af571d39686 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/Set/SetRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/Set/SetRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.Set.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -57,25 +57,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.Set.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.Set.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -115,18 +114,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The [set] in which the relation is relevant. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/ToTerm/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/ToTerm/@Ref/@Ref.cs deleted file mode 100644 index 2d0f6cc8bc7..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/ToTerm/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.ToTerm.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs deleted file mode 100644 index d33c24c94ae..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,238 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.ToTerm.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\groups\{group-id}\sets\{set-id}\relations\{relation-id}\toTerm\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption); - return command; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption); - return command; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/groups/{group_id}/sets/{set_id}/relations/{relation_id}/toTerm/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.ToTerm.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.ToTerm.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/ToTerm/Ref/Ref.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/ToTerm/Ref/Ref.cs new file mode 100644 index 00000000000..5d311c4c2b0 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/ToTerm/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.ToTerm.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..5bb6e38876d --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs @@ -0,0 +1,200 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.ToTerm.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\groups\{group-id}\sets\{set-id}\relations\{relation-id}\toTerm\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption); + return command; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/groups/{group_id}/sets/{set_id}/relations/{relation_id}/toTerm/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.ToTerm.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs index e2c98a43b57..d16a85ee9e5 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.ToTerm.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -57,25 +57,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.ToTerm.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item.ToTerm.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -115,18 +114,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The to [term] of the relation. The term to which the relationship is defined. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/RelationsRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/RelationsRequestBuilder.cs index d750bcce6d6..fd00e7de515 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/RelationsRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Relations/RelationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class RelationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new RelationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildFromTermCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSetCommand(), - builder.BuildToTermCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFromTermCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSetCommand()); + commands.Add(builder.BuildToTermCommand()); return commands; } /// @@ -59,21 +58,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, bodyOption, outputOption); return command; } /// @@ -134,7 +132,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -145,15 +147,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -208,31 +205,6 @@ public RequestInformation CreatePostRequestInformation(Relation body, Action - /// Indicates which terms have been pinned or reused directly under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Indicates which terms have been pinned or reused directly under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Relation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Indicates which terms have been pinned or reused directly under the set. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/SetRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/SetRequestBuilder.cs index 1fffa3069c6..db8ad4f8304 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/SetRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/SetRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,6 +26,9 @@ public class SetRequestBuilder { public Command BuildChildrenCommand() { var command = new Command("children"); var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Children.ChildrenRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -53,11 +56,10 @@ public Command BuildDeleteCommand() { }; setIdOption.IsRequired = true; command.AddOption(setIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId) => { + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, groupIdOption, setIdOption); return command; @@ -95,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentGroupCommand() { @@ -146,14 +147,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string body) => { + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, groupIdOption, setIdOption, bodyOption); return command; @@ -161,6 +161,9 @@ public Command BuildPatchCommand() { public Command BuildRelationsCommand() { var command = new Command("relations"); var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Relations.RelationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -168,6 +171,9 @@ public Command BuildRelationsCommand() { public Command BuildTermsCommand() { var command = new Command("terms"); var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.TermsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -239,42 +245,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All sets under the group in a term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All sets under the group in a term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All sets under the group in a term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.TermStore.Set model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// All sets under the group in a term [store]. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Children/ChildrenRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Children/ChildrenRequestBuilder.cs index 9e18c999aec..c1c1fc07a2a 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Children/ChildrenRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Children/ChildrenRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Children.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ChildrenRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TermRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -60,21 +59,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, bodyOption, outputOption); return command; } /// @@ -139,7 +137,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -150,15 +152,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -213,31 +210,6 @@ public RequestInformation CreatePostRequestInformation(Term body, Action - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Children of current term. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Children/Item/TermRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Children/Item/TermRequestBuilder.cs index 8d7ac56c703..a3c0a79f5d5 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Children/Item/TermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Children/Item/TermRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph.TermStore; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -50,11 +50,10 @@ public Command BuildDeleteCommand() { }; termId1Option.IsRequired = true; command.AddOption(termId1Option); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string termId1) => { + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string termId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, termId1Option); return command; @@ -100,20 +99,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string termId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string termId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, termId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, termId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -151,14 +149,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string termId1, string body) => { + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string termId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, termId1Option, bodyOption); return command; @@ -230,42 +227,6 @@ public RequestInformation CreatePatchRequestInformation(Term body, Action - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Children of current term. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/@Ref/@Ref.cs deleted file mode 100644 index e7a2a75b388..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs deleted file mode 100644 index d6c4e189dbe..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,250 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\groups\{group-id}\sets\{set-id}\terms\{term-id}\relations\{relation-id}\fromTerm\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/groups/{group_id}/sets/{set_id}/terms/{term_id}/relations/{relation_id}/fromTerm/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs index b50dbbb17be..38bfa4993dc 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -61,25 +61,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -119,18 +118,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/Ref/Ref.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/Ref/Ref.cs new file mode 100644 index 00000000000..b159ff2bdfa --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..e02ec9e9414 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs @@ -0,0 +1,212 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\groups\{group-id}\sets\{set-id}\terms\{term-id}\relations\{relation-id}\fromTerm\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); + return command; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/groups/{group_id}/sets/{set_id}/terms/{term_id}/relations/{relation_id}/fromTerm/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/RelationRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/RelationRequestBuilder.cs index d16dcfae724..8c03b67c8b8 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/RelationRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/RelationRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -53,11 +53,10 @@ public Command BuildDeleteCommand() { }; relationIdOption.IsRequired = true; command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId) => { + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); return command; @@ -110,20 +109,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -161,14 +159,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string body) => { + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); return command; @@ -254,42 +251,6 @@ public RequestInformation CreatePatchRequestInformation(Relation body, Action - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Relation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// To indicate which terms are related to the current term as either pinned or reused. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/@Ref/@Ref.cs deleted file mode 100644 index cd169167d38..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.Set.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 95b67f0572a..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,250 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.Set.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\groups\{group-id}\sets\{set-id}\terms\{term-id}\relations\{relation-id}\set\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/groups/{group_id}/sets/{set_id}/terms/{term_id}/relations/{relation_id}/set/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The [set] in which the relation is relevant. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.Set.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.Set.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/Ref/Ref.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/Ref/Ref.cs new file mode 100644 index 00000000000..33a00b8a160 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.Set.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..90a31de38e8 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs @@ -0,0 +1,212 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.Set.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\groups\{group-id}\sets\{set-id}\terms\{term-id}\relations\{relation-id}\set\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); + return command; + } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/groups/{group_id}/sets/{set_id}/terms/{term_id}/relations/{relation_id}/set/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The [set] in which the relation is relevant. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the relation is relevant. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the relation is relevant. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.Set.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/SetRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/SetRequestBuilder.cs index 6d32074ca4b..2d037ce9a24 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/SetRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/Set/SetRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.Set.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -61,25 +61,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.Set.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.Set.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -119,18 +118,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The [set] in which the relation is relevant. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/@Ref/@Ref.cs deleted file mode 100644 index 80d211ce8b6..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs deleted file mode 100644 index eac9341e16d..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,250 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\groups\{group-id}\sets\{set-id}\terms\{term-id}\relations\{relation-id}\toTerm\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/groups/{group_id}/sets/{set_id}/terms/{term_id}/relations/{relation_id}/toTerm/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/Ref/Ref.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/Ref/Ref.cs new file mode 100644 index 00000000000..fd6a982de27 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..8743f2072b8 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs @@ -0,0 +1,212 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\groups\{group-id}\sets\{set-id}\terms\{term-id}\relations\{relation-id}\toTerm\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption); + return command; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/groups/{group_id}/sets/{set_id}/terms/{term_id}/relations/{relation_id}/toTerm/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs index 95c71386fc6..b40a28be20e 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -61,25 +61,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -119,18 +118,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The to [term] of the relation. The term to which the relationship is defined. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/RelationsRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/RelationsRequestBuilder.cs index 1447b5d680f..c656618ffbe 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/RelationsRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Relations/RelationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class RelationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new RelationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildFromTermCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSetCommand(), - builder.BuildToTermCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFromTermCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSetCommand()); + commands.Add(builder.BuildToTermCommand()); return commands; } /// @@ -63,21 +62,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, bodyOption, outputOption); return command; } /// @@ -142,7 +140,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -153,15 +155,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -216,31 +213,6 @@ public RequestInformation CreatePostRequestInformation(Relation body, Action - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Relation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// To indicate which terms are related to the current term as either pinned or reused. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Set/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Set/@Ref/@Ref.cs deleted file mode 100644 index 355d6aa7c93..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Set/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Set.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Set/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Set/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 394abd3464d..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Set/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,238 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Set.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\groups\{group-id}\sets\{set-id}\terms\{term-id}\set\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The [set] in which the term is created. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The [set] in which the term is created."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption); - return command; - } - /// - /// The [set] in which the term is created. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The [set] in which the term is created."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption); - return command; - } - /// - /// The [set] in which the term is created. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The [set] in which the term is created."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var groupIdOption = new Option("--group-id", description: "key: id of group") { - }; - groupIdOption.IsRequired = true; - command.AddOption(groupIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/groups/{group_id}/sets/{set_id}/terms/{term_id}/set/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The [set] in which the term is created. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the term is created. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the term is created. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Set.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Set.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Set/Ref/Ref.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Set/Ref/Ref.cs new file mode 100644 index 00000000000..e7e22fb624f --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Set/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Set.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Set/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Set/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..e29dd939c10 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Set/Ref/RefRequestBuilder.cs @@ -0,0 +1,200 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Set.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\groups\{group-id}\sets\{set-id}\terms\{term-id}\set\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The [set] in which the term is created. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The [set] in which the term is created."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption); + return command; + } + /// + /// The [set] in which the term is created. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The [set] in which the term is created."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, outputOption); + return command; + } + /// + /// The [set] in which the term is created. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The [set] in which the term is created."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var groupIdOption = new Option("--group-id", description: "key: id of group") { + }; + groupIdOption.IsRequired = true; + command.AddOption(groupIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/groups/{group_id}/sets/{set_id}/terms/{term_id}/set/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The [set] in which the term is created. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the term is created. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the term is created. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Set.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Set/SetRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Set/SetRequestBuilder.cs index 96f179c22c8..9fda847b1d8 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Set/SetRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/Set/SetRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Set.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -57,25 +57,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Set.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Set.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -115,18 +114,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The [set] in which the term is created. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/TermRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/TermRequestBuilder.cs index daba6529a29..ed0c0ec7148 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/TermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/Item/TermRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Set; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,6 +25,9 @@ public class TermRequestBuilder { public Command BuildChildrenCommand() { var command = new Command("children"); var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Children.ChildrenRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -56,11 +59,10 @@ public Command BuildDeleteCommand() { }; termIdOption.IsRequired = true; command.AddOption(termIdOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId) => { + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption); return command; @@ -102,20 +104,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -149,14 +150,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string body) => { + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string termId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, groupIdOption, setIdOption, termIdOption, bodyOption); return command; @@ -164,6 +164,9 @@ public Command BuildPatchCommand() { public Command BuildRelationsCommand() { var command = new Command("relations"); var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item.Relations.RelationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -242,42 +245,6 @@ public RequestInformation CreatePatchRequestInformation(Term body, Action - /// All the terms under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All the terms under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All the terms under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// All the terms under the set. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/TermsRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/TermsRequestBuilder.cs index 1b2ac600a22..b398712ca13 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/TermsRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/Item/Terms/TermsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item.Terms.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class TermsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TermRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildChildrenCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildRelationsCommand(), - builder.BuildSetCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildChildrenCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRelationsCommand()); + commands.Add(builder.BuildSetCommand()); return commands; } /// @@ -59,21 +58,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, bodyOption, outputOption); return command; } /// @@ -134,7 +132,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -145,15 +147,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -208,31 +205,6 @@ public RequestInformation CreatePostRequestInformation(Term body, Action - /// All the terms under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All the terms under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// All the terms under the set. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/SetsRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/SetsRequestBuilder.cs index 96baadb4eb0..970cf16d9e8 100644 --- a/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/SetsRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Groups/Item/Sets/SetsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Groups.Item.Sets.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SetsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SetRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildChildrenCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildRelationsCommand(), - builder.BuildTermsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildChildrenCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRelationsCommand()); + commands.Add(builder.BuildTermsCommand()); return commands; } /// @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string groupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, bodyOption, outputOption); return command; } /// @@ -127,7 +125,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string groupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -138,15 +140,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, groupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -201,31 +198,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All sets under the group in a term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All sets under the group in a term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.TermStore.Set model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// All sets under the group in a term [store]. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/ChildrenRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/ChildrenRequestBuilder.cs index 76c33fdd566..2c4fa221d51 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/ChildrenRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/ChildrenRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class ChildrenRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TermRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildChildrenCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildRelationsCommand(), - builder.BuildSetCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildChildrenCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRelationsCommand()); + commands.Add(builder.BuildSetCommand()); return commands; } /// @@ -55,21 +54,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, bodyOption, outputOption); return command; } /// @@ -126,7 +124,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -137,15 +139,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -200,31 +197,6 @@ public RequestInformation CreatePostRequestInformation(Term body, Action - /// Children terms of set in term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children terms of set in term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Children terms of set in term [store]. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Children/ChildrenRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Children/ChildrenRequestBuilder.cs index 12a64e1451d..7ab577b5722 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Children/ChildrenRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Children/ChildrenRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Children.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ChildrenRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TermRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, bodyOption, outputOption); return command; } /// @@ -131,7 +129,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -142,15 +144,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -205,31 +202,6 @@ public RequestInformation CreatePostRequestInformation(Term body, Action - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Children of current term. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Children/Item/TermRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Children/Item/TermRequestBuilder.cs index fb942134db7..7ac51d206ca 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Children/Item/TermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Children/Item/TermRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph.TermStore; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -46,11 +46,10 @@ public Command BuildDeleteCommand() { }; termId1Option.IsRequired = true; command.AddOption(termId1Option); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string termId1) => { + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string termId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, setIdOption, termIdOption, termId1Option); return command; @@ -92,20 +91,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string termId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string termId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, termId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, termId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -139,14 +137,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string termId1, string body) => { + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string termId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, setIdOption, termIdOption, termId1Option, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(Term body, Action - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Children of current term. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/@Ref/@Ref.cs deleted file mode 100644 index 5628361dc6e..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 4adc4d27e1a..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,238 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\sets\{set-id}\children\{term-id}\relations\{relation-id}\fromTerm\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/sets/{set_id}/children/{term_id}/relations/{relation_id}/fromTerm/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs index 40110d56a53..239f58b08cc 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -57,25 +57,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -115,18 +114,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/Ref/Ref.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/Ref/Ref.cs new file mode 100644 index 00000000000..b75be533cc4 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..0e97e951803 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs @@ -0,0 +1,200 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\sets\{set-id}\children\{term-id}\relations\{relation-id}\fromTerm\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption); + return command; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/sets/{set_id}/children/{term_id}/relations/{relation_id}/fromTerm/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.FromTerm.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/RelationRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/RelationRequestBuilder.cs index cd829f08049..70cef68d41d 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/RelationRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/RelationRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.ToTerm; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -49,11 +49,10 @@ public Command BuildDeleteCommand() { }; relationIdOption.IsRequired = true; command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId) => { + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption); return command; @@ -102,20 +101,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -149,14 +147,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string body) => { + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); return command; @@ -242,42 +239,6 @@ public RequestInformation CreatePatchRequestInformation(Relation body, Action - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Relation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// To indicate which terms are related to the current term as either pinned or reused. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/Set/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/Set/@Ref/@Ref.cs deleted file mode 100644 index e375b6a7026..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/Set/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.Set.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 13387ed5f4a..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,238 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.Set.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\sets\{set-id}\children\{term-id}\relations\{relation-id}\set\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/sets/{set_id}/children/{term_id}/relations/{relation_id}/set/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The [set] in which the relation is relevant. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.Set.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.Set.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/Set/Ref/Ref.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/Set/Ref/Ref.cs new file mode 100644 index 00000000000..ed44016b978 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/Set/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.Set.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..75a216c6a87 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs @@ -0,0 +1,200 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.Set.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\sets\{set-id}\children\{term-id}\relations\{relation-id}\set\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption); + return command; + } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/sets/{set_id}/children/{term_id}/relations/{relation_id}/set/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The [set] in which the relation is relevant. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the relation is relevant. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the relation is relevant. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.Set.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/Set/SetRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/Set/SetRequestBuilder.cs index 5598f8cd9b1..0688564ef5c 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/Set/SetRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/Set/SetRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.Set.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -57,25 +57,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.Set.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.Set.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -115,18 +114,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The [set] in which the relation is relevant. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/@Ref/@Ref.cs deleted file mode 100644 index 80d67c22505..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs deleted file mode 100644 index b00b3d5d09c..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,238 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\sets\{set-id}\children\{term-id}\relations\{relation-id}\toTerm\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/sets/{set_id}/children/{term_id}/relations/{relation_id}/toTerm/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/Ref/Ref.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/Ref/Ref.cs new file mode 100644 index 00000000000..28b81aec393 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..395c4bc1025 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs @@ -0,0 +1,200 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\sets\{set-id}\children\{term-id}\relations\{relation-id}\toTerm\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption); + return command; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/sets/{set_id}/children/{term_id}/relations/{relation_id}/toTerm/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs index 61db1bfd97d..89c6a53721c 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -57,25 +57,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item.ToTerm.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -115,18 +114,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The to [term] of the relation. The term to which the relationship is defined. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/RelationsRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/RelationsRequestBuilder.cs index cf068cc7f24..9bb60ba4008 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/RelationsRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Relations/RelationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class RelationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new RelationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildFromTermCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSetCommand(), - builder.BuildToTermCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFromTermCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSetCommand()); + commands.Add(builder.BuildToTermCommand()); return commands; } /// @@ -59,21 +58,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, bodyOption, outputOption); return command; } /// @@ -134,7 +132,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -145,15 +147,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -208,31 +205,6 @@ public RequestInformation CreatePostRequestInformation(Relation body, Action - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Relation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// To indicate which terms are related to the current term as either pinned or reused. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Set/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Set/@Ref/@Ref.cs deleted file mode 100644 index df0d5296f8d..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Set/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Set.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Set/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Set/@Ref/RefRequestBuilder.cs deleted file mode 100644 index f585ae1a8dc..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Set/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,226 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Set.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\sets\{set-id}\children\{term-id}\set\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The [set] in which the term is created. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The [set] in which the term is created."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption); - return command; - } - /// - /// The [set] in which the term is created. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The [set] in which the term is created."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption); - return command; - } - /// - /// The [set] in which the term is created. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The [set] in which the term is created."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/sets/{set_id}/children/{term_id}/set/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The [set] in which the term is created. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the term is created. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the term is created. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Set.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Set.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Set/Ref/Ref.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Set/Ref/Ref.cs new file mode 100644 index 00000000000..8e9cf8edb7c --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Set/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Set.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Set/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Set/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..667bae7f3e1 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Set/Ref/RefRequestBuilder.cs @@ -0,0 +1,188 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Set.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\sets\{set-id}\children\{term-id}\set\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The [set] in which the term is created. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The [set] in which the term is created."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, setIdOption, termIdOption); + return command; + } + /// + /// The [set] in which the term is created. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The [set] in which the term is created."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, outputOption); + return command; + } + /// + /// The [set] in which the term is created. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The [set] in which the term is created."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/sets/{set_id}/children/{term_id}/set/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The [set] in which the term is created. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the term is created. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the term is created. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Set.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Set/SetRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Set/SetRequestBuilder.cs index 17444270a8d..9fcdbf653dd 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Set/SetRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/Set/SetRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Set.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -53,25 +53,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Set.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Set.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -111,18 +110,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The [set] in which the term is created. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/TermRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/TermRequestBuilder.cs index eaaa4302661..65a15f40ce7 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/TermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Children/Item/TermRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Set; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,6 +25,9 @@ public class TermRequestBuilder { public Command BuildChildrenCommand() { var command = new Command("children"); var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Children.ChildrenRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -52,11 +55,10 @@ public Command BuildDeleteCommand() { }; termIdOption.IsRequired = true; command.AddOption(termIdOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId) => { + command.SetHandler(async (string siteId, string storeId, string setId, string termId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, setIdOption, termIdOption); return command; @@ -94,20 +96,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -137,14 +138,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string body) => { + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, setIdOption, termIdOption, bodyOption); return command; @@ -152,6 +152,9 @@ public Command BuildPatchCommand() { public Command BuildRelationsCommand() { var command = new Command("relations"); var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.Item.Relations.RelationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -230,42 +233,6 @@ public RequestInformation CreatePatchRequestInformation(Term body, Action - /// Children terms of set in term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children terms of set in term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children terms of set in term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Children terms of set in term [store]. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/ParentGroup/ParentGroupRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/ParentGroup/ParentGroupRequestBuilder.cs index cbef16bc599..957590e63a5 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/ParentGroup/ParentGroupRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/ParentGroup/ParentGroupRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets.Item.ParentGroup.Sets; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,11 +39,10 @@ public Command BuildDeleteCommand() { }; setIdOption.IsRequired = true; command.AddOption(setIdOption); - command.SetHandler(async (string siteId, string storeId, string setId) => { + command.SetHandler(async (string siteId, string storeId, string setId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, setIdOption); return command; @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -116,14 +114,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string body) => { + command.SetHandler(async (string siteId, string storeId, string setId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, setIdOption, bodyOption); return command; @@ -131,6 +128,9 @@ public Command BuildPatchCommand() { public Command BuildSetsCommand() { var command = new Command("sets"); var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.ParentGroup.Sets.SetsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -202,42 +202,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The parent [group] that contains the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The parent [group] that contains the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The parent [group] that contains the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Group model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The parent [group] that contains the set. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/ParentGroup/Sets/Item/SetRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/ParentGroup/Sets/Item/SetRequestBuilder.cs index 80ac12a5a2b..d5dc227b5f8 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/ParentGroup/Sets/Item/SetRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/ParentGroup/Sets/Item/SetRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph.TermStore; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -42,11 +42,10 @@ public Command BuildDeleteCommand() { }; setId1Option.IsRequired = true; command.AddOption(setId1Option); - command.SetHandler(async (string siteId, string storeId, string setId, string setId1) => { + command.SetHandler(async (string siteId, string storeId, string setId, string setId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, setIdOption, setId1Option); return command; @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, string setId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string setId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, setId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, setId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string setId1, string body) => { + command.SetHandler(async (string siteId, string storeId, string setId, string setId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, setIdOption, setId1Option, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All sets under the group in a term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All sets under the group in a term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All sets under the group in a term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.TermStore.Set model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// All sets under the group in a term [store]. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/ParentGroup/Sets/SetsRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/ParentGroup/Sets/SetsRequestBuilder.cs index d96971ea7a8..56265712237 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/ParentGroup/Sets/SetsRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/ParentGroup/Sets/SetsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets.Item.ParentGroup.Sets.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SetsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SetRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, bodyOption, outputOption); return command; } /// @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All sets under the group in a term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All sets under the group in a term [store]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.TermStore.Set model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// All sets under the group in a term [store]. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/FromTerm/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/FromTerm/@Ref/@Ref.cs deleted file mode 100644 index e9e37e02003..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/FromTerm/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.FromTerm.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 0483bd74145..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,226 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.FromTerm.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\sets\{set-id}\relations\{relation-id}\fromTerm\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string setId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, setIdOption, relationIdOption); - return command; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string setId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, relationIdOption); - return command; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, setIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/sets/{set_id}/relations/{relation_id}/fromTerm/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.FromTerm.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.FromTerm.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs index a13976d4d78..d928617dbd9 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.FromTerm.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -53,25 +53,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.FromTerm.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.FromTerm.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -111,18 +110,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/FromTerm/Ref/Ref.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/FromTerm/Ref/Ref.cs new file mode 100644 index 00000000000..46ad8db6911 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/FromTerm/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.FromTerm.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..71b478e033e --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs @@ -0,0 +1,188 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.FromTerm.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\sets\{set-id}\relations\{relation-id}\fromTerm\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string storeId, string setId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, setIdOption, relationIdOption); + return command; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string storeId, string setId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, setIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/sets/{set_id}/relations/{relation_id}/fromTerm/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.FromTerm.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/RelationRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/RelationRequestBuilder.cs index bbd9fce1999..07ba7da843e 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/RelationRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/RelationRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.ToTerm; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -45,11 +45,10 @@ public Command BuildDeleteCommand() { }; relationIdOption.IsRequired = true; command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string setId, string relationId) => { + command.SetHandler(async (string siteId, string storeId, string setId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, setIdOption, relationIdOption); return command; @@ -94,20 +93,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -137,14 +135,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string relationId, string body) => { + command.SetHandler(async (string siteId, string storeId, string setId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, setIdOption, relationIdOption, bodyOption); return command; @@ -230,42 +227,6 @@ public RequestInformation CreatePatchRequestInformation(Relation body, Action - /// Indicates which terms have been pinned or reused directly under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Indicates which terms have been pinned or reused directly under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Indicates which terms have been pinned or reused directly under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Relation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Indicates which terms have been pinned or reused directly under the set. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/Set/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/Set/@Ref/@Ref.cs deleted file mode 100644 index b130d8e20c9..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/Set/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.Set.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs deleted file mode 100644 index dcd4a94318f..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,226 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.Set.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\sets\{set-id}\relations\{relation-id}\set\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string setId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, setIdOption, relationIdOption); - return command; - } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string setId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, relationIdOption); - return command; - } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, setIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/sets/{set_id}/relations/{relation_id}/set/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The [set] in which the relation is relevant. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.Set.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.Set.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/Set/Ref/Ref.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/Set/Ref/Ref.cs new file mode 100644 index 00000000000..86ff340674d --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/Set/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.Set.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..9a7573c2932 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs @@ -0,0 +1,188 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.Set.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\sets\{set-id}\relations\{relation-id}\set\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string storeId, string setId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, setIdOption, relationIdOption); + return command; + } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string storeId, string setId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, setIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/sets/{set_id}/relations/{relation_id}/set/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The [set] in which the relation is relevant. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the relation is relevant. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the relation is relevant. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.Set.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/Set/SetRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/Set/SetRequestBuilder.cs index 21e30560647..910bd1dd8d7 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/Set/SetRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/Set/SetRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.Set.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -53,25 +53,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.Set.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.Set.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -111,18 +110,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The [set] in which the relation is relevant. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/ToTerm/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/ToTerm/@Ref/@Ref.cs deleted file mode 100644 index 0104471c6f6..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/ToTerm/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.ToTerm.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 3fb15574593..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,226 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.ToTerm.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\sets\{set-id}\relations\{relation-id}\toTerm\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string setId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, setIdOption, relationIdOption); - return command; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string setId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, relationIdOption); - return command; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, setIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/sets/{set_id}/relations/{relation_id}/toTerm/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.ToTerm.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.ToTerm.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/ToTerm/Ref/Ref.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/ToTerm/Ref/Ref.cs new file mode 100644 index 00000000000..2e2f9f350bb --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/ToTerm/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.ToTerm.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..b16d81b5a5e --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs @@ -0,0 +1,188 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.ToTerm.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\sets\{set-id}\relations\{relation-id}\toTerm\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string storeId, string setId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, setIdOption, relationIdOption); + return command; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string storeId, string setId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, setIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/sets/{set_id}/relations/{relation_id}/toTerm/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.ToTerm.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs index f3e0d56c3c7..ecf733b7465 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.ToTerm.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -53,25 +53,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.ToTerm.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item.ToTerm.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -111,18 +110,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The to [term] of the relation. The term to which the relationship is defined. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/RelationsRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/RelationsRequestBuilder.cs index 4113326be3a..feb8585fa4e 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/RelationsRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Relations/RelationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class RelationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new RelationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildFromTermCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSetCommand(), - builder.BuildToTermCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFromTermCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSetCommand()); + commands.Add(builder.BuildToTermCommand()); return commands; } /// @@ -55,21 +54,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, bodyOption, outputOption); return command; } /// @@ -126,7 +124,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -137,15 +139,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -200,31 +197,6 @@ public RequestInformation CreatePostRequestInformation(Relation body, Action - /// Indicates which terms have been pinned or reused directly under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Indicates which terms have been pinned or reused directly under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Relation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Indicates which terms have been pinned or reused directly under the set. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/SetRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/SetRequestBuilder.cs index bc012f4d4b0..c1398b0739e 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/SetRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/SetRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,6 +26,9 @@ public class SetRequestBuilder { public Command BuildChildrenCommand() { var command = new Command("children"); var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Children.ChildrenRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -49,11 +52,10 @@ public Command BuildDeleteCommand() { }; setIdOption.IsRequired = true; command.AddOption(setIdOption); - command.SetHandler(async (string siteId, string storeId, string setId) => { + command.SetHandler(async (string siteId, string storeId, string setId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, setIdOption); return command; @@ -87,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentGroupCommand() { @@ -135,14 +136,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string body) => { + command.SetHandler(async (string siteId, string storeId, string setId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, setIdOption, bodyOption); return command; @@ -150,6 +150,9 @@ public Command BuildPatchCommand() { public Command BuildRelationsCommand() { var command = new Command("relations"); var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Relations.RelationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -157,6 +160,9 @@ public Command BuildRelationsCommand() { public Command BuildTermsCommand() { var command = new Command("terms"); var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.TermsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -228,42 +234,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of all sets available in the term store. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of all sets available in the term store. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of all sets available in the term store. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.TermStore.Set model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of all sets available in the term store. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Children/ChildrenRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Children/ChildrenRequestBuilder.cs index 9419a27219a..96e3f3dd433 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Children/ChildrenRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Children/ChildrenRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Children.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ChildrenRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TermRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, bodyOption, outputOption); return command; } /// @@ -131,7 +129,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -142,15 +144,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -205,31 +202,6 @@ public RequestInformation CreatePostRequestInformation(Term body, Action - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Children of current term. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Children/Item/TermRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Children/Item/TermRequestBuilder.cs index 1802584f394..b984d581a90 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Children/Item/TermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Children/Item/TermRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph.TermStore; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -46,11 +46,10 @@ public Command BuildDeleteCommand() { }; termId1Option.IsRequired = true; command.AddOption(termId1Option); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string termId1) => { + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string termId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, setIdOption, termIdOption, termId1Option); return command; @@ -92,20 +91,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string termId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string termId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, termId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, termId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -139,14 +137,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string termId1, string body) => { + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string termId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, setIdOption, termIdOption, termId1Option, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(Term body, Action - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Children of current term. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Children of current term. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/@Ref/@Ref.cs deleted file mode 100644 index 55bcc30994b..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 889d8476d23..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,238 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\sets\{set-id}\terms\{term-id}\relations\{relation-id}\fromTerm\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/sets/{set_id}/terms/{term_id}/relations/{relation_id}/fromTerm/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs index c3cd382128e..4c0cc619fd0 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/FromTermRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -57,25 +57,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -115,18 +114,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/Ref/Ref.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/Ref/Ref.cs new file mode 100644 index 00000000000..bf32dc5cba9 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..783e4dfa3de --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/FromTerm/Ref/RefRequestBuilder.cs @@ -0,0 +1,200 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\sets\{set-id}\terms\{term-id}\relations\{relation-id}\fromTerm\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption); + return command; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/sets/{set_id}/terms/{term_id}/relations/{relation_id}/fromTerm/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The from [term] of the relation. The term from which the relationship is defined. A null value would indicate the relation is directly with the [set]. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.FromTerm.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/RelationRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/RelationRequestBuilder.cs index 8f780defd5b..194193fb16f 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/RelationRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/RelationRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -49,11 +49,10 @@ public Command BuildDeleteCommand() { }; relationIdOption.IsRequired = true; command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId) => { + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption); return command; @@ -102,20 +101,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -149,14 +147,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string body) => { + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); return command; @@ -242,42 +239,6 @@ public RequestInformation CreatePatchRequestInformation(Relation body, Action - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Relation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// To indicate which terms are related to the current term as either pinned or reused. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/Set/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/Set/@Ref/@Ref.cs deleted file mode 100644 index 89f8d5621a0..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/Set/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.Set.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 9ae386b319a..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/Set/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,238 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.Set.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\sets\{set-id}\terms\{term-id}\relations\{relation-id}\set\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The [set] in which the relation is relevant. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The [set] in which the relation is relevant."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/sets/{set_id}/terms/{term_id}/relations/{relation_id}/set/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The [set] in which the relation is relevant. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.Set.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.Set.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/Set/Ref/Ref.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/Set/Ref/Ref.cs new file mode 100644 index 00000000000..654846c0caf --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/Set/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.Set.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..a4ad168b847 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/Set/Ref/RefRequestBuilder.cs @@ -0,0 +1,200 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.Set.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\sets\{set-id}\terms\{term-id}\relations\{relation-id}\set\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption); + return command; + } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The [set] in which the relation is relevant. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The [set] in which the relation is relevant."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/sets/{set_id}/terms/{term_id}/relations/{relation_id}/set/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The [set] in which the relation is relevant. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the relation is relevant. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the relation is relevant. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.Set.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/Set/SetRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/Set/SetRequestBuilder.cs index 462bfc0918f..95f57162157 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/Set/SetRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/Set/SetRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.Set.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -57,25 +57,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.Set.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.Set.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -115,18 +114,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The [set] in which the relation is relevant. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The [set] in which the relation is relevant. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/@Ref/@Ref.cs deleted file mode 100644 index 507dae9c361..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs deleted file mode 100644 index efd83700f3c..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,238 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\sets\{set-id}\terms\{term-id}\relations\{relation-id}\toTerm\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption); - return command; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The to [term] of the relation. The term to which the relationship is defined."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var relationIdOption = new Option("--relation-id", description: "key: id of relation") { - }; - relationIdOption.IsRequired = true; - command.AddOption(relationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/sets/{set_id}/terms/{term_id}/relations/{relation_id}/toTerm/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/Ref/Ref.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/Ref/Ref.cs new file mode 100644 index 00000000000..e93ebf0b67d --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..747646cca09 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/Ref/RefRequestBuilder.cs @@ -0,0 +1,200 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\sets\{set-id}\terms\{term-id}\relations\{relation-id}\toTerm\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption); + return command; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, outputOption); + return command; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The to [term] of the relation. The term to which the relationship is defined."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var relationIdOption = new Option("--relation-id", description: "key: id of relation") { + }; + relationIdOption.IsRequired = true; + command.AddOption(relationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/sets/{set_id}/terms/{term_id}/relations/{relation_id}/toTerm/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The to [term] of the relation. The term to which the relationship is defined. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs index 6feb60d372c..5435806de02 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/Item/ToTerm/ToTermRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -57,25 +57,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string relationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, relationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item.ToTerm.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -115,18 +114,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The to [term] of the relation. The term to which the relationship is defined. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The to [term] of the relation. The term to which the relationship is defined. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/RelationsRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/RelationsRequestBuilder.cs index 75aff7bd2ea..6ad3b251087 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/RelationsRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Relations/RelationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class RelationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new RelationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildFromTermCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSetCommand(), - builder.BuildToTermCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFromTermCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSetCommand()); + commands.Add(builder.BuildToTermCommand()); return commands; } /// @@ -59,21 +58,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, bodyOption, outputOption); return command; } /// @@ -134,7 +132,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -145,15 +147,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -208,31 +205,6 @@ public RequestInformation CreatePostRequestInformation(Relation body, Action - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// To indicate which terms are related to the current term as either pinned or reused. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Relation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// To indicate which terms are related to the current term as either pinned or reused. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Set/@Ref/@Ref.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Set/@Ref/@Ref.cs deleted file mode 100644 index 51c6b6a1e9c..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Set/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Set.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Set/@Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Set/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 72dd355721a..00000000000 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Set/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,226 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Set.@Ref { - /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\sets\{set-id}\terms\{term-id}\set\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The [set] in which the term is created. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The [set] in which the term is created."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption); - return command; - } - /// - /// The [set] in which the term is created. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The [set] in which the term is created."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption); - return command; - } - /// - /// The [set] in which the term is created. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The [set] in which the term is created."; - // Create options for all the parameters - var siteIdOption = new Option("--site-id", description: "key: id of site") { - }; - siteIdOption.IsRequired = true; - command.AddOption(siteIdOption); - var storeIdOption = new Option("--store-id", description: "key: id of store") { - }; - storeIdOption.IsRequired = true; - command.AddOption(storeIdOption); - var setIdOption = new Option("--set-id", description: "key: id of set") { - }; - setIdOption.IsRequired = true; - command.AddOption(setIdOption); - var termIdOption = new Option("--term-id", description: "key: id of term") { - }; - termIdOption.IsRequired = true; - command.AddOption(termIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/sets/{set_id}/terms/{term_id}/set/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The [set] in which the term is created. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the term is created. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the term is created. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Set.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Set.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Set/Ref/Ref.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Set/Ref/Ref.cs new file mode 100644 index 00000000000..100820836b1 --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Set/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Set.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Set/Ref/RefRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Set/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..9c62a321dfa --- /dev/null +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Set/Ref/RefRequestBuilder.cs @@ -0,0 +1,188 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Set.Ref { + /// Builds and executes requests for operations under \sites\{site-id}\termStores\{store-id}\sets\{set-id}\terms\{term-id}\set\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The [set] in which the term is created. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The [set] in which the term is created."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, setIdOption, termIdOption); + return command; + } + /// + /// The [set] in which the term is created. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The [set] in which the term is created."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, outputOption); + return command; + } + /// + /// The [set] in which the term is created. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The [set] in which the term is created."; + // Create options for all the parameters + var siteIdOption = new Option("--site-id", description: "key: id of site") { + }; + siteIdOption.IsRequired = true; + command.AddOption(siteIdOption); + var storeIdOption = new Option("--store-id", description: "key: id of store") { + }; + storeIdOption.IsRequired = true; + command.AddOption(storeIdOption); + var setIdOption = new Option("--set-id", description: "key: id of set") { + }; + setIdOption.IsRequired = true; + command.AddOption(setIdOption); + var termIdOption = new Option("--term-id", description: "key: id of term") { + }; + termIdOption.IsRequired = true; + command.AddOption(termIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/{site_id}/termStores/{store_id}/sets/{set_id}/terms/{term_id}/set/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The [set] in which the term is created. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the term is created. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The [set] in which the term is created. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Set.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Set/SetRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Set/SetRequestBuilder.cs index d1219024026..b40197ca34e 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Set/SetRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/Set/SetRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Set.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -53,25 +53,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Set.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Set.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -111,18 +110,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The [set] in which the term is created. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The [set] in which the term is created. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/TermRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/TermRequestBuilder.cs index 58e81a58e73..473f17aa595 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/TermRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/Item/TermRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Set; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,6 +25,9 @@ public class TermRequestBuilder { public Command BuildChildrenCommand() { var command = new Command("children"); var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Children.ChildrenRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -52,11 +55,10 @@ public Command BuildDeleteCommand() { }; termIdOption.IsRequired = true; command.AddOption(termIdOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId) => { + command.SetHandler(async (string siteId, string storeId, string setId, string termId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, setIdOption, termIdOption); return command; @@ -94,20 +96,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, termIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, termIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -137,14 +138,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string termId, string body) => { + command.SetHandler(async (string siteId, string storeId, string setId, string termId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, setIdOption, termIdOption, bodyOption); return command; @@ -152,6 +152,9 @@ public Command BuildPatchCommand() { public Command BuildRelationsCommand() { var command = new Command("relations"); var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item.Relations.RelationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -230,42 +233,6 @@ public RequestInformation CreatePatchRequestInformation(Term body, Action - /// All the terms under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All the terms under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All the terms under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// All the terms under the set. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/TermsRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/TermsRequestBuilder.cs index 4d9686480a0..a6336a05a89 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/TermsRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/Item/Terms/TermsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets.Item.Terms.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class TermsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TermRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildChildrenCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildRelationsCommand(), - builder.BuildSetCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildChildrenCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRelationsCommand()); + commands.Add(builder.BuildSetCommand()); return commands; } /// @@ -55,21 +54,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string setId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, bodyOption, outputOption); return command; } /// @@ -126,7 +124,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string setId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -137,15 +139,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, setIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -200,31 +197,6 @@ public RequestInformation CreatePostRequestInformation(Term body, Action - /// All the terms under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All the terms under the set. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Term model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// All the terms under the set. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStores/Item/Sets/SetsRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/Sets/SetsRequestBuilder.cs index 26a376704e9..14b4aac0d9f 100644 --- a/src/generated/Sites/Item/TermStores/Item/Sets/SetsRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/Sets/SetsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SetsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SetRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildChildrenCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildRelationsCommand(), - builder.BuildTermsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildChildrenCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRelationsCommand()); + commands.Add(builder.BuildTermsCommand()); return commands; } /// @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, bodyOption, outputOption); return command; } /// @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -130,15 +132,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -193,31 +190,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of all sets available in the term store. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of all sets available in the term store. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.TermStore.Set model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of all sets available in the term store. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Item/TermStores/Item/StoreRequestBuilder.cs b/src/generated/Sites/Item/TermStores/Item/StoreRequestBuilder.cs index f014a27eafd..1cc22338972 100644 --- a/src/generated/Sites/Item/TermStores/Item/StoreRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/Item/StoreRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Sites.Item.TermStores.Item.Sets; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -36,11 +36,10 @@ public Command BuildDeleteCommand() { }; storeIdOption.IsRequired = true; command.AddOption(storeIdOption); - command.SetHandler(async (string siteId, string storeId) => { + command.SetHandler(async (string siteId, string storeId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption); return command; @@ -70,25 +69,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, string storeId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string storeId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, storeIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, storeIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildGroupsCommand() { var command = new Command("groups"); var builder = new ApiSdk.Sites.Item.TermStores.Item.Groups.GroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -112,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string storeId, string body) => { + command.SetHandler(async (string siteId, string storeId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, siteIdOption, storeIdOption, bodyOption); return command; @@ -127,6 +127,9 @@ public Command BuildPatchCommand() { public Command BuildSetsCommand() { var command = new Command("sets"); var builder = new ApiSdk.Sites.Item.TermStores.Item.Sets.SetsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -198,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(Store body, Action - /// The collection of termStores under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of termStores under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of termStores under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Store model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of termStores under this site. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Sites/Item/TermStores/TermStoresRequestBuilder.cs b/src/generated/Sites/Item/TermStores/TermStoresRequestBuilder.cs index 5ec629278e6..afa3113ce11 100644 --- a/src/generated/Sites/Item/TermStores/TermStoresRequestBuilder.cs +++ b/src/generated/Sites/Item/TermStores/TermStoresRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Sites.Item.TermStores.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class TermStoresRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new StoreRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildGroupsCommand(), - builder.BuildPatchCommand(), - builder.BuildSetsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildGroupsCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSetsCommand()); return commands; } /// @@ -46,21 +45,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string siteId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, bodyOption, outputOption); return command; } /// @@ -109,7 +107,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string siteId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -120,15 +122,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, siteIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -183,31 +180,6 @@ public RequestInformation CreatePostRequestInformation(Store body, Action - /// The collection of termStores under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of termStores under this site. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Store model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of termStores under this site. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Sites/Remove/Remove.cs b/src/generated/Sites/Remove/Remove.cs new file mode 100644 index 00000000000..c9414b8c435 --- /dev/null +++ b/src/generated/Sites/Remove/Remove.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Sites.Remove { + public class Remove : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new remove and sets the default values. + /// + public Remove() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Sites/@Remove/RemoveRequestBody.cs b/src/generated/Sites/Remove/RemoveRequestBody.cs similarity index 98% rename from src/generated/Sites/@Remove/RemoveRequestBody.cs rename to src/generated/Sites/Remove/RemoveRequestBody.cs index 3ec47583f42..9292008dcb7 100644 --- a/src/generated/Sites/@Remove/RemoveRequestBody.cs +++ b/src/generated/Sites/Remove/RemoveRequestBody.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; -namespace ApiSdk.Sites.@Remove { +namespace ApiSdk.Sites.Remove { public class RemoveRequestBody : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } diff --git a/src/generated/Sites/Remove/RemoveRequestBuilder.cs b/src/generated/Sites/Remove/RemoveRequestBuilder.cs new file mode 100644 index 00000000000..8d487f22d65 --- /dev/null +++ b/src/generated/Sites/Remove/RemoveRequestBuilder.cs @@ -0,0 +1,80 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Sites.Remove { + /// Builds and executes requests for operations under \sites\microsoft.graph.remove + public class RemoveRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action remove + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action remove"; + // Create options for all the parameters + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RemoveRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RemoveRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/sites/microsoft.graph.remove"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action remove + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(RemoveRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Sites/SitesRequestBuilder.cs b/src/generated/Sites/SitesRequestBuilder.cs index 0b890860aa7..a881f225f67 100644 --- a/src/generated/Sites/SitesRequestBuilder.cs +++ b/src/generated/Sites/SitesRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Sites.Remove; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -24,30 +24,29 @@ public class SitesRequestBuilder { private string UrlTemplate { get; set; } public Command BuildAddCommand() { var command = new Command("add"); - var builder = new ApiSdk.Sites.@Add.AddRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Add.AddRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } public List BuildCommand() { var builder = new SiteRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAnalyticsCommand(), - builder.BuildColumnsCommand(), - builder.BuildContentTypesCommand(), - builder.BuildDeleteCommand(), - builder.BuildDriveCommand(), - builder.BuildDrivesCommand(), - builder.BuildExternalColumnsCommand(), - builder.BuildGetCommand(), - builder.BuildItemsCommand(), - builder.BuildListsCommand(), - builder.BuildOnenoteCommand(), - builder.BuildPatchCommand(), - builder.BuildPermissionsCommand(), - builder.BuildSitesCommand(), - builder.BuildTermStoreCommand(), - builder.BuildTermStoresCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAnalyticsCommand()); + commands.Add(builder.BuildColumnsCommand()); + commands.Add(builder.BuildContentTypesCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDriveCommand()); + commands.Add(builder.BuildDrivesCommand()); + commands.Add(builder.BuildExternalColumnsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildItemsCommand()); + commands.Add(builder.BuildListsCommand()); + commands.Add(builder.BuildOnenoteCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPermissionsCommand()); + commands.Add(builder.BuildSitesCommand()); + commands.Add(builder.BuildTermStoreCommand()); + commands.Add(builder.BuildTermStoresCommand()); return commands; } /// @@ -61,21 +60,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -131,20 +133,15 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRemoveCommand() { var command = new Command("remove"); - var builder = new ApiSdk.Sites.@Remove.RemoveRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Sites.Remove.RemoveRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } @@ -200,31 +197,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get entities from sites - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to sites - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Site model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from sites public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Solutions/BookingBusinesses/BookingBusinessesRequestBuilder.cs b/src/generated/Solutions/BookingBusinesses/BookingBusinessesRequestBuilder.cs index 1434e0b65aa..e9967ddafbf 100644 --- a/src/generated/Solutions/BookingBusinesses/BookingBusinessesRequestBuilder.cs +++ b/src/generated/Solutions/BookingBusinesses/BookingBusinessesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Solutions.BookingBusinesses.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,19 +22,18 @@ public class BookingBusinessesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new BookingBusinessRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAppointmentsCommand(), - builder.BuildCalendarViewCommand(), - builder.BuildCustomersCommand(), - builder.BuildCustomQuestionsCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildPublishCommand(), - builder.BuildServicesCommand(), - builder.BuildStaffMembersCommand(), - builder.BuildUnpublishCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAppointmentsCommand()); + commands.Add(builder.BuildCalendarViewCommand()); + commands.Add(builder.BuildCustomersCommand()); + commands.Add(builder.BuildCustomQuestionsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPublishCommand()); + commands.Add(builder.BuildServicesCommand()); + commands.Add(builder.BuildStaffMembersCommand()); + commands.Add(builder.BuildUnpublishCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(BookingBusiness body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get bookingBusinesses from solutions - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to bookingBusinesses for solutions - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(BookingBusiness model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get bookingBusinesses from solutions public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Solutions/BookingBusinesses/Item/Appointments/AppointmentsRequestBuilder.cs b/src/generated/Solutions/BookingBusinesses/Item/Appointments/AppointmentsRequestBuilder.cs index bc11dbcbba2..2eff3131157 100644 --- a/src/generated/Solutions/BookingBusinesses/Item/Appointments/AppointmentsRequestBuilder.cs +++ b/src/generated/Solutions/BookingBusinesses/Item/Appointments/AppointmentsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Solutions.BookingBusinesses.Item.Appointments.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class AppointmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new BookingAppointmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCancelCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -37,7 +36,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "All the appointments of this business. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string bookingBusinessId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string bookingBusinessId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bookingBusinessIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bookingBusinessIdOption, bodyOption, outputOption); return command; } /// @@ -69,7 +67,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "All the appointments of this business. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string bookingBusinessId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string bookingBusinessId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bookingBusinessIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bookingBusinessIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(BookingAppointment body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All the appointments of this business. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All the appointments of this business. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(BookingAppointment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// All the appointments of this business. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Solutions/BookingBusinesses/Item/Appointments/Item/BookingAppointmentRequestBuilder.cs b/src/generated/Solutions/BookingBusinesses/Item/Appointments/Item/BookingAppointmentRequestBuilder.cs index c91caa81991..382b3f2468e 100644 --- a/src/generated/Solutions/BookingBusinesses/Item/Appointments/Item/BookingAppointmentRequestBuilder.cs +++ b/src/generated/Solutions/BookingBusinesses/Item/Appointments/Item/BookingAppointmentRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Solutions.BookingBusinesses.Item.Appointments.Item.Cancel; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,19 +33,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "All the appointments of this business. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); - var bookingAppointmentIdOption = new Option("--bookingappointment-id", description: "key: id of bookingAppointment") { + var bookingAppointmentIdOption = new Option("--booking-appointment-id", description: "key: id of bookingAppointment") { }; bookingAppointmentIdOption.IsRequired = true; command.AddOption(bookingAppointmentIdOption); - command.SetHandler(async (string bookingBusinessId, string bookingAppointmentId) => { + command.SetHandler(async (string bookingBusinessId, string bookingAppointmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bookingBusinessIdOption, bookingAppointmentIdOption); return command; @@ -57,11 +56,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "All the appointments of this business. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); - var bookingAppointmentIdOption = new Option("--bookingappointment-id", description: "key: id of bookingAppointment") { + var bookingAppointmentIdOption = new Option("--booking-appointment-id", description: "key: id of bookingAppointment") { }; bookingAppointmentIdOption.IsRequired = true; command.AddOption(bookingAppointmentIdOption); @@ -75,20 +74,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string bookingBusinessId, string bookingAppointmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string bookingBusinessId, string bookingAppointmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bookingBusinessIdOption, bookingAppointmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bookingBusinessIdOption, bookingAppointmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -98,11 +96,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "All the appointments of this business. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); - var bookingAppointmentIdOption = new Option("--bookingappointment-id", description: "key: id of bookingAppointment") { + var bookingAppointmentIdOption = new Option("--booking-appointment-id", description: "key: id of bookingAppointment") { }; bookingAppointmentIdOption.IsRequired = true; command.AddOption(bookingAppointmentIdOption); @@ -110,14 +108,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string bookingBusinessId, string bookingAppointmentId, string body) => { + command.SetHandler(async (string bookingBusinessId, string bookingAppointmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bookingBusinessIdOption, bookingAppointmentIdOption, bodyOption); return command; @@ -189,42 +186,6 @@ public RequestInformation CreatePatchRequestInformation(BookingAppointment body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All the appointments of this business. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All the appointments of this business. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All the appointments of this business. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(BookingAppointment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// All the appointments of this business. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Solutions/BookingBusinesses/Item/Appointments/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Solutions/BookingBusinesses/Item/Appointments/Item/Cancel/CancelRequestBuilder.cs index b522eea005e..258cdcc2b86 100644 --- a/src/generated/Solutions/BookingBusinesses/Item/Appointments/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Solutions/BookingBusinesses/Item/Appointments/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,11 +25,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Cancels the giving booking appointment, sending a message to the involved parties."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); - var bookingAppointmentIdOption = new Option("--bookingappointment-id", description: "key: id of bookingAppointment") { + var bookingAppointmentIdOption = new Option("--booking-appointment-id", description: "key: id of bookingAppointment") { }; bookingAppointmentIdOption.IsRequired = true; command.AddOption(bookingAppointmentIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string bookingBusinessId, string bookingAppointmentId, string body) => { + command.SetHandler(async (string bookingBusinessId, string bookingAppointmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bookingBusinessIdOption, bookingAppointmentIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Cancels the giving booking appointment, sending a message to the involved parties. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Solutions/BookingBusinesses/Item/BookingBusinessRequestBuilder.cs b/src/generated/Solutions/BookingBusinesses/Item/BookingBusinessRequestBuilder.cs index 6144adcea0b..63a463c5da1 100644 --- a/src/generated/Solutions/BookingBusinesses/Item/BookingBusinessRequestBuilder.cs +++ b/src/generated/Solutions/BookingBusinesses/Item/BookingBusinessRequestBuilder.cs @@ -9,10 +9,10 @@ using ApiSdk.Solutions.BookingBusinesses.Item.Unpublish; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,6 +30,9 @@ public class BookingBusinessRequestBuilder { public Command BuildAppointmentsCommand() { var command = new Command("appointments"); var builder = new ApiSdk.Solutions.BookingBusinesses.Item.Appointments.AppointmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -37,6 +40,9 @@ public Command BuildAppointmentsCommand() { public Command BuildCalendarViewCommand() { var command = new Command("calendar-view"); var builder = new ApiSdk.Solutions.BookingBusinesses.Item.CalendarView.CalendarViewRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -44,6 +50,9 @@ public Command BuildCalendarViewCommand() { public Command BuildCustomersCommand() { var command = new Command("customers"); var builder = new ApiSdk.Solutions.BookingBusinesses.Item.Customers.CustomersRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -51,6 +60,9 @@ public Command BuildCustomersCommand() { public Command BuildCustomQuestionsCommand() { var command = new Command("custom-questions"); var builder = new ApiSdk.Solutions.BookingBusinesses.Item.CustomQuestions.CustomQuestionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -62,15 +74,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property bookingBusinesses for solutions"; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); - command.SetHandler(async (string bookingBusinessId) => { + command.SetHandler(async (string bookingBusinessId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bookingBusinessIdOption); return command; @@ -82,7 +93,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get bookingBusinesses from solutions"; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); @@ -96,20 +107,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string bookingBusinessId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string bookingBusinessId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bookingBusinessIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bookingBusinessIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,7 +129,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property bookingBusinesses in solutions"; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); @@ -127,14 +137,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string bookingBusinessId, string body) => { + command.SetHandler(async (string bookingBusinessId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bookingBusinessIdOption, bodyOption); return command; @@ -148,6 +157,9 @@ public Command BuildPublishCommand() { public Command BuildServicesCommand() { var command = new Command("services"); var builder = new ApiSdk.Solutions.BookingBusinesses.Item.Services.ServicesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -155,6 +167,9 @@ public Command BuildServicesCommand() { public Command BuildStaffMembersCommand() { var command = new Command("staff-members"); var builder = new ApiSdk.Solutions.BookingBusinesses.Item.StaffMembers.StaffMembersRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -232,42 +247,6 @@ public RequestInformation CreatePatchRequestInformation(BookingBusiness body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property bookingBusinesses for solutions - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get bookingBusinesses from solutions - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property bookingBusinesses in solutions - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(BookingBusiness model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get bookingBusinesses from solutions public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Solutions/BookingBusinesses/Item/CalendarView/CalendarViewRequestBuilder.cs b/src/generated/Solutions/BookingBusinesses/Item/CalendarView/CalendarViewRequestBuilder.cs index a082b2e4ff4..494ffb101d2 100644 --- a/src/generated/Solutions/BookingBusinesses/Item/CalendarView/CalendarViewRequestBuilder.cs +++ b/src/generated/Solutions/BookingBusinesses/Item/CalendarView/CalendarViewRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Solutions.BookingBusinesses.Item.CalendarView.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class CalendarViewRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new BookingAppointmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCancelCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -37,7 +36,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The set of appointments of this business in a specified date range. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string bookingBusinessId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string bookingBusinessId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bookingBusinessIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bookingBusinessIdOption, bodyOption, outputOption); return command; } /// @@ -69,7 +67,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The set of appointments of this business in a specified date range. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string bookingBusinessId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string bookingBusinessId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bookingBusinessIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bookingBusinessIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(BookingAppointment body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The set of appointments of this business in a specified date range. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The set of appointments of this business in a specified date range. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(BookingAppointment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The set of appointments of this business in a specified date range. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Solutions/BookingBusinesses/Item/CalendarView/Item/BookingAppointmentRequestBuilder.cs b/src/generated/Solutions/BookingBusinesses/Item/CalendarView/Item/BookingAppointmentRequestBuilder.cs index 809610f7c0c..5d91c06c3b9 100644 --- a/src/generated/Solutions/BookingBusinesses/Item/CalendarView/Item/BookingAppointmentRequestBuilder.cs +++ b/src/generated/Solutions/BookingBusinesses/Item/CalendarView/Item/BookingAppointmentRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Solutions.BookingBusinesses.Item.CalendarView.Item.Cancel; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,19 +33,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The set of appointments of this business in a specified date range. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); - var bookingAppointmentIdOption = new Option("--bookingappointment-id", description: "key: id of bookingAppointment") { + var bookingAppointmentIdOption = new Option("--booking-appointment-id", description: "key: id of bookingAppointment") { }; bookingAppointmentIdOption.IsRequired = true; command.AddOption(bookingAppointmentIdOption); - command.SetHandler(async (string bookingBusinessId, string bookingAppointmentId) => { + command.SetHandler(async (string bookingBusinessId, string bookingAppointmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bookingBusinessIdOption, bookingAppointmentIdOption); return command; @@ -57,11 +56,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The set of appointments of this business in a specified date range. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); - var bookingAppointmentIdOption = new Option("--bookingappointment-id", description: "key: id of bookingAppointment") { + var bookingAppointmentIdOption = new Option("--booking-appointment-id", description: "key: id of bookingAppointment") { }; bookingAppointmentIdOption.IsRequired = true; command.AddOption(bookingAppointmentIdOption); @@ -75,20 +74,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string bookingBusinessId, string bookingAppointmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string bookingBusinessId, string bookingAppointmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bookingBusinessIdOption, bookingAppointmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bookingBusinessIdOption, bookingAppointmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -98,11 +96,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The set of appointments of this business in a specified date range. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); - var bookingAppointmentIdOption = new Option("--bookingappointment-id", description: "key: id of bookingAppointment") { + var bookingAppointmentIdOption = new Option("--booking-appointment-id", description: "key: id of bookingAppointment") { }; bookingAppointmentIdOption.IsRequired = true; command.AddOption(bookingAppointmentIdOption); @@ -110,14 +108,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string bookingBusinessId, string bookingAppointmentId, string body) => { + command.SetHandler(async (string bookingBusinessId, string bookingAppointmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bookingBusinessIdOption, bookingAppointmentIdOption, bodyOption); return command; @@ -189,42 +186,6 @@ public RequestInformation CreatePatchRequestInformation(BookingAppointment body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The set of appointments of this business in a specified date range. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The set of appointments of this business in a specified date range. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The set of appointments of this business in a specified date range. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(BookingAppointment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The set of appointments of this business in a specified date range. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Solutions/BookingBusinesses/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Solutions/BookingBusinesses/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs index 81e0917b0f4..2f263b8bcca 100644 --- a/src/generated/Solutions/BookingBusinesses/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Solutions/BookingBusinesses/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,11 +25,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Cancels the giving booking appointment, sending a message to the involved parties."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); - var bookingAppointmentIdOption = new Option("--bookingappointment-id", description: "key: id of bookingAppointment") { + var bookingAppointmentIdOption = new Option("--booking-appointment-id", description: "key: id of bookingAppointment") { }; bookingAppointmentIdOption.IsRequired = true; command.AddOption(bookingAppointmentIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string bookingBusinessId, string bookingAppointmentId, string body) => { + command.SetHandler(async (string bookingBusinessId, string bookingAppointmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bookingBusinessIdOption, bookingAppointmentIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Cancels the giving booking appointment, sending a message to the involved parties. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Solutions/BookingBusinesses/Item/CustomQuestions/CustomQuestionsRequestBuilder.cs b/src/generated/Solutions/BookingBusinesses/Item/CustomQuestions/CustomQuestionsRequestBuilder.cs index 4ede6f060d9..6cc1bbeb0a1 100644 --- a/src/generated/Solutions/BookingBusinesses/Item/CustomQuestions/CustomQuestionsRequestBuilder.cs +++ b/src/generated/Solutions/BookingBusinesses/Item/CustomQuestions/CustomQuestionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Solutions.BookingBusinesses.Item.CustomQuestions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class CustomQuestionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new BookingCustomQuestionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "All the custom questions of this business. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string bookingBusinessId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string bookingBusinessId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bookingBusinessIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bookingBusinessIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "All the custom questions of this business. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string bookingBusinessId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string bookingBusinessId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bookingBusinessIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bookingBusinessIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(BookingCustomQuestion bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All the custom questions of this business. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All the custom questions of this business. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(BookingCustomQuestion model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// All the custom questions of this business. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Solutions/BookingBusinesses/Item/CustomQuestions/Item/BookingCustomQuestionRequestBuilder.cs b/src/generated/Solutions/BookingBusinesses/Item/CustomQuestions/Item/BookingCustomQuestionRequestBuilder.cs index 0691154c1f3..073192dee95 100644 --- a/src/generated/Solutions/BookingBusinesses/Item/CustomQuestions/Item/BookingCustomQuestionRequestBuilder.cs +++ b/src/generated/Solutions/BookingBusinesses/Item/CustomQuestions/Item/BookingCustomQuestionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "All the custom questions of this business. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); - var bookingCustomQuestionIdOption = new Option("--bookingcustomquestion-id", description: "key: id of bookingCustomQuestion") { + var bookingCustomQuestionIdOption = new Option("--booking-custom-question-id", description: "key: id of bookingCustomQuestion") { }; bookingCustomQuestionIdOption.IsRequired = true; command.AddOption(bookingCustomQuestionIdOption); - command.SetHandler(async (string bookingBusinessId, string bookingCustomQuestionId) => { + command.SetHandler(async (string bookingBusinessId, string bookingCustomQuestionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bookingBusinessIdOption, bookingCustomQuestionIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "All the custom questions of this business. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); - var bookingCustomQuestionIdOption = new Option("--bookingcustomquestion-id", description: "key: id of bookingCustomQuestion") { + var bookingCustomQuestionIdOption = new Option("--booking-custom-question-id", description: "key: id of bookingCustomQuestion") { }; bookingCustomQuestionIdOption.IsRequired = true; command.AddOption(bookingCustomQuestionIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string bookingBusinessId, string bookingCustomQuestionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string bookingBusinessId, string bookingCustomQuestionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bookingBusinessIdOption, bookingCustomQuestionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bookingBusinessIdOption, bookingCustomQuestionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "All the custom questions of this business. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); - var bookingCustomQuestionIdOption = new Option("--bookingcustomquestion-id", description: "key: id of bookingCustomQuestion") { + var bookingCustomQuestionIdOption = new Option("--booking-custom-question-id", description: "key: id of bookingCustomQuestion") { }; bookingCustomQuestionIdOption.IsRequired = true; command.AddOption(bookingCustomQuestionIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string bookingBusinessId, string bookingCustomQuestionId, string body) => { + command.SetHandler(async (string bookingBusinessId, string bookingCustomQuestionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bookingBusinessIdOption, bookingCustomQuestionIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(BookingCustomQuestion bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All the custom questions of this business. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All the custom questions of this business. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All the custom questions of this business. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(BookingCustomQuestion model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// All the custom questions of this business. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Solutions/BookingBusinesses/Item/Customers/CustomersRequestBuilder.cs b/src/generated/Solutions/BookingBusinesses/Item/Customers/CustomersRequestBuilder.cs index c6868209c54..73573a95ac5 100644 --- a/src/generated/Solutions/BookingBusinesses/Item/Customers/CustomersRequestBuilder.cs +++ b/src/generated/Solutions/BookingBusinesses/Item/Customers/CustomersRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Solutions.BookingBusinesses.Item.Customers.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class CustomersRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new BookingCustomerBaseRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "All the customers of this business. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string bookingBusinessId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string bookingBusinessId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bookingBusinessIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bookingBusinessIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "All the customers of this business. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string bookingBusinessId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string bookingBusinessId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bookingBusinessIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bookingBusinessIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(BookingCustomerBase body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All the customers of this business. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All the customers of this business. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(BookingCustomerBase model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// All the customers of this business. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Solutions/BookingBusinesses/Item/Customers/Item/BookingCustomerBaseRequestBuilder.cs b/src/generated/Solutions/BookingBusinesses/Item/Customers/Item/BookingCustomerBaseRequestBuilder.cs index 2c90081cd7e..a9d52aa1099 100644 --- a/src/generated/Solutions/BookingBusinesses/Item/Customers/Item/BookingCustomerBaseRequestBuilder.cs +++ b/src/generated/Solutions/BookingBusinesses/Item/Customers/Item/BookingCustomerBaseRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "All the customers of this business. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); - var bookingCustomerBaseIdOption = new Option("--bookingcustomerbase-id", description: "key: id of bookingCustomerBase") { + var bookingCustomerBaseIdOption = new Option("--booking-customer-base-id", description: "key: id of bookingCustomerBase") { }; bookingCustomerBaseIdOption.IsRequired = true; command.AddOption(bookingCustomerBaseIdOption); - command.SetHandler(async (string bookingBusinessId, string bookingCustomerBaseId) => { + command.SetHandler(async (string bookingBusinessId, string bookingCustomerBaseId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bookingBusinessIdOption, bookingCustomerBaseIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "All the customers of this business. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); - var bookingCustomerBaseIdOption = new Option("--bookingcustomerbase-id", description: "key: id of bookingCustomerBase") { + var bookingCustomerBaseIdOption = new Option("--booking-customer-base-id", description: "key: id of bookingCustomerBase") { }; bookingCustomerBaseIdOption.IsRequired = true; command.AddOption(bookingCustomerBaseIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string bookingBusinessId, string bookingCustomerBaseId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string bookingBusinessId, string bookingCustomerBaseId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bookingBusinessIdOption, bookingCustomerBaseIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bookingBusinessIdOption, bookingCustomerBaseIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "All the customers of this business. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); - var bookingCustomerBaseIdOption = new Option("--bookingcustomerbase-id", description: "key: id of bookingCustomerBase") { + var bookingCustomerBaseIdOption = new Option("--booking-customer-base-id", description: "key: id of bookingCustomerBase") { }; bookingCustomerBaseIdOption.IsRequired = true; command.AddOption(bookingCustomerBaseIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string bookingBusinessId, string bookingCustomerBaseId, string body) => { + command.SetHandler(async (string bookingBusinessId, string bookingCustomerBaseId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bookingBusinessIdOption, bookingCustomerBaseIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(BookingCustomerBase body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All the customers of this business. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All the customers of this business. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All the customers of this business. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(BookingCustomerBase model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// All the customers of this business. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Solutions/BookingBusinesses/Item/Publish/PublishRequestBuilder.cs b/src/generated/Solutions/BookingBusinesses/Item/Publish/PublishRequestBuilder.cs index 26117554b21..2a57c796456 100644 --- a/src/generated/Solutions/BookingBusinesses/Item/Publish/PublishRequestBuilder.cs +++ b/src/generated/Solutions/BookingBusinesses/Item/Publish/PublishRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Makes the scheduling page of this business available to the general public."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); - command.SetHandler(async (string bookingBusinessId) => { + command.SetHandler(async (string bookingBusinessId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bookingBusinessIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Makes the scheduling page of this business available to the general public. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Solutions/BookingBusinesses/Item/Services/Item/BookingServiceRequestBuilder.cs b/src/generated/Solutions/BookingBusinesses/Item/Services/Item/BookingServiceRequestBuilder.cs index d7ec74f6d7a..f3e44fd613d 100644 --- a/src/generated/Solutions/BookingBusinesses/Item/Services/Item/BookingServiceRequestBuilder.cs +++ b/src/generated/Solutions/BookingBusinesses/Item/Services/Item/BookingServiceRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "All the services offered by this business. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); - var bookingServiceIdOption = new Option("--bookingservice-id", description: "key: id of bookingService") { + var bookingServiceIdOption = new Option("--booking-service-id", description: "key: id of bookingService") { }; bookingServiceIdOption.IsRequired = true; command.AddOption(bookingServiceIdOption); - command.SetHandler(async (string bookingBusinessId, string bookingServiceId) => { + command.SetHandler(async (string bookingBusinessId, string bookingServiceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bookingBusinessIdOption, bookingServiceIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "All the services offered by this business. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); - var bookingServiceIdOption = new Option("--bookingservice-id", description: "key: id of bookingService") { + var bookingServiceIdOption = new Option("--booking-service-id", description: "key: id of bookingService") { }; bookingServiceIdOption.IsRequired = true; command.AddOption(bookingServiceIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string bookingBusinessId, string bookingServiceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string bookingBusinessId, string bookingServiceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bookingBusinessIdOption, bookingServiceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bookingBusinessIdOption, bookingServiceIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "All the services offered by this business. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); - var bookingServiceIdOption = new Option("--bookingservice-id", description: "key: id of bookingService") { + var bookingServiceIdOption = new Option("--booking-service-id", description: "key: id of bookingService") { }; bookingServiceIdOption.IsRequired = true; command.AddOption(bookingServiceIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string bookingBusinessId, string bookingServiceId, string body) => { + command.SetHandler(async (string bookingBusinessId, string bookingServiceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bookingBusinessIdOption, bookingServiceIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(BookingService body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All the services offered by this business. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All the services offered by this business. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All the services offered by this business. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(BookingService model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// All the services offered by this business. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Solutions/BookingBusinesses/Item/Services/ServicesRequestBuilder.cs b/src/generated/Solutions/BookingBusinesses/Item/Services/ServicesRequestBuilder.cs index f0c1a855cec..19198f86163 100644 --- a/src/generated/Solutions/BookingBusinesses/Item/Services/ServicesRequestBuilder.cs +++ b/src/generated/Solutions/BookingBusinesses/Item/Services/ServicesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Solutions.BookingBusinesses.Item.Services.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ServicesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new BookingServiceRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "All the services offered by this business. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string bookingBusinessId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string bookingBusinessId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bookingBusinessIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bookingBusinessIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "All the services offered by this business. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string bookingBusinessId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string bookingBusinessId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bookingBusinessIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bookingBusinessIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(BookingService body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All the services offered by this business. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All the services offered by this business. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(BookingService model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// All the services offered by this business. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Solutions/BookingBusinesses/Item/StaffMembers/Item/BookingStaffMemberBaseRequestBuilder.cs b/src/generated/Solutions/BookingBusinesses/Item/StaffMembers/Item/BookingStaffMemberBaseRequestBuilder.cs index 8d02ed87139..cf219adb58b 100644 --- a/src/generated/Solutions/BookingBusinesses/Item/StaffMembers/Item/BookingStaffMemberBaseRequestBuilder.cs +++ b/src/generated/Solutions/BookingBusinesses/Item/StaffMembers/Item/BookingStaffMemberBaseRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "All the staff members that provide services in this business. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); - var bookingStaffMemberBaseIdOption = new Option("--bookingstaffmemberbase-id", description: "key: id of bookingStaffMemberBase") { + var bookingStaffMemberBaseIdOption = new Option("--booking-staff-member-base-id", description: "key: id of bookingStaffMemberBase") { }; bookingStaffMemberBaseIdOption.IsRequired = true; command.AddOption(bookingStaffMemberBaseIdOption); - command.SetHandler(async (string bookingBusinessId, string bookingStaffMemberBaseId) => { + command.SetHandler(async (string bookingBusinessId, string bookingStaffMemberBaseId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bookingBusinessIdOption, bookingStaffMemberBaseIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "All the staff members that provide services in this business. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); - var bookingStaffMemberBaseIdOption = new Option("--bookingstaffmemberbase-id", description: "key: id of bookingStaffMemberBase") { + var bookingStaffMemberBaseIdOption = new Option("--booking-staff-member-base-id", description: "key: id of bookingStaffMemberBase") { }; bookingStaffMemberBaseIdOption.IsRequired = true; command.AddOption(bookingStaffMemberBaseIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string bookingBusinessId, string bookingStaffMemberBaseId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string bookingBusinessId, string bookingStaffMemberBaseId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bookingBusinessIdOption, bookingStaffMemberBaseIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bookingBusinessIdOption, bookingStaffMemberBaseIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "All the staff members that provide services in this business. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); - var bookingStaffMemberBaseIdOption = new Option("--bookingstaffmemberbase-id", description: "key: id of bookingStaffMemberBase") { + var bookingStaffMemberBaseIdOption = new Option("--booking-staff-member-base-id", description: "key: id of bookingStaffMemberBase") { }; bookingStaffMemberBaseIdOption.IsRequired = true; command.AddOption(bookingStaffMemberBaseIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string bookingBusinessId, string bookingStaffMemberBaseId, string body) => { + command.SetHandler(async (string bookingBusinessId, string bookingStaffMemberBaseId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bookingBusinessIdOption, bookingStaffMemberBaseIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(BookingStaffMemberBase b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All the staff members that provide services in this business. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All the staff members that provide services in this business. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All the staff members that provide services in this business. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(BookingStaffMemberBase model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// All the staff members that provide services in this business. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Solutions/BookingBusinesses/Item/StaffMembers/StaffMembersRequestBuilder.cs b/src/generated/Solutions/BookingBusinesses/Item/StaffMembers/StaffMembersRequestBuilder.cs index cc29a9cd805..14f00d75e4a 100644 --- a/src/generated/Solutions/BookingBusinesses/Item/StaffMembers/StaffMembersRequestBuilder.cs +++ b/src/generated/Solutions/BookingBusinesses/Item/StaffMembers/StaffMembersRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Solutions.BookingBusinesses.Item.StaffMembers.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class StaffMembersRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new BookingStaffMemberBaseRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "All the staff members that provide services in this business. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string bookingBusinessId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string bookingBusinessId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bookingBusinessIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bookingBusinessIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "All the staff members that provide services in this business. Read-only. Nullable."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string bookingBusinessId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string bookingBusinessId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bookingBusinessIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bookingBusinessIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(BookingStaffMemberBase bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// All the staff members that provide services in this business. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// All the staff members that provide services in this business. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(BookingStaffMemberBase model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// All the staff members that provide services in this business. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Solutions/BookingBusinesses/Item/Unpublish/UnpublishRequestBuilder.cs b/src/generated/Solutions/BookingBusinesses/Item/Unpublish/UnpublishRequestBuilder.cs index 8aa4a6dede6..bce758a1cd9 100644 --- a/src/generated/Solutions/BookingBusinesses/Item/Unpublish/UnpublishRequestBuilder.cs +++ b/src/generated/Solutions/BookingBusinesses/Item/Unpublish/UnpublishRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Prevents the general public from seeing the scheduling page of this business."; // Create options for all the parameters - var bookingBusinessIdOption = new Option("--bookingbusiness-id", description: "key: id of bookingBusiness") { + var bookingBusinessIdOption = new Option("--booking-business-id", description: "key: id of bookingBusiness") { }; bookingBusinessIdOption.IsRequired = true; command.AddOption(bookingBusinessIdOption); - command.SetHandler(async (string bookingBusinessId) => { + command.SetHandler(async (string bookingBusinessId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bookingBusinessIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Prevents the general public from seeing the scheduling page of this business. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Solutions/BookingCurrencies/BookingCurrenciesRequestBuilder.cs b/src/generated/Solutions/BookingCurrencies/BookingCurrenciesRequestBuilder.cs index dcaccd367ac..ab42434570f 100644 --- a/src/generated/Solutions/BookingCurrencies/BookingCurrenciesRequestBuilder.cs +++ b/src/generated/Solutions/BookingCurrencies/BookingCurrenciesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Solutions.BookingCurrencies.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class BookingCurrenciesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new BookingCurrencyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(BookingCurrency body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get bookingCurrencies from solutions - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to bookingCurrencies for solutions - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(BookingCurrency model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get bookingCurrencies from solutions public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Solutions/BookingCurrencies/Item/BookingCurrencyRequestBuilder.cs b/src/generated/Solutions/BookingCurrencies/Item/BookingCurrencyRequestBuilder.cs index 35317a8de34..44b228874f5 100644 --- a/src/generated/Solutions/BookingCurrencies/Item/BookingCurrencyRequestBuilder.cs +++ b/src/generated/Solutions/BookingCurrencies/Item/BookingCurrencyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property bookingCurrencies for solutions"; // Create options for all the parameters - var bookingCurrencyIdOption = new Option("--bookingcurrency-id", description: "key: id of bookingCurrency") { + var bookingCurrencyIdOption = new Option("--booking-currency-id", description: "key: id of bookingCurrency") { }; bookingCurrencyIdOption.IsRequired = true; command.AddOption(bookingCurrencyIdOption); - command.SetHandler(async (string bookingCurrencyId) => { + command.SetHandler(async (string bookingCurrencyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bookingCurrencyIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get bookingCurrencies from solutions"; // Create options for all the parameters - var bookingCurrencyIdOption = new Option("--bookingcurrency-id", description: "key: id of bookingCurrency") { + var bookingCurrencyIdOption = new Option("--booking-currency-id", description: "key: id of bookingCurrency") { }; bookingCurrencyIdOption.IsRequired = true; command.AddOption(bookingCurrencyIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string bookingCurrencyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string bookingCurrencyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bookingCurrencyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bookingCurrencyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property bookingCurrencies in solutions"; // Create options for all the parameters - var bookingCurrencyIdOption = new Option("--bookingcurrency-id", description: "key: id of bookingCurrency") { + var bookingCurrencyIdOption = new Option("--booking-currency-id", description: "key: id of bookingCurrency") { }; bookingCurrencyIdOption.IsRequired = true; command.AddOption(bookingCurrencyIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string bookingCurrencyId, string body) => { + command.SetHandler(async (string bookingCurrencyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bookingCurrencyIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(BookingCurrency body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property bookingCurrencies for solutions - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get bookingCurrencies from solutions - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property bookingCurrencies in solutions - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(BookingCurrency model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get bookingCurrencies from solutions public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Solutions/SolutionsRequestBuilder.cs b/src/generated/Solutions/SolutionsRequestBuilder.cs index dbce027d4a2..add9bf50953 100644 --- a/src/generated/Solutions/SolutionsRequestBuilder.cs +++ b/src/generated/Solutions/SolutionsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Solutions.BookingCurrencies; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -24,6 +24,9 @@ public class SolutionsRequestBuilder { public Command BuildBookingBusinessesCommand() { var command = new Command("booking-businesses"); var builder = new ApiSdk.Solutions.BookingBusinesses.BookingBusinessesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -31,6 +34,9 @@ public Command BuildBookingBusinessesCommand() { public Command BuildBookingCurrenciesCommand() { var command = new Command("booking-currencies"); var builder = new ApiSdk.Solutions.BookingCurrencies.BookingCurrenciesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -52,20 +58,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -79,14 +84,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -131,7 +135,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft.Graph.Solutions body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(SolutionsRoot body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -143,31 +147,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get solutions - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update solutions - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Solutions model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get solutions public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/SubscribedSkus/Item/SubscribedSkuRequestBuilder.cs b/src/generated/SubscribedSkus/Item/SubscribedSkuRequestBuilder.cs index f5af3aed140..4041750552f 100644 --- a/src/generated/SubscribedSkus/Item/SubscribedSkuRequestBuilder.cs +++ b/src/generated/SubscribedSkus/Item/SubscribedSkuRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete entity from subscribedSkus"; // Create options for all the parameters - var subscribedSkuIdOption = new Option("--subscribedsku-id", description: "key: id of subscribedSku") { + var subscribedSkuIdOption = new Option("--subscribed-sku-id", description: "key: id of subscribedSku") { }; subscribedSkuIdOption.IsRequired = true; command.AddOption(subscribedSkuIdOption); - command.SetHandler(async (string subscribedSkuId) => { + command.SetHandler(async (string subscribedSkuId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, subscribedSkuIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get entity from subscribedSkus by key"; // Create options for all the parameters - var subscribedSkuIdOption = new Option("--subscribedsku-id", description: "key: id of subscribedSku") { + var subscribedSkuIdOption = new Option("--subscribed-sku-id", description: "key: id of subscribedSku") { }; subscribedSkuIdOption.IsRequired = true; command.AddOption(subscribedSkuIdOption); @@ -55,19 +54,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string subscribedSkuId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string subscribedSkuId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, subscribedSkuIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, subscribedSkuIdOption, selectOption, outputOption); return command; } /// @@ -77,7 +75,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update entity in subscribedSkus"; // Create options for all the parameters - var subscribedSkuIdOption = new Option("--subscribedsku-id", description: "key: id of subscribedSku") { + var subscribedSkuIdOption = new Option("--subscribed-sku-id", description: "key: id of subscribedSku") { }; subscribedSkuIdOption.IsRequired = true; command.AddOption(subscribedSkuIdOption); @@ -85,14 +83,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string subscribedSkuId, string body) => { + command.SetHandler(async (string subscribedSkuId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, subscribedSkuIdOption, bodyOption); return command; @@ -164,42 +161,6 @@ public RequestInformation CreatePatchRequestInformation(SubscribedSku body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from subscribedSkus - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from subscribedSkus by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in subscribedSkus - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SubscribedSku model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from subscribedSkus by key public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/SubscribedSkus/SubscribedSkusRequestBuilder.cs b/src/generated/SubscribedSkus/SubscribedSkusRequestBuilder.cs index c49a94a3dd5..20e54998164 100644 --- a/src/generated/SubscribedSkus/SubscribedSkusRequestBuilder.cs +++ b/src/generated/SubscribedSkus/SubscribedSkusRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.SubscribedSkus.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SubscribedSkusRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SubscribedSkuRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -78,21 +76,20 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string search, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string search, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { if (!String.IsNullOrEmpty(search)) q.Search = search; q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, searchOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, searchOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -147,31 +144,6 @@ public RequestInformation CreatePostRequestInformation(SubscribedSku body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get entities from subscribedSkus - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to subscribedSkus - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SubscribedSku model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from subscribedSkus public class GetQueryParameters : QueryParametersBase { /// Order items by property values diff --git a/src/generated/Subscriptions/Item/SubscriptionRequestBuilder.cs b/src/generated/Subscriptions/Item/SubscriptionRequestBuilder.cs index 105f37bf8f4..f85639cd72e 100644 --- a/src/generated/Subscriptions/Item/SubscriptionRequestBuilder.cs +++ b/src/generated/Subscriptions/Item/SubscriptionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,10 @@ public Command BuildDeleteCommand() { }; subscriptionIdOption.IsRequired = true; command.AddOption(subscriptionIdOption); - command.SetHandler(async (string subscriptionId) => { + command.SetHandler(async (string subscriptionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, subscriptionIdOption); return command; @@ -55,19 +54,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string subscriptionId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string subscriptionId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, subscriptionIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, subscriptionIdOption, selectOption, outputOption); return command; } /// @@ -85,14 +83,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string subscriptionId, string body) => { + command.SetHandler(async (string subscriptionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, subscriptionIdOption, bodyOption); return command; @@ -164,42 +161,6 @@ public RequestInformation CreatePatchRequestInformation(Subscription body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from subscriptions - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from subscriptions by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in subscriptions - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Subscription model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from subscriptions by key public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Subscriptions/SubscriptionsRequestBuilder.cs b/src/generated/Subscriptions/SubscriptionsRequestBuilder.cs index f469dce440f..f7a9f5274db 100644 --- a/src/generated/Subscriptions/SubscriptionsRequestBuilder.cs +++ b/src/generated/Subscriptions/SubscriptionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Subscriptions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SubscriptionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SubscriptionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -73,20 +71,19 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string search, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string search, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { if (!String.IsNullOrEmpty(search)) q.Search = search; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, searchOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, searchOption, selectOption, outputOption); return command; } /// @@ -141,31 +138,6 @@ public RequestInformation CreatePostRequestInformation(Subscription body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get entities from subscriptions - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to subscriptions - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Subscription model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from subscriptions public class GetQueryParameters : QueryParametersBase { /// Search items by search phrases diff --git a/src/generated/Teams/GetAllMessages/GetAllMessagesRequestBuilder.cs b/src/generated/Teams/GetAllMessages/GetAllMessagesRequestBuilder.cs index bd6f4ed0d7f..507a6728093 100644 --- a/src/generated/Teams/GetAllMessages/GetAllMessagesRequestBuilder.cs +++ b/src/generated/Teams/GetAllMessages/GetAllMessagesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function getAllMessages"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getAllMessages - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Teams/Item/Archive/ArchiveRequestBuilder.cs b/src/generated/Teams/Item/Archive/ArchiveRequestBuilder.cs index 7acf879c772..e325e72d842 100644 --- a/src/generated/Teams/Item/Archive/ArchiveRequestBuilder.cs +++ b/src/generated/Teams/Item/Archive/ArchiveRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { + command.SetHandler(async (string teamId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ArchiveRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action archive - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ArchiveRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Teams/Item/Channels/ChannelsRequestBuilder.cs b/src/generated/Teams/Item/Channels/ChannelsRequestBuilder.cs index ac4377b9c3f..e25408c9432 100644 --- a/src/generated/Teams/Item/Channels/ChannelsRequestBuilder.cs +++ b/src/generated/Teams/Item/Channels/ChannelsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Teams.Item.Channels.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class ChannelsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ChannelRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCompleteMigrationCommand(), - builder.BuildDeleteCommand(), - builder.BuildFilesFolderCommand(), - builder.BuildGetCommand(), - builder.BuildMembersCommand(), - builder.BuildMessagesCommand(), - builder.BuildPatchCommand(), - builder.BuildProvisionEmailCommand(), - builder.BuildRemoveEmailCommand(), - builder.BuildTabsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCompleteMigrationCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFilesFolderCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildMembersCommand()); + commands.Add(builder.BuildMessagesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildProvisionEmailCommand()); + commands.Add(builder.BuildRemoveEmailCommand()); + commands.Add(builder.BuildTabsCommand()); return commands; } /// @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -195,31 +192,6 @@ public RequestInformation CreatePostRequestInformation(Channel body, Action - /// The collection of channels & messages associated with the team. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of channels & messages associated with the team. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Channel model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of channels & messages associated with the team. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Teams/Item/Channels/GetAllMessages/GetAllMessagesRequestBuilder.cs b/src/generated/Teams/Item/Channels/GetAllMessages/GetAllMessagesRequestBuilder.cs index 8f472a2d7a8..04adf170e2c 100644 --- a/src/generated/Teams/Item/Channels/GetAllMessages/GetAllMessagesRequestBuilder.cs +++ b/src/generated/Teams/Item/Channels/GetAllMessages/GetAllMessagesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +29,17 @@ public Command BuildGetCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - command.SetHandler(async (string teamId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getAllMessages - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Teams/Item/Channels/Item/ChannelRequestBuilder.cs b/src/generated/Teams/Item/Channels/Item/ChannelRequestBuilder.cs index e91ea4d2915..3e849ed439c 100644 --- a/src/generated/Teams/Item/Channels/Item/ChannelRequestBuilder.cs +++ b/src/generated/Teams/Item/Channels/Item/ChannelRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Teams.Item.Channels.Item.Tabs; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,11 +47,10 @@ public Command BuildDeleteCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - command.SetHandler(async (string teamId, string channelId) => { + command.SetHandler(async (string teamId, string channelId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, channelIdOption); return command; @@ -90,26 +89,28 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string channelId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string channelId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, channelIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, channelIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildMembersCommand() { var command = new Command("members"); var builder = new ApiSdk.Teams.Item.Channels.Item.Members.MembersRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -117,6 +118,9 @@ public Command BuildMembersCommand() { public Command BuildMessagesCommand() { var command = new Command("messages"); var builder = new ApiSdk.Teams.Item.Channels.Item.Messages.MessagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -140,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string channelId, string body) => { + command.SetHandler(async (string teamId, string channelId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, channelIdOption, bodyOption); return command; @@ -167,6 +170,9 @@ public Command BuildRemoveEmailCommand() { public Command BuildTabsCommand() { var command = new Command("tabs"); var builder = new ApiSdk.Teams.Item.Channels.Item.Tabs.TabsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -238,42 +244,6 @@ public RequestInformation CreatePatchRequestInformation(Channel body, Action - /// The collection of channels & messages associated with the team. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of channels & messages associated with the team. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of channels & messages associated with the team. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Channel model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of channels & messages associated with the team. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/Channels/Item/CompleteMigration/CompleteMigrationRequestBuilder.cs b/src/generated/Teams/Item/Channels/Item/CompleteMigration/CompleteMigrationRequestBuilder.cs index 54116451a57..14571f3e3cf 100644 --- a/src/generated/Teams/Item/Channels/Item/CompleteMigration/CompleteMigrationRequestBuilder.cs +++ b/src/generated/Teams/Item/Channels/Item/CompleteMigration/CompleteMigrationRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,11 +33,10 @@ public Command BuildPostCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - command.SetHandler(async (string teamId, string channelId) => { + command.SetHandler(async (string teamId, string channelId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, channelIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action completeMigration - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Teams/Item/Channels/Item/FilesFolder/Content/ContentRequestBuilder.cs b/src/generated/Teams/Item/Channels/Item/FilesFolder/Content/ContentRequestBuilder.cs index 146b1ea0439..17f4dcb11f9 100644 --- a/src/generated/Teams/Item/Channels/Item/FilesFolder/Content/ContentRequestBuilder.cs +++ b/src/generated/Teams/Item/Channels/Item/FilesFolder/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,24 +33,26 @@ public Command BuildGetCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string teamId, string channelId, FileInfo output) => { + command.SetHandler(async (string teamId, string channelId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, teamIdOption, channelIdOption, outputOption); + }, teamIdOption, channelIdOption, fileOption, outputOption); return command; } /// @@ -72,12 +74,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string channelId, FileInfo file) => { + command.SetHandler(async (string teamId, string channelId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, channelIdOption, bodyOption); return command; @@ -128,29 +129,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property filesFolder from teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property filesFolder in teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Teams/Item/Channels/Item/FilesFolder/FilesFolderRequestBuilder.cs b/src/generated/Teams/Item/Channels/Item/FilesFolder/FilesFolderRequestBuilder.cs index d258e8f07bc..54af5cf8813 100644 --- a/src/generated/Teams/Item/Channels/Item/FilesFolder/FilesFolderRequestBuilder.cs +++ b/src/generated/Teams/Item/Channels/Item/FilesFolder/FilesFolderRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Teams.Item.Channels.Item.FilesFolder.Content; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -42,11 +42,10 @@ public Command BuildDeleteCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - command.SetHandler(async (string teamId, string channelId) => { + command.SetHandler(async (string teamId, string channelId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, channelIdOption); return command; @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string channelId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string channelId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, channelIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, channelIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,14 +109,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string channelId, string body) => { + command.SetHandler(async (string teamId, string channelId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, channelIdOption, bodyOption); return command; @@ -190,42 +187,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Metadata for the location where the channel's files are stored. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Metadata for the location where the channel's files are stored. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Metadata for the location where the channel's files are stored. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Metadata for the location where the channel's files are stored. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/Channels/Item/Members/@Add/@Add.cs b/src/generated/Teams/Item/Channels/Item/Members/@Add/@Add.cs deleted file mode 100644 index db6109cd580..00000000000 --- a/src/generated/Teams/Item/Channels/Item/Members/@Add/@Add.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Teams.Item.Channels.Item.Members.@Add { - public class @Add : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Add and sets the default values. - /// - public @Add() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Teams/Item/Channels/Item/Members/@Add/AddRequestBody.cs b/src/generated/Teams/Item/Channels/Item/Members/@Add/AddRequestBody.cs deleted file mode 100644 index 6274b4dbc75..00000000000 --- a/src/generated/Teams/Item/Channels/Item/Members/@Add/AddRequestBody.cs +++ /dev/null @@ -1,36 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Teams.Item.Channels.Item.Members.@Add { - public class AddRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public List Values { get; set; } - /// - /// Instantiates a new addRequestBody and sets the default values. - /// - public AddRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"values", (o,n) => { (o as AddRequestBody).Values = n.GetCollectionOfObjectValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteCollectionOfObjectValues("values", Values); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Teams/Item/Channels/Item/Members/@Add/AddRequestBuilder.cs b/src/generated/Teams/Item/Channels/Item/Members/@Add/AddRequestBuilder.cs deleted file mode 100644 index ebbf09720a3..00000000000 --- a/src/generated/Teams/Item/Channels/Item/Members/@Add/AddRequestBuilder.cs +++ /dev/null @@ -1,102 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Teams.Item.Channels.Item.Members.@Add { - /// Builds and executes requests for operations under \teams\{team-id}\channels\{channel-id}\members\microsoft.graph.add - public class AddRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action add - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action add"; - // Create options for all the parameters - var teamIdOption = new Option("--team-id", description: "key: id of team") { - }; - teamIdOption.IsRequired = true; - command.AddOption(teamIdOption); - var channelIdOption = new Option("--channel-id", description: "key: id of channel") { - }; - channelIdOption.IsRequired = true; - command.AddOption(channelIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string channelId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, channelIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AddRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/teams/{team_id}/channels/{channel_id}/members/microsoft.graph.add"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action add - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action add - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(AddRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Teams/Item/Channels/Item/Members/Add/Add.cs b/src/generated/Teams/Item/Channels/Item/Members/Add/Add.cs new file mode 100644 index 00000000000..df64f92bb4d --- /dev/null +++ b/src/generated/Teams/Item/Channels/Item/Members/Add/Add.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Teams.Item.Channels.Item.Members.Add { + public class Add : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new add and sets the default values. + /// + public Add() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Teams/Item/Channels/Item/Members/Add/AddRequestBody.cs b/src/generated/Teams/Item/Channels/Item/Members/Add/AddRequestBody.cs new file mode 100644 index 00000000000..a56b37d34f4 --- /dev/null +++ b/src/generated/Teams/Item/Channels/Item/Members/Add/AddRequestBody.cs @@ -0,0 +1,36 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Teams.Item.Channels.Item.Members.Add { + public class AddRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public List Values { get; set; } + /// + /// Instantiates a new addRequestBody and sets the default values. + /// + public AddRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"values", (o,n) => { (o as AddRequestBody).Values = n.GetCollectionOfObjectValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("values", Values); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Teams/Item/Channels/Item/Members/Add/AddRequestBuilder.cs b/src/generated/Teams/Item/Channels/Item/Members/Add/AddRequestBuilder.cs new file mode 100644 index 00000000000..3eb1a89438c --- /dev/null +++ b/src/generated/Teams/Item/Channels/Item/Members/Add/AddRequestBuilder.cs @@ -0,0 +1,88 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Teams.Item.Channels.Item.Members.Add { + /// Builds and executes requests for operations under \teams\{team-id}\channels\{channel-id}\members\microsoft.graph.add + public class AddRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action add + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action add"; + // Create options for all the parameters + var teamIdOption = new Option("--team-id", description: "key: id of team") { + }; + teamIdOption.IsRequired = true; + command.AddOption(teamIdOption); + var channelIdOption = new Option("--channel-id", description: "key: id of channel") { + }; + channelIdOption.IsRequired = true; + command.AddOption(channelIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string channelId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, channelIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new AddRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/teams/{team_id}/channels/{channel_id}/members/microsoft.graph.add"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action add + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Teams/Item/Channels/Item/Members/Item/ConversationMemberRequestBuilder.cs b/src/generated/Teams/Item/Channels/Item/Members/Item/ConversationMemberRequestBuilder.cs index e50396ed2ea..6596cab0dc9 100644 --- a/src/generated/Teams/Item/Channels/Item/Members/Item/ConversationMemberRequestBuilder.cs +++ b/src/generated/Teams/Item/Channels/Item/Members/Item/ConversationMemberRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - var conversationMemberIdOption = new Option("--conversationmember-id", description: "key: id of conversationMember") { + var conversationMemberIdOption = new Option("--conversation-member-id", description: "key: id of conversationMember") { }; conversationMemberIdOption.IsRequired = true; command.AddOption(conversationMemberIdOption); - command.SetHandler(async (string teamId, string channelId, string conversationMemberId) => { + command.SetHandler(async (string teamId, string channelId, string conversationMemberId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, channelIdOption, conversationMemberIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - var conversationMemberIdOption = new Option("--conversationmember-id", description: "key: id of conversationMember") { + var conversationMemberIdOption = new Option("--conversation-member-id", description: "key: id of conversationMember") { }; conversationMemberIdOption.IsRequired = true; command.AddOption(conversationMemberIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string channelId, string conversationMemberId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string channelId, string conversationMemberId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, channelIdOption, conversationMemberIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, channelIdOption, conversationMemberIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - var conversationMemberIdOption = new Option("--conversationmember-id", description: "key: id of conversationMember") { + var conversationMemberIdOption = new Option("--conversation-member-id", description: "key: id of conversationMember") { }; conversationMemberIdOption.IsRequired = true; command.AddOption(conversationMemberIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string channelId, string conversationMemberId, string body) => { + command.SetHandler(async (string teamId, string channelId, string conversationMemberId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, channelIdOption, conversationMemberIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(ConversationMember body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of membership records associated with the channel. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of membership records associated with the channel. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of membership records associated with the channel. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ConversationMember model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of membership records associated with the channel. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/Channels/Item/Members/MembersRequestBuilder.cs b/src/generated/Teams/Item/Channels/Item/Members/MembersRequestBuilder.cs index 943e55bf1ad..8428c3fc976 100644 --- a/src/generated/Teams/Item/Channels/Item/Members/MembersRequestBuilder.cs +++ b/src/generated/Teams/Item/Channels/Item/Members/MembersRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Teams.Item.Channels.Item.Members.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,17 +23,16 @@ public class MembersRequestBuilder { private string UrlTemplate { get; set; } public Command BuildAddCommand() { var command = new Command("add"); - var builder = new ApiSdk.Teams.Item.Channels.Item.Members.@Add.AddRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Teams.Item.Channels.Item.Members.Add.AddRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } public List BuildCommand() { var builder = new ConversationMemberRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -55,21 +54,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string channelId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string channelId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, channelIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, channelIdOption, bodyOption, outputOption); return command; } /// @@ -122,7 +120,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string channelId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string channelId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -133,15 +135,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, channelIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, channelIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -196,31 +193,6 @@ public RequestInformation CreatePostRequestInformation(ConversationMember body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of membership records associated with the channel. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of membership records associated with the channel. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ConversationMember model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of membership records associated with the channel. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Teams/Item/Channels/Item/Messages/Delta/DeltaRequestBuilder.cs b/src/generated/Teams/Item/Channels/Item/Messages/Delta/DeltaRequestBuilder.cs index e2e7192a4d5..4b560275c88 100644 --- a/src/generated/Teams/Item/Channels/Item/Messages/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Teams/Item/Channels/Item/Messages/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +33,17 @@ public Command BuildGetCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - command.SetHandler(async (string teamId, string channelId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string channelId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, channelIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, channelIdOption, outputOption); return command; } /// @@ -75,16 +74,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Teams/Item/Channels/Item/Messages/Item/ChatMessageRequestBuilder.cs b/src/generated/Teams/Item/Channels/Item/Messages/Item/ChatMessageRequestBuilder.cs index 49eeed0e64b..eb56e0cee90 100644 --- a/src/generated/Teams/Item/Channels/Item/Messages/Item/ChatMessageRequestBuilder.cs +++ b/src/generated/Teams/Item/Channels/Item/Messages/Item/ChatMessageRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Teams.Item.Channels.Item.Messages.Item.Replies; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -36,15 +36,14 @@ public Command BuildDeleteCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); - command.SetHandler(async (string teamId, string channelId, string chatMessageId) => { + command.SetHandler(async (string teamId, string channelId, string chatMessageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, channelIdOption, chatMessageIdOption); return command; @@ -64,7 +63,7 @@ public Command BuildGetCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); @@ -78,25 +77,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string channelId, string chatMessageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string channelId, string chatMessageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, channelIdOption, chatMessageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, channelIdOption, chatMessageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildHostedContentsCommand() { var command = new Command("hosted-contents"); var builder = new ApiSdk.Teams.Item.Channels.Item.Messages.Item.HostedContents.HostedContentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -116,7 +117,7 @@ public Command BuildPatchCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); @@ -124,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string channelId, string chatMessageId, string body) => { + command.SetHandler(async (string teamId, string channelId, string chatMessageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, channelIdOption, chatMessageIdOption, bodyOption); return command; @@ -139,6 +139,9 @@ public Command BuildPatchCommand() { public Command BuildRepliesCommand() { var command = new Command("replies"); var builder = new ApiSdk.Teams.Item.Channels.Item.Messages.Item.Replies.RepliesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -210,42 +213,6 @@ public RequestInformation CreatePatchRequestInformation(ChatMessage body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of all the messages in the channel. A navigation property. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of all the messages in the channel. A navigation property. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of all the messages in the channel. A navigation property. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ChatMessage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of all the messages in the channel. A navigation property. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/Channels/Item/Messages/Item/HostedContents/HostedContentsRequestBuilder.cs b/src/generated/Teams/Item/Channels/Item/Messages/Item/HostedContents/HostedContentsRequestBuilder.cs index e2a3bc9a899..fe2e306f8f4 100644 --- a/src/generated/Teams/Item/Channels/Item/Messages/Item/HostedContents/HostedContentsRequestBuilder.cs +++ b/src/generated/Teams/Item/Channels/Item/Messages/Item/HostedContents/HostedContentsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Teams.Item.Channels.Item.Messages.Item.HostedContents.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class HostedContentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ChatMessageHostedContentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,7 +43,7 @@ public Command BuildCreateCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string channelId, string chatMessageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string channelId, string chatMessageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, channelIdOption, chatMessageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, channelIdOption, chatMessageIdOption, bodyOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildListCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string channelId, string chatMessageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string channelId, string chatMessageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, channelIdOption, chatMessageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, channelIdOption, chatMessageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(ChatMessageHostedContent requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Content in a message hosted by Microsoft Teams - for example, images or code snippets. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Content in a message hosted by Microsoft Teams - for example, images or code snippets. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ChatMessageHostedContent model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Content in a message hosted by Microsoft Teams - for example, images or code snippets. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Teams/Item/Channels/Item/Messages/Item/HostedContents/Item/ChatMessageHostedContentRequestBuilder.cs b/src/generated/Teams/Item/Channels/Item/Messages/Item/HostedContents/Item/ChatMessageHostedContentRequestBuilder.cs index 414dd291b06..ff70da15675 100644 --- a/src/generated/Teams/Item/Channels/Item/Messages/Item/HostedContents/Item/ChatMessageHostedContentRequestBuilder.cs +++ b/src/generated/Teams/Item/Channels/Item/Messages/Item/HostedContents/Item/ChatMessageHostedContentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); - var chatMessageHostedContentIdOption = new Option("--chatmessagehostedcontent-id", description: "key: id of chatMessageHostedContent") { + var chatMessageHostedContentIdOption = new Option("--chat-message-hosted-content-id", description: "key: id of chatMessageHostedContent") { }; chatMessageHostedContentIdOption.IsRequired = true; command.AddOption(chatMessageHostedContentIdOption); - command.SetHandler(async (string teamId, string channelId, string chatMessageId, string chatMessageHostedContentId) => { + command.SetHandler(async (string teamId, string channelId, string chatMessageId, string chatMessageHostedContentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, channelIdOption, chatMessageIdOption, chatMessageHostedContentIdOption); return command; @@ -66,11 +65,11 @@ public Command BuildGetCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); - var chatMessageHostedContentIdOption = new Option("--chatmessagehostedcontent-id", description: "key: id of chatMessageHostedContent") { + var chatMessageHostedContentIdOption = new Option("--chat-message-hosted-content-id", description: "key: id of chatMessageHostedContent") { }; chatMessageHostedContentIdOption.IsRequired = true; command.AddOption(chatMessageHostedContentIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string channelId, string chatMessageId, string chatMessageHostedContentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string channelId, string chatMessageId, string chatMessageHostedContentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, channelIdOption, chatMessageIdOption, chatMessageHostedContentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, channelIdOption, chatMessageIdOption, chatMessageHostedContentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,11 +113,11 @@ public Command BuildPatchCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); - var chatMessageHostedContentIdOption = new Option("--chatmessagehostedcontent-id", description: "key: id of chatMessageHostedContent") { + var chatMessageHostedContentIdOption = new Option("--chat-message-hosted-content-id", description: "key: id of chatMessageHostedContent") { }; chatMessageHostedContentIdOption.IsRequired = true; command.AddOption(chatMessageHostedContentIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string channelId, string chatMessageId, string chatMessageHostedContentId, string body) => { + command.SetHandler(async (string teamId, string channelId, string chatMessageId, string chatMessageHostedContentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, channelIdOption, chatMessageIdOption, chatMessageHostedContentIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(ChatMessageHostedContent requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Content in a message hosted by Microsoft Teams - for example, images or code snippets. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Content in a message hosted by Microsoft Teams - for example, images or code snippets. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Content in a message hosted by Microsoft Teams - for example, images or code snippets. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ChatMessageHostedContent model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Content in a message hosted by Microsoft Teams - for example, images or code snippets. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/Channels/Item/Messages/Item/Replies/Delta/DeltaRequestBuilder.cs b/src/generated/Teams/Item/Channels/Item/Messages/Item/Replies/Delta/DeltaRequestBuilder.cs index ddc56a222ce..561fa604e42 100644 --- a/src/generated/Teams/Item/Channels/Item/Messages/Item/Replies/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Teams/Item/Channels/Item/Messages/Item/Replies/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,22 +33,21 @@ public Command BuildGetCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); - command.SetHandler(async (string teamId, string channelId, string chatMessageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string channelId, string chatMessageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, channelIdOption, chatMessageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, channelIdOption, chatMessageIdOption, outputOption); return command; } /// @@ -79,16 +78,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Teams/Item/Channels/Item/Messages/Item/Replies/Item/ChatMessageRequestBuilder.cs b/src/generated/Teams/Item/Channels/Item/Messages/Item/Replies/Item/ChatMessageRequestBuilder.cs index c2edce8994e..08108e29343 100644 --- a/src/generated/Teams/Item/Channels/Item/Messages/Item/Replies/Item/ChatMessageRequestBuilder.cs +++ b/src/generated/Teams/Item/Channels/Item/Messages/Item/Replies/Item/ChatMessageRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); - var chatMessageId1Option = new Option("--chatmessage-id1", description: "key: id of chatMessage") { + var chatMessageId1Option = new Option("--chat-message-id1", description: "key: id of chatMessage") { }; chatMessageId1Option.IsRequired = true; command.AddOption(chatMessageId1Option); - command.SetHandler(async (string teamId, string channelId, string chatMessageId, string chatMessageId1) => { + command.SetHandler(async (string teamId, string channelId, string chatMessageId, string chatMessageId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, channelIdOption, chatMessageIdOption, chatMessageId1Option); return command; @@ -66,11 +65,11 @@ public Command BuildGetCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); - var chatMessageId1Option = new Option("--chatmessage-id1", description: "key: id of chatMessage") { + var chatMessageId1Option = new Option("--chat-message-id1", description: "key: id of chatMessage") { }; chatMessageId1Option.IsRequired = true; command.AddOption(chatMessageId1Option); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string channelId, string chatMessageId, string chatMessageId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string channelId, string chatMessageId, string chatMessageId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, channelIdOption, chatMessageIdOption, chatMessageId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, channelIdOption, chatMessageIdOption, chatMessageId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -115,11 +113,11 @@ public Command BuildPatchCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); - var chatMessageId1Option = new Option("--chatmessage-id1", description: "key: id of chatMessage") { + var chatMessageId1Option = new Option("--chat-message-id1", description: "key: id of chatMessage") { }; chatMessageId1Option.IsRequired = true; command.AddOption(chatMessageId1Option); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string channelId, string chatMessageId, string chatMessageId1, string body) => { + command.SetHandler(async (string teamId, string channelId, string chatMessageId, string chatMessageId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, channelIdOption, chatMessageIdOption, chatMessageId1Option, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(ChatMessage body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Replies for a specified message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Replies for a specified message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Replies for a specified message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ChatMessage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Replies for a specified message. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/Channels/Item/Messages/Item/Replies/RepliesRequestBuilder.cs b/src/generated/Teams/Item/Channels/Item/Messages/Item/Replies/RepliesRequestBuilder.cs index 1c07f2a9f75..1af152064b2 100644 --- a/src/generated/Teams/Item/Channels/Item/Messages/Item/Replies/RepliesRequestBuilder.cs +++ b/src/generated/Teams/Item/Channels/Item/Messages/Item/Replies/RepliesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Teams.Item.Channels.Item.Messages.Item.Replies.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class RepliesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ChatMessageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,7 +44,7 @@ public Command BuildCreateCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string channelId, string chatMessageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string channelId, string chatMessageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, channelIdOption, chatMessageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, channelIdOption, chatMessageIdOption, bodyOption, outputOption); return command; } /// @@ -85,7 +83,7 @@ public Command BuildListCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); @@ -124,7 +122,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string channelId, string chatMessageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string channelId, string chatMessageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -135,15 +137,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, channelIdOption, chatMessageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, channelIdOption, chatMessageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -204,31 +201,6 @@ public RequestInformation CreatePostRequestInformation(ChatMessage body, Action< public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// Replies for a specified message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Replies for a specified message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ChatMessage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Replies for a specified message. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Teams/Item/Channels/Item/Messages/MessagesRequestBuilder.cs b/src/generated/Teams/Item/Channels/Item/Messages/MessagesRequestBuilder.cs index f7c49204179..6f25029dd3a 100644 --- a/src/generated/Teams/Item/Channels/Item/Messages/MessagesRequestBuilder.cs +++ b/src/generated/Teams/Item/Channels/Item/Messages/MessagesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Teams.Item.Channels.Item.Messages.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,13 +23,12 @@ public class MessagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ChatMessageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildHostedContentsCommand(), - builder.BuildPatchCommand(), - builder.BuildRepliesCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildHostedContentsCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRepliesCommand()); return commands; } /// @@ -51,21 +50,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string channelId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string channelId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, channelIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, channelIdOption, bodyOption, outputOption); return command; } /// @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string channelId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string channelId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -129,15 +131,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, channelIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, channelIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -198,31 +195,6 @@ public RequestInformation CreatePostRequestInformation(ChatMessage body, Action< public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// A collection of all the messages in the channel. A navigation property. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of all the messages in the channel. A navigation property. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ChatMessage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of all the messages in the channel. A navigation property. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Teams/Item/Channels/Item/ProvisionEmail/ProvisionEmailRequestBuilder.cs b/src/generated/Teams/Item/Channels/Item/ProvisionEmail/ProvisionEmailRequestBuilder.cs index ce7fb5dbf6d..fc090a8e5b7 100644 --- a/src/generated/Teams/Item/Channels/Item/ProvisionEmail/ProvisionEmailRequestBuilder.cs +++ b/src/generated/Teams/Item/Channels/Item/ProvisionEmail/ProvisionEmailRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,18 +34,17 @@ public Command BuildPostCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - command.SetHandler(async (string teamId, string channelId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string channelId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, channelIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, channelIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action provisionEmail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes provisionChannelEmailResult public class ProvisionEmailResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Teams/Item/Channels/Item/RemoveEmail/RemoveEmailRequestBuilder.cs b/src/generated/Teams/Item/Channels/Item/RemoveEmail/RemoveEmailRequestBuilder.cs index 32db1afa378..fdf5e56ee3c 100644 --- a/src/generated/Teams/Item/Channels/Item/RemoveEmail/RemoveEmailRequestBuilder.cs +++ b/src/generated/Teams/Item/Channels/Item/RemoveEmail/RemoveEmailRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,11 +33,10 @@ public Command BuildPostCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - command.SetHandler(async (string teamId, string channelId) => { + command.SetHandler(async (string teamId, string channelId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, channelIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action removeEmail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Teams/Item/Channels/Item/Tabs/Item/TeamsApp/@Ref/@Ref.cs b/src/generated/Teams/Item/Channels/Item/Tabs/Item/TeamsApp/@Ref/@Ref.cs deleted file mode 100644 index 1df8b2c5893..00000000000 --- a/src/generated/Teams/Item/Channels/Item/Tabs/Item/TeamsApp/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Teams.Item.Channels.Item.Tabs.Item.TeamsApp.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Teams/Item/Channels/Item/Tabs/Item/TeamsApp/@Ref/RefRequestBuilder.cs b/src/generated/Teams/Item/Channels/Item/Tabs/Item/TeamsApp/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 36d43cf7424..00000000000 --- a/src/generated/Teams/Item/Channels/Item/Tabs/Item/TeamsApp/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,214 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Teams.Item.Channels.Item.Tabs.Item.TeamsApp.@Ref { - /// Builds and executes requests for operations under \teams\{team-id}\channels\{channel-id}\tabs\{teamsTab-id}\teamsApp\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The application that is linked to the tab. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The application that is linked to the tab."; - // Create options for all the parameters - var teamIdOption = new Option("--team-id", description: "key: id of team") { - }; - teamIdOption.IsRequired = true; - command.AddOption(teamIdOption); - var channelIdOption = new Option("--channel-id", description: "key: id of channel") { - }; - channelIdOption.IsRequired = true; - command.AddOption(channelIdOption); - var teamsTabIdOption = new Option("--teamstab-id", description: "key: id of teamsTab") { - }; - teamsTabIdOption.IsRequired = true; - command.AddOption(teamsTabIdOption); - command.SetHandler(async (string teamId, string channelId, string teamsTabId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, teamIdOption, channelIdOption, teamsTabIdOption); - return command; - } - /// - /// The application that is linked to the tab. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The application that is linked to the tab."; - // Create options for all the parameters - var teamIdOption = new Option("--team-id", description: "key: id of team") { - }; - teamIdOption.IsRequired = true; - command.AddOption(teamIdOption); - var channelIdOption = new Option("--channel-id", description: "key: id of channel") { - }; - channelIdOption.IsRequired = true; - command.AddOption(channelIdOption); - var teamsTabIdOption = new Option("--teamstab-id", description: "key: id of teamsTab") { - }; - teamsTabIdOption.IsRequired = true; - command.AddOption(teamsTabIdOption); - command.SetHandler(async (string teamId, string channelId, string teamsTabId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, channelIdOption, teamsTabIdOption); - return command; - } - /// - /// The application that is linked to the tab. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The application that is linked to the tab."; - // Create options for all the parameters - var teamIdOption = new Option("--team-id", description: "key: id of team") { - }; - teamIdOption.IsRequired = true; - command.AddOption(teamIdOption); - var channelIdOption = new Option("--channel-id", description: "key: id of channel") { - }; - channelIdOption.IsRequired = true; - command.AddOption(channelIdOption); - var teamsTabIdOption = new Option("--teamstab-id", description: "key: id of teamsTab") { - }; - teamsTabIdOption.IsRequired = true; - command.AddOption(teamsTabIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string channelId, string teamsTabId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, teamIdOption, channelIdOption, teamsTabIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/teams/{team_id}/channels/{channel_id}/tabs/{teamsTab_id}/teamsApp/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The application that is linked to the tab. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The application that is linked to the tab. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The application that is linked to the tab. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Teams.Item.Channels.Item.Tabs.Item.TeamsApp.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The application that is linked to the tab. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The application that is linked to the tab. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The application that is linked to the tab. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Teams.Item.Channels.Item.Tabs.Item.TeamsApp.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Teams/Item/Channels/Item/Tabs/Item/TeamsApp/Ref/Ref.cs b/src/generated/Teams/Item/Channels/Item/Tabs/Item/TeamsApp/Ref/Ref.cs new file mode 100644 index 00000000000..c026f0ebf98 --- /dev/null +++ b/src/generated/Teams/Item/Channels/Item/Tabs/Item/TeamsApp/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Teams.Item.Channels.Item.Tabs.Item.TeamsApp.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Teams/Item/Channels/Item/Tabs/Item/TeamsApp/Ref/RefRequestBuilder.cs b/src/generated/Teams/Item/Channels/Item/Tabs/Item/TeamsApp/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..dc92291f821 --- /dev/null +++ b/src/generated/Teams/Item/Channels/Item/Tabs/Item/TeamsApp/Ref/RefRequestBuilder.cs @@ -0,0 +1,176 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Teams.Item.Channels.Item.Tabs.Item.TeamsApp.Ref { + /// Builds and executes requests for operations under \teams\{team-id}\channels\{channel-id}\tabs\{teamsTab-id}\teamsApp\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The application that is linked to the tab. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The application that is linked to the tab."; + // Create options for all the parameters + var teamIdOption = new Option("--team-id", description: "key: id of team") { + }; + teamIdOption.IsRequired = true; + command.AddOption(teamIdOption); + var channelIdOption = new Option("--channel-id", description: "key: id of channel") { + }; + channelIdOption.IsRequired = true; + command.AddOption(channelIdOption); + var teamsTabIdOption = new Option("--teams-tab-id", description: "key: id of teamsTab") { + }; + teamsTabIdOption.IsRequired = true; + command.AddOption(teamsTabIdOption); + command.SetHandler(async (string teamId, string channelId, string teamsTabId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, teamIdOption, channelIdOption, teamsTabIdOption); + return command; + } + /// + /// The application that is linked to the tab. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The application that is linked to the tab."; + // Create options for all the parameters + var teamIdOption = new Option("--team-id", description: "key: id of team") { + }; + teamIdOption.IsRequired = true; + command.AddOption(teamIdOption); + var channelIdOption = new Option("--channel-id", description: "key: id of channel") { + }; + channelIdOption.IsRequired = true; + command.AddOption(channelIdOption); + var teamsTabIdOption = new Option("--teams-tab-id", description: "key: id of teamsTab") { + }; + teamsTabIdOption.IsRequired = true; + command.AddOption(teamsTabIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string channelId, string teamsTabId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, channelIdOption, teamsTabIdOption, outputOption); + return command; + } + /// + /// The application that is linked to the tab. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The application that is linked to the tab."; + // Create options for all the parameters + var teamIdOption = new Option("--team-id", description: "key: id of team") { + }; + teamIdOption.IsRequired = true; + command.AddOption(teamIdOption); + var channelIdOption = new Option("--channel-id", description: "key: id of channel") { + }; + channelIdOption.IsRequired = true; + command.AddOption(channelIdOption); + var teamsTabIdOption = new Option("--teams-tab-id", description: "key: id of teamsTab") { + }; + teamsTabIdOption.IsRequired = true; + command.AddOption(teamsTabIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string teamId, string channelId, string teamsTabId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, teamIdOption, channelIdOption, teamsTabIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/teams/{team_id}/channels/{channel_id}/tabs/{teamsTab_id}/teamsApp/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The application that is linked to the tab. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The application that is linked to the tab. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The application that is linked to the tab. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Teams.Item.Channels.Item.Tabs.Item.TeamsApp.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Teams/Item/Channels/Item/Tabs/Item/TeamsApp/TeamsAppRequestBuilder.cs b/src/generated/Teams/Item/Channels/Item/Tabs/Item/TeamsApp/TeamsAppRequestBuilder.cs index c6b1c8a0ec9..5258189c6f8 100644 --- a/src/generated/Teams/Item/Channels/Item/Tabs/Item/TeamsApp/TeamsAppRequestBuilder.cs +++ b/src/generated/Teams/Item/Channels/Item/Tabs/Item/TeamsApp/TeamsAppRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Teams.Item.Channels.Item.Tabs.Item.TeamsApp.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,7 +35,7 @@ public Command BuildGetCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - var teamsTabIdOption = new Option("--teamstab-id", description: "key: id of teamsTab") { + var teamsTabIdOption = new Option("--teams-tab-id", description: "key: id of teamsTab") { }; teamsTabIdOption.IsRequired = true; command.AddOption(teamsTabIdOption); @@ -49,25 +49,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string channelId, string teamsTabId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string channelId, string teamsTabId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, channelIdOption, teamsTabIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, channelIdOption, teamsTabIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Teams.Item.Channels.Item.Tabs.Item.TeamsApp.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Teams.Item.Channels.Item.Tabs.Item.TeamsApp.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -107,18 +106,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The application that is linked to the tab. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The application that is linked to the tab. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/Channels/Item/Tabs/Item/TeamsTabRequestBuilder.cs b/src/generated/Teams/Item/Channels/Item/Tabs/Item/TeamsTabRequestBuilder.cs index b505d828fa2..d70dbe69aff 100644 --- a/src/generated/Teams/Item/Channels/Item/Tabs/Item/TeamsTabRequestBuilder.cs +++ b/src/generated/Teams/Item/Channels/Item/Tabs/Item/TeamsTabRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Teams.Item.Channels.Item.Tabs.Item.TeamsApp; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,15 +35,14 @@ public Command BuildDeleteCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - var teamsTabIdOption = new Option("--teamstab-id", description: "key: id of teamsTab") { + var teamsTabIdOption = new Option("--teams-tab-id", description: "key: id of teamsTab") { }; teamsTabIdOption.IsRequired = true; command.AddOption(teamsTabIdOption); - command.SetHandler(async (string teamId, string channelId, string teamsTabId) => { + command.SetHandler(async (string teamId, string channelId, string teamsTabId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, channelIdOption, teamsTabIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - var teamsTabIdOption = new Option("--teamstab-id", description: "key: id of teamsTab") { + var teamsTabIdOption = new Option("--teams-tab-id", description: "key: id of teamsTab") { }; teamsTabIdOption.IsRequired = true; command.AddOption(teamsTabIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string channelId, string teamsTabId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string channelId, string teamsTabId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, channelIdOption, teamsTabIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, channelIdOption, teamsTabIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -108,7 +106,7 @@ public Command BuildPatchCommand() { }; channelIdOption.IsRequired = true; command.AddOption(channelIdOption); - var teamsTabIdOption = new Option("--teamstab-id", description: "key: id of teamsTab") { + var teamsTabIdOption = new Option("--teams-tab-id", description: "key: id of teamsTab") { }; teamsTabIdOption.IsRequired = true; command.AddOption(teamsTabIdOption); @@ -116,14 +114,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string channelId, string teamsTabId, string body) => { + command.SetHandler(async (string teamId, string channelId, string teamsTabId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, channelIdOption, teamsTabIdOption, bodyOption); return command; @@ -202,42 +199,6 @@ public RequestInformation CreatePatchRequestInformation(TeamsTab body, Action - /// A collection of all the tabs in the channel. A navigation property. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of all the tabs in the channel. A navigation property. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of all the tabs in the channel. A navigation property. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(TeamsTab model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of all the tabs in the channel. A navigation property. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/Channels/Item/Tabs/TabsRequestBuilder.cs b/src/generated/Teams/Item/Channels/Item/Tabs/TabsRequestBuilder.cs index 6e6cb18ced9..7bd43bb5745 100644 --- a/src/generated/Teams/Item/Channels/Item/Tabs/TabsRequestBuilder.cs +++ b/src/generated/Teams/Item/Channels/Item/Tabs/TabsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Teams.Item.Channels.Item.Tabs.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class TabsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TeamsTabRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildTeamsAppCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildTeamsAppCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string channelId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string channelId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, channelIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, channelIdOption, bodyOption, outputOption); return command; } /// @@ -116,7 +114,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string channelId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string channelId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -127,15 +129,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, channelIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, channelIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -190,31 +187,6 @@ public RequestInformation CreatePostRequestInformation(TeamsTab body, Action - /// A collection of all the tabs in the channel. A navigation property. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of all the tabs in the channel. A navigation property. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TeamsTab model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of all the tabs in the channel. A navigation property. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Teams/Item/Clone/CloneRequestBuilder.cs b/src/generated/Teams/Item/Clone/CloneRequestBuilder.cs index 3dfa7fe2a5b..8e2e1b25f9d 100644 --- a/src/generated/Teams/Item/Clone/CloneRequestBuilder.cs +++ b/src/generated/Teams/Item/Clone/CloneRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { + command.SetHandler(async (string teamId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(CloneRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action clone - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CloneRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Teams/Item/CompleteMigration/CompleteMigrationRequestBuilder.cs b/src/generated/Teams/Item/CompleteMigration/CompleteMigrationRequestBuilder.cs index f14cf585cef..b3187c8383d 100644 --- a/src/generated/Teams/Item/CompleteMigration/CompleteMigrationRequestBuilder.cs +++ b/src/generated/Teams/Item/CompleteMigration/CompleteMigrationRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,10 @@ public Command BuildPostCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - command.SetHandler(async (string teamId) => { + command.SetHandler(async (string teamId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action completeMigration - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Teams/Item/Group/@Ref/@Ref.cs b/src/generated/Teams/Item/Group/@Ref/@Ref.cs deleted file mode 100644 index cac0ef717b1..00000000000 --- a/src/generated/Teams/Item/Group/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Teams.Item.Group.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Teams/Item/Group/@Ref/RefRequestBuilder.cs b/src/generated/Teams/Item/Group/@Ref/RefRequestBuilder.cs deleted file mode 100644 index caed0673971..00000000000 --- a/src/generated/Teams/Item/Group/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Teams.Item.Group.@Ref { - /// Builds and executes requests for operations under \teams\{team-id}\group\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Delete ref of navigation property group for teams - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Delete ref of navigation property group for teams"; - // Create options for all the parameters - var teamIdOption = new Option("--team-id", description: "key: id of team") { - }; - teamIdOption.IsRequired = true; - command.AddOption(teamIdOption); - command.SetHandler(async (string teamId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, teamIdOption); - return command; - } - /// - /// Get ref of group from teams - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Get ref of group from teams"; - // Create options for all the parameters - var teamIdOption = new Option("--team-id", description: "key: id of team") { - }; - teamIdOption.IsRequired = true; - command.AddOption(teamIdOption); - command.SetHandler(async (string teamId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption); - return command; - } - /// - /// Update the ref of navigation property group in teams - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Update the ref of navigation property group in teams"; - // Create options for all the parameters - var teamIdOption = new Option("--team-id", description: "key: id of team") { - }; - teamIdOption.IsRequired = true; - command.AddOption(teamIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, teamIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/teams/{team_id}/group/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Delete ref of navigation property group for teams - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Get ref of group from teams - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Update the ref of navigation property group in teams - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Teams.Item.Group.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Delete ref of navigation property group for teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get ref of group from teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the ref of navigation property group in teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Teams.Item.Group.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Teams/Item/Group/GroupRequestBuilder.cs b/src/generated/Teams/Item/Group/GroupRequestBuilder.cs index acb8560b31f..8a72b414f8f 100644 --- a/src/generated/Teams/Item/Group/GroupRequestBuilder.cs +++ b/src/generated/Teams/Item/Group/GroupRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Teams.Item.Group.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Teams.Item.Group.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Teams.Item.Group.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get group from teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get group from teams public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/Group/Ref/Ref.cs b/src/generated/Teams/Item/Group/Ref/Ref.cs new file mode 100644 index 00000000000..1b61775cfea --- /dev/null +++ b/src/generated/Teams/Item/Group/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Teams.Item.Group.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Teams/Item/Group/Ref/RefRequestBuilder.cs b/src/generated/Teams/Item/Group/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..14b4110d866 --- /dev/null +++ b/src/generated/Teams/Item/Group/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Teams.Item.Group.Ref { + /// Builds and executes requests for operations under \teams\{team-id}\group\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Delete ref of navigation property group for teams + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Delete ref of navigation property group for teams"; + // Create options for all the parameters + var teamIdOption = new Option("--team-id", description: "key: id of team") { + }; + teamIdOption.IsRequired = true; + command.AddOption(teamIdOption); + command.SetHandler(async (string teamId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, teamIdOption); + return command; + } + /// + /// Get ref of group from teams + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Get ref of group from teams"; + // Create options for all the parameters + var teamIdOption = new Option("--team-id", description: "key: id of team") { + }; + teamIdOption.IsRequired = true; + command.AddOption(teamIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, outputOption); + return command; + } + /// + /// Update the ref of navigation property group in teams + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Update the ref of navigation property group in teams"; + // Create options for all the parameters + var teamIdOption = new Option("--team-id", description: "key: id of team") { + }; + teamIdOption.IsRequired = true; + command.AddOption(teamIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string teamId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, teamIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/teams/{team_id}/group/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Delete ref of navigation property group for teams + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Get ref of group from teams + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Update the ref of navigation property group in teams + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Teams.Item.Group.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Teams/Item/InstalledApps/InstalledAppsRequestBuilder.cs b/src/generated/Teams/Item/InstalledApps/InstalledAppsRequestBuilder.cs index ea9ab8da6a5..2fdb2db0b66 100644 --- a/src/generated/Teams/Item/InstalledApps/InstalledAppsRequestBuilder.cs +++ b/src/generated/Teams/Item/InstalledApps/InstalledAppsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Teams.Item.InstalledApps.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class InstalledAppsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TeamsAppInstallationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildTeamsAppCommand(), - builder.BuildTeamsAppDefinitionCommand(), - builder.BuildUpgradeCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildTeamsAppCommand()); + commands.Add(builder.BuildTeamsAppDefinitionCommand()); + commands.Add(builder.BuildUpgradeCommand()); return commands; } /// @@ -47,21 +46,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, bodyOption, outputOption); return command; } /// @@ -110,7 +108,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(TeamsAppInstallation body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The apps installed in this team. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The apps installed in this team. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TeamsAppInstallation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The apps installed in this team. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Teams/Item/InstalledApps/Item/TeamsApp/@Ref/@Ref.cs b/src/generated/Teams/Item/InstalledApps/Item/TeamsApp/@Ref/@Ref.cs deleted file mode 100644 index 7a65f961535..00000000000 --- a/src/generated/Teams/Item/InstalledApps/Item/TeamsApp/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Teams.Item.InstalledApps.Item.TeamsApp.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Teams/Item/InstalledApps/Item/TeamsApp/@Ref/RefRequestBuilder.cs b/src/generated/Teams/Item/InstalledApps/Item/TeamsApp/@Ref/RefRequestBuilder.cs deleted file mode 100644 index a37935c0c1e..00000000000 --- a/src/generated/Teams/Item/InstalledApps/Item/TeamsApp/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Teams.Item.InstalledApps.Item.TeamsApp.@Ref { - /// Builds and executes requests for operations under \teams\{team-id}\installedApps\{teamsAppInstallation-id}\teamsApp\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The app that is installed. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The app that is installed."; - // Create options for all the parameters - var teamIdOption = new Option("--team-id", description: "key: id of team") { - }; - teamIdOption.IsRequired = true; - command.AddOption(teamIdOption); - var teamsAppInstallationIdOption = new Option("--teamsappinstallation-id", description: "key: id of teamsAppInstallation") { - }; - teamsAppInstallationIdOption.IsRequired = true; - command.AddOption(teamsAppInstallationIdOption); - command.SetHandler(async (string teamId, string teamsAppInstallationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, teamIdOption, teamsAppInstallationIdOption); - return command; - } - /// - /// The app that is installed. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The app that is installed."; - // Create options for all the parameters - var teamIdOption = new Option("--team-id", description: "key: id of team") { - }; - teamIdOption.IsRequired = true; - command.AddOption(teamIdOption); - var teamsAppInstallationIdOption = new Option("--teamsappinstallation-id", description: "key: id of teamsAppInstallation") { - }; - teamsAppInstallationIdOption.IsRequired = true; - command.AddOption(teamsAppInstallationIdOption); - command.SetHandler(async (string teamId, string teamsAppInstallationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, teamsAppInstallationIdOption); - return command; - } - /// - /// The app that is installed. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The app that is installed."; - // Create options for all the parameters - var teamIdOption = new Option("--team-id", description: "key: id of team") { - }; - teamIdOption.IsRequired = true; - command.AddOption(teamIdOption); - var teamsAppInstallationIdOption = new Option("--teamsappinstallation-id", description: "key: id of teamsAppInstallation") { - }; - teamsAppInstallationIdOption.IsRequired = true; - command.AddOption(teamsAppInstallationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string teamsAppInstallationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, teamIdOption, teamsAppInstallationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/teams/{team_id}/installedApps/{teamsAppInstallation_id}/teamsApp/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The app that is installed. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The app that is installed. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The app that is installed. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Teams.Item.InstalledApps.Item.TeamsApp.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The app that is installed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The app that is installed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The app that is installed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Teams.Item.InstalledApps.Item.TeamsApp.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Teams/Item/InstalledApps/Item/TeamsApp/Ref/Ref.cs b/src/generated/Teams/Item/InstalledApps/Item/TeamsApp/Ref/Ref.cs new file mode 100644 index 00000000000..accdde7fdb5 --- /dev/null +++ b/src/generated/Teams/Item/InstalledApps/Item/TeamsApp/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Teams.Item.InstalledApps.Item.TeamsApp.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Teams/Item/InstalledApps/Item/TeamsApp/Ref/RefRequestBuilder.cs b/src/generated/Teams/Item/InstalledApps/Item/TeamsApp/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..eec2a054b7b --- /dev/null +++ b/src/generated/Teams/Item/InstalledApps/Item/TeamsApp/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Teams.Item.InstalledApps.Item.TeamsApp.Ref { + /// Builds and executes requests for operations under \teams\{team-id}\installedApps\{teamsAppInstallation-id}\teamsApp\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The app that is installed. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The app that is installed."; + // Create options for all the parameters + var teamIdOption = new Option("--team-id", description: "key: id of team") { + }; + teamIdOption.IsRequired = true; + command.AddOption(teamIdOption); + var teamsAppInstallationIdOption = new Option("--teams-app-installation-id", description: "key: id of teamsAppInstallation") { + }; + teamsAppInstallationIdOption.IsRequired = true; + command.AddOption(teamsAppInstallationIdOption); + command.SetHandler(async (string teamId, string teamsAppInstallationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, teamIdOption, teamsAppInstallationIdOption); + return command; + } + /// + /// The app that is installed. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The app that is installed."; + // Create options for all the parameters + var teamIdOption = new Option("--team-id", description: "key: id of team") { + }; + teamIdOption.IsRequired = true; + command.AddOption(teamIdOption); + var teamsAppInstallationIdOption = new Option("--teams-app-installation-id", description: "key: id of teamsAppInstallation") { + }; + teamsAppInstallationIdOption.IsRequired = true; + command.AddOption(teamsAppInstallationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string teamsAppInstallationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, teamsAppInstallationIdOption, outputOption); + return command; + } + /// + /// The app that is installed. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The app that is installed."; + // Create options for all the parameters + var teamIdOption = new Option("--team-id", description: "key: id of team") { + }; + teamIdOption.IsRequired = true; + command.AddOption(teamIdOption); + var teamsAppInstallationIdOption = new Option("--teams-app-installation-id", description: "key: id of teamsAppInstallation") { + }; + teamsAppInstallationIdOption.IsRequired = true; + command.AddOption(teamsAppInstallationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string teamId, string teamsAppInstallationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, teamIdOption, teamsAppInstallationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/teams/{team_id}/installedApps/{teamsAppInstallation_id}/teamsApp/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The app that is installed. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The app that is installed. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The app that is installed. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Teams.Item.InstalledApps.Item.TeamsApp.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Teams/Item/InstalledApps/Item/TeamsApp/TeamsAppRequestBuilder.cs b/src/generated/Teams/Item/InstalledApps/Item/TeamsApp/TeamsAppRequestBuilder.cs index a8b6aeca420..a7e0136cd34 100644 --- a/src/generated/Teams/Item/InstalledApps/Item/TeamsApp/TeamsAppRequestBuilder.cs +++ b/src/generated/Teams/Item/InstalledApps/Item/TeamsApp/TeamsAppRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Teams.Item.InstalledApps.Item.TeamsApp.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,7 +31,7 @@ public Command BuildGetCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var teamsAppInstallationIdOption = new Option("--teamsappinstallation-id", description: "key: id of teamsAppInstallation") { + var teamsAppInstallationIdOption = new Option("--teams-app-installation-id", description: "key: id of teamsAppInstallation") { }; teamsAppInstallationIdOption.IsRequired = true; command.AddOption(teamsAppInstallationIdOption); @@ -45,25 +45,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string teamsAppInstallationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string teamsAppInstallationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, teamsAppInstallationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, teamsAppInstallationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Teams.Item.InstalledApps.Item.TeamsApp.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Teams.Item.InstalledApps.Item.TeamsApp.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -103,18 +102,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The app that is installed. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The app that is installed. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/InstalledApps/Item/TeamsAppDefinition/@Ref/@Ref.cs b/src/generated/Teams/Item/InstalledApps/Item/TeamsAppDefinition/@Ref/@Ref.cs deleted file mode 100644 index 19185d58dca..00000000000 --- a/src/generated/Teams/Item/InstalledApps/Item/TeamsAppDefinition/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Teams.Item.InstalledApps.Item.TeamsAppDefinition.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Teams/Item/InstalledApps/Item/TeamsAppDefinition/@Ref/RefRequestBuilder.cs b/src/generated/Teams/Item/InstalledApps/Item/TeamsAppDefinition/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 10a80205630..00000000000 --- a/src/generated/Teams/Item/InstalledApps/Item/TeamsAppDefinition/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Teams.Item.InstalledApps.Item.TeamsAppDefinition.@Ref { - /// Builds and executes requests for operations under \teams\{team-id}\installedApps\{teamsAppInstallation-id}\teamsAppDefinition\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The details of this version of the app. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The details of this version of the app."; - // Create options for all the parameters - var teamIdOption = new Option("--team-id", description: "key: id of team") { - }; - teamIdOption.IsRequired = true; - command.AddOption(teamIdOption); - var teamsAppInstallationIdOption = new Option("--teamsappinstallation-id", description: "key: id of teamsAppInstallation") { - }; - teamsAppInstallationIdOption.IsRequired = true; - command.AddOption(teamsAppInstallationIdOption); - command.SetHandler(async (string teamId, string teamsAppInstallationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, teamIdOption, teamsAppInstallationIdOption); - return command; - } - /// - /// The details of this version of the app. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The details of this version of the app."; - // Create options for all the parameters - var teamIdOption = new Option("--team-id", description: "key: id of team") { - }; - teamIdOption.IsRequired = true; - command.AddOption(teamIdOption); - var teamsAppInstallationIdOption = new Option("--teamsappinstallation-id", description: "key: id of teamsAppInstallation") { - }; - teamsAppInstallationIdOption.IsRequired = true; - command.AddOption(teamsAppInstallationIdOption); - command.SetHandler(async (string teamId, string teamsAppInstallationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, teamsAppInstallationIdOption); - return command; - } - /// - /// The details of this version of the app. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The details of this version of the app."; - // Create options for all the parameters - var teamIdOption = new Option("--team-id", description: "key: id of team") { - }; - teamIdOption.IsRequired = true; - command.AddOption(teamIdOption); - var teamsAppInstallationIdOption = new Option("--teamsappinstallation-id", description: "key: id of teamsAppInstallation") { - }; - teamsAppInstallationIdOption.IsRequired = true; - command.AddOption(teamsAppInstallationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string teamsAppInstallationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, teamIdOption, teamsAppInstallationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/teams/{team_id}/installedApps/{teamsAppInstallation_id}/teamsAppDefinition/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The details of this version of the app. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The details of this version of the app. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The details of this version of the app. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Teams.Item.InstalledApps.Item.TeamsAppDefinition.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The details of this version of the app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The details of this version of the app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The details of this version of the app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Teams.Item.InstalledApps.Item.TeamsAppDefinition.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Teams/Item/InstalledApps/Item/TeamsAppDefinition/Ref/Ref.cs b/src/generated/Teams/Item/InstalledApps/Item/TeamsAppDefinition/Ref/Ref.cs new file mode 100644 index 00000000000..72a5204549d --- /dev/null +++ b/src/generated/Teams/Item/InstalledApps/Item/TeamsAppDefinition/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Teams.Item.InstalledApps.Item.TeamsAppDefinition.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Teams/Item/InstalledApps/Item/TeamsAppDefinition/Ref/RefRequestBuilder.cs b/src/generated/Teams/Item/InstalledApps/Item/TeamsAppDefinition/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..46d4e9db3ca --- /dev/null +++ b/src/generated/Teams/Item/InstalledApps/Item/TeamsAppDefinition/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Teams.Item.InstalledApps.Item.TeamsAppDefinition.Ref { + /// Builds and executes requests for operations under \teams\{team-id}\installedApps\{teamsAppInstallation-id}\teamsAppDefinition\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The details of this version of the app. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The details of this version of the app."; + // Create options for all the parameters + var teamIdOption = new Option("--team-id", description: "key: id of team") { + }; + teamIdOption.IsRequired = true; + command.AddOption(teamIdOption); + var teamsAppInstallationIdOption = new Option("--teams-app-installation-id", description: "key: id of teamsAppInstallation") { + }; + teamsAppInstallationIdOption.IsRequired = true; + command.AddOption(teamsAppInstallationIdOption); + command.SetHandler(async (string teamId, string teamsAppInstallationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, teamIdOption, teamsAppInstallationIdOption); + return command; + } + /// + /// The details of this version of the app. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The details of this version of the app."; + // Create options for all the parameters + var teamIdOption = new Option("--team-id", description: "key: id of team") { + }; + teamIdOption.IsRequired = true; + command.AddOption(teamIdOption); + var teamsAppInstallationIdOption = new Option("--teams-app-installation-id", description: "key: id of teamsAppInstallation") { + }; + teamsAppInstallationIdOption.IsRequired = true; + command.AddOption(teamsAppInstallationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string teamsAppInstallationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, teamsAppInstallationIdOption, outputOption); + return command; + } + /// + /// The details of this version of the app. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The details of this version of the app."; + // Create options for all the parameters + var teamIdOption = new Option("--team-id", description: "key: id of team") { + }; + teamIdOption.IsRequired = true; + command.AddOption(teamIdOption); + var teamsAppInstallationIdOption = new Option("--teams-app-installation-id", description: "key: id of teamsAppInstallation") { + }; + teamsAppInstallationIdOption.IsRequired = true; + command.AddOption(teamsAppInstallationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string teamId, string teamsAppInstallationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, teamIdOption, teamsAppInstallationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/teams/{team_id}/installedApps/{teamsAppInstallation_id}/teamsAppDefinition/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The details of this version of the app. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The details of this version of the app. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The details of this version of the app. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Teams.Item.InstalledApps.Item.TeamsAppDefinition.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Teams/Item/InstalledApps/Item/TeamsAppDefinition/TeamsAppDefinitionRequestBuilder.cs b/src/generated/Teams/Item/InstalledApps/Item/TeamsAppDefinition/TeamsAppDefinitionRequestBuilder.cs index 7f06d42160e..777db2baf28 100644 --- a/src/generated/Teams/Item/InstalledApps/Item/TeamsAppDefinition/TeamsAppDefinitionRequestBuilder.cs +++ b/src/generated/Teams/Item/InstalledApps/Item/TeamsAppDefinition/TeamsAppDefinitionRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Teams.Item.InstalledApps.Item.TeamsAppDefinition.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,7 +31,7 @@ public Command BuildGetCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var teamsAppInstallationIdOption = new Option("--teamsappinstallation-id", description: "key: id of teamsAppInstallation") { + var teamsAppInstallationIdOption = new Option("--teams-app-installation-id", description: "key: id of teamsAppInstallation") { }; teamsAppInstallationIdOption.IsRequired = true; command.AddOption(teamsAppInstallationIdOption); @@ -45,25 +45,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string teamsAppInstallationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string teamsAppInstallationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, teamsAppInstallationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, teamsAppInstallationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Teams.Item.InstalledApps.Item.TeamsAppDefinition.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Teams.Item.InstalledApps.Item.TeamsAppDefinition.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -103,18 +102,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The details of this version of the app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The details of this version of the app. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/InstalledApps/Item/TeamsAppInstallationRequestBuilder.cs b/src/generated/Teams/Item/InstalledApps/Item/TeamsAppInstallationRequestBuilder.cs index 2f16e10b316..5b1bbc2ffb3 100644 --- a/src/generated/Teams/Item/InstalledApps/Item/TeamsAppInstallationRequestBuilder.cs +++ b/src/generated/Teams/Item/InstalledApps/Item/TeamsAppInstallationRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Teams.Item.InstalledApps.Item.Upgrade; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,15 +33,14 @@ public Command BuildDeleteCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var teamsAppInstallationIdOption = new Option("--teamsappinstallation-id", description: "key: id of teamsAppInstallation") { + var teamsAppInstallationIdOption = new Option("--teams-app-installation-id", description: "key: id of teamsAppInstallation") { }; teamsAppInstallationIdOption.IsRequired = true; command.AddOption(teamsAppInstallationIdOption); - command.SetHandler(async (string teamId, string teamsAppInstallationId) => { + command.SetHandler(async (string teamId, string teamsAppInstallationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, teamsAppInstallationIdOption); return command; @@ -57,7 +56,7 @@ public Command BuildGetCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var teamsAppInstallationIdOption = new Option("--teamsappinstallation-id", description: "key: id of teamsAppInstallation") { + var teamsAppInstallationIdOption = new Option("--teams-app-installation-id", description: "key: id of teamsAppInstallation") { }; teamsAppInstallationIdOption.IsRequired = true; command.AddOption(teamsAppInstallationIdOption); @@ -71,20 +70,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string teamsAppInstallationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string teamsAppInstallationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, teamsAppInstallationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, teamsAppInstallationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -98,7 +96,7 @@ public Command BuildPatchCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var teamsAppInstallationIdOption = new Option("--teamsappinstallation-id", description: "key: id of teamsAppInstallation") { + var teamsAppInstallationIdOption = new Option("--teams-app-installation-id", description: "key: id of teamsAppInstallation") { }; teamsAppInstallationIdOption.IsRequired = true; command.AddOption(teamsAppInstallationIdOption); @@ -106,14 +104,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string teamsAppInstallationId, string body) => { + command.SetHandler(async (string teamId, string teamsAppInstallationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, teamsAppInstallationIdOption, bodyOption); return command; @@ -205,42 +202,6 @@ public RequestInformation CreatePatchRequestInformation(TeamsAppInstallation bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The apps installed in this team. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The apps installed in this team. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The apps installed in this team. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(TeamsAppInstallation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The apps installed in this team. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/InstalledApps/Item/Upgrade/UpgradeRequestBuilder.cs b/src/generated/Teams/Item/InstalledApps/Item/Upgrade/UpgradeRequestBuilder.cs index c74ec86119b..2331f371c4e 100644 --- a/src/generated/Teams/Item/InstalledApps/Item/Upgrade/UpgradeRequestBuilder.cs +++ b/src/generated/Teams/Item/InstalledApps/Item/Upgrade/UpgradeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var teamsAppInstallationIdOption = new Option("--teamsappinstallation-id", description: "key: id of teamsAppInstallation") { + var teamsAppInstallationIdOption = new Option("--teams-app-installation-id", description: "key: id of teamsAppInstallation") { }; teamsAppInstallationIdOption.IsRequired = true; command.AddOption(teamsAppInstallationIdOption); - command.SetHandler(async (string teamId, string teamsAppInstallationId) => { + command.SetHandler(async (string teamId, string teamsAppInstallationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, teamsAppInstallationIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action upgrade - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Teams/Item/Members/@Add/@Add.cs b/src/generated/Teams/Item/Members/@Add/@Add.cs deleted file mode 100644 index 2d0806a520c..00000000000 --- a/src/generated/Teams/Item/Members/@Add/@Add.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Teams.Item.Members.@Add { - public class @Add : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Add and sets the default values. - /// - public @Add() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Teams/Item/Members/@Add/AddRequestBody.cs b/src/generated/Teams/Item/Members/@Add/AddRequestBody.cs deleted file mode 100644 index 674e18e0a85..00000000000 --- a/src/generated/Teams/Item/Members/@Add/AddRequestBody.cs +++ /dev/null @@ -1,36 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Teams.Item.Members.@Add { - public class AddRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public List Values { get; set; } - /// - /// Instantiates a new addRequestBody and sets the default values. - /// - public AddRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"values", (o,n) => { (o as AddRequestBody).Values = n.GetCollectionOfObjectValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteCollectionOfObjectValues("values", Values); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Teams/Item/Members/@Add/AddRequestBuilder.cs b/src/generated/Teams/Item/Members/@Add/AddRequestBuilder.cs deleted file mode 100644 index d1ff91d8e5d..00000000000 --- a/src/generated/Teams/Item/Members/@Add/AddRequestBuilder.cs +++ /dev/null @@ -1,98 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Teams.Item.Members.@Add { - /// Builds and executes requests for operations under \teams\{team-id}\members\microsoft.graph.add - public class AddRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action add - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action add"; - // Create options for all the parameters - var teamIdOption = new Option("--team-id", description: "key: id of team") { - }; - teamIdOption.IsRequired = true; - command.AddOption(teamIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AddRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/teams/{team_id}/members/microsoft.graph.add"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action add - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action add - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(AddRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Teams/Item/Members/Add/Add.cs b/src/generated/Teams/Item/Members/Add/Add.cs new file mode 100644 index 00000000000..a10b51cc1ab --- /dev/null +++ b/src/generated/Teams/Item/Members/Add/Add.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Teams.Item.Members.Add { + public class Add : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new add and sets the default values. + /// + public Add() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Teams/Item/Members/Add/AddRequestBody.cs b/src/generated/Teams/Item/Members/Add/AddRequestBody.cs new file mode 100644 index 00000000000..bc2dc324317 --- /dev/null +++ b/src/generated/Teams/Item/Members/Add/AddRequestBody.cs @@ -0,0 +1,36 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Teams.Item.Members.Add { + public class AddRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public List Values { get; set; } + /// + /// Instantiates a new addRequestBody and sets the default values. + /// + public AddRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"values", (o,n) => { (o as AddRequestBody).Values = n.GetCollectionOfObjectValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("values", Values); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Teams/Item/Members/Add/AddRequestBuilder.cs b/src/generated/Teams/Item/Members/Add/AddRequestBuilder.cs new file mode 100644 index 00000000000..7e505118bb1 --- /dev/null +++ b/src/generated/Teams/Item/Members/Add/AddRequestBuilder.cs @@ -0,0 +1,84 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Teams.Item.Members.Add { + /// Builds and executes requests for operations under \teams\{team-id}\members\microsoft.graph.add + public class AddRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action add + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action add"; + // Create options for all the parameters + var teamIdOption = new Option("--team-id", description: "key: id of team") { + }; + teamIdOption.IsRequired = true; + command.AddOption(teamIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new AddRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/teams/{team_id}/members/microsoft.graph.add"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action add + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Teams/Item/Members/Item/ConversationMemberRequestBuilder.cs b/src/generated/Teams/Item/Members/Item/ConversationMemberRequestBuilder.cs index 6d39a7c29fe..102a36f4f09 100644 --- a/src/generated/Teams/Item/Members/Item/ConversationMemberRequestBuilder.cs +++ b/src/generated/Teams/Item/Members/Item/ConversationMemberRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var conversationMemberIdOption = new Option("--conversationmember-id", description: "key: id of conversationMember") { + var conversationMemberIdOption = new Option("--conversation-member-id", description: "key: id of conversationMember") { }; conversationMemberIdOption.IsRequired = true; command.AddOption(conversationMemberIdOption); - command.SetHandler(async (string teamId, string conversationMemberId) => { + command.SetHandler(async (string teamId, string conversationMemberId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, conversationMemberIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var conversationMemberIdOption = new Option("--conversationmember-id", description: "key: id of conversationMember") { + var conversationMemberIdOption = new Option("--conversation-member-id", description: "key: id of conversationMember") { }; conversationMemberIdOption.IsRequired = true; command.AddOption(conversationMemberIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string conversationMemberId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string conversationMemberId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, conversationMemberIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, conversationMemberIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var conversationMemberIdOption = new Option("--conversationmember-id", description: "key: id of conversationMember") { + var conversationMemberIdOption = new Option("--conversation-member-id", description: "key: id of conversationMember") { }; conversationMemberIdOption.IsRequired = true; command.AddOption(conversationMemberIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string conversationMemberId, string body) => { + command.SetHandler(async (string teamId, string conversationMemberId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, conversationMemberIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ConversationMember body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Members and owners of the team. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Members and owners of the team. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Members and owners of the team. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ConversationMember model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Members and owners of the team. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/Members/MembersRequestBuilder.cs b/src/generated/Teams/Item/Members/MembersRequestBuilder.cs index 71766c8e8b7..386e3289b1c 100644 --- a/src/generated/Teams/Item/Members/MembersRequestBuilder.cs +++ b/src/generated/Teams/Item/Members/MembersRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Teams.Item.Members.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,17 +23,16 @@ public class MembersRequestBuilder { private string UrlTemplate { get; set; } public Command BuildAddCommand() { var command = new Command("add"); - var builder = new ApiSdk.Teams.Item.Members.@Add.AddRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Teams.Item.Members.Add.AddRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } public List BuildCommand() { var builder = new ConversationMemberRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -51,21 +50,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, bodyOption, outputOption); return command; } /// @@ -114,7 +112,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -125,15 +127,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -188,31 +185,6 @@ public RequestInformation CreatePostRequestInformation(ConversationMember body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Members and owners of the team. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Members and owners of the team. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ConversationMember model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Members and owners of the team. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Teams/Item/Operations/Item/TeamsAsyncOperationRequestBuilder.cs b/src/generated/Teams/Item/Operations/Item/TeamsAsyncOperationRequestBuilder.cs index fc62b1c685f..a82ad6b0167 100644 --- a/src/generated/Teams/Item/Operations/Item/TeamsAsyncOperationRequestBuilder.cs +++ b/src/generated/Teams/Item/Operations/Item/TeamsAsyncOperationRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var teamsAsyncOperationIdOption = new Option("--teamsasyncoperation-id", description: "key: id of teamsAsyncOperation") { + var teamsAsyncOperationIdOption = new Option("--teams-async-operation-id", description: "key: id of teamsAsyncOperation") { }; teamsAsyncOperationIdOption.IsRequired = true; command.AddOption(teamsAsyncOperationIdOption); - command.SetHandler(async (string teamId, string teamsAsyncOperationId) => { + command.SetHandler(async (string teamId, string teamsAsyncOperationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, teamsAsyncOperationIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var teamsAsyncOperationIdOption = new Option("--teamsasyncoperation-id", description: "key: id of teamsAsyncOperation") { + var teamsAsyncOperationIdOption = new Option("--teams-async-operation-id", description: "key: id of teamsAsyncOperation") { }; teamsAsyncOperationIdOption.IsRequired = true; command.AddOption(teamsAsyncOperationIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string teamsAsyncOperationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string teamsAsyncOperationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, teamsAsyncOperationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, teamsAsyncOperationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var teamsAsyncOperationIdOption = new Option("--teamsasyncoperation-id", description: "key: id of teamsAsyncOperation") { + var teamsAsyncOperationIdOption = new Option("--teams-async-operation-id", description: "key: id of teamsAsyncOperation") { }; teamsAsyncOperationIdOption.IsRequired = true; command.AddOption(teamsAsyncOperationIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string teamsAsyncOperationId, string body) => { + command.SetHandler(async (string teamId, string teamsAsyncOperationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, teamsAsyncOperationIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(TeamsAsyncOperation body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The async operations that ran or are running on this team. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The async operations that ran or are running on this team. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The async operations that ran or are running on this team. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(TeamsAsyncOperation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The async operations that ran or are running on this team. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/Operations/OperationsRequestBuilder.cs b/src/generated/Teams/Item/Operations/OperationsRequestBuilder.cs index f1d67c51de1..20911980dcf 100644 --- a/src/generated/Teams/Item/Operations/OperationsRequestBuilder.cs +++ b/src/generated/Teams/Item/Operations/OperationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Teams.Item.Operations.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class OperationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TeamsAsyncOperationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(TeamsAsyncOperation body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The async operations that ran or are running on this team. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The async operations that ran or are running on this team. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TeamsAsyncOperation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The async operations that ran or are running on this team. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Teams/Item/PrimaryChannel/CompleteMigration/CompleteMigrationRequestBuilder.cs b/src/generated/Teams/Item/PrimaryChannel/CompleteMigration/CompleteMigrationRequestBuilder.cs index 3c014976aab..b3588eacb66 100644 --- a/src/generated/Teams/Item/PrimaryChannel/CompleteMigration/CompleteMigrationRequestBuilder.cs +++ b/src/generated/Teams/Item/PrimaryChannel/CompleteMigration/CompleteMigrationRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,10 @@ public Command BuildPostCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - command.SetHandler(async (string teamId) => { + command.SetHandler(async (string teamId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action completeMigration - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Teams/Item/PrimaryChannel/FilesFolder/Content/ContentRequestBuilder.cs b/src/generated/Teams/Item/PrimaryChannel/FilesFolder/Content/ContentRequestBuilder.cs index 7f9060d91f2..9c2cd8408ed 100644 --- a/src/generated/Teams/Item/PrimaryChannel/FilesFolder/Content/ContentRequestBuilder.cs +++ b/src/generated/Teams/Item/PrimaryChannel/FilesFolder/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string teamId, FileInfo output) => { + command.SetHandler(async (string teamId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, teamIdOption, outputOption); + }, teamIdOption, fileOption, outputOption); return command; } /// @@ -64,12 +66,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, FileInfo file) => { + command.SetHandler(async (string teamId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, bodyOption); return command; @@ -120,29 +121,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property filesFolder from teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property filesFolder in teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Teams/Item/PrimaryChannel/FilesFolder/FilesFolderRequestBuilder.cs b/src/generated/Teams/Item/PrimaryChannel/FilesFolder/FilesFolderRequestBuilder.cs index 1c1ba206a36..1fef406cfdf 100644 --- a/src/generated/Teams/Item/PrimaryChannel/FilesFolder/FilesFolderRequestBuilder.cs +++ b/src/generated/Teams/Item/PrimaryChannel/FilesFolder/FilesFolderRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Teams.Item.PrimaryChannel.FilesFolder.Content; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - command.SetHandler(async (string teamId) => { + command.SetHandler(async (string teamId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption); return command; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,14 +97,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { + command.SetHandler(async (string teamId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, bodyOption); return command; @@ -178,42 +175,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Metadata for the location where the channel's files are stored. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Metadata for the location where the channel's files are stored. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Metadata for the location where the channel's files are stored. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Metadata for the location where the channel's files are stored. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/PrimaryChannel/Members/@Add/@Add.cs b/src/generated/Teams/Item/PrimaryChannel/Members/@Add/@Add.cs deleted file mode 100644 index c2bbad59b39..00000000000 --- a/src/generated/Teams/Item/PrimaryChannel/Members/@Add/@Add.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Teams.Item.PrimaryChannel.Members.@Add { - public class @Add : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Add and sets the default values. - /// - public @Add() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Teams/Item/PrimaryChannel/Members/@Add/AddRequestBody.cs b/src/generated/Teams/Item/PrimaryChannel/Members/@Add/AddRequestBody.cs deleted file mode 100644 index ff630b4cd21..00000000000 --- a/src/generated/Teams/Item/PrimaryChannel/Members/@Add/AddRequestBody.cs +++ /dev/null @@ -1,36 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Teams.Item.PrimaryChannel.Members.@Add { - public class AddRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public List Values { get; set; } - /// - /// Instantiates a new addRequestBody and sets the default values. - /// - public AddRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"values", (o,n) => { (o as AddRequestBody).Values = n.GetCollectionOfObjectValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteCollectionOfObjectValues("values", Values); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Teams/Item/PrimaryChannel/Members/@Add/AddRequestBuilder.cs b/src/generated/Teams/Item/PrimaryChannel/Members/@Add/AddRequestBuilder.cs deleted file mode 100644 index 4b0f7ad9f39..00000000000 --- a/src/generated/Teams/Item/PrimaryChannel/Members/@Add/AddRequestBuilder.cs +++ /dev/null @@ -1,98 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Teams.Item.PrimaryChannel.Members.@Add { - /// Builds and executes requests for operations under \teams\{team-id}\primaryChannel\members\microsoft.graph.add - public class AddRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action add - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action add"; - // Create options for all the parameters - var teamIdOption = new Option("--team-id", description: "key: id of team") { - }; - teamIdOption.IsRequired = true; - command.AddOption(teamIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AddRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/teams/{team_id}/primaryChannel/members/microsoft.graph.add"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action add - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action add - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(AddRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Teams/Item/PrimaryChannel/Members/Add/Add.cs b/src/generated/Teams/Item/PrimaryChannel/Members/Add/Add.cs new file mode 100644 index 00000000000..1cdb9edeb12 --- /dev/null +++ b/src/generated/Teams/Item/PrimaryChannel/Members/Add/Add.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Teams.Item.PrimaryChannel.Members.Add { + public class Add : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new add and sets the default values. + /// + public Add() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Teams/Item/PrimaryChannel/Members/Add/AddRequestBody.cs b/src/generated/Teams/Item/PrimaryChannel/Members/Add/AddRequestBody.cs new file mode 100644 index 00000000000..744cb338bf3 --- /dev/null +++ b/src/generated/Teams/Item/PrimaryChannel/Members/Add/AddRequestBody.cs @@ -0,0 +1,36 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Teams.Item.PrimaryChannel.Members.Add { + public class AddRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public List Values { get; set; } + /// + /// Instantiates a new addRequestBody and sets the default values. + /// + public AddRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"values", (o,n) => { (o as AddRequestBody).Values = n.GetCollectionOfObjectValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("values", Values); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Teams/Item/PrimaryChannel/Members/Add/AddRequestBuilder.cs b/src/generated/Teams/Item/PrimaryChannel/Members/Add/AddRequestBuilder.cs new file mode 100644 index 00000000000..c0d7aef0cef --- /dev/null +++ b/src/generated/Teams/Item/PrimaryChannel/Members/Add/AddRequestBuilder.cs @@ -0,0 +1,84 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Teams.Item.PrimaryChannel.Members.Add { + /// Builds and executes requests for operations under \teams\{team-id}\primaryChannel\members\microsoft.graph.add + public class AddRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action add + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action add"; + // Create options for all the parameters + var teamIdOption = new Option("--team-id", description: "key: id of team") { + }; + teamIdOption.IsRequired = true; + command.AddOption(teamIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new AddRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/teams/{team_id}/primaryChannel/members/microsoft.graph.add"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action add + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Teams/Item/PrimaryChannel/Members/Item/ConversationMemberRequestBuilder.cs b/src/generated/Teams/Item/PrimaryChannel/Members/Item/ConversationMemberRequestBuilder.cs index 0a0651c85bc..670810eff23 100644 --- a/src/generated/Teams/Item/PrimaryChannel/Members/Item/ConversationMemberRequestBuilder.cs +++ b/src/generated/Teams/Item/PrimaryChannel/Members/Item/ConversationMemberRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var conversationMemberIdOption = new Option("--conversationmember-id", description: "key: id of conversationMember") { + var conversationMemberIdOption = new Option("--conversation-member-id", description: "key: id of conversationMember") { }; conversationMemberIdOption.IsRequired = true; command.AddOption(conversationMemberIdOption); - command.SetHandler(async (string teamId, string conversationMemberId) => { + command.SetHandler(async (string teamId, string conversationMemberId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, conversationMemberIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var conversationMemberIdOption = new Option("--conversationmember-id", description: "key: id of conversationMember") { + var conversationMemberIdOption = new Option("--conversation-member-id", description: "key: id of conversationMember") { }; conversationMemberIdOption.IsRequired = true; command.AddOption(conversationMemberIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string conversationMemberId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string conversationMemberId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, conversationMemberIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, conversationMemberIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var conversationMemberIdOption = new Option("--conversationmember-id", description: "key: id of conversationMember") { + var conversationMemberIdOption = new Option("--conversation-member-id", description: "key: id of conversationMember") { }; conversationMemberIdOption.IsRequired = true; command.AddOption(conversationMemberIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string conversationMemberId, string body) => { + command.SetHandler(async (string teamId, string conversationMemberId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, conversationMemberIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ConversationMember body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of membership records associated with the channel. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of membership records associated with the channel. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of membership records associated with the channel. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ConversationMember model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of membership records associated with the channel. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/PrimaryChannel/Members/MembersRequestBuilder.cs b/src/generated/Teams/Item/PrimaryChannel/Members/MembersRequestBuilder.cs index f328acf789a..12dd264623c 100644 --- a/src/generated/Teams/Item/PrimaryChannel/Members/MembersRequestBuilder.cs +++ b/src/generated/Teams/Item/PrimaryChannel/Members/MembersRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Teams.Item.PrimaryChannel.Members.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,17 +23,16 @@ public class MembersRequestBuilder { private string UrlTemplate { get; set; } public Command BuildAddCommand() { var command = new Command("add"); - var builder = new ApiSdk.Teams.Item.PrimaryChannel.Members.@Add.AddRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Teams.Item.PrimaryChannel.Members.Add.AddRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } public List BuildCommand() { var builder = new ConversationMemberRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -51,21 +50,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, bodyOption, outputOption); return command; } /// @@ -114,7 +112,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -125,15 +127,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -188,31 +185,6 @@ public RequestInformation CreatePostRequestInformation(ConversationMember body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of membership records associated with the channel. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of membership records associated with the channel. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ConversationMember model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of membership records associated with the channel. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Teams/Item/PrimaryChannel/Messages/Delta/DeltaRequestBuilder.cs b/src/generated/Teams/Item/PrimaryChannel/Messages/Delta/DeltaRequestBuilder.cs index 6d97e89f583..26866a669df 100644 --- a/src/generated/Teams/Item/PrimaryChannel/Messages/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Teams/Item/PrimaryChannel/Messages/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +29,17 @@ public Command BuildGetCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - command.SetHandler(async (string teamId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Teams/Item/PrimaryChannel/Messages/Item/ChatMessageRequestBuilder.cs b/src/generated/Teams/Item/PrimaryChannel/Messages/Item/ChatMessageRequestBuilder.cs index 82d554e9d2b..55d5b1c4a8a 100644 --- a/src/generated/Teams/Item/PrimaryChannel/Messages/Item/ChatMessageRequestBuilder.cs +++ b/src/generated/Teams/Item/PrimaryChannel/Messages/Item/ChatMessageRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Teams.Item.PrimaryChannel.Messages.Item.Replies; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -32,15 +32,14 @@ public Command BuildDeleteCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); - command.SetHandler(async (string teamId, string chatMessageId) => { + command.SetHandler(async (string teamId, string chatMessageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, chatMessageIdOption); return command; @@ -56,7 +55,7 @@ public Command BuildGetCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); @@ -70,25 +69,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string chatMessageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string chatMessageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, chatMessageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, chatMessageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildHostedContentsCommand() { var command = new Command("hosted-contents"); var builder = new ApiSdk.Teams.Item.PrimaryChannel.Messages.Item.HostedContents.HostedContentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -104,7 +105,7 @@ public Command BuildPatchCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); @@ -112,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string chatMessageId, string body) => { + command.SetHandler(async (string teamId, string chatMessageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, chatMessageIdOption, bodyOption); return command; @@ -127,6 +127,9 @@ public Command BuildPatchCommand() { public Command BuildRepliesCommand() { var command = new Command("replies"); var builder = new ApiSdk.Teams.Item.PrimaryChannel.Messages.Item.Replies.RepliesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -198,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(ChatMessage body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of all the messages in the channel. A navigation property. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of all the messages in the channel. A navigation property. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of all the messages in the channel. A navigation property. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ChatMessage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of all the messages in the channel. A navigation property. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/PrimaryChannel/Messages/Item/HostedContents/HostedContentsRequestBuilder.cs b/src/generated/Teams/Item/PrimaryChannel/Messages/Item/HostedContents/HostedContentsRequestBuilder.cs index b2994db7342..7fcf17bd061 100644 --- a/src/generated/Teams/Item/PrimaryChannel/Messages/Item/HostedContents/HostedContentsRequestBuilder.cs +++ b/src/generated/Teams/Item/PrimaryChannel/Messages/Item/HostedContents/HostedContentsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Teams.Item.PrimaryChannel.Messages.Item.HostedContents.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class HostedContentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ChatMessageHostedContentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string chatMessageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string chatMessageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, chatMessageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, chatMessageIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string chatMessageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string chatMessageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, chatMessageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, chatMessageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(ChatMessageHostedContent requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Content in a message hosted by Microsoft Teams - for example, images or code snippets. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Content in a message hosted by Microsoft Teams - for example, images or code snippets. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ChatMessageHostedContent model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Content in a message hosted by Microsoft Teams - for example, images or code snippets. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Teams/Item/PrimaryChannel/Messages/Item/HostedContents/Item/ChatMessageHostedContentRequestBuilder.cs b/src/generated/Teams/Item/PrimaryChannel/Messages/Item/HostedContents/Item/ChatMessageHostedContentRequestBuilder.cs index 58a3d0f04b9..372d5e8da2f 100644 --- a/src/generated/Teams/Item/PrimaryChannel/Messages/Item/HostedContents/Item/ChatMessageHostedContentRequestBuilder.cs +++ b/src/generated/Teams/Item/PrimaryChannel/Messages/Item/HostedContents/Item/ChatMessageHostedContentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); - var chatMessageHostedContentIdOption = new Option("--chatmessagehostedcontent-id", description: "key: id of chatMessageHostedContent") { + var chatMessageHostedContentIdOption = new Option("--chat-message-hosted-content-id", description: "key: id of chatMessageHostedContent") { }; chatMessageHostedContentIdOption.IsRequired = true; command.AddOption(chatMessageHostedContentIdOption); - command.SetHandler(async (string teamId, string chatMessageId, string chatMessageHostedContentId) => { + command.SetHandler(async (string teamId, string chatMessageId, string chatMessageHostedContentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, chatMessageIdOption, chatMessageHostedContentIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); - var chatMessageHostedContentIdOption = new Option("--chatmessagehostedcontent-id", description: "key: id of chatMessageHostedContent") { + var chatMessageHostedContentIdOption = new Option("--chat-message-hosted-content-id", description: "key: id of chatMessageHostedContent") { }; chatMessageHostedContentIdOption.IsRequired = true; command.AddOption(chatMessageHostedContentIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string chatMessageId, string chatMessageHostedContentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string chatMessageId, string chatMessageHostedContentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, chatMessageIdOption, chatMessageHostedContentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, chatMessageIdOption, chatMessageHostedContentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); - var chatMessageHostedContentIdOption = new Option("--chatmessagehostedcontent-id", description: "key: id of chatMessageHostedContent") { + var chatMessageHostedContentIdOption = new Option("--chat-message-hosted-content-id", description: "key: id of chatMessageHostedContent") { }; chatMessageHostedContentIdOption.IsRequired = true; command.AddOption(chatMessageHostedContentIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string chatMessageId, string chatMessageHostedContentId, string body) => { + command.SetHandler(async (string teamId, string chatMessageId, string chatMessageHostedContentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, chatMessageIdOption, chatMessageHostedContentIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(ChatMessageHostedContent requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Content in a message hosted by Microsoft Teams - for example, images or code snippets. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Content in a message hosted by Microsoft Teams - for example, images or code snippets. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Content in a message hosted by Microsoft Teams - for example, images or code snippets. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ChatMessageHostedContent model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Content in a message hosted by Microsoft Teams - for example, images or code snippets. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/PrimaryChannel/Messages/Item/Replies/Delta/DeltaRequestBuilder.cs b/src/generated/Teams/Item/PrimaryChannel/Messages/Item/Replies/Delta/DeltaRequestBuilder.cs index cb68deea483..6c3e636e42a 100644 --- a/src/generated/Teams/Item/PrimaryChannel/Messages/Item/Replies/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Teams/Item/PrimaryChannel/Messages/Item/Replies/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,22 +29,21 @@ public Command BuildGetCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); - command.SetHandler(async (string teamId, string chatMessageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string chatMessageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, chatMessageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, chatMessageIdOption, outputOption); return command; } /// @@ -75,16 +74,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Teams/Item/PrimaryChannel/Messages/Item/Replies/Item/ChatMessageRequestBuilder.cs b/src/generated/Teams/Item/PrimaryChannel/Messages/Item/Replies/Item/ChatMessageRequestBuilder.cs index 3273f166b20..dda5b982d4f 100644 --- a/src/generated/Teams/Item/PrimaryChannel/Messages/Item/Replies/Item/ChatMessageRequestBuilder.cs +++ b/src/generated/Teams/Item/PrimaryChannel/Messages/Item/Replies/Item/ChatMessageRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); - var chatMessageId1Option = new Option("--chatmessage-id1", description: "key: id of chatMessage") { + var chatMessageId1Option = new Option("--chat-message-id1", description: "key: id of chatMessage") { }; chatMessageId1Option.IsRequired = true; command.AddOption(chatMessageId1Option); - command.SetHandler(async (string teamId, string chatMessageId, string chatMessageId1) => { + command.SetHandler(async (string teamId, string chatMessageId, string chatMessageId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, chatMessageIdOption, chatMessageId1Option); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); - var chatMessageId1Option = new Option("--chatmessage-id1", description: "key: id of chatMessage") { + var chatMessageId1Option = new Option("--chat-message-id1", description: "key: id of chatMessage") { }; chatMessageId1Option.IsRequired = true; command.AddOption(chatMessageId1Option); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string chatMessageId, string chatMessageId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string chatMessageId, string chatMessageId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, chatMessageIdOption, chatMessageId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, chatMessageIdOption, chatMessageId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); - var chatMessageId1Option = new Option("--chatmessage-id1", description: "key: id of chatMessage") { + var chatMessageId1Option = new Option("--chat-message-id1", description: "key: id of chatMessage") { }; chatMessageId1Option.IsRequired = true; command.AddOption(chatMessageId1Option); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string chatMessageId, string chatMessageId1, string body) => { + command.SetHandler(async (string teamId, string chatMessageId, string chatMessageId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, chatMessageIdOption, chatMessageId1Option, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(ChatMessage body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Replies for a specified message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Replies for a specified message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Replies for a specified message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ChatMessage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Replies for a specified message. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/PrimaryChannel/Messages/Item/Replies/RepliesRequestBuilder.cs b/src/generated/Teams/Item/PrimaryChannel/Messages/Item/Replies/RepliesRequestBuilder.cs index d7b1d72c11b..22584bc7653 100644 --- a/src/generated/Teams/Item/PrimaryChannel/Messages/Item/Replies/RepliesRequestBuilder.cs +++ b/src/generated/Teams/Item/PrimaryChannel/Messages/Item/Replies/RepliesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Teams.Item.PrimaryChannel.Messages.Item.Replies.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class RepliesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ChatMessageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,7 +40,7 @@ public Command BuildCreateCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string chatMessageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string chatMessageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, chatMessageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, chatMessageIdOption, bodyOption, outputOption); return command; } /// @@ -77,7 +75,7 @@ public Command BuildListCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var chatMessageIdOption = new Option("--chatmessage-id", description: "key: id of chatMessage") { + var chatMessageIdOption = new Option("--chat-message-id", description: "key: id of chatMessage") { }; chatMessageIdOption.IsRequired = true; command.AddOption(chatMessageIdOption); @@ -116,7 +114,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string chatMessageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string chatMessageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -127,15 +129,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, chatMessageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, chatMessageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -196,31 +193,6 @@ public RequestInformation CreatePostRequestInformation(ChatMessage body, Action< public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// Replies for a specified message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Replies for a specified message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ChatMessage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Replies for a specified message. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Teams/Item/PrimaryChannel/Messages/MessagesRequestBuilder.cs b/src/generated/Teams/Item/PrimaryChannel/Messages/MessagesRequestBuilder.cs index 4db0ebee522..323176657ef 100644 --- a/src/generated/Teams/Item/PrimaryChannel/Messages/MessagesRequestBuilder.cs +++ b/src/generated/Teams/Item/PrimaryChannel/Messages/MessagesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Teams.Item.PrimaryChannel.Messages.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,13 +23,12 @@ public class MessagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ChatMessageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildHostedContentsCommand(), - builder.BuildPatchCommand(), - builder.BuildRepliesCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildHostedContentsCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRepliesCommand()); return commands; } /// @@ -47,21 +46,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, bodyOption, outputOption); return command; } /// @@ -110,7 +108,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -190,31 +187,6 @@ public RequestInformation CreatePostRequestInformation(ChatMessage body, Action< public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// A collection of all the messages in the channel. A navigation property. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of all the messages in the channel. A navigation property. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ChatMessage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of all the messages in the channel. A navigation property. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Teams/Item/PrimaryChannel/PrimaryChannelRequestBuilder.cs b/src/generated/Teams/Item/PrimaryChannel/PrimaryChannelRequestBuilder.cs index 9309a26a569..0d59a5158f1 100644 --- a/src/generated/Teams/Item/PrimaryChannel/PrimaryChannelRequestBuilder.cs +++ b/src/generated/Teams/Item/PrimaryChannel/PrimaryChannelRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Teams.Item.PrimaryChannel.Tabs; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -43,11 +43,10 @@ public Command BuildDeleteCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - command.SetHandler(async (string teamId) => { + command.SetHandler(async (string teamId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption); return command; @@ -82,26 +81,28 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildMembersCommand() { var command = new Command("members"); var builder = new ApiSdk.Teams.Item.PrimaryChannel.Members.MembersRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -109,6 +110,9 @@ public Command BuildMembersCommand() { public Command BuildMessagesCommand() { var command = new Command("messages"); var builder = new ApiSdk.Teams.Item.PrimaryChannel.Messages.MessagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -128,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { + command.SetHandler(async (string teamId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, bodyOption); return command; @@ -155,6 +158,9 @@ public Command BuildRemoveEmailCommand() { public Command BuildTabsCommand() { var command = new Command("tabs"); var builder = new ApiSdk.Teams.Item.PrimaryChannel.Tabs.TabsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -226,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(Channel body, Action - /// The general channel for the team. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The general channel for the team. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The general channel for the team. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Channel model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The general channel for the team. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/PrimaryChannel/ProvisionEmail/ProvisionEmailRequestBuilder.cs b/src/generated/Teams/Item/PrimaryChannel/ProvisionEmail/ProvisionEmailRequestBuilder.cs index 2aacffc0fa5..68b802aef37 100644 --- a/src/generated/Teams/Item/PrimaryChannel/ProvisionEmail/ProvisionEmailRequestBuilder.cs +++ b/src/generated/Teams/Item/PrimaryChannel/ProvisionEmail/ProvisionEmailRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildPostCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - command.SetHandler(async (string teamId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action provisionEmail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes provisionChannelEmailResult public class ProvisionEmailResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Teams/Item/PrimaryChannel/RemoveEmail/RemoveEmailRequestBuilder.cs b/src/generated/Teams/Item/PrimaryChannel/RemoveEmail/RemoveEmailRequestBuilder.cs index 98f38f0e7d2..207f586bfef 100644 --- a/src/generated/Teams/Item/PrimaryChannel/RemoveEmail/RemoveEmailRequestBuilder.cs +++ b/src/generated/Teams/Item/PrimaryChannel/RemoveEmail/RemoveEmailRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,10 @@ public Command BuildPostCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - command.SetHandler(async (string teamId) => { + command.SetHandler(async (string teamId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action removeEmail - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Teams/Item/PrimaryChannel/Tabs/Item/TeamsApp/@Ref/@Ref.cs b/src/generated/Teams/Item/PrimaryChannel/Tabs/Item/TeamsApp/@Ref/@Ref.cs deleted file mode 100644 index 3dc7687f1ca..00000000000 --- a/src/generated/Teams/Item/PrimaryChannel/Tabs/Item/TeamsApp/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Teams.Item.PrimaryChannel.Tabs.Item.TeamsApp.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Teams/Item/PrimaryChannel/Tabs/Item/TeamsApp/@Ref/RefRequestBuilder.cs b/src/generated/Teams/Item/PrimaryChannel/Tabs/Item/TeamsApp/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 5bd34d22255..00000000000 --- a/src/generated/Teams/Item/PrimaryChannel/Tabs/Item/TeamsApp/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Teams.Item.PrimaryChannel.Tabs.Item.TeamsApp.@Ref { - /// Builds and executes requests for operations under \teams\{team-id}\primaryChannel\tabs\{teamsTab-id}\teamsApp\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The application that is linked to the tab. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The application that is linked to the tab."; - // Create options for all the parameters - var teamIdOption = new Option("--team-id", description: "key: id of team") { - }; - teamIdOption.IsRequired = true; - command.AddOption(teamIdOption); - var teamsTabIdOption = new Option("--teamstab-id", description: "key: id of teamsTab") { - }; - teamsTabIdOption.IsRequired = true; - command.AddOption(teamsTabIdOption); - command.SetHandler(async (string teamId, string teamsTabId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, teamIdOption, teamsTabIdOption); - return command; - } - /// - /// The application that is linked to the tab. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The application that is linked to the tab."; - // Create options for all the parameters - var teamIdOption = new Option("--team-id", description: "key: id of team") { - }; - teamIdOption.IsRequired = true; - command.AddOption(teamIdOption); - var teamsTabIdOption = new Option("--teamstab-id", description: "key: id of teamsTab") { - }; - teamsTabIdOption.IsRequired = true; - command.AddOption(teamsTabIdOption); - command.SetHandler(async (string teamId, string teamsTabId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, teamsTabIdOption); - return command; - } - /// - /// The application that is linked to the tab. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The application that is linked to the tab."; - // Create options for all the parameters - var teamIdOption = new Option("--team-id", description: "key: id of team") { - }; - teamIdOption.IsRequired = true; - command.AddOption(teamIdOption); - var teamsTabIdOption = new Option("--teamstab-id", description: "key: id of teamsTab") { - }; - teamsTabIdOption.IsRequired = true; - command.AddOption(teamsTabIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string teamsTabId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, teamIdOption, teamsTabIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/teams/{team_id}/primaryChannel/tabs/{teamsTab_id}/teamsApp/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The application that is linked to the tab. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The application that is linked to the tab. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The application that is linked to the tab. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Teams.Item.PrimaryChannel.Tabs.Item.TeamsApp.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The application that is linked to the tab. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The application that is linked to the tab. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The application that is linked to the tab. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Teams.Item.PrimaryChannel.Tabs.Item.TeamsApp.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Teams/Item/PrimaryChannel/Tabs/Item/TeamsApp/Ref/Ref.cs b/src/generated/Teams/Item/PrimaryChannel/Tabs/Item/TeamsApp/Ref/Ref.cs new file mode 100644 index 00000000000..fffa51037eb --- /dev/null +++ b/src/generated/Teams/Item/PrimaryChannel/Tabs/Item/TeamsApp/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Teams.Item.PrimaryChannel.Tabs.Item.TeamsApp.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Teams/Item/PrimaryChannel/Tabs/Item/TeamsApp/Ref/RefRequestBuilder.cs b/src/generated/Teams/Item/PrimaryChannel/Tabs/Item/TeamsApp/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..acba6e644f8 --- /dev/null +++ b/src/generated/Teams/Item/PrimaryChannel/Tabs/Item/TeamsApp/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Teams.Item.PrimaryChannel.Tabs.Item.TeamsApp.Ref { + /// Builds and executes requests for operations under \teams\{team-id}\primaryChannel\tabs\{teamsTab-id}\teamsApp\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The application that is linked to the tab. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The application that is linked to the tab."; + // Create options for all the parameters + var teamIdOption = new Option("--team-id", description: "key: id of team") { + }; + teamIdOption.IsRequired = true; + command.AddOption(teamIdOption); + var teamsTabIdOption = new Option("--teams-tab-id", description: "key: id of teamsTab") { + }; + teamsTabIdOption.IsRequired = true; + command.AddOption(teamsTabIdOption); + command.SetHandler(async (string teamId, string teamsTabId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, teamIdOption, teamsTabIdOption); + return command; + } + /// + /// The application that is linked to the tab. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The application that is linked to the tab."; + // Create options for all the parameters + var teamIdOption = new Option("--team-id", description: "key: id of team") { + }; + teamIdOption.IsRequired = true; + command.AddOption(teamIdOption); + var teamsTabIdOption = new Option("--teams-tab-id", description: "key: id of teamsTab") { + }; + teamsTabIdOption.IsRequired = true; + command.AddOption(teamsTabIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string teamsTabId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, teamsTabIdOption, outputOption); + return command; + } + /// + /// The application that is linked to the tab. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The application that is linked to the tab."; + // Create options for all the parameters + var teamIdOption = new Option("--team-id", description: "key: id of team") { + }; + teamIdOption.IsRequired = true; + command.AddOption(teamIdOption); + var teamsTabIdOption = new Option("--teams-tab-id", description: "key: id of teamsTab") { + }; + teamsTabIdOption.IsRequired = true; + command.AddOption(teamsTabIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string teamId, string teamsTabId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, teamIdOption, teamsTabIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/teams/{team_id}/primaryChannel/tabs/{teamsTab_id}/teamsApp/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The application that is linked to the tab. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The application that is linked to the tab. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The application that is linked to the tab. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Teams.Item.PrimaryChannel.Tabs.Item.TeamsApp.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Teams/Item/PrimaryChannel/Tabs/Item/TeamsApp/TeamsAppRequestBuilder.cs b/src/generated/Teams/Item/PrimaryChannel/Tabs/Item/TeamsApp/TeamsAppRequestBuilder.cs index b7d0c936002..ac85f1f2635 100644 --- a/src/generated/Teams/Item/PrimaryChannel/Tabs/Item/TeamsApp/TeamsAppRequestBuilder.cs +++ b/src/generated/Teams/Item/PrimaryChannel/Tabs/Item/TeamsApp/TeamsAppRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Teams.Item.PrimaryChannel.Tabs.Item.TeamsApp.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,7 +31,7 @@ public Command BuildGetCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var teamsTabIdOption = new Option("--teamstab-id", description: "key: id of teamsTab") { + var teamsTabIdOption = new Option("--teams-tab-id", description: "key: id of teamsTab") { }; teamsTabIdOption.IsRequired = true; command.AddOption(teamsTabIdOption); @@ -45,25 +45,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string teamsTabId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string teamsTabId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, teamsTabIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, teamsTabIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Teams.Item.PrimaryChannel.Tabs.Item.TeamsApp.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Teams.Item.PrimaryChannel.Tabs.Item.TeamsApp.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -103,18 +102,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The application that is linked to the tab. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The application that is linked to the tab. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/PrimaryChannel/Tabs/Item/TeamsTabRequestBuilder.cs b/src/generated/Teams/Item/PrimaryChannel/Tabs/Item/TeamsTabRequestBuilder.cs index a0e6eb83955..9c4b060195f 100644 --- a/src/generated/Teams/Item/PrimaryChannel/Tabs/Item/TeamsTabRequestBuilder.cs +++ b/src/generated/Teams/Item/PrimaryChannel/Tabs/Item/TeamsTabRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Teams.Item.PrimaryChannel.Tabs.Item.TeamsApp; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,15 +31,14 @@ public Command BuildDeleteCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var teamsTabIdOption = new Option("--teamstab-id", description: "key: id of teamsTab") { + var teamsTabIdOption = new Option("--teams-tab-id", description: "key: id of teamsTab") { }; teamsTabIdOption.IsRequired = true; command.AddOption(teamsTabIdOption); - command.SetHandler(async (string teamId, string teamsTabId) => { + command.SetHandler(async (string teamId, string teamsTabId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, teamsTabIdOption); return command; @@ -55,7 +54,7 @@ public Command BuildGetCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var teamsTabIdOption = new Option("--teamstab-id", description: "key: id of teamsTab") { + var teamsTabIdOption = new Option("--teams-tab-id", description: "key: id of teamsTab") { }; teamsTabIdOption.IsRequired = true; command.AddOption(teamsTabIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string teamsTabId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string teamsTabId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, teamsTabIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, teamsTabIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -96,7 +94,7 @@ public Command BuildPatchCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var teamsTabIdOption = new Option("--teamstab-id", description: "key: id of teamsTab") { + var teamsTabIdOption = new Option("--teams-tab-id", description: "key: id of teamsTab") { }; teamsTabIdOption.IsRequired = true; command.AddOption(teamsTabIdOption); @@ -104,14 +102,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string teamsTabId, string body) => { + command.SetHandler(async (string teamId, string teamsTabId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, teamsTabIdOption, bodyOption); return command; @@ -190,42 +187,6 @@ public RequestInformation CreatePatchRequestInformation(TeamsTab body, Action - /// A collection of all the tabs in the channel. A navigation property. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of all the tabs in the channel. A navigation property. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of all the tabs in the channel. A navigation property. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(TeamsTab model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of all the tabs in the channel. A navigation property. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/PrimaryChannel/Tabs/TabsRequestBuilder.cs b/src/generated/Teams/Item/PrimaryChannel/Tabs/TabsRequestBuilder.cs index 42f66e92554..a8114b083fc 100644 --- a/src/generated/Teams/Item/PrimaryChannel/Tabs/TabsRequestBuilder.cs +++ b/src/generated/Teams/Item/PrimaryChannel/Tabs/TabsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Teams.Item.PrimaryChannel.Tabs.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class TabsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TeamsTabRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildTeamsAppCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildTeamsAppCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, bodyOption, outputOption); return command; } /// @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(TeamsTab body, Action - /// A collection of all the tabs in the channel. A navigation property. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of all the tabs in the channel. A navigation property. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TeamsTab model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of all the tabs in the channel. A navigation property. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Teams/Item/Schedule/OfferShiftRequests/Item/OfferShiftRequestRequestBuilder.cs b/src/generated/Teams/Item/Schedule/OfferShiftRequests/Item/OfferShiftRequestRequestBuilder.cs index 836eb1fa3e5..4521a3bce3f 100644 --- a/src/generated/Teams/Item/Schedule/OfferShiftRequests/Item/OfferShiftRequestRequestBuilder.cs +++ b/src/generated/Teams/Item/Schedule/OfferShiftRequests/Item/OfferShiftRequestRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var offerShiftRequestIdOption = new Option("--offershiftrequest-id", description: "key: id of offerShiftRequest") { + var offerShiftRequestIdOption = new Option("--offer-shift-request-id", description: "key: id of offerShiftRequest") { }; offerShiftRequestIdOption.IsRequired = true; command.AddOption(offerShiftRequestIdOption); - command.SetHandler(async (string teamId, string offerShiftRequestId) => { + command.SetHandler(async (string teamId, string offerShiftRequestId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, offerShiftRequestIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var offerShiftRequestIdOption = new Option("--offershiftrequest-id", description: "key: id of offerShiftRequest") { + var offerShiftRequestIdOption = new Option("--offer-shift-request-id", description: "key: id of offerShiftRequest") { }; offerShiftRequestIdOption.IsRequired = true; command.AddOption(offerShiftRequestIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string offerShiftRequestId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string offerShiftRequestId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, offerShiftRequestIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, offerShiftRequestIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var offerShiftRequestIdOption = new Option("--offershiftrequest-id", description: "key: id of offerShiftRequest") { + var offerShiftRequestIdOption = new Option("--offer-shift-request-id", description: "key: id of offerShiftRequest") { }; offerShiftRequestIdOption.IsRequired = true; command.AddOption(offerShiftRequestIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string offerShiftRequestId, string body) => { + command.SetHandler(async (string teamId, string offerShiftRequestId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, offerShiftRequestIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(OfferShiftRequest body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property offerShiftRequests for teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get offerShiftRequests from teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property offerShiftRequests in teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OfferShiftRequest model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get offerShiftRequests from teams public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/Schedule/OfferShiftRequests/OfferShiftRequestsRequestBuilder.cs b/src/generated/Teams/Item/Schedule/OfferShiftRequests/OfferShiftRequestsRequestBuilder.cs index de002bacbee..380159289de 100644 --- a/src/generated/Teams/Item/Schedule/OfferShiftRequests/OfferShiftRequestsRequestBuilder.cs +++ b/src/generated/Teams/Item/Schedule/OfferShiftRequests/OfferShiftRequestsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Teams.Item.Schedule.OfferShiftRequests.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class OfferShiftRequestsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OfferShiftRequestRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(OfferShiftRequest body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get offerShiftRequests from teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to offerShiftRequests for teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OfferShiftRequest model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get offerShiftRequests from teams public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Teams/Item/Schedule/OpenShiftChangeRequests/Item/OpenShiftChangeRequestRequestBuilder.cs b/src/generated/Teams/Item/Schedule/OpenShiftChangeRequests/Item/OpenShiftChangeRequestRequestBuilder.cs index 4ce0d8330cb..be8d57b9bee 100644 --- a/src/generated/Teams/Item/Schedule/OpenShiftChangeRequests/Item/OpenShiftChangeRequestRequestBuilder.cs +++ b/src/generated/Teams/Item/Schedule/OpenShiftChangeRequests/Item/OpenShiftChangeRequestRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var openShiftChangeRequestIdOption = new Option("--openshiftchangerequest-id", description: "key: id of openShiftChangeRequest") { + var openShiftChangeRequestIdOption = new Option("--open-shift-change-request-id", description: "key: id of openShiftChangeRequest") { }; openShiftChangeRequestIdOption.IsRequired = true; command.AddOption(openShiftChangeRequestIdOption); - command.SetHandler(async (string teamId, string openShiftChangeRequestId) => { + command.SetHandler(async (string teamId, string openShiftChangeRequestId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, openShiftChangeRequestIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var openShiftChangeRequestIdOption = new Option("--openshiftchangerequest-id", description: "key: id of openShiftChangeRequest") { + var openShiftChangeRequestIdOption = new Option("--open-shift-change-request-id", description: "key: id of openShiftChangeRequest") { }; openShiftChangeRequestIdOption.IsRequired = true; command.AddOption(openShiftChangeRequestIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string openShiftChangeRequestId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string openShiftChangeRequestId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, openShiftChangeRequestIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, openShiftChangeRequestIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var openShiftChangeRequestIdOption = new Option("--openshiftchangerequest-id", description: "key: id of openShiftChangeRequest") { + var openShiftChangeRequestIdOption = new Option("--open-shift-change-request-id", description: "key: id of openShiftChangeRequest") { }; openShiftChangeRequestIdOption.IsRequired = true; command.AddOption(openShiftChangeRequestIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string openShiftChangeRequestId, string body) => { + command.SetHandler(async (string teamId, string openShiftChangeRequestId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, openShiftChangeRequestIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(OpenShiftChangeRequest b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property openShiftChangeRequests for teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get openShiftChangeRequests from teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property openShiftChangeRequests in teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OpenShiftChangeRequest model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get openShiftChangeRequests from teams public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/Schedule/OpenShiftChangeRequests/OpenShiftChangeRequestsRequestBuilder.cs b/src/generated/Teams/Item/Schedule/OpenShiftChangeRequests/OpenShiftChangeRequestsRequestBuilder.cs index b2f442ba063..8b38724bb70 100644 --- a/src/generated/Teams/Item/Schedule/OpenShiftChangeRequests/OpenShiftChangeRequestsRequestBuilder.cs +++ b/src/generated/Teams/Item/Schedule/OpenShiftChangeRequests/OpenShiftChangeRequestsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Teams.Item.Schedule.OpenShiftChangeRequests.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class OpenShiftChangeRequestsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OpenShiftChangeRequestRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(OpenShiftChangeRequest bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get openShiftChangeRequests from teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to openShiftChangeRequests for teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OpenShiftChangeRequest model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get openShiftChangeRequests from teams public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Teams/Item/Schedule/OpenShifts/Item/OpenShiftRequestBuilder.cs b/src/generated/Teams/Item/Schedule/OpenShifts/Item/OpenShiftRequestBuilder.cs index 1527192351c..58906005d71 100644 --- a/src/generated/Teams/Item/Schedule/OpenShifts/Item/OpenShiftRequestBuilder.cs +++ b/src/generated/Teams/Item/Schedule/OpenShifts/Item/OpenShiftRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var openShiftIdOption = new Option("--openshift-id", description: "key: id of openShift") { + var openShiftIdOption = new Option("--open-shift-id", description: "key: id of openShift") { }; openShiftIdOption.IsRequired = true; command.AddOption(openShiftIdOption); - command.SetHandler(async (string teamId, string openShiftId) => { + command.SetHandler(async (string teamId, string openShiftId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, openShiftIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var openShiftIdOption = new Option("--openshift-id", description: "key: id of openShift") { + var openShiftIdOption = new Option("--open-shift-id", description: "key: id of openShift") { }; openShiftIdOption.IsRequired = true; command.AddOption(openShiftIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string openShiftId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string openShiftId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, openShiftIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, openShiftIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var openShiftIdOption = new Option("--openshift-id", description: "key: id of openShift") { + var openShiftIdOption = new Option("--open-shift-id", description: "key: id of openShift") { }; openShiftIdOption.IsRequired = true; command.AddOption(openShiftIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string openShiftId, string body) => { + command.SetHandler(async (string teamId, string openShiftId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, openShiftIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(OpenShift body, Action - /// Delete navigation property openShifts for teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get openShifts from teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property openShifts in teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OpenShift model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get openShifts from teams public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/Schedule/OpenShifts/OpenShiftsRequestBuilder.cs b/src/generated/Teams/Item/Schedule/OpenShifts/OpenShiftsRequestBuilder.cs index 2997108a10c..266b1e25644 100644 --- a/src/generated/Teams/Item/Schedule/OpenShifts/OpenShiftsRequestBuilder.cs +++ b/src/generated/Teams/Item/Schedule/OpenShifts/OpenShiftsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Teams.Item.Schedule.OpenShifts.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class OpenShiftsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OpenShiftRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(OpenShift body, Action - /// Get openShifts from teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to openShifts for teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OpenShift model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get openShifts from teams public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Teams/Item/Schedule/ScheduleRequestBuilder.cs b/src/generated/Teams/Item/Schedule/ScheduleRequestBuilder.cs index 365b3ba2d60..4f044a48bbc 100644 --- a/src/generated/Teams/Item/Schedule/ScheduleRequestBuilder.cs +++ b/src/generated/Teams/Item/Schedule/ScheduleRequestBuilder.cs @@ -11,10 +11,10 @@ using ApiSdk.Teams.Item.Schedule.TimesOff; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -40,11 +40,10 @@ public Command BuildDeleteCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - command.SetHandler(async (string teamId) => { + command.SetHandler(async (string teamId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption); return command; @@ -70,25 +69,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOfferShiftRequestsCommand() { var command = new Command("offer-shift-requests"); var builder = new ApiSdk.Teams.Item.Schedule.OfferShiftRequests.OfferShiftRequestsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -96,6 +97,9 @@ public Command BuildOfferShiftRequestsCommand() { public Command BuildOpenShiftChangeRequestsCommand() { var command = new Command("open-shift-change-requests"); var builder = new ApiSdk.Teams.Item.Schedule.OpenShiftChangeRequests.OpenShiftChangeRequestsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -103,6 +107,9 @@ public Command BuildOpenShiftChangeRequestsCommand() { public Command BuildOpenShiftsCommand() { var command = new Command("open-shifts"); var builder = new ApiSdk.Teams.Item.Schedule.OpenShifts.OpenShiftsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -122,14 +129,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { + command.SetHandler(async (string teamId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, bodyOption); return command; @@ -137,6 +143,9 @@ public Command BuildPatchCommand() { public Command BuildSchedulingGroupsCommand() { var command = new Command("scheduling-groups"); var builder = new ApiSdk.Teams.Item.Schedule.SchedulingGroups.SchedulingGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -150,6 +159,9 @@ public Command BuildShareCommand() { public Command BuildShiftsCommand() { var command = new Command("shifts"); var builder = new ApiSdk.Teams.Item.Schedule.Shifts.ShiftsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -157,6 +169,9 @@ public Command BuildShiftsCommand() { public Command BuildSwapShiftsChangeRequestsCommand() { var command = new Command("swap-shifts-change-requests"); var builder = new ApiSdk.Teams.Item.Schedule.SwapShiftsChangeRequests.SwapShiftsChangeRequestsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -164,6 +179,9 @@ public Command BuildSwapShiftsChangeRequestsCommand() { public Command BuildTimeOffReasonsCommand() { var command = new Command("time-off-reasons"); var builder = new ApiSdk.Teams.Item.Schedule.TimeOffReasons.TimeOffReasonsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -171,6 +189,9 @@ public Command BuildTimeOffReasonsCommand() { public Command BuildTimeOffRequestsCommand() { var command = new Command("time-off-requests"); var builder = new ApiSdk.Teams.Item.Schedule.TimeOffRequests.TimeOffRequestsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -178,6 +199,9 @@ public Command BuildTimeOffRequestsCommand() { public Command BuildTimesOffCommand() { var command = new Command("times-off"); var builder = new ApiSdk.Teams.Item.Schedule.TimesOff.TimesOffRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -249,42 +273,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The schedule of shifts for this team. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The schedule of shifts for this team. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The schedule of shifts for this team. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Schedule model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The schedule of shifts for this team. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/Schedule/SchedulingGroups/Item/SchedulingGroupRequestBuilder.cs b/src/generated/Teams/Item/Schedule/SchedulingGroups/Item/SchedulingGroupRequestBuilder.cs index 3f57677d79c..d77a893171e 100644 --- a/src/generated/Teams/Item/Schedule/SchedulingGroups/Item/SchedulingGroupRequestBuilder.cs +++ b/src/generated/Teams/Item/Schedule/SchedulingGroups/Item/SchedulingGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var schedulingGroupIdOption = new Option("--schedulinggroup-id", description: "key: id of schedulingGroup") { + var schedulingGroupIdOption = new Option("--scheduling-group-id", description: "key: id of schedulingGroup") { }; schedulingGroupIdOption.IsRequired = true; command.AddOption(schedulingGroupIdOption); - command.SetHandler(async (string teamId, string schedulingGroupId) => { + command.SetHandler(async (string teamId, string schedulingGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, schedulingGroupIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var schedulingGroupIdOption = new Option("--schedulinggroup-id", description: "key: id of schedulingGroup") { + var schedulingGroupIdOption = new Option("--scheduling-group-id", description: "key: id of schedulingGroup") { }; schedulingGroupIdOption.IsRequired = true; command.AddOption(schedulingGroupIdOption); @@ -63,19 +62,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string teamId, string schedulingGroupId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string schedulingGroupId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, schedulingGroupIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, schedulingGroupIdOption, selectOption, outputOption); return command; } /// @@ -89,7 +87,7 @@ public Command BuildPatchCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var schedulingGroupIdOption = new Option("--schedulinggroup-id", description: "key: id of schedulingGroup") { + var schedulingGroupIdOption = new Option("--scheduling-group-id", description: "key: id of schedulingGroup") { }; schedulingGroupIdOption.IsRequired = true; command.AddOption(schedulingGroupIdOption); @@ -97,14 +95,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string schedulingGroupId, string body) => { + command.SetHandler(async (string teamId, string schedulingGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, schedulingGroupIdOption, bodyOption); return command; @@ -176,42 +173,6 @@ public RequestInformation CreatePatchRequestInformation(SchedulingGroup body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The logical grouping of users in the schedule (usually by role). - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The logical grouping of users in the schedule (usually by role). - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The logical grouping of users in the schedule (usually by role). - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SchedulingGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The logical grouping of users in the schedule (usually by role). public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Teams/Item/Schedule/SchedulingGroups/SchedulingGroupsRequestBuilder.cs b/src/generated/Teams/Item/Schedule/SchedulingGroups/SchedulingGroupsRequestBuilder.cs index c300a206541..daa47689bda 100644 --- a/src/generated/Teams/Item/Schedule/SchedulingGroups/SchedulingGroupsRequestBuilder.cs +++ b/src/generated/Teams/Item/Schedule/SchedulingGroups/SchedulingGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Teams.Item.Schedule.SchedulingGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SchedulingGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SchedulingGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, bodyOption, outputOption); return command; } /// @@ -102,7 +100,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -112,15 +114,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -175,31 +172,6 @@ public RequestInformation CreatePostRequestInformation(SchedulingGroup body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The logical grouping of users in the schedule (usually by role). - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The logical grouping of users in the schedule (usually by role). - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SchedulingGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The logical grouping of users in the schedule (usually by role). public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Teams/Item/Schedule/Share/ShareRequestBuilder.cs b/src/generated/Teams/Item/Schedule/Share/ShareRequestBuilder.cs index 3ac97836780..d730a28439b 100644 --- a/src/generated/Teams/Item/Schedule/Share/ShareRequestBuilder.cs +++ b/src/generated/Teams/Item/Schedule/Share/ShareRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { + command.SetHandler(async (string teamId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ShareRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action share - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ShareRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Teams/Item/Schedule/Shifts/Item/ShiftRequestBuilder.cs b/src/generated/Teams/Item/Schedule/Shifts/Item/ShiftRequestBuilder.cs index 54bdcd7b362..0b5792144e8 100644 --- a/src/generated/Teams/Item/Schedule/Shifts/Item/ShiftRequestBuilder.cs +++ b/src/generated/Teams/Item/Schedule/Shifts/Item/ShiftRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; shiftIdOption.IsRequired = true; command.AddOption(shiftIdOption); - command.SetHandler(async (string teamId, string shiftId) => { + command.SetHandler(async (string teamId, string shiftId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, shiftIdOption); return command; @@ -63,19 +62,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string teamId, string shiftId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string shiftId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, shiftIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, shiftIdOption, selectOption, outputOption); return command; } /// @@ -97,14 +95,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string shiftId, string body) => { + command.SetHandler(async (string teamId, string shiftId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, shiftIdOption, bodyOption); return command; @@ -176,42 +173,6 @@ public RequestInformation CreatePatchRequestInformation(Shift body, Action - /// The shifts in the schedule. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The shifts in the schedule. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The shifts in the schedule. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Shift model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The shifts in the schedule. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Teams/Item/Schedule/Shifts/ShiftsRequestBuilder.cs b/src/generated/Teams/Item/Schedule/Shifts/ShiftsRequestBuilder.cs index 1f420042c29..ec7be9edb6b 100644 --- a/src/generated/Teams/Item/Schedule/Shifts/ShiftsRequestBuilder.cs +++ b/src/generated/Teams/Item/Schedule/Shifts/ShiftsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Teams.Item.Schedule.Shifts.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ShiftsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ShiftRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, bodyOption, outputOption); return command; } /// @@ -102,7 +100,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -112,15 +114,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -175,31 +172,6 @@ public RequestInformation CreatePostRequestInformation(Shift body, Action - /// The shifts in the schedule. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The shifts in the schedule. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Shift model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The shifts in the schedule. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Teams/Item/Schedule/SwapShiftsChangeRequests/Item/SwapShiftsChangeRequestRequestBuilder.cs b/src/generated/Teams/Item/Schedule/SwapShiftsChangeRequests/Item/SwapShiftsChangeRequestRequestBuilder.cs index f81e82a7cd6..d41095af49d 100644 --- a/src/generated/Teams/Item/Schedule/SwapShiftsChangeRequests/Item/SwapShiftsChangeRequestRequestBuilder.cs +++ b/src/generated/Teams/Item/Schedule/SwapShiftsChangeRequests/Item/SwapShiftsChangeRequestRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var swapShiftsChangeRequestIdOption = new Option("--swapshiftschangerequest-id", description: "key: id of swapShiftsChangeRequest") { + var swapShiftsChangeRequestIdOption = new Option("--swap-shifts-change-request-id", description: "key: id of swapShiftsChangeRequest") { }; swapShiftsChangeRequestIdOption.IsRequired = true; command.AddOption(swapShiftsChangeRequestIdOption); - command.SetHandler(async (string teamId, string swapShiftsChangeRequestId) => { + command.SetHandler(async (string teamId, string swapShiftsChangeRequestId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, swapShiftsChangeRequestIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var swapShiftsChangeRequestIdOption = new Option("--swapshiftschangerequest-id", description: "key: id of swapShiftsChangeRequest") { + var swapShiftsChangeRequestIdOption = new Option("--swap-shifts-change-request-id", description: "key: id of swapShiftsChangeRequest") { }; swapShiftsChangeRequestIdOption.IsRequired = true; command.AddOption(swapShiftsChangeRequestIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string swapShiftsChangeRequestId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string swapShiftsChangeRequestId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, swapShiftsChangeRequestIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, swapShiftsChangeRequestIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var swapShiftsChangeRequestIdOption = new Option("--swapshiftschangerequest-id", description: "key: id of swapShiftsChangeRequest") { + var swapShiftsChangeRequestIdOption = new Option("--swap-shifts-change-request-id", description: "key: id of swapShiftsChangeRequest") { }; swapShiftsChangeRequestIdOption.IsRequired = true; command.AddOption(swapShiftsChangeRequestIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string swapShiftsChangeRequestId, string body) => { + command.SetHandler(async (string teamId, string swapShiftsChangeRequestId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, swapShiftsChangeRequestIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SwapShiftsChangeRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property swapShiftsChangeRequests for teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get swapShiftsChangeRequests from teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property swapShiftsChangeRequests in teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SwapShiftsChangeRequest model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get swapShiftsChangeRequests from teams public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/Schedule/SwapShiftsChangeRequests/SwapShiftsChangeRequestsRequestBuilder.cs b/src/generated/Teams/Item/Schedule/SwapShiftsChangeRequests/SwapShiftsChangeRequestsRequestBuilder.cs index a4d6edd9d81..48ed2f0ddb6 100644 --- a/src/generated/Teams/Item/Schedule/SwapShiftsChangeRequests/SwapShiftsChangeRequestsRequestBuilder.cs +++ b/src/generated/Teams/Item/Schedule/SwapShiftsChangeRequests/SwapShiftsChangeRequestsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Teams.Item.Schedule.SwapShiftsChangeRequests.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SwapShiftsChangeRequestsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SwapShiftsChangeRequestRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(SwapShiftsChangeRequest b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get swapShiftsChangeRequests from teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to swapShiftsChangeRequests for teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SwapShiftsChangeRequest model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get swapShiftsChangeRequests from teams public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Teams/Item/Schedule/TimeOffReasons/Item/TimeOffReasonRequestBuilder.cs b/src/generated/Teams/Item/Schedule/TimeOffReasons/Item/TimeOffReasonRequestBuilder.cs index e288c789bee..2feb4fb681c 100644 --- a/src/generated/Teams/Item/Schedule/TimeOffReasons/Item/TimeOffReasonRequestBuilder.cs +++ b/src/generated/Teams/Item/Schedule/TimeOffReasons/Item/TimeOffReasonRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var timeOffReasonIdOption = new Option("--timeoffreason-id", description: "key: id of timeOffReason") { + var timeOffReasonIdOption = new Option("--time-off-reason-id", description: "key: id of timeOffReason") { }; timeOffReasonIdOption.IsRequired = true; command.AddOption(timeOffReasonIdOption); - command.SetHandler(async (string teamId, string timeOffReasonId) => { + command.SetHandler(async (string teamId, string timeOffReasonId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, timeOffReasonIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var timeOffReasonIdOption = new Option("--timeoffreason-id", description: "key: id of timeOffReason") { + var timeOffReasonIdOption = new Option("--time-off-reason-id", description: "key: id of timeOffReason") { }; timeOffReasonIdOption.IsRequired = true; command.AddOption(timeOffReasonIdOption); @@ -63,19 +62,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string teamId, string timeOffReasonId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string timeOffReasonId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, timeOffReasonIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, timeOffReasonIdOption, selectOption, outputOption); return command; } /// @@ -89,7 +87,7 @@ public Command BuildPatchCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var timeOffReasonIdOption = new Option("--timeoffreason-id", description: "key: id of timeOffReason") { + var timeOffReasonIdOption = new Option("--time-off-reason-id", description: "key: id of timeOffReason") { }; timeOffReasonIdOption.IsRequired = true; command.AddOption(timeOffReasonIdOption); @@ -97,14 +95,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string timeOffReasonId, string body) => { + command.SetHandler(async (string teamId, string timeOffReasonId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, timeOffReasonIdOption, bodyOption); return command; @@ -176,42 +173,6 @@ public RequestInformation CreatePatchRequestInformation(TimeOffReason body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The set of reasons for a time off in the schedule. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The set of reasons for a time off in the schedule. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The set of reasons for a time off in the schedule. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(TimeOffReason model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The set of reasons for a time off in the schedule. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Teams/Item/Schedule/TimeOffReasons/TimeOffReasonsRequestBuilder.cs b/src/generated/Teams/Item/Schedule/TimeOffReasons/TimeOffReasonsRequestBuilder.cs index 282188d1111..4ffb5546fcb 100644 --- a/src/generated/Teams/Item/Schedule/TimeOffReasons/TimeOffReasonsRequestBuilder.cs +++ b/src/generated/Teams/Item/Schedule/TimeOffReasons/TimeOffReasonsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Teams.Item.Schedule.TimeOffReasons.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class TimeOffReasonsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TimeOffReasonRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, bodyOption, outputOption); return command; } /// @@ -102,7 +100,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -112,15 +114,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -175,31 +172,6 @@ public RequestInformation CreatePostRequestInformation(TimeOffReason body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The set of reasons for a time off in the schedule. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The set of reasons for a time off in the schedule. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TimeOffReason model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The set of reasons for a time off in the schedule. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Teams/Item/Schedule/TimeOffRequests/Item/TimeOffRequestRequestBuilder.cs b/src/generated/Teams/Item/Schedule/TimeOffRequests/Item/TimeOffRequestRequestBuilder.cs index 081c1be7373..11d139181b9 100644 --- a/src/generated/Teams/Item/Schedule/TimeOffRequests/Item/TimeOffRequestRequestBuilder.cs +++ b/src/generated/Teams/Item/Schedule/TimeOffRequests/Item/TimeOffRequestRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var timeOffRequestIdOption = new Option("--timeoffrequest-id", description: "key: id of timeOffRequest") { + var timeOffRequestIdOption = new Option("--time-off-request-id", description: "key: id of timeOffRequest") { }; timeOffRequestIdOption.IsRequired = true; command.AddOption(timeOffRequestIdOption); - command.SetHandler(async (string teamId, string timeOffRequestId) => { + command.SetHandler(async (string teamId, string timeOffRequestId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, timeOffRequestIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var timeOffRequestIdOption = new Option("--timeoffrequest-id", description: "key: id of timeOffRequest") { + var timeOffRequestIdOption = new Option("--time-off-request-id", description: "key: id of timeOffRequest") { }; timeOffRequestIdOption.IsRequired = true; command.AddOption(timeOffRequestIdOption); @@ -63,19 +62,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string teamId, string timeOffRequestId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string timeOffRequestId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, timeOffRequestIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, timeOffRequestIdOption, selectOption, outputOption); return command; } /// @@ -89,7 +87,7 @@ public Command BuildPatchCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var timeOffRequestIdOption = new Option("--timeoffrequest-id", description: "key: id of timeOffRequest") { + var timeOffRequestIdOption = new Option("--time-off-request-id", description: "key: id of timeOffRequest") { }; timeOffRequestIdOption.IsRequired = true; command.AddOption(timeOffRequestIdOption); @@ -97,14 +95,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string timeOffRequestId, string body) => { + command.SetHandler(async (string teamId, string timeOffRequestId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, timeOffRequestIdOption, bodyOption); return command; @@ -176,42 +173,6 @@ public RequestInformation CreatePatchRequestInformation(TimeOffRequest body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property timeOffRequests for teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get timeOffRequests from teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property timeOffRequests in teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(TimeOffRequest model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get timeOffRequests from teams public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Teams/Item/Schedule/TimeOffRequests/TimeOffRequestsRequestBuilder.cs b/src/generated/Teams/Item/Schedule/TimeOffRequests/TimeOffRequestsRequestBuilder.cs index a469ef3d5bd..dae9d7b46d7 100644 --- a/src/generated/Teams/Item/Schedule/TimeOffRequests/TimeOffRequestsRequestBuilder.cs +++ b/src/generated/Teams/Item/Schedule/TimeOffRequests/TimeOffRequestsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Teams.Item.Schedule.TimeOffRequests.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class TimeOffRequestsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TimeOffRequestRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, bodyOption, outputOption); return command; } /// @@ -102,7 +100,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -112,15 +114,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -175,31 +172,6 @@ public RequestInformation CreatePostRequestInformation(TimeOffRequest body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get timeOffRequests from teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to timeOffRequests for teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TimeOffRequest model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get timeOffRequests from teams public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Teams/Item/Schedule/TimesOff/Item/TimeOffRequestBuilder.cs b/src/generated/Teams/Item/Schedule/TimesOff/Item/TimeOffRequestBuilder.cs index 65828769827..ef1537023f9 100644 --- a/src/generated/Teams/Item/Schedule/TimesOff/Item/TimeOffRequestBuilder.cs +++ b/src/generated/Teams/Item/Schedule/TimesOff/Item/TimeOffRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var timeOffIdOption = new Option("--timeoff-id", description: "key: id of timeOff") { + var timeOffIdOption = new Option("--time-off-id", description: "key: id of timeOff") { }; timeOffIdOption.IsRequired = true; command.AddOption(timeOffIdOption); - command.SetHandler(async (string teamId, string timeOffId) => { + command.SetHandler(async (string teamId, string timeOffId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, timeOffIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var timeOffIdOption = new Option("--timeoff-id", description: "key: id of timeOff") { + var timeOffIdOption = new Option("--time-off-id", description: "key: id of timeOff") { }; timeOffIdOption.IsRequired = true; command.AddOption(timeOffIdOption); @@ -63,19 +62,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string teamId, string timeOffId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string timeOffId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, timeOffIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, timeOffIdOption, selectOption, outputOption); return command; } /// @@ -89,7 +87,7 @@ public Command BuildPatchCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - var timeOffIdOption = new Option("--timeoff-id", description: "key: id of timeOff") { + var timeOffIdOption = new Option("--time-off-id", description: "key: id of timeOff") { }; timeOffIdOption.IsRequired = true; command.AddOption(timeOffIdOption); @@ -97,14 +95,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string timeOffId, string body) => { + command.SetHandler(async (string teamId, string timeOffId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, timeOffIdOption, bodyOption); return command; @@ -176,42 +173,6 @@ public RequestInformation CreatePatchRequestInformation(TimeOff body, Action - /// The instances of times off in the schedule. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The instances of times off in the schedule. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The instances of times off in the schedule. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(TimeOff model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The instances of times off in the schedule. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Teams/Item/Schedule/TimesOff/TimesOffRequestBuilder.cs b/src/generated/Teams/Item/Schedule/TimesOff/TimesOffRequestBuilder.cs index 4da743585e1..6bcc6be58fe 100644 --- a/src/generated/Teams/Item/Schedule/TimesOff/TimesOffRequestBuilder.cs +++ b/src/generated/Teams/Item/Schedule/TimesOff/TimesOffRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Teams.Item.Schedule.TimesOff.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class TimesOffRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TimeOffRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, bodyOption, outputOption); return command; } /// @@ -102,7 +100,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -112,15 +114,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -175,31 +172,6 @@ public RequestInformation CreatePostRequestInformation(TimeOff body, Action - /// The instances of times off in the schedule. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The instances of times off in the schedule. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TimeOff model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The instances of times off in the schedule. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Teams/Item/SendActivityNotification/SendActivityNotificationRequestBuilder.cs b/src/generated/Teams/Item/SendActivityNotification/SendActivityNotificationRequestBuilder.cs index 50625be3fd0..85633b8dc9b 100644 --- a/src/generated/Teams/Item/SendActivityNotification/SendActivityNotificationRequestBuilder.cs +++ b/src/generated/Teams/Item/SendActivityNotification/SendActivityNotificationRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { + command.SetHandler(async (string teamId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(SendActivityNotificationR requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action sendActivityNotification - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SendActivityNotificationRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Teams/Item/TeamRequestBuilder.cs b/src/generated/Teams/Item/TeamRequestBuilder.cs index 358794b3b56..9dd8595fe18 100644 --- a/src/generated/Teams/Item/TeamRequestBuilder.cs +++ b/src/generated/Teams/Item/TeamRequestBuilder.cs @@ -14,10 +14,10 @@ using ApiSdk.Teams.Item.Unarchive; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,6 +41,9 @@ public Command BuildArchiveCommand() { public Command BuildChannelsCommand() { var command = new Command("channels"); var builder = new ApiSdk.Teams.Item.Channels.ChannelsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -68,11 +71,10 @@ public Command BuildDeleteCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - command.SetHandler(async (string teamId) => { + command.SetHandler(async (string teamId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption); return command; @@ -98,20 +100,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildGroupCommand() { @@ -124,6 +125,9 @@ public Command BuildGroupCommand() { public Command BuildInstalledAppsCommand() { var command = new Command("installed-apps"); var builder = new ApiSdk.Teams.Item.InstalledApps.InstalledAppsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -132,6 +136,9 @@ public Command BuildMembersCommand() { var command = new Command("members"); var builder = new ApiSdk.Teams.Item.Members.MembersRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -139,6 +146,9 @@ public Command BuildMembersCommand() { public Command BuildOperationsCommand() { var command = new Command("operations"); var builder = new ApiSdk.Teams.Item.Operations.OperationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -158,14 +168,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { + command.SetHandler(async (string teamId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption, bodyOption); return command; @@ -289,42 +298,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from teams by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Team model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from teams by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/Template/@Ref/@Ref.cs b/src/generated/Teams/Item/Template/@Ref/@Ref.cs deleted file mode 100644 index 6bc698f10aa..00000000000 --- a/src/generated/Teams/Item/Template/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Teams.Item.Template.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Teams/Item/Template/@Ref/RefRequestBuilder.cs b/src/generated/Teams/Item/Template/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 536f0bbaebc..00000000000 --- a/src/generated/Teams/Item/Template/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Teams.Item.Template.@Ref { - /// Builds and executes requests for operations under \teams\{team-id}\template\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The template this team was created from. See available templates. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The template this team was created from. See available templates."; - // Create options for all the parameters - var teamIdOption = new Option("--team-id", description: "key: id of team") { - }; - teamIdOption.IsRequired = true; - command.AddOption(teamIdOption); - command.SetHandler(async (string teamId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, teamIdOption); - return command; - } - /// - /// The template this team was created from. See available templates. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The template this team was created from. See available templates."; - // Create options for all the parameters - var teamIdOption = new Option("--team-id", description: "key: id of team") { - }; - teamIdOption.IsRequired = true; - command.AddOption(teamIdOption); - command.SetHandler(async (string teamId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption); - return command; - } - /// - /// The template this team was created from. See available templates. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The template this team was created from. See available templates."; - // Create options for all the parameters - var teamIdOption = new Option("--team-id", description: "key: id of team") { - }; - teamIdOption.IsRequired = true; - command.AddOption(teamIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string teamId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, teamIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/teams/{team_id}/template/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The template this team was created from. See available templates. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The template this team was created from. See available templates. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The template this team was created from. See available templates. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Teams.Item.Template.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The template this team was created from. See available templates. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The template this team was created from. See available templates. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The template this team was created from. See available templates. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Teams.Item.Template.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Teams/Item/Template/Ref/Ref.cs b/src/generated/Teams/Item/Template/Ref/Ref.cs new file mode 100644 index 00000000000..d8f857462dd --- /dev/null +++ b/src/generated/Teams/Item/Template/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Teams.Item.Template.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Teams/Item/Template/Ref/RefRequestBuilder.cs b/src/generated/Teams/Item/Template/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..e7bf4c684c0 --- /dev/null +++ b/src/generated/Teams/Item/Template/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Teams.Item.Template.Ref { + /// Builds and executes requests for operations under \teams\{team-id}\template\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The template this team was created from. See available templates. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The template this team was created from. See available templates."; + // Create options for all the parameters + var teamIdOption = new Option("--team-id", description: "key: id of team") { + }; + teamIdOption.IsRequired = true; + command.AddOption(teamIdOption); + command.SetHandler(async (string teamId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, teamIdOption); + return command; + } + /// + /// The template this team was created from. See available templates. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The template this team was created from. See available templates."; + // Create options for all the parameters + var teamIdOption = new Option("--team-id", description: "key: id of team") { + }; + teamIdOption.IsRequired = true; + command.AddOption(teamIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, outputOption); + return command; + } + /// + /// The template this team was created from. See available templates. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The template this team was created from. See available templates."; + // Create options for all the parameters + var teamIdOption = new Option("--team-id", description: "key: id of team") { + }; + teamIdOption.IsRequired = true; + command.AddOption(teamIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string teamId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, teamIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/teams/{team_id}/template/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The template this team was created from. See available templates. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The template this team was created from. See available templates. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The template this team was created from. See available templates. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Teams.Item.Template.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Teams/Item/Template/TemplateRequestBuilder.cs b/src/generated/Teams/Item/Template/TemplateRequestBuilder.cs index 7cfc6ce4b0c..2cfdc96e617 100644 --- a/src/generated/Teams/Item/Template/TemplateRequestBuilder.cs +++ b/src/generated/Teams/Item/Template/TemplateRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Teams.Item.Template.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Teams.Item.Template.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Teams.Item.Template.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The template this team was created from. See available templates. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The template this team was created from. See available templates. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teams/Item/Unarchive/UnarchiveRequestBuilder.cs b/src/generated/Teams/Item/Unarchive/UnarchiveRequestBuilder.cs index 5c628fc3fc6..1ab0303a987 100644 --- a/src/generated/Teams/Item/Unarchive/UnarchiveRequestBuilder.cs +++ b/src/generated/Teams/Item/Unarchive/UnarchiveRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,10 @@ public Command BuildPostCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - command.SetHandler(async (string teamId) => { + command.SetHandler(async (string teamId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action unarchive - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Teams/TeamsRequestBuilder.cs b/src/generated/Teams/TeamsRequestBuilder.cs index 8c652983753..66f97b0dd53 100644 --- a/src/generated/Teams/TeamsRequestBuilder.cs +++ b/src/generated/Teams/TeamsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Teams.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,24 +23,23 @@ public class TeamsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TeamRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildArchiveCommand(), - builder.BuildChannelsCommand(), - builder.BuildCloneCommand(), - builder.BuildCompleteMigrationCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildGroupCommand(), - builder.BuildInstalledAppsCommand(), - builder.BuildMembersCommand(), - builder.BuildOperationsCommand(), - builder.BuildPatchCommand(), - builder.BuildPrimaryChannelCommand(), - builder.BuildScheduleCommand(), - builder.BuildSendActivityNotificationCommand(), - builder.BuildTemplateCommand(), - builder.BuildUnarchiveCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildArchiveCommand()); + commands.Add(builder.BuildChannelsCommand()); + commands.Add(builder.BuildCloneCommand()); + commands.Add(builder.BuildCompleteMigrationCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildGroupCommand()); + commands.Add(builder.BuildInstalledAppsCommand()); + commands.Add(builder.BuildMembersCommand()); + commands.Add(builder.BuildOperationsCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPrimaryChannelCommand()); + commands.Add(builder.BuildScheduleCommand()); + commands.Add(builder.BuildSendActivityNotificationCommand()); + commands.Add(builder.BuildTemplateCommand()); + commands.Add(builder.BuildUnarchiveCommand()); return commands; } /// @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -113,7 +111,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -124,15 +126,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -193,31 +190,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G public GetAllMessagesRequestBuilder GetAllMessages() { return new GetAllMessagesRequestBuilder(PathParameters, RequestAdapter); } - /// - /// Get entities from teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to teams - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Team model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from teams public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/TeamsTemplates/Item/TeamsTemplateRequestBuilder.cs b/src/generated/TeamsTemplates/Item/TeamsTemplateRequestBuilder.cs index 103a366d906..052f5dfd839 100644 --- a/src/generated/TeamsTemplates/Item/TeamsTemplateRequestBuilder.cs +++ b/src/generated/TeamsTemplates/Item/TeamsTemplateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete entity from teamsTemplates"; // Create options for all the parameters - var teamsTemplateIdOption = new Option("--teamstemplate-id", description: "key: id of teamsTemplate") { + var teamsTemplateIdOption = new Option("--teams-template-id", description: "key: id of teamsTemplate") { }; teamsTemplateIdOption.IsRequired = true; command.AddOption(teamsTemplateIdOption); - command.SetHandler(async (string teamsTemplateId) => { + command.SetHandler(async (string teamsTemplateId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamsTemplateIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get entity from teamsTemplates by key"; // Create options for all the parameters - var teamsTemplateIdOption = new Option("--teamstemplate-id", description: "key: id of teamsTemplate") { + var teamsTemplateIdOption = new Option("--teams-template-id", description: "key: id of teamsTemplate") { }; teamsTemplateIdOption.IsRequired = true; command.AddOption(teamsTemplateIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string teamsTemplateId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string teamsTemplateId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, teamsTemplateIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, teamsTemplateIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update entity in teamsTemplates"; // Create options for all the parameters - var teamsTemplateIdOption = new Option("--teamstemplate-id", description: "key: id of teamsTemplate") { + var teamsTemplateIdOption = new Option("--teams-template-id", description: "key: id of teamsTemplate") { }; teamsTemplateIdOption.IsRequired = true; command.AddOption(teamsTemplateIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string teamsTemplateId, string body) => { + command.SetHandler(async (string teamsTemplateId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, teamsTemplateIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(TeamsTemplate body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete entity from teamsTemplates - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from teamsTemplates by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in teamsTemplates - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(TeamsTemplate model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entity from teamsTemplates by key public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/TeamsTemplates/TeamsTemplatesRequestBuilder.cs b/src/generated/TeamsTemplates/TeamsTemplatesRequestBuilder.cs index 01fd816d723..22c2371cf45 100644 --- a/src/generated/TeamsTemplates/TeamsTemplatesRequestBuilder.cs +++ b/src/generated/TeamsTemplates/TeamsTemplatesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.TeamsTemplates.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class TeamsTemplatesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TeamsTemplateRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(TeamsTemplate body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get entities from teamsTemplates - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to teamsTemplates - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TeamsTemplate model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from teamsTemplates public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Teamwork/TeamworkRequestBuilder.cs b/src/generated/Teamwork/TeamworkRequestBuilder.cs index 835528d89b4..61a69d9db06 100644 --- a/src/generated/Teamwork/TeamworkRequestBuilder.cs +++ b/src/generated/Teamwork/TeamworkRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Teamwork.WorkforceIntegrations; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,20 +37,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, selectOption, expandOption, outputOption); return command; } /// @@ -64,14 +63,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -79,6 +77,9 @@ public Command BuildPatchCommand() { public Command BuildWorkforceIntegrationsCommand() { var command = new Command("workforce-integrations"); var builder = new ApiSdk.Teamwork.WorkforceIntegrations.WorkforceIntegrationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -135,31 +136,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get teamwork - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update teamwork - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Teamwork model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get teamwork public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teamwork/WorkforceIntegrations/Item/WorkforceIntegrationRequestBuilder.cs b/src/generated/Teamwork/WorkforceIntegrations/Item/WorkforceIntegrationRequestBuilder.cs index 416854a6172..eaf35019aeb 100644 --- a/src/generated/Teamwork/WorkforceIntegrations/Item/WorkforceIntegrationRequestBuilder.cs +++ b/src/generated/Teamwork/WorkforceIntegrations/Item/WorkforceIntegrationRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property workforceIntegrations for teamwork"; // Create options for all the parameters - var workforceIntegrationIdOption = new Option("--workforceintegration-id", description: "key: id of workforceIntegration") { + var workforceIntegrationIdOption = new Option("--workforce-integration-id", description: "key: id of workforceIntegration") { }; workforceIntegrationIdOption.IsRequired = true; command.AddOption(workforceIntegrationIdOption); - command.SetHandler(async (string workforceIntegrationId) => { + command.SetHandler(async (string workforceIntegrationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, workforceIntegrationIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get workforceIntegrations from teamwork"; // Create options for all the parameters - var workforceIntegrationIdOption = new Option("--workforceintegration-id", description: "key: id of workforceIntegration") { + var workforceIntegrationIdOption = new Option("--workforce-integration-id", description: "key: id of workforceIntegration") { }; workforceIntegrationIdOption.IsRequired = true; command.AddOption(workforceIntegrationIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string workforceIntegrationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string workforceIntegrationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, workforceIntegrationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, workforceIntegrationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property workforceIntegrations in teamwork"; // Create options for all the parameters - var workforceIntegrationIdOption = new Option("--workforceintegration-id", description: "key: id of workforceIntegration") { + var workforceIntegrationIdOption = new Option("--workforce-integration-id", description: "key: id of workforceIntegration") { }; workforceIntegrationIdOption.IsRequired = true; command.AddOption(workforceIntegrationIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string workforceIntegrationId, string body) => { + command.SetHandler(async (string workforceIntegrationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, workforceIntegrationIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(WorkforceIntegration bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property workforceIntegrations for teamwork - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get workforceIntegrations from teamwork - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property workforceIntegrations in teamwork - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkforceIntegration model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get workforceIntegrations from teamwork public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Teamwork/WorkforceIntegrations/WorkforceIntegrationsRequestBuilder.cs b/src/generated/Teamwork/WorkforceIntegrations/WorkforceIntegrationsRequestBuilder.cs index fcc86c766b6..7457a4ad600 100644 --- a/src/generated/Teamwork/WorkforceIntegrations/WorkforceIntegrationsRequestBuilder.cs +++ b/src/generated/Teamwork/WorkforceIntegrations/WorkforceIntegrationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Teamwork.WorkforceIntegrations.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class WorkforceIntegrationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new WorkforceIntegrationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,21 +39,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -110,15 +112,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -173,31 +170,6 @@ public RequestInformation CreatePostRequestInformation(WorkforceIntegration body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get workforceIntegrations from teamwork - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to workforceIntegrations for teamwork - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkforceIntegration model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get workforceIntegrations from teamwork public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Delta/DeltaRequestBuilder.cs index f6a95970ff4..408632432b5 100644 --- a/src/generated/Users/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - command.SetHandler(async () => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, outputOption); return command; } /// @@ -67,16 +66,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs b/src/generated/Users/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs deleted file mode 100644 index 63e7e0e09f9..00000000000 --- a/src/generated/Users/GetAvailableExtensionProperties/GetAvailableExtensionProperties.cs +++ /dev/null @@ -1,45 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.GetAvailableExtensionProperties { - public class GetAvailableExtensionProperties : DirectoryObject, IParsable { - /// Display name of the application object on which this extension property is defined. Read-only. - public string AppDisplayName { get; set; } - /// Specifies the data type of the value the extension property can hold. Following values are supported. Not nullable. Binary - 256 bytes maximumBooleanDateTime - Must be specified in ISO 8601 format. Will be stored in UTC.Integer - 32-bit value.LargeInteger - 64-bit value.String - 256 characters maximum - public string DataType { get; set; } - /// Indicates if this extension property was sycned from onpremises directory using Azure AD Connect. Read-only. - public bool? IsSyncedFromOnPremises { get; set; } - /// Name of the extension property. Not nullable. - public string Name { get; set; } - /// Following values are supported. Not nullable. UserGroupOrganizationDeviceApplication - public List TargetObjects { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"appDisplayName", (o,n) => { (o as GetAvailableExtensionProperties).AppDisplayName = n.GetStringValue(); } }, - {"dataType", (o,n) => { (o as GetAvailableExtensionProperties).DataType = n.GetStringValue(); } }, - {"isSyncedFromOnPremises", (o,n) => { (o as GetAvailableExtensionProperties).IsSyncedFromOnPremises = n.GetBoolValue(); } }, - {"name", (o,n) => { (o as GetAvailableExtensionProperties).Name = n.GetStringValue(); } }, - {"targetObjects", (o,n) => { (o as GetAvailableExtensionProperties).TargetObjects = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteStringValue("appDisplayName", AppDisplayName); - writer.WriteStringValue("dataType", DataType); - writer.WriteBoolValue("isSyncedFromOnPremises", IsSyncedFromOnPremises); - writer.WriteStringValue("name", Name); - writer.WriteCollectionOfPrimitiveValues("targetObjects", TargetObjects); - } - } -} diff --git a/src/generated/Users/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs b/src/generated/Users/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs index 0249674bb3a..8fb9010215d 100644 --- a/src/generated/Users/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs +++ b/src/generated/Users/GetAvailableExtensionProperties/GetAvailableExtensionPropertiesRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(GetAvailableExtensionProp requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getAvailableExtensionProperties - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetAvailableExtensionPropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/GetByIds/GetByIds.cs b/src/generated/Users/GetByIds/GetByIds.cs deleted file mode 100644 index 9634825c5f5..00000000000 --- a/src/generated/Users/GetByIds/GetByIds.cs +++ /dev/null @@ -1,28 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.GetByIds { - public class GetByIds : Entity, IParsable { - public DateTimeOffset? DeletedDateTime { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"deletedDateTime", (o,n) => { (o as GetByIds).DeletedDateTime = n.GetDateTimeOffsetValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteDateTimeOffsetValue("deletedDateTime", DeletedDateTime); - } - } -} diff --git a/src/generated/Users/GetByIds/GetByIdsRequestBuilder.cs b/src/generated/Users/GetByIds/GetByIdsRequestBuilder.cs index a2d7550055d..770a219151d 100644 --- a/src/generated/Users/GetByIds/GetByIdsRequestBuilder.cs +++ b/src/generated/Users/GetByIds/GetByIdsRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,21 +30,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -77,18 +77,5 @@ public RequestInformation CreatePostRequestInformation(GetByIdsRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getByIds - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetByIdsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Activities/ActivitiesRequestBuilder.cs b/src/generated/Users/Item/Activities/ActivitiesRequestBuilder.cs index 92d7234d820..981b9f484ee 100644 --- a/src/generated/Users/Item/Activities/ActivitiesRequestBuilder.cs +++ b/src/generated/Users/Item/Activities/ActivitiesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Activities.Recent; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,12 +23,11 @@ public class ActivitiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new UserActivityRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildHistoryItemsCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildHistoryItemsCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -46,21 +45,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -109,7 +107,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -120,15 +122,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(UserActivity body, Action return requestInfo; } /// - /// The user's activities across devices. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's activities across devices. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UserActivity model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \users\{user-id}\activities\microsoft.graph.recent() /// public RecentRequestBuilder Recent() { diff --git a/src/generated/Users/Item/Activities/Item/HistoryItems/HistoryItemsRequestBuilder.cs b/src/generated/Users/Item/Activities/Item/HistoryItems/HistoryItemsRequestBuilder.cs index 470a0331d94..262baa16a5a 100644 --- a/src/generated/Users/Item/Activities/Item/HistoryItems/HistoryItemsRequestBuilder.cs +++ b/src/generated/Users/Item/Activities/Item/HistoryItems/HistoryItemsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Activities.Item.HistoryItems.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class HistoryItemsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ActivityHistoryItemRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildActivityCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildActivityCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,7 +40,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var userActivityIdOption = new Option("--useractivity-id", description: "key: id of userActivity") { + var userActivityIdOption = new Option("--user-activity-id", description: "key: id of userActivity") { }; userActivityIdOption.IsRequired = true; command.AddOption(userActivityIdOption); @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string userActivityId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string userActivityId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, userActivityIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, userActivityIdOption, bodyOption, outputOption); return command; } /// @@ -77,7 +75,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var userActivityIdOption = new Option("--useractivity-id", description: "key: id of userActivity") { + var userActivityIdOption = new Option("--user-activity-id", description: "key: id of userActivity") { }; userActivityIdOption.IsRequired = true; command.AddOption(userActivityIdOption); @@ -116,7 +114,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string userActivityId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string userActivityId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -127,15 +129,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, userActivityIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, userActivityIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -190,31 +187,6 @@ public RequestInformation CreatePostRequestInformation(ActivityHistoryItem body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Optional. NavigationProperty/Containment; navigation property to the activity's historyItems. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Optional. NavigationProperty/Containment; navigation property to the activity's historyItems. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ActivityHistoryItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Optional. NavigationProperty/Containment; navigation property to the activity's historyItems. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Activities/Item/HistoryItems/Item/Activity/@Ref/@Ref.cs b/src/generated/Users/Item/Activities/Item/HistoryItems/Item/Activity/@Ref/@Ref.cs deleted file mode 100644 index d6d9ea3b85d..00000000000 --- a/src/generated/Users/Item/Activities/Item/HistoryItems/Item/Activity/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.Activities.Item.HistoryItems.Item.Activity.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/Activities/Item/HistoryItems/Item/Activity/@Ref/RefRequestBuilder.cs b/src/generated/Users/Item/Activities/Item/HistoryItems/Item/Activity/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 165cdfdf918..00000000000 --- a/src/generated/Users/Item/Activities/Item/HistoryItems/Item/Activity/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,214 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Users.Item.Activities.Item.HistoryItems.Item.Activity.@Ref { - /// Builds and executes requests for operations under \users\{user-id}\activities\{userActivity-id}\historyItems\{activityHistoryItem-id}\activity\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Optional. NavigationProperty/Containment; navigation property to the associated activity. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Optional. NavigationProperty/Containment; navigation property to the associated activity."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var userActivityIdOption = new Option("--useractivity-id", description: "key: id of userActivity") { - }; - userActivityIdOption.IsRequired = true; - command.AddOption(userActivityIdOption); - var activityHistoryItemIdOption = new Option("--activityhistoryitem-id", description: "key: id of activityHistoryItem") { - }; - activityHistoryItemIdOption.IsRequired = true; - command.AddOption(activityHistoryItemIdOption); - command.SetHandler(async (string userId, string userActivityId, string activityHistoryItemId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userIdOption, userActivityIdOption, activityHistoryItemIdOption); - return command; - } - /// - /// Optional. NavigationProperty/Containment; navigation property to the associated activity. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Optional. NavigationProperty/Containment; navigation property to the associated activity."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var userActivityIdOption = new Option("--useractivity-id", description: "key: id of userActivity") { - }; - userActivityIdOption.IsRequired = true; - command.AddOption(userActivityIdOption); - var activityHistoryItemIdOption = new Option("--activityhistoryitem-id", description: "key: id of activityHistoryItem") { - }; - activityHistoryItemIdOption.IsRequired = true; - command.AddOption(activityHistoryItemIdOption); - command.SetHandler(async (string userId, string userActivityId, string activityHistoryItemId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, userActivityIdOption, activityHistoryItemIdOption); - return command; - } - /// - /// Optional. NavigationProperty/Containment; navigation property to the associated activity. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Optional. NavigationProperty/Containment; navigation property to the associated activity."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var userActivityIdOption = new Option("--useractivity-id", description: "key: id of userActivity") { - }; - userActivityIdOption.IsRequired = true; - command.AddOption(userActivityIdOption); - var activityHistoryItemIdOption = new Option("--activityhistoryitem-id", description: "key: id of activityHistoryItem") { - }; - activityHistoryItemIdOption.IsRequired = true; - command.AddOption(activityHistoryItemIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string userId, string userActivityId, string activityHistoryItemId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userIdOption, userActivityIdOption, activityHistoryItemIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/activities/{userActivity_id}/historyItems/{activityHistoryItem_id}/activity/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Optional. NavigationProperty/Containment; navigation property to the associated activity. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Optional. NavigationProperty/Containment; navigation property to the associated activity. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Optional. NavigationProperty/Containment; navigation property to the associated activity. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Users.Item.Activities.Item.HistoryItems.Item.Activity.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Optional. NavigationProperty/Containment; navigation property to the associated activity. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Optional. NavigationProperty/Containment; navigation property to the associated activity. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Optional. NavigationProperty/Containment; navigation property to the associated activity. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Users.Item.Activities.Item.HistoryItems.Item.Activity.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Users/Item/Activities/Item/HistoryItems/Item/Activity/ActivityRequestBuilder.cs b/src/generated/Users/Item/Activities/Item/HistoryItems/Item/Activity/ActivityRequestBuilder.cs index d7c7e7a45b1..8cbfbdcf400 100644 --- a/src/generated/Users/Item/Activities/Item/HistoryItems/Item/Activity/ActivityRequestBuilder.cs +++ b/src/generated/Users/Item/Activities/Item/HistoryItems/Item/Activity/ActivityRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Activities.Item.HistoryItems.Item.Activity.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,11 +31,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var userActivityIdOption = new Option("--useractivity-id", description: "key: id of userActivity") { + var userActivityIdOption = new Option("--user-activity-id", description: "key: id of userActivity") { }; userActivityIdOption.IsRequired = true; command.AddOption(userActivityIdOption); - var activityHistoryItemIdOption = new Option("--activityhistoryitem-id", description: "key: id of activityHistoryItem") { + var activityHistoryItemIdOption = new Option("--activity-history-item-id", description: "key: id of activityHistoryItem") { }; activityHistoryItemIdOption.IsRequired = true; command.AddOption(activityHistoryItemIdOption); @@ -49,25 +49,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string userActivityId, string activityHistoryItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string userActivityId, string activityHistoryItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, userActivityIdOption, activityHistoryItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, userActivityIdOption, activityHistoryItemIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Users.Item.Activities.Item.HistoryItems.Item.Activity.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Users.Item.Activities.Item.HistoryItems.Item.Activity.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -107,18 +106,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Optional. NavigationProperty/Containment; navigation property to the associated activity. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Optional. NavigationProperty/Containment; navigation property to the associated activity. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Activities/Item/HistoryItems/Item/Activity/Ref/Ref.cs b/src/generated/Users/Item/Activities/Item/HistoryItems/Item/Activity/Ref/Ref.cs new file mode 100644 index 00000000000..9576176f139 --- /dev/null +++ b/src/generated/Users/Item/Activities/Item/HistoryItems/Item/Activity/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.Activities.Item.HistoryItems.Item.Activity.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/Activities/Item/HistoryItems/Item/Activity/Ref/RefRequestBuilder.cs b/src/generated/Users/Item/Activities/Item/HistoryItems/Item/Activity/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..48d6bf8fb16 --- /dev/null +++ b/src/generated/Users/Item/Activities/Item/HistoryItems/Item/Activity/Ref/RefRequestBuilder.cs @@ -0,0 +1,176 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Users.Item.Activities.Item.HistoryItems.Item.Activity.Ref { + /// Builds and executes requests for operations under \users\{user-id}\activities\{userActivity-id}\historyItems\{activityHistoryItem-id}\activity\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Optional. NavigationProperty/Containment; navigation property to the associated activity. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Optional. NavigationProperty/Containment; navigation property to the associated activity."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var userActivityIdOption = new Option("--user-activity-id", description: "key: id of userActivity") { + }; + userActivityIdOption.IsRequired = true; + command.AddOption(userActivityIdOption); + var activityHistoryItemIdOption = new Option("--activity-history-item-id", description: "key: id of activityHistoryItem") { + }; + activityHistoryItemIdOption.IsRequired = true; + command.AddOption(activityHistoryItemIdOption); + command.SetHandler(async (string userId, string userActivityId, string activityHistoryItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, userIdOption, userActivityIdOption, activityHistoryItemIdOption); + return command; + } + /// + /// Optional. NavigationProperty/Containment; navigation property to the associated activity. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Optional. NavigationProperty/Containment; navigation property to the associated activity."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var userActivityIdOption = new Option("--user-activity-id", description: "key: id of userActivity") { + }; + userActivityIdOption.IsRequired = true; + command.AddOption(userActivityIdOption); + var activityHistoryItemIdOption = new Option("--activity-history-item-id", description: "key: id of activityHistoryItem") { + }; + activityHistoryItemIdOption.IsRequired = true; + command.AddOption(activityHistoryItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string userActivityId, string activityHistoryItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, userActivityIdOption, activityHistoryItemIdOption, outputOption); + return command; + } + /// + /// Optional. NavigationProperty/Containment; navigation property to the associated activity. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Optional. NavigationProperty/Containment; navigation property to the associated activity."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var userActivityIdOption = new Option("--user-activity-id", description: "key: id of userActivity") { + }; + userActivityIdOption.IsRequired = true; + command.AddOption(userActivityIdOption); + var activityHistoryItemIdOption = new Option("--activity-history-item-id", description: "key: id of activityHistoryItem") { + }; + activityHistoryItemIdOption.IsRequired = true; + command.AddOption(activityHistoryItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string userId, string userActivityId, string activityHistoryItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, userIdOption, userActivityIdOption, activityHistoryItemIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/users/{user_id}/activities/{userActivity_id}/historyItems/{activityHistoryItem_id}/activity/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Optional. NavigationProperty/Containment; navigation property to the associated activity. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Optional. NavigationProperty/Containment; navigation property to the associated activity. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Optional. NavigationProperty/Containment; navigation property to the associated activity. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Users.Item.Activities.Item.HistoryItems.Item.Activity.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Users/Item/Activities/Item/HistoryItems/Item/ActivityHistoryItemRequestBuilder.cs b/src/generated/Users/Item/Activities/Item/HistoryItems/Item/ActivityHistoryItemRequestBuilder.cs index 4555474c50d..bbd3250b917 100644 --- a/src/generated/Users/Item/Activities/Item/HistoryItems/Item/ActivityHistoryItemRequestBuilder.cs +++ b/src/generated/Users/Item/Activities/Item/HistoryItems/Item/ActivityHistoryItemRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Activities.Item.HistoryItems.Item.Activity; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,19 +38,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var userActivityIdOption = new Option("--useractivity-id", description: "key: id of userActivity") { + var userActivityIdOption = new Option("--user-activity-id", description: "key: id of userActivity") { }; userActivityIdOption.IsRequired = true; command.AddOption(userActivityIdOption); - var activityHistoryItemIdOption = new Option("--activityhistoryitem-id", description: "key: id of activityHistoryItem") { + var activityHistoryItemIdOption = new Option("--activity-history-item-id", description: "key: id of activityHistoryItem") { }; activityHistoryItemIdOption.IsRequired = true; command.AddOption(activityHistoryItemIdOption); - command.SetHandler(async (string userId, string userActivityId, string activityHistoryItemId) => { + command.SetHandler(async (string userId, string userActivityId, string activityHistoryItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, userActivityIdOption, activityHistoryItemIdOption); return command; @@ -66,11 +65,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var userActivityIdOption = new Option("--useractivity-id", description: "key: id of userActivity") { + var userActivityIdOption = new Option("--user-activity-id", description: "key: id of userActivity") { }; userActivityIdOption.IsRequired = true; command.AddOption(userActivityIdOption); - var activityHistoryItemIdOption = new Option("--activityhistoryitem-id", description: "key: id of activityHistoryItem") { + var activityHistoryItemIdOption = new Option("--activity-history-item-id", description: "key: id of activityHistoryItem") { }; activityHistoryItemIdOption.IsRequired = true; command.AddOption(activityHistoryItemIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string userActivityId, string activityHistoryItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string userActivityId, string activityHistoryItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, userActivityIdOption, activityHistoryItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, userActivityIdOption, activityHistoryItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,11 +109,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var userActivityIdOption = new Option("--useractivity-id", description: "key: id of userActivity") { + var userActivityIdOption = new Option("--user-activity-id", description: "key: id of userActivity") { }; userActivityIdOption.IsRequired = true; command.AddOption(userActivityIdOption); - var activityHistoryItemIdOption = new Option("--activityhistoryitem-id", description: "key: id of activityHistoryItem") { + var activityHistoryItemIdOption = new Option("--activity-history-item-id", description: "key: id of activityHistoryItem") { }; activityHistoryItemIdOption.IsRequired = true; command.AddOption(activityHistoryItemIdOption); @@ -123,14 +121,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string userActivityId, string activityHistoryItemId, string body) => { + command.SetHandler(async (string userId, string userActivityId, string activityHistoryItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, userActivityIdOption, activityHistoryItemIdOption, bodyOption); return command; @@ -202,42 +199,6 @@ public RequestInformation CreatePatchRequestInformation(ActivityHistoryItem body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Optional. NavigationProperty/Containment; navigation property to the activity's historyItems. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Optional. NavigationProperty/Containment; navigation property to the activity's historyItems. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Optional. NavigationProperty/Containment; navigation property to the activity's historyItems. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ActivityHistoryItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Optional. NavigationProperty/Containment; navigation property to the activity's historyItems. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Activities/Item/UserActivityRequestBuilder.cs b/src/generated/Users/Item/Activities/Item/UserActivityRequestBuilder.cs index a279f2f6558..e31f1eacdc2 100644 --- a/src/generated/Users/Item/Activities/Item/UserActivityRequestBuilder.cs +++ b/src/generated/Users/Item/Activities/Item/UserActivityRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Activities.Item.HistoryItems; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,15 +31,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var userActivityIdOption = new Option("--useractivity-id", description: "key: id of userActivity") { + var userActivityIdOption = new Option("--user-activity-id", description: "key: id of userActivity") { }; userActivityIdOption.IsRequired = true; command.AddOption(userActivityIdOption); - command.SetHandler(async (string userId, string userActivityId) => { + command.SetHandler(async (string userId, string userActivityId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, userActivityIdOption); return command; @@ -55,7 +54,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var userActivityIdOption = new Option("--useractivity-id", description: "key: id of userActivity") { + var userActivityIdOption = new Option("--user-activity-id", description: "key: id of userActivity") { }; userActivityIdOption.IsRequired = true; command.AddOption(userActivityIdOption); @@ -69,25 +68,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string userActivityId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string userActivityId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, userActivityIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, userActivityIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildHistoryItemsCommand() { var command = new Command("history-items"); var builder = new ApiSdk.Users.Item.Activities.Item.HistoryItems.HistoryItemsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -103,7 +104,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var userActivityIdOption = new Option("--useractivity-id", description: "key: id of userActivity") { + var userActivityIdOption = new Option("--user-activity-id", description: "key: id of userActivity") { }; userActivityIdOption.IsRequired = true; command.AddOption(userActivityIdOption); @@ -111,14 +112,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string userActivityId, string body) => { + command.SetHandler(async (string userId, string userActivityId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, userActivityIdOption, bodyOption); return command; @@ -190,42 +190,6 @@ public RequestInformation CreatePatchRequestInformation(UserActivity body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user's activities across devices. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's activities across devices. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's activities across devices. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(UserActivity model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's activities across devices. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Activities/Recent/RecentRequestBuilder.cs b/src/generated/Users/Item/Activities/Recent/RecentRequestBuilder.cs index 0dbadd7a908..65af6572826 100644 --- a/src/generated/Users/Item/Activities/Recent/RecentRequestBuilder.cs +++ b/src/generated/Users/Item/Activities/Recent/RecentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +29,17 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function recent - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/AgreementAcceptances/@Ref/@Ref.cs b/src/generated/Users/Item/AgreementAcceptances/@Ref/@Ref.cs deleted file mode 100644 index 24d1792fc86..00000000000 --- a/src/generated/Users/Item/AgreementAcceptances/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.AgreementAcceptances.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/AgreementAcceptances/@Ref/RefRequestBuilder.cs b/src/generated/Users/Item/AgreementAcceptances/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 4fe9c57f763..00000000000 --- a/src/generated/Users/Item/AgreementAcceptances/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Users.Item.AgreementAcceptances.@Ref { - /// Builds and executes requests for operations under \users\{user-id}\agreementAcceptances\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The user's terms of use acceptance statuses. Read-only. Nullable. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The user's terms of use acceptance statuses. Read-only. Nullable."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The user's terms of use acceptance statuses. Read-only. Nullable. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The user's terms of use acceptance statuses. Read-only. Nullable."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/agreementAcceptances/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The user's terms of use acceptance statuses. Read-only. Nullable. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The user's terms of use acceptance statuses. Read-only. Nullable. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Users.Item.AgreementAcceptances.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The user's terms of use acceptance statuses. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's terms of use acceptance statuses. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Users.Item.AgreementAcceptances.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The user's terms of use acceptance statuses. Read-only. Nullable. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Users/Item/AgreementAcceptances/@Ref/RefResponse.cs b/src/generated/Users/Item/AgreementAcceptances/@Ref/RefResponse.cs deleted file mode 100644 index 7603541fcdf..00000000000 --- a/src/generated/Users/Item/AgreementAcceptances/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.AgreementAcceptances.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/AgreementAcceptances/AgreementAcceptancesRequestBuilder.cs b/src/generated/Users/Item/AgreementAcceptances/AgreementAcceptancesRequestBuilder.cs index 2a0df373994..04889f5dbc4 100644 --- a/src/generated/Users/Item/AgreementAcceptances/AgreementAcceptancesRequestBuilder.cs +++ b/src/generated/Users/Item/AgreementAcceptances/AgreementAcceptancesRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Users.Item.AgreementAcceptances.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Users.Item.AgreementAcceptances.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Users.Item.AgreementAcceptances.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user's terms of use acceptance statuses. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's terms of use acceptance statuses. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/AgreementAcceptances/Ref/Ref.cs b/src/generated/Users/Item/AgreementAcceptances/Ref/Ref.cs new file mode 100644 index 00000000000..2d9cf1bbc6d --- /dev/null +++ b/src/generated/Users/Item/AgreementAcceptances/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.AgreementAcceptances.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/AgreementAcceptances/Ref/RefRequestBuilder.cs b/src/generated/Users/Item/AgreementAcceptances/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..7d3c48b31a4 --- /dev/null +++ b/src/generated/Users/Item/AgreementAcceptances/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Users.Item.AgreementAcceptances.Ref { + /// Builds and executes requests for operations under \users\{user-id}\agreementAcceptances\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The user's terms of use acceptance statuses. Read-only. Nullable. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The user's terms of use acceptance statuses. Read-only. Nullable."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The user's terms of use acceptance statuses. Read-only. Nullable. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The user's terms of use acceptance statuses. Read-only. Nullable."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/users/{user_id}/agreementAcceptances/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The user's terms of use acceptance statuses. Read-only. Nullable. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The user's terms of use acceptance statuses. Read-only. Nullable. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Users.Item.AgreementAcceptances.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The user's terms of use acceptance statuses. Read-only. Nullable. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Users/Item/AgreementAcceptances/Ref/RefResponse.cs b/src/generated/Users/Item/AgreementAcceptances/Ref/RefResponse.cs new file mode 100644 index 00000000000..ab33d525c14 --- /dev/null +++ b/src/generated/Users/Item/AgreementAcceptances/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.AgreementAcceptances.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/AppRoleAssignments/AppRoleAssignmentsRequestBuilder.cs b/src/generated/Users/Item/AppRoleAssignments/AppRoleAssignmentsRequestBuilder.cs index bb2135ce187..f0f9a7c8dd3 100644 --- a/src/generated/Users/Item/AppRoleAssignments/AppRoleAssignmentsRequestBuilder.cs +++ b/src/generated/Users/Item/AppRoleAssignments/AppRoleAssignmentsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.AppRoleAssignments.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AppRoleAssignmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AppRoleAssignmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(AppRoleAssignment body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the app roles a user has been granted for an application. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the app roles a user has been granted for an application. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AppRoleAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the app roles a user has been granted for an application. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/AppRoleAssignments/Item/AppRoleAssignmentRequestBuilder.cs b/src/generated/Users/Item/AppRoleAssignments/Item/AppRoleAssignmentRequestBuilder.cs index b03ea1cc880..1557f1595e5 100644 --- a/src/generated/Users/Item/AppRoleAssignments/Item/AppRoleAssignmentRequestBuilder.cs +++ b/src/generated/Users/Item/AppRoleAssignments/Item/AppRoleAssignmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var appRoleAssignmentIdOption = new Option("--approleassignment-id", description: "key: id of appRoleAssignment") { + var appRoleAssignmentIdOption = new Option("--app-role-assignment-id", description: "key: id of appRoleAssignment") { }; appRoleAssignmentIdOption.IsRequired = true; command.AddOption(appRoleAssignmentIdOption); - command.SetHandler(async (string userId, string appRoleAssignmentId) => { + command.SetHandler(async (string userId, string appRoleAssignmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, appRoleAssignmentIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var appRoleAssignmentIdOption = new Option("--approleassignment-id", description: "key: id of appRoleAssignment") { + var appRoleAssignmentIdOption = new Option("--app-role-assignment-id", description: "key: id of appRoleAssignment") { }; appRoleAssignmentIdOption.IsRequired = true; command.AddOption(appRoleAssignmentIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string appRoleAssignmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string appRoleAssignmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, appRoleAssignmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, appRoleAssignmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var appRoleAssignmentIdOption = new Option("--approleassignment-id", description: "key: id of appRoleAssignment") { + var appRoleAssignmentIdOption = new Option("--app-role-assignment-id", description: "key: id of appRoleAssignment") { }; appRoleAssignmentIdOption.IsRequired = true; command.AddOption(appRoleAssignmentIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string appRoleAssignmentId, string body) => { + command.SetHandler(async (string userId, string appRoleAssignmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, appRoleAssignmentIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(AppRoleAssignment body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the app roles a user has been granted for an application. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the app roles a user has been granted for an application. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the app roles a user has been granted for an application. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AppRoleAssignment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the app roles a user has been granted for an application. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/AssignLicense/AssignLicenseRequestBuilder.cs b/src/generated/Users/Item/AssignLicense/AssignLicenseRequestBuilder.cs index f139d8cb815..292ed817f20 100644 --- a/src/generated/Users/Item/AssignLicense/AssignLicenseRequestBuilder.cs +++ b/src/generated/Users/Item/AssignLicense/AssignLicenseRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(AssignLicenseRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assignLicense - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignLicenseRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes user public class AssignLicenseResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Authentication/AuthenticationRequestBuilder.cs b/src/generated/Users/Item/Authentication/AuthenticationRequestBuilder.cs index af676df8a99..a3afd8aee0f 100644 --- a/src/generated/Users/Item/Authentication/AuthenticationRequestBuilder.cs +++ b/src/generated/Users/Item/Authentication/AuthenticationRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Users.Item.Authentication.WindowsHelloForBusinessMethods; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + command.SetHandler(async (string userId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption); return command; @@ -46,6 +45,9 @@ public Command BuildDeleteCommand() { public Command BuildFido2MethodsCommand() { var command = new Command("fido2-methods"); var builder = new ApiSdk.Users.Item.Authentication.Fido2Methods.Fido2MethodsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -71,25 +73,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildMethodsCommand() { var command = new Command("methods"); var builder = new ApiSdk.Users.Item.Authentication.Methods.MethodsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -97,6 +101,9 @@ public Command BuildMethodsCommand() { public Command BuildMicrosoftAuthenticatorMethodsCommand() { var command = new Command("microsoft-authenticator-methods"); var builder = new ApiSdk.Users.Item.Authentication.MicrosoftAuthenticatorMethods.MicrosoftAuthenticatorMethodsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -116,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + command.SetHandler(async (string userId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, bodyOption); return command; @@ -131,6 +137,9 @@ public Command BuildPatchCommand() { public Command BuildWindowsHelloForBusinessMethodsCommand() { var command = new Command("windows-hello-for-business-methods"); var builder = new ApiSdk.Users.Item.Authentication.WindowsHelloForBusinessMethods.WindowsHelloForBusinessMethodsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -202,42 +211,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property authentication for users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get authentication from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property authentication in users - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Authentication model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get authentication from users public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Authentication/Fido2Methods/Fido2MethodsRequestBuilder.cs b/src/generated/Users/Item/Authentication/Fido2Methods/Fido2MethodsRequestBuilder.cs index d54fd4d0143..aeb002d79c7 100644 --- a/src/generated/Users/Item/Authentication/Fido2Methods/Fido2MethodsRequestBuilder.cs +++ b/src/generated/Users/Item/Authentication/Fido2Methods/Fido2MethodsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Authentication.Fido2Methods.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class Fido2MethodsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new Fido2AuthenticationMethodRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(Fido2AuthenticationMethod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get fido2Methods from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to fido2Methods for users - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Fido2AuthenticationMethod model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get fido2Methods from users public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Authentication/Fido2Methods/Item/Fido2AuthenticationMethodRequestBuilder.cs b/src/generated/Users/Item/Authentication/Fido2Methods/Item/Fido2AuthenticationMethodRequestBuilder.cs index 66675383eea..8f5f83fb9a4 100644 --- a/src/generated/Users/Item/Authentication/Fido2Methods/Item/Fido2AuthenticationMethodRequestBuilder.cs +++ b/src/generated/Users/Item/Authentication/Fido2Methods/Item/Fido2AuthenticationMethodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var fido2AuthenticationMethodIdOption = new Option("--fido2authenticationmethod-id", description: "key: id of fido2AuthenticationMethod") { + var fido2AuthenticationMethodIdOption = new Option("--fido2authentication-method-id", description: "key: id of fido2AuthenticationMethod") { }; fido2AuthenticationMethodIdOption.IsRequired = true; command.AddOption(fido2AuthenticationMethodIdOption); - command.SetHandler(async (string userId, string fido2AuthenticationMethodId) => { + command.SetHandler(async (string userId, string fido2AuthenticationMethodId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, fido2AuthenticationMethodIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var fido2AuthenticationMethodIdOption = new Option("--fido2authenticationmethod-id", description: "key: id of fido2AuthenticationMethod") { + var fido2AuthenticationMethodIdOption = new Option("--fido2authentication-method-id", description: "key: id of fido2AuthenticationMethod") { }; fido2AuthenticationMethodIdOption.IsRequired = true; command.AddOption(fido2AuthenticationMethodIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string fido2AuthenticationMethodId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string fido2AuthenticationMethodId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, fido2AuthenticationMethodIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, fido2AuthenticationMethodIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var fido2AuthenticationMethodIdOption = new Option("--fido2authenticationmethod-id", description: "key: id of fido2AuthenticationMethod") { + var fido2AuthenticationMethodIdOption = new Option("--fido2authentication-method-id", description: "key: id of fido2AuthenticationMethod") { }; fido2AuthenticationMethodIdOption.IsRequired = true; command.AddOption(fido2AuthenticationMethodIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string fido2AuthenticationMethodId, string body) => { + command.SetHandler(async (string userId, string fido2AuthenticationMethodId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, fido2AuthenticationMethodIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(Fido2AuthenticationMetho requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property fido2Methods for users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get fido2Methods from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property fido2Methods in users - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Fido2AuthenticationMethod model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get fido2Methods from users public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Authentication/Methods/Item/AuthenticationMethodRequestBuilder.cs b/src/generated/Users/Item/Authentication/Methods/Item/AuthenticationMethodRequestBuilder.cs index f59fca109ad..8f325c98297 100644 --- a/src/generated/Users/Item/Authentication/Methods/Item/AuthenticationMethodRequestBuilder.cs +++ b/src/generated/Users/Item/Authentication/Methods/Item/AuthenticationMethodRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var authenticationMethodIdOption = new Option("--authenticationmethod-id", description: "key: id of authenticationMethod") { + var authenticationMethodIdOption = new Option("--authentication-method-id", description: "key: id of authenticationMethod") { }; authenticationMethodIdOption.IsRequired = true; command.AddOption(authenticationMethodIdOption); - command.SetHandler(async (string userId, string authenticationMethodId) => { + command.SetHandler(async (string userId, string authenticationMethodId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, authenticationMethodIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var authenticationMethodIdOption = new Option("--authenticationmethod-id", description: "key: id of authenticationMethod") { + var authenticationMethodIdOption = new Option("--authentication-method-id", description: "key: id of authenticationMethod") { }; authenticationMethodIdOption.IsRequired = true; command.AddOption(authenticationMethodIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string authenticationMethodId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string authenticationMethodId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, authenticationMethodIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, authenticationMethodIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var authenticationMethodIdOption = new Option("--authenticationmethod-id", description: "key: id of authenticationMethod") { + var authenticationMethodIdOption = new Option("--authentication-method-id", description: "key: id of authenticationMethod") { }; authenticationMethodIdOption.IsRequired = true; command.AddOption(authenticationMethodIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string authenticationMethodId, string body) => { + command.SetHandler(async (string userId, string authenticationMethodId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, authenticationMethodIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(AuthenticationMethod bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property methods for users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get methods from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property methods in users - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AuthenticationMethod model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get methods from users public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Authentication/Methods/MethodsRequestBuilder.cs b/src/generated/Users/Item/Authentication/Methods/MethodsRequestBuilder.cs index af57706bb77..4e884512bb9 100644 --- a/src/generated/Users/Item/Authentication/Methods/MethodsRequestBuilder.cs +++ b/src/generated/Users/Item/Authentication/Methods/MethodsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Authentication.Methods.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MethodsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AuthenticationMethodRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(AuthenticationMethod body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get methods from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to methods for users - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AuthenticationMethod model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get methods from users public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Authentication/MicrosoftAuthenticatorMethods/Item/Device/DeviceRequestBuilder.cs b/src/generated/Users/Item/Authentication/MicrosoftAuthenticatorMethods/Item/Device/DeviceRequestBuilder.cs index 440d51aaf03..22d54a684ea 100644 --- a/src/generated/Users/Item/Authentication/MicrosoftAuthenticatorMethods/Item/Device/DeviceRequestBuilder.cs +++ b/src/generated/Users/Item/Authentication/MicrosoftAuthenticatorMethods/Item/Device/DeviceRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var microsoftAuthenticatorAuthenticationMethodIdOption = new Option("--microsoftauthenticatorauthenticationmethod-id", description: "key: id of microsoftAuthenticatorAuthenticationMethod") { + var microsoftAuthenticatorAuthenticationMethodIdOption = new Option("--microsoft-authenticator-authentication-method-id", description: "key: id of microsoftAuthenticatorAuthenticationMethod") { }; microsoftAuthenticatorAuthenticationMethodIdOption.IsRequired = true; command.AddOption(microsoftAuthenticatorAuthenticationMethodIdOption); - command.SetHandler(async (string userId, string microsoftAuthenticatorAuthenticationMethodId) => { + command.SetHandler(async (string userId, string microsoftAuthenticatorAuthenticationMethodId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, microsoftAuthenticatorAuthenticationMethodIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var microsoftAuthenticatorAuthenticationMethodIdOption = new Option("--microsoftauthenticatorauthenticationmethod-id", description: "key: id of microsoftAuthenticatorAuthenticationMethod") { + var microsoftAuthenticatorAuthenticationMethodIdOption = new Option("--microsoft-authenticator-authentication-method-id", description: "key: id of microsoftAuthenticatorAuthenticationMethod") { }; microsoftAuthenticatorAuthenticationMethodIdOption.IsRequired = true; command.AddOption(microsoftAuthenticatorAuthenticationMethodIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string microsoftAuthenticatorAuthenticationMethodId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string microsoftAuthenticatorAuthenticationMethodId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, microsoftAuthenticatorAuthenticationMethodIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, microsoftAuthenticatorAuthenticationMethodIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var microsoftAuthenticatorAuthenticationMethodIdOption = new Option("--microsoftauthenticatorauthenticationmethod-id", description: "key: id of microsoftAuthenticatorAuthenticationMethod") { + var microsoftAuthenticatorAuthenticationMethodIdOption = new Option("--microsoft-authenticator-authentication-method-id", description: "key: id of microsoftAuthenticatorAuthenticationMethod") { }; microsoftAuthenticatorAuthenticationMethodIdOption.IsRequired = true; command.AddOption(microsoftAuthenticatorAuthenticationMethodIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string microsoftAuthenticatorAuthenticationMethodId, string body) => { + command.SetHandler(async (string userId, string microsoftAuthenticatorAuthenticationMethodId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, microsoftAuthenticatorAuthenticationMethodIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The registered device on which Microsoft Authenticator resides. This property is null if the device is not registered for passwordless Phone Sign-In. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The registered device on which Microsoft Authenticator resides. This property is null if the device is not registered for passwordless Phone Sign-In. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The registered device on which Microsoft Authenticator resides. This property is null if the device is not registered for passwordless Phone Sign-In. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Device model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The registered device on which Microsoft Authenticator resides. This property is null if the device is not registered for passwordless Phone Sign-In. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Authentication/MicrosoftAuthenticatorMethods/Item/MicrosoftAuthenticatorAuthenticationMethodRequestBuilder.cs b/src/generated/Users/Item/Authentication/MicrosoftAuthenticatorMethods/Item/MicrosoftAuthenticatorAuthenticationMethodRequestBuilder.cs index 46e7b800ec3..1383a0fbc14 100644 --- a/src/generated/Users/Item/Authentication/MicrosoftAuthenticatorMethods/Item/MicrosoftAuthenticatorAuthenticationMethodRequestBuilder.cs +++ b/src/generated/Users/Item/Authentication/MicrosoftAuthenticatorMethods/Item/MicrosoftAuthenticatorAuthenticationMethodRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Authentication.MicrosoftAuthenticatorMethods.Item.Device; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,15 +31,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var microsoftAuthenticatorAuthenticationMethodIdOption = new Option("--microsoftauthenticatorauthenticationmethod-id", description: "key: id of microsoftAuthenticatorAuthenticationMethod") { + var microsoftAuthenticatorAuthenticationMethodIdOption = new Option("--microsoft-authenticator-authentication-method-id", description: "key: id of microsoftAuthenticatorAuthenticationMethod") { }; microsoftAuthenticatorAuthenticationMethodIdOption.IsRequired = true; command.AddOption(microsoftAuthenticatorAuthenticationMethodIdOption); - command.SetHandler(async (string userId, string microsoftAuthenticatorAuthenticationMethodId) => { + command.SetHandler(async (string userId, string microsoftAuthenticatorAuthenticationMethodId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, microsoftAuthenticatorAuthenticationMethodIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var microsoftAuthenticatorAuthenticationMethodIdOption = new Option("--microsoftauthenticatorauthenticationmethod-id", description: "key: id of microsoftAuthenticatorAuthenticationMethod") { + var microsoftAuthenticatorAuthenticationMethodIdOption = new Option("--microsoft-authenticator-authentication-method-id", description: "key: id of microsoftAuthenticatorAuthenticationMethod") { }; microsoftAuthenticatorAuthenticationMethodIdOption.IsRequired = true; command.AddOption(microsoftAuthenticatorAuthenticationMethodIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string microsoftAuthenticatorAuthenticationMethodId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string microsoftAuthenticatorAuthenticationMethodId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, microsoftAuthenticatorAuthenticationMethodIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, microsoftAuthenticatorAuthenticationMethodIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,7 +102,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var microsoftAuthenticatorAuthenticationMethodIdOption = new Option("--microsoftauthenticatorauthenticationmethod-id", description: "key: id of microsoftAuthenticatorAuthenticationMethod") { + var microsoftAuthenticatorAuthenticationMethodIdOption = new Option("--microsoft-authenticator-authentication-method-id", description: "key: id of microsoftAuthenticatorAuthenticationMethod") { }; microsoftAuthenticatorAuthenticationMethodIdOption.IsRequired = true; command.AddOption(microsoftAuthenticatorAuthenticationMethodIdOption); @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string microsoftAuthenticatorAuthenticationMethodId, string body) => { + command.SetHandler(async (string userId, string microsoftAuthenticatorAuthenticationMethodId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, microsoftAuthenticatorAuthenticationMethodIdOption, bodyOption); return command; @@ -191,42 +188,6 @@ public RequestInformation CreatePatchRequestInformation(MicrosoftAuthenticatorAu requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property microsoftAuthenticatorMethods for users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get microsoftAuthenticatorMethods from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property microsoftAuthenticatorMethods in users - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MicrosoftAuthenticatorAuthenticationMethod model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get microsoftAuthenticatorMethods from users public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Authentication/MicrosoftAuthenticatorMethods/MicrosoftAuthenticatorMethodsRequestBuilder.cs b/src/generated/Users/Item/Authentication/MicrosoftAuthenticatorMethods/MicrosoftAuthenticatorMethodsRequestBuilder.cs index 6ee52e25f3e..d5544a57c4e 100644 --- a/src/generated/Users/Item/Authentication/MicrosoftAuthenticatorMethods/MicrosoftAuthenticatorMethodsRequestBuilder.cs +++ b/src/generated/Users/Item/Authentication/MicrosoftAuthenticatorMethods/MicrosoftAuthenticatorMethodsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Authentication.MicrosoftAuthenticatorMethods.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class MicrosoftAuthenticatorMethodsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MicrosoftAuthenticatorAuthenticationMethodRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildDeviceCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDeviceCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(MicrosoftAuthenticatorAut requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get microsoftAuthenticatorMethods from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to microsoftAuthenticatorMethods for users - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MicrosoftAuthenticatorAuthenticationMethod model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get microsoftAuthenticatorMethods from users public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Authentication/WindowsHelloForBusinessMethods/Item/Device/DeviceRequestBuilder.cs b/src/generated/Users/Item/Authentication/WindowsHelloForBusinessMethods/Item/Device/DeviceRequestBuilder.cs index 49f88842810..2ee2f503298 100644 --- a/src/generated/Users/Item/Authentication/WindowsHelloForBusinessMethods/Item/Device/DeviceRequestBuilder.cs +++ b/src/generated/Users/Item/Authentication/WindowsHelloForBusinessMethods/Item/Device/DeviceRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var windowsHelloForBusinessAuthenticationMethodIdOption = new Option("--windowshelloforbusinessauthenticationmethod-id", description: "key: id of windowsHelloForBusinessAuthenticationMethod") { + var windowsHelloForBusinessAuthenticationMethodIdOption = new Option("--windows-hello-for-business-authentication-method-id", description: "key: id of windowsHelloForBusinessAuthenticationMethod") { }; windowsHelloForBusinessAuthenticationMethodIdOption.IsRequired = true; command.AddOption(windowsHelloForBusinessAuthenticationMethodIdOption); - command.SetHandler(async (string userId, string windowsHelloForBusinessAuthenticationMethodId) => { + command.SetHandler(async (string userId, string windowsHelloForBusinessAuthenticationMethodId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, windowsHelloForBusinessAuthenticationMethodIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var windowsHelloForBusinessAuthenticationMethodIdOption = new Option("--windowshelloforbusinessauthenticationmethod-id", description: "key: id of windowsHelloForBusinessAuthenticationMethod") { + var windowsHelloForBusinessAuthenticationMethodIdOption = new Option("--windows-hello-for-business-authentication-method-id", description: "key: id of windowsHelloForBusinessAuthenticationMethod") { }; windowsHelloForBusinessAuthenticationMethodIdOption.IsRequired = true; command.AddOption(windowsHelloForBusinessAuthenticationMethodIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string windowsHelloForBusinessAuthenticationMethodId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string windowsHelloForBusinessAuthenticationMethodId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, windowsHelloForBusinessAuthenticationMethodIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, windowsHelloForBusinessAuthenticationMethodIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var windowsHelloForBusinessAuthenticationMethodIdOption = new Option("--windowshelloforbusinessauthenticationmethod-id", description: "key: id of windowsHelloForBusinessAuthenticationMethod") { + var windowsHelloForBusinessAuthenticationMethodIdOption = new Option("--windows-hello-for-business-authentication-method-id", description: "key: id of windowsHelloForBusinessAuthenticationMethod") { }; windowsHelloForBusinessAuthenticationMethodIdOption.IsRequired = true; command.AddOption(windowsHelloForBusinessAuthenticationMethodIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string windowsHelloForBusinessAuthenticationMethodId, string body) => { + command.SetHandler(async (string userId, string windowsHelloForBusinessAuthenticationMethodId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, windowsHelloForBusinessAuthenticationMethodIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The registered device on which this Windows Hello for Business key resides. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The registered device on which this Windows Hello for Business key resides. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The registered device on which this Windows Hello for Business key resides. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Device model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The registered device on which this Windows Hello for Business key resides. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Authentication/WindowsHelloForBusinessMethods/Item/WindowsHelloForBusinessAuthenticationMethodRequestBuilder.cs b/src/generated/Users/Item/Authentication/WindowsHelloForBusinessMethods/Item/WindowsHelloForBusinessAuthenticationMethodRequestBuilder.cs index 8d601df0e6d..36dea39af85 100644 --- a/src/generated/Users/Item/Authentication/WindowsHelloForBusinessMethods/Item/WindowsHelloForBusinessAuthenticationMethodRequestBuilder.cs +++ b/src/generated/Users/Item/Authentication/WindowsHelloForBusinessMethods/Item/WindowsHelloForBusinessAuthenticationMethodRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Authentication.WindowsHelloForBusinessMethods.Item.Device; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,15 +31,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var windowsHelloForBusinessAuthenticationMethodIdOption = new Option("--windowshelloforbusinessauthenticationmethod-id", description: "key: id of windowsHelloForBusinessAuthenticationMethod") { + var windowsHelloForBusinessAuthenticationMethodIdOption = new Option("--windows-hello-for-business-authentication-method-id", description: "key: id of windowsHelloForBusinessAuthenticationMethod") { }; windowsHelloForBusinessAuthenticationMethodIdOption.IsRequired = true; command.AddOption(windowsHelloForBusinessAuthenticationMethodIdOption); - command.SetHandler(async (string userId, string windowsHelloForBusinessAuthenticationMethodId) => { + command.SetHandler(async (string userId, string windowsHelloForBusinessAuthenticationMethodId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, windowsHelloForBusinessAuthenticationMethodIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var windowsHelloForBusinessAuthenticationMethodIdOption = new Option("--windowshelloforbusinessauthenticationmethod-id", description: "key: id of windowsHelloForBusinessAuthenticationMethod") { + var windowsHelloForBusinessAuthenticationMethodIdOption = new Option("--windows-hello-for-business-authentication-method-id", description: "key: id of windowsHelloForBusinessAuthenticationMethod") { }; windowsHelloForBusinessAuthenticationMethodIdOption.IsRequired = true; command.AddOption(windowsHelloForBusinessAuthenticationMethodIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string windowsHelloForBusinessAuthenticationMethodId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string windowsHelloForBusinessAuthenticationMethodId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, windowsHelloForBusinessAuthenticationMethodIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, windowsHelloForBusinessAuthenticationMethodIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,7 +102,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var windowsHelloForBusinessAuthenticationMethodIdOption = new Option("--windowshelloforbusinessauthenticationmethod-id", description: "key: id of windowsHelloForBusinessAuthenticationMethod") { + var windowsHelloForBusinessAuthenticationMethodIdOption = new Option("--windows-hello-for-business-authentication-method-id", description: "key: id of windowsHelloForBusinessAuthenticationMethod") { }; windowsHelloForBusinessAuthenticationMethodIdOption.IsRequired = true; command.AddOption(windowsHelloForBusinessAuthenticationMethodIdOption); @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string windowsHelloForBusinessAuthenticationMethodId, string body) => { + command.SetHandler(async (string userId, string windowsHelloForBusinessAuthenticationMethodId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, windowsHelloForBusinessAuthenticationMethodIdOption, bodyOption); return command; @@ -191,42 +188,6 @@ public RequestInformation CreatePatchRequestInformation(WindowsHelloForBusinessA requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property windowsHelloForBusinessMethods for users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get windowsHelloForBusinessMethods from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property windowsHelloForBusinessMethods in users - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WindowsHelloForBusinessAuthenticationMethod model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get windowsHelloForBusinessMethods from users public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Authentication/WindowsHelloForBusinessMethods/WindowsHelloForBusinessMethodsRequestBuilder.cs b/src/generated/Users/Item/Authentication/WindowsHelloForBusinessMethods/WindowsHelloForBusinessMethodsRequestBuilder.cs index e499c267859..f45ec58e8dd 100644 --- a/src/generated/Users/Item/Authentication/WindowsHelloForBusinessMethods/WindowsHelloForBusinessMethodsRequestBuilder.cs +++ b/src/generated/Users/Item/Authentication/WindowsHelloForBusinessMethods/WindowsHelloForBusinessMethodsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Authentication.WindowsHelloForBusinessMethods.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class WindowsHelloForBusinessMethodsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new WindowsHelloForBusinessAuthenticationMethodRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildDeviceCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDeviceCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(WindowsHelloForBusinessAu requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get windowsHelloForBusinessMethods from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to windowsHelloForBusinessMethods for users - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WindowsHelloForBusinessAuthenticationMethod model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get windowsHelloForBusinessMethods from users public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs b/src/generated/Users/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs index 5b5c1721c26..36d0da4136f 100644 --- a/src/generated/Users/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +33,17 @@ public Command BuildGetCommand() { }; UserOption.IsRequired = true; command.AddOption(UserOption); - command.SetHandler(async (string userId, string User) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string User, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, UserOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, UserOption, outputOption); return command; } /// @@ -77,16 +76,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function allowedCalendarSharingRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs index 23026b61a97..c42f853a86b 100644 --- a/src/generated/Users/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Calendar.CalendarPermissions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class CalendarPermissionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new CalendarPermissionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -98,7 +96,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -107,15 +109,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -170,31 +167,6 @@ public RequestInformation CreatePostRequestInformation(CalendarPermission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CalendarPermission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions of the users with whom the calendar is shared. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs index 2873768a7ca..d517346ddd3 100644 --- a/src/generated/Users/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); - command.SetHandler(async (string userId, string calendarPermissionId) => { + command.SetHandler(async (string userId, string calendarPermissionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarPermissionIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); @@ -63,19 +62,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarPermissionId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarPermissionId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarPermissionIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarPermissionIdOption, selectOption, outputOption); return command; } /// @@ -89,7 +87,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); @@ -97,14 +95,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarPermissionId, string body) => { + command.SetHandler(async (string userId, string calendarPermissionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarPermissionIdOption, bodyOption); return command; @@ -176,42 +173,6 @@ public RequestInformation CreatePatchRequestInformation(CalendarPermission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(CalendarPermission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions of the users with whom the calendar is shared. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/Calendar/CalendarRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarRequestBuilder.cs index 8b89592d53b..60bbb01b2a3 100644 --- a/src/generated/Users/Item/Calendar/CalendarRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Users.Item.Calendar.SingleValueExtendedProperties; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,6 +37,9 @@ public AllowedCalendarSharingRolesWithUserRequestBuilder AllowedCalendarSharingR public Command BuildCalendarPermissionsCommand() { var command = new Command("calendar-permissions"); var builder = new ApiSdk.Users.Item.Calendar.CalendarPermissions.CalendarPermissionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -44,6 +47,9 @@ public Command BuildCalendarPermissionsCommand() { public Command BuildCalendarViewCommand() { var command = new Command("calendar-view"); var builder = new ApiSdk.Users.Item.Calendar.CalendarView.CalendarViewRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -59,11 +65,10 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + command.SetHandler(async (string userId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption); return command; @@ -71,6 +76,9 @@ public Command BuildDeleteCommand() { public Command BuildEventsCommand() { var command = new Command("events"); var builder = new ApiSdk.Users.Item.Calendar.Events.EventsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -91,19 +99,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, selectOption, outputOption); return command; } public Command BuildGetScheduleCommand() { @@ -115,6 +122,9 @@ public Command BuildGetScheduleCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Users.Item.Calendar.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + command.SetHandler(async (string userId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, bodyOption); return command; @@ -149,6 +158,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Users.Item.Calendar.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -220,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user's primary calendar. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's primary calendar. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's primary calendar. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's primary calendar. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs index 1032e8feb1a..4c7809c481d 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Calendar.CalendarView.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,24 +23,23 @@ public class CalendarViewRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildAttachmentsCommand(), - builder.BuildCalendarCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildExtensionsCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildInstancesCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildAttachmentsCommand()); + commands.Add(builder.BuildCalendarCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInstancesCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -58,21 +57,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -86,11 +84,11 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var startDateTimeOption = new Option("--startdatetime", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { + var startDateTimeOption = new Option("--start-date-time", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { }; startDateTimeOption.IsRequired = true; command.AddOption(startDateTimeOption); - var endDateTimeOption = new Option("--enddatetime", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { + var endDateTimeOption = new Option("--end-date-time", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { }; endDateTimeOption.IsRequired = true; command.AddOption(endDateTimeOption); @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string startDateTime, string endDateTime, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string startDateTime, string endDateTime, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { if (!String.IsNullOrEmpty(startDateTime)) q.StartDateTime = startDateTime; if (!String.IsNullOrEmpty(endDateTime)) q.EndDateTime = endDateTime; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, startDateTimeOption, endDateTimeOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, startDateTimeOption, endDateTimeOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -182,7 +179,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -200,31 +197,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendar/CalendarView/CalendarViewResponse.cs b/src/generated/Users/Item/Calendar/CalendarView/CalendarViewResponse.cs index 62b85ece312..5baa0b7f4b5 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/CalendarViewResponse.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/CalendarViewResponse.cs @@ -9,7 +9,7 @@ public class CalendarViewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new calendarViewResponse and sets the default values. /// @@ -22,7 +22,7 @@ public CalendarViewResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as CalendarViewResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Users/Item/Calendar/CalendarView/Delta/Delta.cs b/src/generated/Users/Item/Calendar/CalendarView/Delta/Delta.cs deleted file mode 100644 index 504c1e8173d..00000000000 --- a/src/generated/Users/Item/Calendar/CalendarView/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.Calendar.CalendarView.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Users/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs index bd78d3536a8..a7570e30d2a 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +30,17 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs index d82c7a2ddad..cbbf2ba50b4 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs index b1a54f47973..b5354bf2d69 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Calendar.CalendarView.Item.Attachments.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class AttachmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttachmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } public Command BuildCreateUploadSessionCommand() { @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(Attachment body, Action - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index f8eb578ea45..e2cf4f93422 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs index 78f9ba31150..174d7c33ad5 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; attachmentIdOption.IsRequired = true; command.AddOption(attachmentIdOption); - command.SetHandler(async (string userId, string eventId, string attachmentId) => { + command.SetHandler(async (string userId, string eventId, string attachmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, attachmentIdOption); return command; @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, string attachmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string attachmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string attachmentId, string body) => { + command.SetHandler(async (string userId, string eventId, string attachmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, attachmentIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Attachment body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs index e1166261290..ce70930b5db 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,18 +37,17 @@ public Command BuildGetCommand() { }; UserOption.IsRequired = true; command.AddOption(UserOption); - command.SetHandler(async (string userId, string eventId, string User) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string User, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, UserOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, UserOption, outputOption); return command; } /// @@ -81,16 +80,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function allowedCalendarSharingRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/Calendar/CalendarRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/Calendar/CalendarRequestBuilder.cs index 6f5ad90a960..a9872387bb9 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/Calendar/CalendarRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/Calendar/CalendarRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Calendar.CalendarView.Item.Calendar.GetSchedule; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,11 +44,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string eventId) => { + command.SetHandler(async (string userId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption); return command; @@ -73,19 +72,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, selectOption, outputOption); return command; } public Command BuildGetScheduleCommand() { @@ -113,14 +111,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -192,42 +189,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar that contains the event. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs index aae434dd70e..6a1cd0cfda0 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,21 +37,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -85,18 +84,5 @@ public RequestInformation CreatePostRequestInformation(GetScheduleRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSchedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetScheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs index 2d10ced7960..ae72df67ba6 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs index 08529929d02..257d7858659 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs index f9e17da1b90..5bbd8072ca6 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,11 +33,10 @@ public Command BuildPostCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string eventId) => { + command.SetHandler(async (string userId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs index 18f1505ec1e..aaa673f4003 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs @@ -14,10 +14,10 @@ using ApiSdk.Users.Item.Calendar.CalendarView.Item.TentativelyAccept; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,6 +41,9 @@ public Command BuildAcceptCommand() { public Command BuildAttachmentsCommand() { var command = new Command("attachments"); var builder = new ApiSdk.Users.Item.Calendar.CalendarView.Item.Attachments.AttachmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateUploadSessionCommand()); command.AddCommand(builder.BuildListCommand()); @@ -82,11 +85,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string eventId) => { + command.SetHandler(async (string userId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption); return command; @@ -100,6 +102,9 @@ public Command BuildDismissReminderCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Users.Item.Calendar.CalendarView.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -125,11 +130,11 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var startDateTimeOption = new Option("--startdatetime", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { + var startDateTimeOption = new Option("--start-date-time", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { }; startDateTimeOption.IsRequired = true; command.AddOption(startDateTimeOption); - var endDateTimeOption = new Option("--enddatetime", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { + var endDateTimeOption = new Option("--end-date-time", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { }; endDateTimeOption.IsRequired = true; command.AddOption(endDateTimeOption); @@ -138,26 +143,28 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, string startDateTime, string endDateTime, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string startDateTime, string endDateTime, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { if (!String.IsNullOrEmpty(startDateTime)) q.StartDateTime = startDateTime; if (!String.IsNullOrEmpty(endDateTime)) q.EndDateTime = endDateTime; q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, startDateTimeOption, endDateTimeOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, startDateTimeOption, endDateTimeOption, selectOption, outputOption); return command; } public Command BuildInstancesCommand() { var command = new Command("instances"); var builder = new ApiSdk.Users.Item.Calendar.CalendarView.Item.Instances.InstancesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -165,6 +172,9 @@ public Command BuildInstancesCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Users.Item.Calendar.CalendarView.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -188,14 +198,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -203,6 +212,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Users.Item.Calendar.CalendarView.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -274,7 +286,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -286,42 +298,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00 diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs index 97b55803b40..b920a7da5a1 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Calendar.CalendarView.Item.Extensions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs index d2e2b431b05..5dd764f3813 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string userId, string eventId, string extensionId) => { + command.SetHandler(async (string userId, string eventId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, extensionIdOption); return command; @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string extensionId, string body) => { + command.SetHandler(async (string userId, string eventId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, extensionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs index 7a42c455961..e88e515ec3f 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Delta/Delta.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Delta/Delta.cs deleted file mode 100644 index 8b0e4fa84f5..00000000000 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.Calendar.CalendarView.Item.Instances.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs index ec7b8298346..317961a7a08 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +34,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, outputOption); return command; } /// @@ -75,16 +75,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/InstancesRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/InstancesRequestBuilder.cs index b4511132cd8..ed403558805 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/InstancesRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/InstancesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Calendar.CalendarView.Item.Instances.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class InstancesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -114,7 +112,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -174,7 +171,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/InstancesResponse.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/InstancesResponse.cs index 603240a8ca9..f4c228568cc 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/InstancesResponse.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/InstancesResponse.cs @@ -9,7 +9,7 @@ public class InstancesResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new instancesResponse and sets the default values. /// @@ -22,7 +22,7 @@ public InstancesResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as InstancesResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs index bfff69af1c9..21de66ebce3 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs index 4680690608f..57ac7620cdc 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs index 2b5d7be752b..0ba559820bd 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs index c859470f9d5..104577f28ee 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,11 +37,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string userId, string eventId, string eventId1) => { + command.SetHandler(async (string userId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/EventRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/EventRequestBuilder.cs index 7435a40e7af..caffd34f801 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/EventRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Users.Item.Calendar.CalendarView.Item.Instances.Item.TentativelyAccept; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -63,11 +63,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string userId, string eventId, string eventId1) => { + command.SetHandler(async (string userId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option); return command; @@ -108,19 +107,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -146,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -225,7 +222,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -237,42 +234,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs index fad3a744aff..e62e5318dfd 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 48ff7713b54..514ee599ac6 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index 9d4d8887e36..7804f720189 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 324f0769d7b..b65f03a9fa7 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 078ca86bd64..c74c4a23b0b 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Calendar.CalendarView.Item.MultiValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index ed69c52f903..c570e30a181 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 0c6a2d01544..2e599d71f86 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Calendar.CalendarView.Item.SingleValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index fdc8590fec5..7d3ff45bede 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Users/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index 9581005f8aa..8b0fc65e707 100644 --- a/src/generated/Users/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/Events/Delta/Delta.cs b/src/generated/Users/Item/Calendar/Events/Delta/Delta.cs deleted file mode 100644 index dc204d301f8..00000000000 --- a/src/generated/Users/Item/Calendar/Events/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.Calendar.Events.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Users/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs index ffd0205d22b..d483f2178e5 100644 --- a/src/generated/Users/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +30,17 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/Events/EventsRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/EventsRequestBuilder.cs index a7355a23efd..0dd69e572c6 100644 --- a/src/generated/Users/Item/Calendar/Events/EventsRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/EventsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Calendar.Events.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,24 +23,23 @@ public class EventsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildAttachmentsCommand(), - builder.BuildCalendarCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildExtensionsCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildInstancesCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildAttachmentsCommand()); + commands.Add(builder.BuildCalendarCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInstancesCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -58,21 +57,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -112,7 +110,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -172,7 +169,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -190,31 +187,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The events in the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendar/Events/EventsResponse.cs b/src/generated/Users/Item/Calendar/Events/EventsResponse.cs index 0facf719392..1c8dc4729ef 100644 --- a/src/generated/Users/Item/Calendar/Events/EventsResponse.cs +++ b/src/generated/Users/Item/Calendar/Events/EventsResponse.cs @@ -9,7 +9,7 @@ public class EventsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new eventsResponse and sets the default values. /// @@ -22,7 +22,7 @@ public EventsResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as EventsResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Users/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs index 91a9546d6e0..a22a04670b6 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/Events/Item/Attachments/AttachmentsRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/Attachments/AttachmentsRequestBuilder.cs index 46650cf109f..065614e72b3 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/Attachments/AttachmentsRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/Attachments/AttachmentsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Calendar.Events.Item.Attachments.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class AttachmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttachmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } public Command BuildCreateUploadSessionCommand() { @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(Attachment body, Action - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendar/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index e484ecdab45..a1271b158d4 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Calendar/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs index 4589493fdfa..f31820ca741 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; attachmentIdOption.IsRequired = true; command.AddOption(attachmentIdOption); - command.SetHandler(async (string userId, string eventId, string attachmentId) => { + command.SetHandler(async (string userId, string eventId, string attachmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, attachmentIdOption); return command; @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, string attachmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string attachmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string attachmentId, string body) => { + command.SetHandler(async (string userId, string eventId, string attachmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, attachmentIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Attachment body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Calendar/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs index 6c46370a3d8..f50bdff691f 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,18 +37,17 @@ public Command BuildGetCommand() { }; UserOption.IsRequired = true; command.AddOption(UserOption); - command.SetHandler(async (string userId, string eventId, string User) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string User, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, UserOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, UserOption, outputOption); return command; } /// @@ -81,16 +80,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function allowedCalendarSharingRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/Events/Item/Calendar/CalendarRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/Calendar/CalendarRequestBuilder.cs index 1366752ad8d..619ad5be85d 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/Calendar/CalendarRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/Calendar/CalendarRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Calendar.Events.Item.Calendar.GetSchedule; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,11 +44,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string eventId) => { + command.SetHandler(async (string userId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption); return command; @@ -73,19 +72,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, selectOption, outputOption); return command; } public Command BuildGetScheduleCommand() { @@ -113,14 +111,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -192,42 +189,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar that contains the event. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/Calendar/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs index 0f7dfd187c0..10c4e9f6300 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,21 +37,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -85,18 +84,5 @@ public RequestInformation CreatePostRequestInformation(GetScheduleRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSchedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetScheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs index da7012be4b6..059047038e7 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs index 66205c0dcac..9e89f81bde5 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs index ae8a79cbd7a..9ec3618bcdb 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,11 +33,10 @@ public Command BuildPostCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string eventId) => { + command.SetHandler(async (string userId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/Events/Item/EventRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/EventRequestBuilder.cs index d00ad5752a4..0a99429b27c 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/EventRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/EventRequestBuilder.cs @@ -14,10 +14,10 @@ using ApiSdk.Users.Item.Calendar.Events.Item.TentativelyAccept; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,6 +41,9 @@ public Command BuildAcceptCommand() { public Command BuildAttachmentsCommand() { var command = new Command("attachments"); var builder = new ApiSdk.Users.Item.Calendar.Events.Item.Attachments.AttachmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateUploadSessionCommand()); command.AddCommand(builder.BuildListCommand()); @@ -82,11 +85,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string eventId) => { + command.SetHandler(async (string userId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption); return command; @@ -100,6 +102,9 @@ public Command BuildDismissReminderCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Users.Item.Calendar.Events.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -130,24 +135,26 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, selectOption, outputOption); return command; } public Command BuildInstancesCommand() { var command = new Command("instances"); var builder = new ApiSdk.Users.Item.Calendar.Events.Item.Instances.InstancesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -155,6 +162,9 @@ public Command BuildInstancesCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Users.Item.Calendar.Events.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -178,14 +188,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -193,6 +202,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Users.Item.Calendar.Events.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -264,7 +276,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -276,42 +288,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The events in the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/Calendar/Events/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/Extensions/ExtensionsRequestBuilder.cs index 8e93d0249b9..f916b2a28b7 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Calendar.Events.Item.Extensions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendar/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs index c81e80f6f13..fa9ee708f9e 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string userId, string eventId, string extensionId) => { + command.SetHandler(async (string userId, string eventId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, extensionIdOption); return command; @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string extensionId, string body) => { + command.SetHandler(async (string userId, string eventId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, extensionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs index ddf8fc16870..c9aec8c5a5a 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/Events/Item/Instances/Delta/Delta.cs b/src/generated/Users/Item/Calendar/Events/Item/Instances/Delta/Delta.cs deleted file mode 100644 index 6d666e6cb49..00000000000 --- a/src/generated/Users/Item/Calendar/Events/Item/Instances/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.Calendar.Events.Item.Instances.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Users/Item/Calendar/Events/Item/Instances/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/Instances/Delta/DeltaRequestBuilder.cs index 3e2b38ab1fc..d1bb94b66e6 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/Instances/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/Instances/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +34,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, outputOption); return command; } /// @@ -75,16 +75,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/Events/Item/Instances/InstancesRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/Instances/InstancesRequestBuilder.cs index 719f8c8a28a..bdeb36bf261 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/Instances/InstancesRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/Instances/InstancesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Calendar.Events.Item.Instances.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class InstancesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -114,7 +112,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -174,7 +171,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendar/Events/Item/Instances/InstancesResponse.cs b/src/generated/Users/Item/Calendar/Events/Item/Instances/InstancesResponse.cs index f6ab7d65e05..8e399fdcfdd 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/Instances/InstancesResponse.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/Instances/InstancesResponse.cs @@ -9,7 +9,7 @@ public class InstancesResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new instancesResponse and sets the default values. /// @@ -22,7 +22,7 @@ public InstancesResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as InstancesResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs index 6c4da7105a3..a406bfa86ed 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs index ded1cfcab36..e9dc28ff38d 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs index ff5d1d04abb..1795586759a 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs index 0d9a4a58ff9..d93818977f6 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,11 +37,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string userId, string eventId, string eventId1) => { + command.SetHandler(async (string userId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/EventRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/EventRequestBuilder.cs index 267fcbb75d8..2b07321e721 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/EventRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Users.Item.Calendar.Events.Item.Instances.Item.TentativelyAccept; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -63,11 +63,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string userId, string eventId, string eventId1) => { + command.SetHandler(async (string userId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option); return command; @@ -108,19 +107,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -146,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -225,7 +222,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -237,42 +234,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs index e481b247515..776bb79945a 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index a8fc4dbbf84..b362b8181ee 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index a231944b394..f71fd3ac17e 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 1803868122e..fde7c80e33a 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Calendar/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 475b5ca17f4..ebc160276aa 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Calendar.Events.Item.MultiValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendar/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 6ea92de46a1..e7ccf9c687e 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Calendar/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 6ae4615e812..8858eda7b83 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Calendar.Events.Item.SingleValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 5168354b0a8..816c4574216 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Users/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index 7d33eb6596a..1da32d52555 100644 --- a/src/generated/Users/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs b/src/generated/Users/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs index 4d6f0e4c9fd..e818df075ae 100644 --- a/src/generated/Users/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetScheduleRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSchedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetScheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 4a05dc4e3ae..d359e295fc1 100644 --- a/src/generated/Users/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index f2ca9c6385e..1bcc4c74298 100644 --- a/src/generated/Users/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Calendar.MultiValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index e1ab76bfba7..afd2ceae707 100644 --- a/src/generated/Users/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 995ca7492f8..14e503e54b0 100644 --- a/src/generated/Users/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Calendar.SingleValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarGroups/CalendarGroupsRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/CalendarGroupsRequestBuilder.cs index 34bab574008..cdfb03920d4 100644 --- a/src/generated/Users/Item/CalendarGroups/CalendarGroupsRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/CalendarGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.CalendarGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class CalendarGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new CalendarGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCalendarsCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCalendarsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -108,15 +110,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -171,31 +168,6 @@ public RequestInformation CreatePostRequestInformation(CalendarGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user's calendar groups. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's calendar groups. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CalendarGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's calendar groups. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarGroups/Item/CalendarGroupRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/CalendarGroupRequestBuilder.cs index 498f671d6ef..0a06d0af0e6 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/CalendarGroupRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/CalendarGroupRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.CalendarGroups.Item.Calendars; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,6 +23,9 @@ public class CalendarGroupRequestBuilder { public Command BuildCalendarsCommand() { var command = new Command("calendars"); var builder = new ApiSdk.Users.Item.CalendarGroups.Item.Calendars.CalendarsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -38,15 +41,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); - command.SetHandler(async (string userId, string calendarGroupId) => { + command.SetHandler(async (string userId, string calendarGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption); return command; @@ -62,7 +64,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -71,19 +73,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarGroupId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, selectOption, outputOption); return command; } /// @@ -97,7 +98,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -105,14 +106,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, bodyOption); return command; @@ -184,42 +184,6 @@ public RequestInformation CreatePatchRequestInformation(CalendarGroup body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user's calendar groups. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's calendar groups. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's calendar groups. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(CalendarGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's calendar groups. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/CalendarsRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/CalendarsRequestBuilder.cs index 2c6506f5a39..4cd26c8628c 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/CalendarsRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/CalendarsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,17 +22,16 @@ public class CalendarsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new CalendarRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCalendarPermissionsCommand(), - builder.BuildCalendarViewCommand(), - builder.BuildDeleteCommand(), - builder.BuildEventsCommand(), - builder.BuildGetCommand(), - builder.BuildGetScheduleCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCalendarPermissionsCommand()); + commands.Add(builder.BuildCalendarViewCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildEventsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildGetScheduleCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); return commands; } /// @@ -46,7 +45,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, bodyOption, outputOption); return command; } /// @@ -82,7 +80,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -112,7 +110,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarGroupId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The calendars in the calendar group. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendars in the calendar group. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendars in the calendar group. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs index ee9f52d78c6..7c5ded3d9d6 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -41,18 +41,17 @@ public Command BuildGetCommand() { }; UserOption.IsRequired = true; command.AddOption(UserOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string User) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string User, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, UserOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, UserOption, outputOption); return command; } /// @@ -85,16 +84,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function allowedCalendarSharingRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarPermissions/CalendarPermissionsRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarPermissions/CalendarPermissionsRequestBuilder.cs index 293d37a476a..3b704f5fd85 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarPermissions/CalendarPermissionsRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarPermissions/CalendarPermissionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.CalendarPermissions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class CalendarPermissionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new CalendarPermissionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, bodyOption, outputOption); return command; } /// @@ -80,7 +78,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -114,7 +112,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -186,31 +183,6 @@ public RequestInformation CreatePostRequestInformation(CalendarPermission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CalendarPermission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions of the users with whom the calendar is shared. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs index 1e2ed035071..e545168ac9f 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string calendarPermissionId) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string calendarPermissionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, calendarPermissionIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -70,7 +69,7 @@ public Command BuildGetCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); @@ -79,19 +78,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string calendarPermissionId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string calendarPermissionId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, calendarPermissionIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, calendarPermissionIdOption, selectOption, outputOption); return command; } /// @@ -105,7 +103,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -113,7 +111,7 @@ public Command BuildPatchCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); @@ -121,14 +119,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string calendarPermissionId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string calendarPermissionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, calendarPermissionIdOption, bodyOption); return command; @@ -200,42 +197,6 @@ public RequestInformation CreatePatchRequestInformation(CalendarPermission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(CalendarPermission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions of the users with whom the calendar is shared. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarRequestBuilder.cs index 09df658d91b..66dfc063c35 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.SingleValueExtendedProperties; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,6 +37,9 @@ public AllowedCalendarSharingRolesWithUserRequestBuilder AllowedCalendarSharingR public Command BuildCalendarPermissionsCommand() { var command = new Command("calendar-permissions"); var builder = new ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.CalendarPermissions.CalendarPermissionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -44,6 +47,9 @@ public Command BuildCalendarPermissionsCommand() { public Command BuildCalendarViewCommand() { var command = new Command("calendar-view"); var builder = new ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.CalendarView.CalendarViewRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -59,7 +65,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -67,11 +73,10 @@ public Command BuildDeleteCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption); return command; @@ -79,6 +84,9 @@ public Command BuildDeleteCommand() { public Command BuildEventsCommand() { var command = new Command("events"); var builder = new ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.Events.EventsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -94,7 +102,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -107,19 +115,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, selectOption, outputOption); return command; } public Command BuildGetScheduleCommand() { @@ -131,6 +138,9 @@ public Command BuildGetScheduleCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -146,7 +156,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -158,14 +168,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, bodyOption); return command; @@ -173,6 +182,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -244,42 +256,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The calendars in the calendar group. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendars in the calendar group. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendars in the calendar group. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendars in the calendar group. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/CalendarViewRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/CalendarViewRequestBuilder.cs index dd076308c78..418eff72957 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/CalendarViewRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/CalendarViewRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.CalendarView.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,24 +23,23 @@ public class CalendarViewRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildAttachmentsCommand(), - builder.BuildCalendarCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildExtensionsCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildInstancesCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildAttachmentsCommand()); + commands.Add(builder.BuildCalendarCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInstancesCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -54,7 +53,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -66,21 +65,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, bodyOption, outputOption); return command; } /// @@ -94,7 +92,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -128,7 +126,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -137,15 +139,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -188,7 +185,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -206,31 +203,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/CalendarViewResponse.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/CalendarViewResponse.cs index 38a09c3e01d..78aee25a000 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/CalendarViewResponse.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/CalendarViewResponse.cs @@ -9,7 +9,7 @@ public class CalendarViewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new calendarViewResponse and sets the default values. /// @@ -22,7 +22,7 @@ public CalendarViewResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as CalendarViewResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Delta/Delta.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Delta/Delta.cs deleted file mode 100644 index a5faf61f366..00000000000 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.CalendarView.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Delta/DeltaRequestBuilder.cs index eb5f79e8ef6..4c1ad7d4456 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +30,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -37,18 +38,17 @@ public Command BuildGetCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, outputOption); return command; } /// @@ -79,16 +79,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Accept/AcceptRequestBuilder.cs index f7627d390ab..1006aa49a10 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs index e68e18db4c2..e44b7272d26 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.CalendarView.Item.Attachments.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class AttachmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttachmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,7 +40,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -57,21 +56,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } public Command BuildCreateUploadSessionCommand() { @@ -91,7 +89,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -134,7 +132,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -144,15 +146,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -207,31 +204,6 @@ public RequestInformation CreatePostRequestInformation(Attachment body, Action - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index 5c81ec86564..93b16d81b1d 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs index 06469fa2ac9..0f997554112 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -46,11 +46,10 @@ public Command BuildDeleteCommand() { }; attachmentIdOption.IsRequired = true; command.AddOption(attachmentIdOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string attachmentId) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string attachmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, attachmentIdOption); return command; @@ -66,7 +65,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -92,20 +91,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string attachmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string attachmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,7 +117,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -139,14 +137,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string attachmentId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string attachmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, attachmentIdOption, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(Attachment body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs index d66b1f637a4..86ac35915e1 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,18 +45,17 @@ public Command BuildGetCommand() { }; UserOption.IsRequired = true; command.AddOption(UserOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string User) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string User, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, UserOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, UserOption, outputOption); return command; } /// @@ -89,16 +88,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function allowedCalendarSharingRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Calendar/CalendarRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Calendar/CalendarRequestBuilder.cs index 82f92f8cf2f..331b74ebd9e 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Calendar/CalendarRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Calendar/CalendarRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.CalendarView.Item.Calendar.GetSchedule; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -40,7 +40,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -52,11 +52,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption); return command; @@ -72,7 +71,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -89,19 +88,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, selectOption, outputOption); return command; } public Command BuildGetScheduleCommand() { @@ -121,7 +119,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -137,14 +135,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -216,42 +213,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar that contains the event. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs index dde118d1a7c..7f6b45e476e 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,21 +45,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -93,18 +92,5 @@ public RequestInformation CreatePostRequestInformation(GetScheduleRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSchedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetScheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs index a03a90c0985..f63fc064094 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Decline/DeclineRequestBuilder.cs index 8bc77990851..ae08e1554b9 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs index 526bc563aee..add2963af82 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -41,11 +41,10 @@ public Command BuildPostCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption); return command; @@ -78,16 +77,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/EventRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/EventRequestBuilder.cs index 583f2f034f5..c03a19475e0 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/EventRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/EventRequestBuilder.cs @@ -14,10 +14,10 @@ using ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.CalendarView.Item.TentativelyAccept; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,6 +41,9 @@ public Command BuildAcceptCommand() { public Command BuildAttachmentsCommand() { var command = new Command("attachments"); var builder = new ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.CalendarView.Item.Attachments.AttachmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateUploadSessionCommand()); command.AddCommand(builder.BuildListCommand()); @@ -78,7 +81,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -90,11 +93,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption); return command; @@ -108,6 +110,9 @@ public Command BuildDismissReminderCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.CalendarView.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -129,7 +134,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -146,24 +151,26 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, selectOption, outputOption); return command; } public Command BuildInstancesCommand() { var command = new Command("instances"); var builder = new ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.CalendarView.Item.Instances.InstancesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -171,6 +178,9 @@ public Command BuildInstancesCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.CalendarView.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -186,7 +196,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -202,14 +212,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -217,6 +226,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.CalendarView.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -288,7 +300,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -300,42 +312,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs index 6650258cb64..81cce94f53e 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.CalendarView.Item.Extensions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -127,7 +125,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -137,15 +139,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -200,31 +197,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs index 21251bca966..19ccf1f86ce 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -46,11 +46,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string extensionId) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, extensionIdOption); return command; @@ -66,7 +65,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -92,20 +91,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,7 +117,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -139,14 +137,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string extensionId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, extensionIdOption, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Forward/ForwardRequestBuilder.cs index 73e7a01c90e..c380e8db048 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Delta/Delta.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Delta/Delta.cs deleted file mode 100644 index ad34ca2ec29..00000000000 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.CalendarView.Item.Instances.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs index 24562a0a19a..e98621b94c7 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +30,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -41,18 +42,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, outputOption); return command; } /// @@ -83,16 +83,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/InstancesRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/InstancesRequestBuilder.cs index dcec1a73bb5..86d669de519 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/InstancesRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/InstancesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.CalendarView.Item.Instances.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class InstancesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -48,7 +47,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -64,21 +63,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -92,7 +90,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -130,7 +128,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -139,15 +141,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -190,7 +187,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -208,31 +205,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/InstancesResponse.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/InstancesResponse.cs index 7c7e021458a..72fe1107db2 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/InstancesResponse.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/InstancesResponse.cs @@ -9,7 +9,7 @@ public class InstancesResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new instancesResponse and sets the default values. /// @@ -22,7 +22,7 @@ public InstancesResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as InstancesResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs index 080a1d69c86..88cc00072df 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -49,14 +49,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -92,18 +91,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs index 72cc99d043f..a324f6d7c1e 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -49,14 +49,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -92,18 +91,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs index e2cfa470e03..be9f5b3dbaf 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -49,14 +49,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -92,18 +91,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs index 518426911d6..44ffac9d655 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,11 +45,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option); return command; @@ -82,16 +81,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/EventRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/EventRequestBuilder.cs index 1b50c14fe8a..a03a9a00bf7 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/EventRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.CalendarView.Item.Instances.Item.TentativelyAccept; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -55,7 +55,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -71,11 +71,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option); return command; @@ -103,7 +102,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -124,19 +123,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -150,7 +148,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -170,14 +168,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -249,7 +246,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -261,42 +258,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs index f7fb16f2f0d..f7d07d59b41 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -49,14 +49,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -92,18 +91,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index f9fe16480e4..2542b8e5ffc 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -49,14 +49,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -92,18 +91,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index 391aa7ffb7c..4e9a0156f80 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -49,14 +49,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -92,18 +91,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 25a2c942d99..2933f6dae27 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -42,15 +42,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -66,7 +65,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -78,7 +77,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -92,20 +91,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,7 +117,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -131,7 +129,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -139,14 +137,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index f734460c3e7..4ca246d1eca 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.CalendarView.Item.MultiValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -131,7 +129,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -142,15 +144,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -205,31 +202,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index e6a1a417857..a2f63bc784a 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -42,15 +42,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -66,7 +65,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -78,7 +77,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -92,20 +91,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,7 +117,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -131,7 +129,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -139,14 +137,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 0250db1a76b..29bb61e1a44 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.CalendarView.Item.SingleValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -131,7 +129,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -142,15 +144,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -205,31 +202,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index c25fc3ce4dd..91f3f42e5c9 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index 3443d7da2bb..d27ad207dc5 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Delta/Delta.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Delta/Delta.cs deleted file mode 100644 index 9d6e6e5ac1b..00000000000 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.Events.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Delta/DeltaRequestBuilder.cs index 8c191ab867b..c241d924f67 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +30,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -37,18 +38,17 @@ public Command BuildGetCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, outputOption); return command; } /// @@ -79,16 +79,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/EventsRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/EventsRequestBuilder.cs index 1df082a638b..859f92adb97 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/EventsRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/EventsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.Events.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,24 +23,23 @@ public class EventsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildAttachmentsCommand(), - builder.BuildCalendarCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildExtensionsCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildInstancesCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildAttachmentsCommand()); + commands.Add(builder.BuildCalendarCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInstancesCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -54,7 +53,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -66,21 +65,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, bodyOption, outputOption); return command; } /// @@ -94,7 +92,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -128,7 +126,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -137,15 +139,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -188,7 +185,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -206,31 +203,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The events in the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/EventsResponse.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/EventsResponse.cs index f330921d016..7873f4d630c 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/EventsResponse.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/EventsResponse.cs @@ -9,7 +9,7 @@ public class EventsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new eventsResponse and sets the default values. /// @@ -22,7 +22,7 @@ public EventsResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as EventsResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Accept/AcceptRequestBuilder.cs index 5dfa3852ca5..bfa15d122ef 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Attachments/AttachmentsRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Attachments/AttachmentsRequestBuilder.cs index 9be95de5014..d8bed3e21c8 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Attachments/AttachmentsRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Attachments/AttachmentsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.Events.Item.Attachments.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class AttachmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttachmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,7 +40,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -57,21 +56,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } public Command BuildCreateUploadSessionCommand() { @@ -91,7 +89,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -134,7 +132,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -144,15 +146,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -207,31 +204,6 @@ public RequestInformation CreatePostRequestInformation(Attachment body, Action - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index 0fb77618b36..6c18d8fc888 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs index c4275db84ca..124284b3208 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -46,11 +46,10 @@ public Command BuildDeleteCommand() { }; attachmentIdOption.IsRequired = true; command.AddOption(attachmentIdOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string attachmentId) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string attachmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, attachmentIdOption); return command; @@ -66,7 +65,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -92,20 +91,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string attachmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string attachmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,7 +117,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -139,14 +137,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string attachmentId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string attachmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, attachmentIdOption, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(Attachment body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs index dd1eb86657e..c61cda2c9ea 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,18 +45,17 @@ public Command BuildGetCommand() { }; UserOption.IsRequired = true; command.AddOption(UserOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string User) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string User, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, UserOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, UserOption, outputOption); return command; } /// @@ -89,16 +88,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function allowedCalendarSharingRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Calendar/CalendarRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Calendar/CalendarRequestBuilder.cs index 7c90a117fce..5daedf47882 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Calendar/CalendarRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Calendar/CalendarRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.Events.Item.Calendar.GetSchedule; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -40,7 +40,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -52,11 +52,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption); return command; @@ -72,7 +71,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -89,19 +88,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, selectOption, outputOption); return command; } public Command BuildGetScheduleCommand() { @@ -121,7 +119,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -137,14 +135,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -216,42 +213,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar that contains the event. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs index 8c4a87ebe00..0d7d2436717 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,21 +45,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -93,18 +92,5 @@ public RequestInformation CreatePostRequestInformation(GetScheduleRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSchedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetScheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Cancel/CancelRequestBuilder.cs index 52075fbebf6..d4f025c0b26 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Decline/DeclineRequestBuilder.cs index 78bf488f0d8..35312ebe092 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs index 54beed22861..c7295d23981 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -41,11 +41,10 @@ public Command BuildPostCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption); return command; @@ -78,16 +77,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/EventRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/EventRequestBuilder.cs index 12a037622ce..d6e56efbfcd 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/EventRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/EventRequestBuilder.cs @@ -14,10 +14,10 @@ using ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.Events.Item.TentativelyAccept; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,6 +41,9 @@ public Command BuildAcceptCommand() { public Command BuildAttachmentsCommand() { var command = new Command("attachments"); var builder = new ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.Events.Item.Attachments.AttachmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateUploadSessionCommand()); command.AddCommand(builder.BuildListCommand()); @@ -78,7 +81,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -90,11 +93,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption); return command; @@ -108,6 +110,9 @@ public Command BuildDismissReminderCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.Events.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -129,7 +134,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -146,24 +151,26 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, selectOption, outputOption); return command; } public Command BuildInstancesCommand() { var command = new Command("instances"); var builder = new ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.Events.Item.Instances.InstancesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -171,6 +178,9 @@ public Command BuildInstancesCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.Events.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -186,7 +196,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -202,14 +212,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -217,6 +226,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.Events.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -288,7 +300,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -300,42 +312,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The events in the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Extensions/ExtensionsRequestBuilder.cs index b95243b2591..1b2275ad9d3 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.Events.Item.Extensions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -127,7 +125,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -137,15 +139,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -200,31 +197,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs index 60b9a55defc..fea3589be85 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -46,11 +46,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string extensionId) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, extensionIdOption); return command; @@ -66,7 +65,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -92,20 +91,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,7 +117,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -139,14 +137,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string extensionId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, extensionIdOption, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Forward/ForwardRequestBuilder.cs index 74dee75a603..3cc59e27dbc 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Delta/Delta.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Delta/Delta.cs deleted file mode 100644 index 10dad0c437f..00000000000 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.Events.Item.Instances.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Delta/DeltaRequestBuilder.cs index 0e80377a86f..2dc1d499cf8 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +30,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -41,18 +42,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, outputOption); return command; } /// @@ -83,16 +83,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/InstancesRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/InstancesRequestBuilder.cs index e306417f315..ebdc7297186 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/InstancesRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/InstancesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.Events.Item.Instances.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class InstancesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -48,7 +47,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -64,21 +63,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -92,7 +90,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -130,7 +128,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -139,15 +141,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -190,7 +187,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -208,31 +205,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/InstancesResponse.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/InstancesResponse.cs index 3b86fff91bf..a2c4e346ea3 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/InstancesResponse.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/InstancesResponse.cs @@ -9,7 +9,7 @@ public class InstancesResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new instancesResponse and sets the default values. /// @@ -22,7 +22,7 @@ public InstancesResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as InstancesResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs index d5f152028ba..241d5a6bfac 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -49,14 +49,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -92,18 +91,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs index 1cf9029fabf..31fc6a815dd 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -49,14 +49,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -92,18 +91,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs index b6b85f2c3a2..9fe2ff7aac0 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -49,14 +49,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -92,18 +91,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs index 98859d5e8a1..df22e4fe1a9 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,11 +45,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option); return command; @@ -82,16 +81,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/EventRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/EventRequestBuilder.cs index e5a53f117d5..30eadd42138 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/EventRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.Events.Item.Instances.Item.TentativelyAccept; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -55,7 +55,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -71,11 +71,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option); return command; @@ -103,7 +102,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -124,19 +123,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -150,7 +148,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -170,14 +168,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -249,7 +246,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -261,42 +258,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs index 5257ac179af..83d25da90e1 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -49,14 +49,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -92,18 +91,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 7408f4beb0e..a58ebf9c9f0 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -49,14 +49,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -92,18 +91,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index 85fc413bc4c..ca7b43e6b95 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -49,14 +49,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -92,18 +91,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 871af2ff087..9726ba13806 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -42,15 +42,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -66,7 +65,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -78,7 +77,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -92,20 +91,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,7 +117,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -131,7 +129,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -139,14 +137,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 1b4785b93ac..5ef008ee8f1 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.Events.Item.MultiValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -131,7 +129,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -142,15 +144,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -205,31 +202,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 8ba85988a46..27920951868 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -42,15 +42,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -66,7 +65,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -78,7 +77,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -92,20 +91,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,7 +117,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -131,7 +129,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -139,14 +137,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 1a4d833a33e..8966b2adc84 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.Events.Item.SingleValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -131,7 +129,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -142,15 +144,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -205,31 +202,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 5a5c0398a2e..f6aa3467c0b 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index 26c2dc14509..93921f056a5 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/GetSchedule/GetScheduleRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/GetSchedule/GetScheduleRequestBuilder.cs index 81331151abb..4815798ee39 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/GetSchedule/GetScheduleRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/GetSchedule/GetScheduleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -41,21 +41,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, bodyOption, outputOption); return command; } /// @@ -89,18 +88,5 @@ public RequestInformation CreatePostRequestInformation(GetScheduleRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSchedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetScheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 9ca2f1980da..81d0fba82a9 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -70,7 +69,7 @@ public Command BuildGetCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,7 +109,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -119,7 +117,7 @@ public Command BuildPatchCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index c368f028ca0..767954491fe 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.MultiValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, bodyOption, outputOption); return command; } /// @@ -80,7 +78,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index f3f537312cf..62ece7f41a1 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -70,7 +69,7 @@ public Command BuildGetCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,7 +109,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -119,7 +117,7 @@ public Command BuildPatchCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarGroupIdOption, calendarIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 808b1a350e3..b1f88a29042 100644 --- a/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarGroups/Item/Calendars/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.CalendarGroups.Item.Calendars.Item.SingleValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, bodyOption, outputOption); return command; } /// @@ -80,7 +78,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var calendarGroupIdOption = new Option("--calendargroup-id", description: "key: id of calendarGroup") { + var calendarGroupIdOption = new Option("--calendar-group-id", description: "key: id of calendarGroup") { }; calendarGroupIdOption.IsRequired = true; command.AddOption(calendarGroupIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarGroupId, string calendarId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarGroupId, string calendarId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarGroupIdOption, calendarIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarGroupIdOption, calendarIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarView/CalendarViewRequestBuilder.cs b/src/generated/Users/Item/CalendarView/CalendarViewRequestBuilder.cs index 7eec3472569..9584e97648b 100644 --- a/src/generated/Users/Item/CalendarView/CalendarViewRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/CalendarViewRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.CalendarView.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,24 +23,23 @@ public class CalendarViewRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildAttachmentsCommand(), - builder.BuildCalendarCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildExtensionsCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildInstancesCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildAttachmentsCommand()); + commands.Add(builder.BuildCalendarCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInstancesCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -58,21 +57,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -86,11 +84,11 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var startDateTimeOption = new Option("--startdatetime", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { + var startDateTimeOption = new Option("--start-date-time", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { }; startDateTimeOption.IsRequired = true; command.AddOption(startDateTimeOption); - var endDateTimeOption = new Option("--enddatetime", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { + var endDateTimeOption = new Option("--end-date-time", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { }; endDateTimeOption.IsRequired = true; command.AddOption(endDateTimeOption); @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string startDateTime, string endDateTime, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string startDateTime, string endDateTime, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { if (!String.IsNullOrEmpty(startDateTime)) q.StartDateTime = startDateTime; if (!String.IsNullOrEmpty(endDateTime)) q.EndDateTime = endDateTime; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, startDateTimeOption, endDateTimeOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, startDateTimeOption, endDateTimeOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -182,7 +179,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -200,31 +197,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The calendar view for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarView/CalendarViewResponse.cs b/src/generated/Users/Item/CalendarView/CalendarViewResponse.cs index 97a5e12605e..12d4ae39450 100644 --- a/src/generated/Users/Item/CalendarView/CalendarViewResponse.cs +++ b/src/generated/Users/Item/CalendarView/CalendarViewResponse.cs @@ -9,7 +9,7 @@ public class CalendarViewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new calendarViewResponse and sets the default values. /// @@ -22,7 +22,7 @@ public CalendarViewResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as CalendarViewResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Users/Item/CalendarView/Delta/Delta.cs b/src/generated/Users/Item/CalendarView/Delta/Delta.cs deleted file mode 100644 index 55c310b7d19..00000000000 --- a/src/generated/Users/Item/CalendarView/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.CalendarView.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Users/Item/CalendarView/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Delta/DeltaRequestBuilder.cs index c8ebb03f9e0..7e07c17bbd7 100644 --- a/src/generated/Users/Item/CalendarView/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +30,17 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Accept/AcceptRequestBuilder.cs index 81c07b85911..d18da464ae4 100644 --- a/src/generated/Users/Item/CalendarView/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs index 8dd9efe239d..9dbbbdd70bb 100644 --- a/src/generated/Users/Item/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.CalendarView.Item.Attachments.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class AttachmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttachmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } public Command BuildCreateUploadSessionCommand() { @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(Attachment body, Action - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index 9eeaba66dfc..1c96be2448d 100644 --- a/src/generated/Users/Item/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs index c39782022f5..d1860512e6c 100644 --- a/src/generated/Users/Item/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; attachmentIdOption.IsRequired = true; command.AddOption(attachmentIdOption); - command.SetHandler(async (string userId, string eventId, string attachmentId) => { + command.SetHandler(async (string userId, string eventId, string attachmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, attachmentIdOption); return command; @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, string attachmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string attachmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string attachmentId, string body) => { + command.SetHandler(async (string userId, string eventId, string attachmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, attachmentIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Attachment body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs index 62266fb417d..dfca0c35b17 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,18 +37,17 @@ public Command BuildGetCommand() { }; UserOption.IsRequired = true; command.AddOption(UserOption); - command.SetHandler(async (string userId, string eventId, string User) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string User, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, UserOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, UserOption, outputOption); return command; } /// @@ -81,16 +80,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function allowedCalendarSharingRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs index 953222142cf..7ae20708d28 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.CalendarView.Item.Calendar.CalendarPermissions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class CalendarPermissionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new CalendarPermissionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -106,7 +104,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -115,15 +117,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -178,31 +175,6 @@ public RequestInformation CreatePostRequestInformation(CalendarPermission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CalendarPermission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions of the users with whom the calendar is shared. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs index 03b7211d675..605e5f1ecb7 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); - command.SetHandler(async (string userId, string eventId, string calendarPermissionId) => { + command.SetHandler(async (string userId, string eventId, string calendarPermissionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, calendarPermissionIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); @@ -71,19 +70,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, string calendarPermissionId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string calendarPermissionId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, calendarPermissionIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, calendarPermissionIdOption, selectOption, outputOption); return command; } /// @@ -101,7 +99,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); @@ -109,14 +107,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string calendarPermissionId, string body) => { + command.SetHandler(async (string userId, string eventId, string calendarPermissionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, calendarPermissionIdOption, bodyOption); return command; @@ -188,42 +185,6 @@ public RequestInformation CreatePatchRequestInformation(CalendarPermission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(CalendarPermission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions of the users with whom the calendar is shared. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarRequestBuilder.cs index c160afc9045..c1813e53975 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Users.Item.CalendarView.Item.Calendar.SingleValueExtendedProperties; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,6 +37,9 @@ public AllowedCalendarSharingRolesWithUserRequestBuilder AllowedCalendarSharingR public Command BuildCalendarPermissionsCommand() { var command = new Command("calendar-permissions"); var builder = new ApiSdk.Users.Item.CalendarView.Item.Calendar.CalendarPermissions.CalendarPermissionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -44,6 +47,9 @@ public Command BuildCalendarPermissionsCommand() { public Command BuildCalendarViewCommand() { var command = new Command("calendar-view"); var builder = new ApiSdk.Users.Item.CalendarView.Item.Calendar.CalendarView.CalendarViewRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -63,11 +69,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string eventId) => { + command.SetHandler(async (string userId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption); return command; @@ -75,6 +80,9 @@ public Command BuildDeleteCommand() { public Command BuildEventsCommand() { var command = new Command("events"); var builder = new ApiSdk.Users.Item.CalendarView.Item.Calendar.Events.EventsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -99,19 +107,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, selectOption, outputOption); return command; } public Command BuildGetScheduleCommand() { @@ -123,6 +130,9 @@ public Command BuildGetScheduleCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Users.Item.CalendarView.Item.Calendar.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -146,14 +156,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -161,6 +170,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Users.Item.CalendarView.Item.Calendar.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -232,42 +244,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar that contains the event. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs index fbae7de06de..7826d556e3c 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.CalendarView.Item.Calendar.CalendarView.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class CalendarViewRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -114,7 +112,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -174,7 +171,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/CalendarViewResponse.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/CalendarViewResponse.cs index b900f6e1a0d..b561bc30daa 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/CalendarViewResponse.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/CalendarViewResponse.cs @@ -9,7 +9,7 @@ public class CalendarViewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new calendarViewResponse and sets the default values. /// @@ -22,7 +22,7 @@ public CalendarViewResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as CalendarViewResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Delta/Delta.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Delta/Delta.cs deleted file mode 100644 index 0f84fc23bbd..00000000000 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.CalendarView.Item.Calendar.CalendarView.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs index a27a525922a..b17f739b1d5 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +34,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, outputOption); return command; } /// @@ -75,16 +75,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs index e25d829e6f9..51e326000f3 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs index 7f185527431..178c07255d6 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs index e0d4dfdc96f..e732274aef1 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs index 5a3302b8ba0..41781ac5c5e 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,11 +37,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string userId, string eventId, string eventId1) => { + command.SetHandler(async (string userId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs index 73936439635..e0c7a4b97ae 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Users.Item.CalendarView.Item.Calendar.CalendarView.Item.TentativelyAccept; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -63,11 +63,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string userId, string eventId, string eventId1) => { + command.SetHandler(async (string userId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option); return command; @@ -108,19 +107,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -146,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -225,7 +222,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -237,42 +234,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs index ed6835ad4b3..96a9322e31b 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 465ced41adc..c1055a3aca7 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index e71bbee72cd..1e215bf83f2 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Delta/Delta.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Delta/Delta.cs deleted file mode 100644 index c2507bfc92b..00000000000 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.CalendarView.Item.Calendar.Events.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs index dc2f6718d13..bb0a4e7a3f9 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +34,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, outputOption); return command; } /// @@ -75,16 +75,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/Events/EventsRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/Events/EventsRequestBuilder.cs index 10585947b98..223fab59f6b 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/Events/EventsRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/Events/EventsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.CalendarView.Item.Calendar.Events.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class EventsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -114,7 +112,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -174,7 +171,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The events in the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/Events/EventsResponse.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/Events/EventsResponse.cs index 545efa0371c..eeb3594dadb 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/Events/EventsResponse.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/Events/EventsResponse.cs @@ -9,7 +9,7 @@ public class EventsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new eventsResponse and sets the default values. /// @@ -22,7 +22,7 @@ public EventsResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as EventsResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs index 917b799e2b5..dd3cf974c2f 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs index 0483f65828a..6b11b41ae48 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs index d28dcb42cca..fcacc05a27a 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs index 48b58e4aea7..a89074b97dd 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,11 +37,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string userId, string eventId, string eventId1) => { + command.SetHandler(async (string userId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/EventRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/EventRequestBuilder.cs index 6d57b07862a..569539c9e28 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/EventRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Users.Item.CalendarView.Item.Calendar.Events.Item.TentativelyAccept; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -63,11 +63,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string userId, string eventId, string eventId1) => { + command.SetHandler(async (string userId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option); return command; @@ -108,19 +107,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -146,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -225,7 +222,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -237,42 +234,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The events in the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs index eee27ab9305..04ed4411d15 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 2550720a87e..2400bfbbd78 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index d44f0274773..b834f0672fd 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs index 2b10e0f990c..ef7d8c413a1 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,21 +37,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -85,18 +84,5 @@ public RequestInformation CreatePostRequestInformation(GetScheduleRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSchedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetScheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index abcf42732e7..a16c27914ab 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index aeddf3f190a..75a4a314c52 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.CalendarView.Item.Calendar.MultiValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 7ff1d5c4f0b..6723ad9562b 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/CalendarView/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 5b7e364d63b..9a13b208616 100644 --- a/src/generated/Users/Item/CalendarView/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.CalendarView.Item.Calendar.SingleValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs index 258a5180e6f..a0d4af66362 100644 --- a/src/generated/Users/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Decline/DeclineRequestBuilder.cs index 79f5cd36b7e..5b4543b44c7 100644 --- a/src/generated/Users/Item/CalendarView/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs index b3a271051e1..70039235dff 100644 --- a/src/generated/Users/Item/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,11 +33,10 @@ public Command BuildPostCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string eventId) => { + command.SetHandler(async (string userId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/EventRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/EventRequestBuilder.cs index 35a7ca85b67..3c289a6d986 100644 --- a/src/generated/Users/Item/CalendarView/Item/EventRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/EventRequestBuilder.cs @@ -14,10 +14,10 @@ using ApiSdk.Users.Item.CalendarView.Item.TentativelyAccept; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,6 +41,9 @@ public Command BuildAcceptCommand() { public Command BuildAttachmentsCommand() { var command = new Command("attachments"); var builder = new ApiSdk.Users.Item.CalendarView.Item.Attachments.AttachmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateUploadSessionCommand()); command.AddCommand(builder.BuildListCommand()); @@ -87,11 +90,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string eventId) => { + command.SetHandler(async (string userId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption); return command; @@ -105,6 +107,9 @@ public Command BuildDismissReminderCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Users.Item.CalendarView.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -130,11 +135,11 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var startDateTimeOption = new Option("--startdatetime", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { + var startDateTimeOption = new Option("--start-date-time", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { }; startDateTimeOption.IsRequired = true; command.AddOption(startDateTimeOption); - var endDateTimeOption = new Option("--enddatetime", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { + var endDateTimeOption = new Option("--end-date-time", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { }; endDateTimeOption.IsRequired = true; command.AddOption(endDateTimeOption); @@ -143,26 +148,28 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, string startDateTime, string endDateTime, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string startDateTime, string endDateTime, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { if (!String.IsNullOrEmpty(startDateTime)) q.StartDateTime = startDateTime; if (!String.IsNullOrEmpty(endDateTime)) q.EndDateTime = endDateTime; q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, startDateTimeOption, endDateTimeOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, startDateTimeOption, endDateTimeOption, selectOption, outputOption); return command; } public Command BuildInstancesCommand() { var command = new Command("instances"); var builder = new ApiSdk.Users.Item.CalendarView.Item.Instances.InstancesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -170,6 +177,9 @@ public Command BuildInstancesCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Users.Item.CalendarView.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -193,14 +203,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -208,6 +217,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Users.Item.CalendarView.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -279,7 +291,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -291,42 +303,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The calendar view for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00 diff --git a/src/generated/Users/Item/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs index 673189e97e2..678f01abd63 100644 --- a/src/generated/Users/Item/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.CalendarView.Item.Extensions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs index 61742c81d5a..8ceacfa6a3a 100644 --- a/src/generated/Users/Item/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string userId, string eventId, string extensionId) => { + command.SetHandler(async (string userId, string eventId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, extensionIdOption); return command; @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string extensionId, string body) => { + command.SetHandler(async (string userId, string eventId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, extensionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/CalendarView/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Forward/ForwardRequestBuilder.cs index c1e1fe35d5d..064635a4271 100644 --- a/src/generated/Users/Item/CalendarView/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Instances/Delta/Delta.cs b/src/generated/Users/Item/CalendarView/Item/Instances/Delta/Delta.cs deleted file mode 100644 index bef18abc022..00000000000 --- a/src/generated/Users/Item/CalendarView/Item/Instances/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.CalendarView.Item.Instances.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Users/Item/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs index 2c011a43106..26b01e866d4 100644 --- a/src/generated/Users/Item/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +34,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, outputOption); return command; } /// @@ -75,16 +75,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Instances/InstancesRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Instances/InstancesRequestBuilder.cs index dfb1bb497c2..94d10d79b7f 100644 --- a/src/generated/Users/Item/CalendarView/Item/Instances/InstancesRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Instances/InstancesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.CalendarView.Item.Instances.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class InstancesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -114,7 +112,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -174,7 +171,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarView/Item/Instances/InstancesResponse.cs b/src/generated/Users/Item/CalendarView/Item/Instances/InstancesResponse.cs index 040a55b6b8b..76901cc385a 100644 --- a/src/generated/Users/Item/CalendarView/Item/Instances/InstancesResponse.cs +++ b/src/generated/Users/Item/CalendarView/Item/Instances/InstancesResponse.cs @@ -9,7 +9,7 @@ public class InstancesResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new instancesResponse and sets the default values. /// @@ -22,7 +22,7 @@ public InstancesResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as InstancesResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Users/Item/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs index 41e44e384de..5931322d671 100644 --- a/src/generated/Users/Item/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs index ead530d20cb..fef144112b5 100644 --- a/src/generated/Users/Item/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs index 9b5b06427c4..70dd793bb69 100644 --- a/src/generated/Users/Item/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs index 727a8d70c48..12cf8b4721c 100644 --- a/src/generated/Users/Item/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,11 +37,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string userId, string eventId, string eventId1) => { + command.SetHandler(async (string userId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Instances/Item/EventRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Instances/Item/EventRequestBuilder.cs index e70a3c82045..f20dde18a1a 100644 --- a/src/generated/Users/Item/CalendarView/Item/Instances/Item/EventRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Instances/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Users.Item.CalendarView.Item.Instances.Item.TentativelyAccept; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -63,11 +63,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string userId, string eventId, string eventId1) => { + command.SetHandler(async (string userId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option); return command; @@ -108,19 +107,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -146,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -225,7 +222,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -237,42 +234,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs index b8e7c0a65a5..2ec4dcf7c31 100644 --- a/src/generated/Users/Item/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index c54ecfd0560..b407401c7f0 100644 --- a/src/generated/Users/Item/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index 63289a76776..d39ad7e11a3 100644 --- a/src/generated/Users/Item/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index bfcb4d3f074..5727985b149 100644 --- a/src/generated/Users/Item/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 00e0e5a797f..9775cf987ab 100644 --- a/src/generated/Users/Item/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.CalendarView.Item.MultiValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 07f933b7bff..02450aa3826 100644 --- a/src/generated/Users/Item/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index b906fbf7225..a602709f2a4 100644 --- a/src/generated/Users/Item/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.CalendarView.Item.SingleValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 053b13418b9..8b7e724dff8 100644 --- a/src/generated/Users/Item/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Users/Item/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index b2007edb4c5..df9826fae8e 100644 --- a/src/generated/Users/Item/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Users/Item/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/CalendarsRequestBuilder.cs b/src/generated/Users/Item/Calendars/CalendarsRequestBuilder.cs index cb85b1cbc8d..a424c8a96ed 100644 --- a/src/generated/Users/Item/Calendars/CalendarsRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/CalendarsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Calendars.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,17 +22,16 @@ public class CalendarsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new CalendarRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCalendarPermissionsCommand(), - builder.BuildCalendarViewCommand(), - builder.BuildDeleteCommand(), - builder.BuildEventsCommand(), - builder.BuildGetCommand(), - builder.BuildGetScheduleCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCalendarPermissionsCommand()); + commands.Add(builder.BuildCalendarViewCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildEventsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildGetScheduleCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); return commands; } /// @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -104,7 +102,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -113,15 +115,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -176,31 +173,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user's calendars. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's calendars. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's calendars. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendars/Item/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs index 47763e21b68..e2d55cc1eac 100644 --- a/src/generated/Users/Item/Calendars/Item/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,18 +37,17 @@ public Command BuildGetCommand() { }; UserOption.IsRequired = true; command.AddOption(UserOption); - command.SetHandler(async (string userId, string calendarId, string User) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string User, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, UserOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, UserOption, outputOption); return command; } /// @@ -81,16 +80,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function allowedCalendarSharingRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/CalendarPermissions/CalendarPermissionsRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarPermissions/CalendarPermissionsRequestBuilder.cs index 6c251cc887d..8ac8275a685 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarPermissions/CalendarPermissionsRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarPermissions/CalendarPermissionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Calendars.Item.CalendarPermissions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class CalendarPermissionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new CalendarPermissionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, bodyOption, outputOption); return command; } /// @@ -106,7 +104,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -115,15 +117,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -178,31 +175,6 @@ public RequestInformation CreatePostRequestInformation(CalendarPermission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CalendarPermission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions of the users with whom the calendar is shared. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendars/Item/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs index f710fed7a98..6eb4c775104 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); - command.SetHandler(async (string userId, string calendarId, string calendarPermissionId) => { + command.SetHandler(async (string userId, string calendarId, string calendarPermissionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, calendarPermissionIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); @@ -71,19 +70,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarId, string calendarPermissionId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string calendarPermissionId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, calendarPermissionIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, calendarPermissionIdOption, selectOption, outputOption); return command; } /// @@ -101,7 +99,7 @@ public Command BuildPatchCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); @@ -109,14 +107,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string calendarPermissionId, string body) => { + command.SetHandler(async (string userId, string calendarId, string calendarPermissionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, calendarPermissionIdOption, bodyOption); return command; @@ -188,42 +185,6 @@ public RequestInformation CreatePatchRequestInformation(CalendarPermission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(CalendarPermission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions of the users with whom the calendar is shared. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/Calendars/Item/CalendarRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarRequestBuilder.cs index dddaae91839..aff74841878 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Users.Item.Calendars.Item.SingleValueExtendedProperties; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,6 +37,9 @@ public AllowedCalendarSharingRolesWithUserRequestBuilder AllowedCalendarSharingR public Command BuildCalendarPermissionsCommand() { var command = new Command("calendar-permissions"); var builder = new ApiSdk.Users.Item.Calendars.Item.CalendarPermissions.CalendarPermissionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -44,6 +47,9 @@ public Command BuildCalendarPermissionsCommand() { public Command BuildCalendarViewCommand() { var command = new Command("calendar-view"); var builder = new ApiSdk.Users.Item.Calendars.Item.CalendarView.CalendarViewRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -63,11 +69,10 @@ public Command BuildDeleteCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - command.SetHandler(async (string userId, string calendarId) => { + command.SetHandler(async (string userId, string calendarId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption); return command; @@ -75,6 +80,9 @@ public Command BuildDeleteCommand() { public Command BuildEventsCommand() { var command = new Command("events"); var builder = new ApiSdk.Users.Item.Calendars.Item.Events.EventsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -99,19 +107,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, selectOption, outputOption); return command; } public Command BuildGetScheduleCommand() { @@ -123,6 +130,9 @@ public Command BuildGetScheduleCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Users.Item.Calendars.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -146,14 +156,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string body) => { + command.SetHandler(async (string userId, string calendarId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, bodyOption); return command; @@ -161,6 +170,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Users.Item.Calendars.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -232,42 +244,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user's calendars. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's calendars. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's calendars. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's calendars. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/CalendarViewRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/CalendarViewRequestBuilder.cs index a75c69a0e6d..cdccbf8a209 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/CalendarViewRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/CalendarViewRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Calendars.Item.CalendarView.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,24 +23,23 @@ public class CalendarViewRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildAttachmentsCommand(), - builder.BuildCalendarCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildExtensionsCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildInstancesCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildAttachmentsCommand()); + commands.Add(builder.BuildCalendarCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInstancesCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -62,21 +61,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, bodyOption, outputOption); return command; } /// @@ -94,11 +92,11 @@ public Command BuildListCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var startDateTimeOption = new Option("--startdatetime", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { + var startDateTimeOption = new Option("--start-date-time", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { }; startDateTimeOption.IsRequired = true; command.AddOption(startDateTimeOption); - var endDateTimeOption = new Option("--enddatetime", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { + var endDateTimeOption = new Option("--end-date-time", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { }; endDateTimeOption.IsRequired = true; command.AddOption(endDateTimeOption); @@ -128,7 +126,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarId, string startDateTime, string endDateTime, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string startDateTime, string endDateTime, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { if (!String.IsNullOrEmpty(startDateTime)) q.StartDateTime = startDateTime; if (!String.IsNullOrEmpty(endDateTime)) q.EndDateTime = endDateTime; @@ -139,15 +141,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, startDateTimeOption, endDateTimeOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, startDateTimeOption, endDateTimeOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -190,7 +187,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -208,31 +205,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/CalendarViewResponse.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/CalendarViewResponse.cs index 87713ab1e5f..d538117cca0 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/CalendarViewResponse.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/CalendarViewResponse.cs @@ -9,7 +9,7 @@ public class CalendarViewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new calendarViewResponse and sets the default values. /// @@ -22,7 +22,7 @@ public CalendarViewResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as CalendarViewResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Delta/Delta.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Delta/Delta.cs deleted file mode 100644 index 389466ae132..00000000000 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.Calendars.Item.CalendarView.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Delta/DeltaRequestBuilder.cs index 608266829f5..cd7daca9b46 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +34,17 @@ public Command BuildGetCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - command.SetHandler(async (string userId, string calendarId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, outputOption); return command; } /// @@ -75,16 +75,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Accept/AcceptRequestBuilder.cs index 2fa8392789b..1f2abdfb690 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs index c2f98c4e795..4ea057ba965 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Attachments/AttachmentsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Calendars.Item.CalendarView.Item.Attachments.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class AttachmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttachmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } public Command BuildCreateUploadSessionCommand() { @@ -126,7 +124,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(Attachment body, Action - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index 6ea8960daee..297c603f5f3 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs index a108fd05270..2292d1c0ffb 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Attachments/Item/AttachmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -42,11 +42,10 @@ public Command BuildDeleteCommand() { }; attachmentIdOption.IsRequired = true; command.AddOption(attachmentIdOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string attachmentId) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string attachmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, attachmentIdOption); return command; @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string attachmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string attachmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string attachmentId, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string attachmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, attachmentIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(Attachment body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs index 5e9dc5cc2ae..ad8caf87150 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,18 +41,17 @@ public Command BuildGetCommand() { }; UserOption.IsRequired = true; command.AddOption(UserOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string User) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string User, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, UserOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, UserOption, outputOption); return command; } /// @@ -85,16 +84,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function allowedCalendarSharingRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Calendar/CalendarRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Calendar/CalendarRequestBuilder.cs index d906f283915..1478d5df72b 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Calendar/CalendarRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Calendar/CalendarRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Calendars.Item.CalendarView.Item.Calendar.GetSchedule; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -48,11 +48,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string calendarId, string eventId) => { + command.SetHandler(async (string userId, string calendarId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption); return command; @@ -81,19 +80,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, selectOption, outputOption); return command; } public Command BuildGetScheduleCommand() { @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar that contains the event. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs index 30ce09934f8..0a5df2b0bf1 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,21 +41,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -89,18 +88,5 @@ public RequestInformation CreatePostRequestInformation(GetScheduleRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSchedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetScheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs index 1221e17527c..ad0c5bd1e4e 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Decline/DeclineRequestBuilder.cs index 4d72573679d..1e9c635f725 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs index 2796aeb0f4f..3194f725bcc 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,11 +37,10 @@ public Command BuildPostCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string calendarId, string eventId) => { + command.SetHandler(async (string userId, string calendarId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/EventRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/EventRequestBuilder.cs index 7580cb67510..04dfe938e92 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/EventRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/EventRequestBuilder.cs @@ -14,10 +14,10 @@ using ApiSdk.Users.Item.Calendars.Item.CalendarView.Item.TentativelyAccept; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,6 +41,9 @@ public Command BuildAcceptCommand() { public Command BuildAttachmentsCommand() { var command = new Command("attachments"); var builder = new ApiSdk.Users.Item.Calendars.Item.CalendarView.Item.Attachments.AttachmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateUploadSessionCommand()); command.AddCommand(builder.BuildListCommand()); @@ -86,11 +89,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string calendarId, string eventId) => { + command.SetHandler(async (string userId, string calendarId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption); return command; @@ -104,6 +106,9 @@ public Command BuildDismissReminderCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Users.Item.Calendars.Item.CalendarView.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -133,11 +138,11 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var startDateTimeOption = new Option("--startdatetime", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { + var startDateTimeOption = new Option("--start-date-time", description: "The start date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T19:00:00-08:00") { }; startDateTimeOption.IsRequired = true; command.AddOption(startDateTimeOption); - var endDateTimeOption = new Option("--enddatetime", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { + var endDateTimeOption = new Option("--end-date-time", description: "The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00") { }; endDateTimeOption.IsRequired = true; command.AddOption(endDateTimeOption); @@ -146,26 +151,28 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string startDateTime, string endDateTime, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string startDateTime, string endDateTime, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { if (!String.IsNullOrEmpty(startDateTime)) q.StartDateTime = startDateTime; if (!String.IsNullOrEmpty(endDateTime)) q.EndDateTime = endDateTime; q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, startDateTimeOption, endDateTimeOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, startDateTimeOption, endDateTimeOption, selectOption, outputOption); return command; } public Command BuildInstancesCommand() { var command = new Command("instances"); var builder = new ApiSdk.Users.Item.Calendars.Item.CalendarView.Item.Instances.InstancesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -173,6 +180,9 @@ public Command BuildInstancesCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Users.Item.Calendars.Item.CalendarView.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -200,14 +210,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -215,6 +224,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Users.Item.Calendars.Item.CalendarView.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -286,7 +298,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -298,42 +310,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// The end date and time of the time range, represented in ISO 8601 format. For example, 2019-11-08T20:00:00-08:00 diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs index b08707965fb..e40203424db 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Calendars.Item.CalendarView.Item.Extensions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -129,15 +131,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs index c0f07da21b8..815ac5f1f81 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -42,11 +42,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string extensionId) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, extensionIdOption); return command; @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string extensionId, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, extensionIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Forward/ForwardRequestBuilder.cs index 45b437177fd..9e4d9e8ce18 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Delta/Delta.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Delta/Delta.cs deleted file mode 100644 index 910aa317a9b..00000000000 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.Calendars.Item.CalendarView.Item.Instances.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs index 464ec72ff3b..6f3ec01955e 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,18 +38,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string calendarId, string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, outputOption); return command; } /// @@ -79,16 +79,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/InstancesRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/InstancesRequestBuilder.cs index 4e06b89cb0d..3be74ceae3a 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/InstancesRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/InstancesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Calendars.Item.CalendarView.Item.Instances.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class InstancesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -60,21 +59,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -122,7 +120,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -182,7 +179,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -200,31 +197,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/InstancesResponse.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/InstancesResponse.cs index 8f4e85f52d9..4026e1959d4 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/InstancesResponse.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/InstancesResponse.cs @@ -9,7 +9,7 @@ public class InstancesResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new instancesResponse and sets the default values. /// @@ -22,7 +22,7 @@ public InstancesResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as InstancesResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs index 26b03f0be0a..69959240caa 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs index 513a691eedf..4629f038a31 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs index f334e468c5b..9500d98eec4 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs index 5b0e0560fc1..9caaf254b79 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,11 +41,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, eventId1Option); return command; @@ -78,16 +77,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/EventRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/EventRequestBuilder.cs index 40cd2d93c03..3c3f296e3b9 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/EventRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Users.Item.Calendars.Item.CalendarView.Item.Instances.Item.TentativelyAccept; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -67,11 +67,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, eventId1Option); return command; @@ -116,19 +115,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -158,14 +156,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -237,7 +234,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -249,42 +246,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs index 13400a71c26..10bdbca7a64 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 083652ba058..68c419183db 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index b8c21f8fbc5..7880a0688a1 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 23ddc9e58da..6c1c002008d 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -70,7 +69,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,7 +117,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 5577d539c4f..50b3a2b4ad2 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Calendars.Item.CalendarView.Item.MultiValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 3569e17ccd5..a9a77a7d663 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -70,7 +69,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,7 +117,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 69e2239421f..ee976313876 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Calendars.Item.CalendarView.Item.SingleValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index fc081e1fcd1..171e1a195de 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index cf47027d7a4..5f9f1f0557d 100644 --- a/src/generated/Users/Item/Calendars/Item/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/Events/Delta/Delta.cs b/src/generated/Users/Item/Calendars/Item/Events/Delta/Delta.cs deleted file mode 100644 index 9b07b5714a5..00000000000 --- a/src/generated/Users/Item/Calendars/Item/Events/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.Calendars.Item.Events.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Users/Item/Calendars/Item/Events/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Delta/DeltaRequestBuilder.cs index 0141cddc3d7..23a2c0c0627 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +34,17 @@ public Command BuildGetCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - command.SetHandler(async (string userId, string calendarId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, outputOption); return command; } /// @@ -75,16 +75,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/Events/EventsRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/EventsRequestBuilder.cs index b8bab13ba3a..0d560a62c85 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/EventsRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/EventsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Calendars.Item.Events.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,24 +23,23 @@ public class EventsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildAttachmentsCommand(), - builder.BuildCalendarCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildExtensionsCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildInstancesCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildAttachmentsCommand()); + commands.Add(builder.BuildCalendarCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInstancesCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -62,21 +61,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, bodyOption, outputOption); return command; } /// @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -129,15 +131,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -180,7 +177,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -198,31 +195,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The events in the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendars/Item/Events/EventsResponse.cs b/src/generated/Users/Item/Calendars/Item/Events/EventsResponse.cs index ff4487237ee..763077e7593 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/EventsResponse.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/EventsResponse.cs @@ -9,7 +9,7 @@ public class EventsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new eventsResponse and sets the default values. /// @@ -22,7 +22,7 @@ public EventsResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as EventsResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/Accept/AcceptRequestBuilder.cs index 800aa032e98..fdf8d2d8794 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/Attachments/AttachmentsRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/Attachments/AttachmentsRequestBuilder.cs index 014afa4292e..80fbd4e211a 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/Attachments/AttachmentsRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/Attachments/AttachmentsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Calendars.Item.Events.Item.Attachments.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class AttachmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttachmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } public Command BuildCreateUploadSessionCommand() { @@ -126,7 +124,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(Attachment body, Action - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index 713f8e468a2..803ceb6fb5e 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs index 47a485f7652..c3fdb548db2 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -42,11 +42,10 @@ public Command BuildDeleteCommand() { }; attachmentIdOption.IsRequired = true; command.AddOption(attachmentIdOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string attachmentId) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string attachmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, attachmentIdOption); return command; @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string attachmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string attachmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string attachmentId, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string attachmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, attachmentIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(Attachment body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs index 78f16f984fe..112b8242030 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,18 +41,17 @@ public Command BuildGetCommand() { }; UserOption.IsRequired = true; command.AddOption(UserOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string User) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string User, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, UserOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, UserOption, outputOption); return command; } /// @@ -85,16 +84,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function allowedCalendarSharingRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/Calendar/CalendarRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/Calendar/CalendarRequestBuilder.cs index 014c9214e46..b88290669c5 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/Calendar/CalendarRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/Calendar/CalendarRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Calendars.Item.Events.Item.Calendar.GetSchedule; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -48,11 +48,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string calendarId, string eventId) => { + command.SetHandler(async (string userId, string calendarId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption); return command; @@ -81,19 +80,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, selectOption, outputOption); return command; } public Command BuildGetScheduleCommand() { @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar that contains the event. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs index 2d7c5227cc0..97825431a3b 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,21 +41,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -89,18 +88,5 @@ public RequestInformation CreatePostRequestInformation(GetScheduleRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSchedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetScheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/Cancel/CancelRequestBuilder.cs index 7938d76e3b3..17af30d2085 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/Decline/DeclineRequestBuilder.cs index dbfd87ad3f4..be04f1d6cf0 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs index facbec47ade..e459710da64 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,11 +37,10 @@ public Command BuildPostCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string calendarId, string eventId) => { + command.SetHandler(async (string userId, string calendarId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/EventRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/EventRequestBuilder.cs index 5d5842d96f5..2ef7b25f855 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/EventRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/EventRequestBuilder.cs @@ -14,10 +14,10 @@ using ApiSdk.Users.Item.Calendars.Item.Events.Item.TentativelyAccept; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,6 +41,9 @@ public Command BuildAcceptCommand() { public Command BuildAttachmentsCommand() { var command = new Command("attachments"); var builder = new ApiSdk.Users.Item.Calendars.Item.Events.Item.Attachments.AttachmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateUploadSessionCommand()); command.AddCommand(builder.BuildListCommand()); @@ -86,11 +89,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string calendarId, string eventId) => { + command.SetHandler(async (string userId, string calendarId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption); return command; @@ -104,6 +106,9 @@ public Command BuildDismissReminderCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Users.Item.Calendars.Item.Events.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -138,24 +143,26 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, selectOption, outputOption); return command; } public Command BuildInstancesCommand() { var command = new Command("instances"); var builder = new ApiSdk.Users.Item.Calendars.Item.Events.Item.Instances.InstancesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -163,6 +170,9 @@ public Command BuildInstancesCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Users.Item.Calendars.Item.Events.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -190,14 +200,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -205,6 +214,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Users.Item.Calendars.Item.Events.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -276,7 +288,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -288,42 +300,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The events in the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/Extensions/ExtensionsRequestBuilder.cs index dcd5667d690..9235ef1a32b 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Calendars.Item.Events.Item.Extensions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -129,15 +131,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs index c26da60df96..48db92efd91 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -42,11 +42,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string extensionId) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, extensionIdOption); return command; @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string extensionId, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, extensionIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/Forward/ForwardRequestBuilder.cs index 27fd3218bda..f860d56881e 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Delta/Delta.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Delta/Delta.cs deleted file mode 100644 index 4b2b43e0f60..00000000000 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.Calendars.Item.Events.Item.Instances.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Delta/DeltaRequestBuilder.cs index 6f3e3655688..4e20c14959c 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,18 +38,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string calendarId, string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, outputOption); return command; } /// @@ -79,16 +79,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/InstancesRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/InstancesRequestBuilder.cs index d381af9bc42..60ee0df92ae 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/InstancesRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/InstancesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Calendars.Item.Events.Item.Instances.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class InstancesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -60,21 +59,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -122,7 +120,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -182,7 +179,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -200,31 +197,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/InstancesResponse.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/InstancesResponse.cs index 356760e833b..62f3e7243c6 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/InstancesResponse.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/InstancesResponse.cs @@ -9,7 +9,7 @@ public class InstancesResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new instancesResponse and sets the default values. /// @@ -22,7 +22,7 @@ public InstancesResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as InstancesResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs index 7df039fd51d..475febac894 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs index cf70c63f3af..abd7ee73159 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs index c80cda827f2..d0483bc123a 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs index 0fc37c4c395..1826b144574 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,11 +41,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, eventId1Option); return command; @@ -78,16 +77,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/EventRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/EventRequestBuilder.cs index 7367443bd2d..66a6c1568b5 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/EventRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Users.Item.Calendars.Item.Events.Item.Instances.Item.TentativelyAccept; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -67,11 +67,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, eventId1Option); return command; @@ -116,19 +115,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -158,14 +156,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -237,7 +234,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -249,42 +246,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs index 5ff12d3ed47..4706570cde3 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 301cad05991..f9ad12870c7 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index 703625a8008..303e48efdfb 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 1a5d39ae2b5..af5f6583398 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -70,7 +69,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,7 +117,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 33ea44dcfde..73ce84053f5 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Calendars.Item.Events.Item.MultiValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index d11f7210ae8..09c3ca503a8 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -70,7 +69,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,7 +117,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index b762408666c..9c3452be71f 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Calendars.Item.Events.Item.SingleValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 26f3c7ada93..de13698c912 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index 9f597afca2b..9dce1df8552 100644 --- a/src/generated/Users/Item/Calendars/Item/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string eventId, string body) => { + command.SetHandler(async (string userId, string calendarId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, eventIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/GetSchedule/GetScheduleRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/GetSchedule/GetScheduleRequestBuilder.cs index 97dab702fda..39c88bf9d78 100644 --- a/src/generated/Users/Item/Calendars/Item/GetSchedule/GetScheduleRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/GetSchedule/GetScheduleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,21 +37,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, bodyOption, outputOption); return command; } /// @@ -85,18 +84,5 @@ public RequestInformation CreatePostRequestInformation(GetScheduleRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSchedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetScheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Calendars/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 18ceea354f4..09be2e27ea2 100644 --- a/src/generated/Users/Item/Calendars/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string calendarId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string calendarId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string calendarId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Calendars/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 24d2108f522..2946959d3f4 100644 --- a/src/generated/Users/Item/Calendars/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Calendars.Item.MultiValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Calendars/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 71601ce616a..a89f81e4def 100644 --- a/src/generated/Users/Item/Calendars/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string calendarId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string calendarId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; calendarIdOption.IsRequired = true; command.AddOption(calendarIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string calendarId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, calendarIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Calendars/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/Calendars/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 592591c645d..339419d5a74 100644 --- a/src/generated/Users/Item/Calendars/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/Calendars/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Calendars.Item.SingleValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string calendarId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string calendarId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string calendarId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, calendarIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, calendarIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/ChangePassword/ChangePasswordRequestBuilder.cs b/src/generated/Users/Item/ChangePassword/ChangePasswordRequestBuilder.cs index 75f39232ac8..63c5302f6b4 100644 --- a/src/generated/Users/Item/ChangePassword/ChangePasswordRequestBuilder.cs +++ b/src/generated/Users/Item/ChangePassword/ChangePasswordRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + command.SetHandler(async (string userId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ChangePasswordRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action changePassword - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ChangePasswordRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Chats/ChatsRequestBuilder.cs b/src/generated/Users/Item/Chats/ChatsRequestBuilder.cs index 3aa61c074dc..c97fcfe8bd3 100644 --- a/src/generated/Users/Item/Chats/ChatsRequestBuilder.cs +++ b/src/generated/Users/Item/Chats/ChatsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Chats.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ChatsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ChatRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get chats from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to chats for users - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Chat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get chats from users public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Chats/Item/ChatRequestBuilder.cs b/src/generated/Users/Item/Chats/Item/ChatRequestBuilder.cs index e207b8e0d93..bcc96dbb8b3 100644 --- a/src/generated/Users/Item/Chats/Item/ChatRequestBuilder.cs +++ b/src/generated/Users/Item/Chats/Item/ChatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; chatIdOption.IsRequired = true; command.AddOption(chatIdOption); - command.SetHandler(async (string userId, string chatId) => { + command.SetHandler(async (string userId, string chatId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, chatIdOption); return command; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string chatId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string chatId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, chatIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, chatIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string chatId, string body) => { + command.SetHandler(async (string userId, string chatId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, chatIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property chats for users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get chats from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property chats in users - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Chat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get chats from users public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs b/src/generated/Users/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs index 150eaf62f2c..d123a81165f 100644 --- a/src/generated/Users/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs +++ b/src/generated/Users/Item/CheckMemberGroups/CheckMemberGroupsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberGroupsRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs b/src/generated/Users/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs index fea773d992c..5236bdfd4b2 100644 --- a/src/generated/Users/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs +++ b/src/generated/Users/Item/CheckMemberObjects/CheckMemberObjectsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(CheckMemberObjectsRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(CheckMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/ContactFolders/ContactFoldersRequestBuilder.cs b/src/generated/Users/Item/ContactFolders/ContactFoldersRequestBuilder.cs index cdf7f980d1d..2e7c5a8613c 100644 --- a/src/generated/Users/Item/ContactFolders/ContactFoldersRequestBuilder.cs +++ b/src/generated/Users/Item/ContactFolders/ContactFoldersRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.ContactFolders.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,15 +23,14 @@ public class ContactFoldersRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ContactFolderRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildChildFoldersCommand(), - builder.BuildContactsCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildChildFoldersCommand()); + commands.Add(builder.BuildContactsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -103,7 +101,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -112,15 +114,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ContactFolder body, Actio public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// The user's contacts folders. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's contacts folders. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ContactFolder model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's contacts folders. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/ContactFolders/Delta/Delta.cs b/src/generated/Users/Item/ContactFolders/Delta/Delta.cs deleted file mode 100644 index 958b0f6aa31..00000000000 --- a/src/generated/Users/Item/ContactFolders/Delta/Delta.cs +++ /dev/null @@ -1,49 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.ContactFolders.Delta { - public class Delta : Entity, IParsable { - /// The collection of child folders in the folder. Navigation property. Read-only. Nullable. - public List ChildFolders { get; set; } - /// The contacts in the folder. Navigation property. Read-only. Nullable. - public List Contacts { get; set; } - /// The folder's display name. - public string DisplayName { get; set; } - /// The collection of multi-value extended properties defined for the contactFolder. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - /// The ID of the folder's parent folder. - public string ParentFolderId { get; set; } - /// The collection of single-value extended properties defined for the contactFolder. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"childFolders", (o,n) => { (o as Delta).ChildFolders = n.GetCollectionOfObjectValues().ToList(); } }, - {"contacts", (o,n) => { (o as Delta).Contacts = n.GetCollectionOfObjectValues().ToList(); } }, - {"displayName", (o,n) => { (o as Delta).DisplayName = n.GetStringValue(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"parentFolderId", (o,n) => { (o as Delta).ParentFolderId = n.GetStringValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteCollectionOfObjectValues("childFolders", ChildFolders); - writer.WriteCollectionOfObjectValues("contacts", Contacts); - writer.WriteStringValue("displayName", DisplayName); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteStringValue("parentFolderId", ParentFolderId); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - } - } -} diff --git a/src/generated/Users/Item/ContactFolders/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/ContactFolders/Delta/DeltaRequestBuilder.cs index cb7e30bd432..15c5d7bb488 100644 --- a/src/generated/Users/Item/ContactFolders/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/ContactFolders/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +30,17 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/ContactFolders/Item/ChildFolders/ChildFoldersRequestBuilder.cs b/src/generated/Users/Item/ContactFolders/Item/ChildFolders/ChildFoldersRequestBuilder.cs index cd9f8d2f887..6b5f0868894 100644 --- a/src/generated/Users/Item/ContactFolders/Item/ChildFolders/ChildFoldersRequestBuilder.cs +++ b/src/generated/Users/Item/ContactFolders/Item/ChildFolders/ChildFoldersRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.ContactFolders.Item.ChildFolders.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class ChildFoldersRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ContactFolderRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,7 +40,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string contactFolderId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactFolderId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactFolderIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactFolderIdOption, bodyOption, outputOption); return command; } /// @@ -77,7 +75,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -112,7 +110,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string contactFolderId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactFolderId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -122,15 +124,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactFolderIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactFolderIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(ContactFolder body, Actio public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// The collection of child folders in the folder. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of child folders in the folder. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ContactFolder model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of child folders in the folder. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/ContactFolders/Item/ChildFolders/Delta/Delta.cs b/src/generated/Users/Item/ContactFolders/Item/ChildFolders/Delta/Delta.cs deleted file mode 100644 index 09964fc683d..00000000000 --- a/src/generated/Users/Item/ContactFolders/Item/ChildFolders/Delta/Delta.cs +++ /dev/null @@ -1,49 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.ContactFolders.Item.ChildFolders.Delta { - public class Delta : Entity, IParsable { - /// The collection of child folders in the folder. Navigation property. Read-only. Nullable. - public List ChildFolders { get; set; } - /// The contacts in the folder. Navigation property. Read-only. Nullable. - public List Contacts { get; set; } - /// The folder's display name. - public string DisplayName { get; set; } - /// The collection of multi-value extended properties defined for the contactFolder. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - /// The ID of the folder's parent folder. - public string ParentFolderId { get; set; } - /// The collection of single-value extended properties defined for the contactFolder. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"childFolders", (o,n) => { (o as Delta).ChildFolders = n.GetCollectionOfObjectValues().ToList(); } }, - {"contacts", (o,n) => { (o as Delta).Contacts = n.GetCollectionOfObjectValues().ToList(); } }, - {"displayName", (o,n) => { (o as Delta).DisplayName = n.GetStringValue(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"parentFolderId", (o,n) => { (o as Delta).ParentFolderId = n.GetStringValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteCollectionOfObjectValues("childFolders", ChildFolders); - writer.WriteCollectionOfObjectValues("contacts", Contacts); - writer.WriteStringValue("displayName", DisplayName); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteStringValue("parentFolderId", ParentFolderId); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - } - } -} diff --git a/src/generated/Users/Item/ContactFolders/Item/ChildFolders/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/ContactFolders/Item/ChildFolders/Delta/DeltaRequestBuilder.cs index 7d14ef14163..e4be23fa758 100644 --- a/src/generated/Users/Item/ContactFolders/Item/ChildFolders/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/ContactFolders/Item/ChildFolders/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); - command.SetHandler(async (string userId, string contactFolderId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactFolderId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactFolderIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactFolderIdOption, outputOption); return command; } /// @@ -75,16 +75,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/ContactFolders/Item/ChildFolders/Item/ContactFolderRequestBuilder.cs b/src/generated/Users/Item/ContactFolders/Item/ChildFolders/Item/ContactFolderRequestBuilder.cs index 56cd284800f..85ae99e82cc 100644 --- a/src/generated/Users/Item/ContactFolders/Item/ChildFolders/Item/ContactFolderRequestBuilder.cs +++ b/src/generated/Users/Item/ContactFolders/Item/ChildFolders/Item/ContactFolderRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); - var contactFolderId1Option = new Option("--contactfolder-id1", description: "key: id of contactFolder") { + var contactFolderId1Option = new Option("--contact-folder-id1", description: "key: id of contactFolder") { }; contactFolderId1Option.IsRequired = true; command.AddOption(contactFolderId1Option); - command.SetHandler(async (string userId, string contactFolderId, string contactFolderId1) => { + command.SetHandler(async (string userId, string contactFolderId, string contactFolderId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactFolderIdOption, contactFolderId1Option); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); - var contactFolderId1Option = new Option("--contactfolder-id1", description: "key: id of contactFolder") { + var contactFolderId1Option = new Option("--contact-folder-id1", description: "key: id of contactFolder") { }; contactFolderId1Option.IsRequired = true; command.AddOption(contactFolderId1Option); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string contactFolderId, string contactFolderId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactFolderId, string contactFolderId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactFolderIdOption, contactFolderId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactFolderIdOption, contactFolderId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); - var contactFolderId1Option = new Option("--contactfolder-id1", description: "key: id of contactFolder") { + var contactFolderId1Option = new Option("--contact-folder-id1", description: "key: id of contactFolder") { }; contactFolderId1Option.IsRequired = true; command.AddOption(contactFolderId1Option); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string contactFolderId, string contactFolderId1, string body) => { + command.SetHandler(async (string userId, string contactFolderId, string contactFolderId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactFolderIdOption, contactFolderId1Option, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(ContactFolder body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of child folders in the folder. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of child folders in the folder. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of child folders in the folder. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ContactFolder model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of child folders in the folder. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/ContactFolders/Item/ContactFolderRequestBuilder.cs b/src/generated/Users/Item/ContactFolders/Item/ContactFolderRequestBuilder.cs index 61c87eb27d9..ae1c91ea07e 100644 --- a/src/generated/Users/Item/ContactFolders/Item/ContactFolderRequestBuilder.cs +++ b/src/generated/Users/Item/ContactFolders/Item/ContactFolderRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Users.Item.ContactFolders.Item.SingleValueExtendedProperties; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,6 +26,9 @@ public class ContactFolderRequestBuilder { public Command BuildChildFoldersCommand() { var command = new Command("child-folders"); var builder = new ApiSdk.Users.Item.ContactFolders.Item.ChildFolders.ChildFoldersRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -33,6 +36,9 @@ public Command BuildChildFoldersCommand() { public Command BuildContactsCommand() { var command = new Command("contacts"); var builder = new ApiSdk.Users.Item.ContactFolders.Item.Contacts.ContactsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -48,15 +54,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); - command.SetHandler(async (string userId, string contactFolderId) => { + command.SetHandler(async (string userId, string contactFolderId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactFolderIdOption); return command; @@ -72,7 +77,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -81,24 +86,26 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string contactFolderId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactFolderId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactFolderIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactFolderIdOption, selectOption, outputOption); return command; } public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Users.Item.ContactFolders.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -114,7 +121,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -122,14 +129,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string contactFolderId, string body) => { + command.SetHandler(async (string userId, string contactFolderId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactFolderIdOption, bodyOption); return command; @@ -137,6 +143,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Users.Item.ContactFolders.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -208,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(ContactFolder body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user's contacts folders. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's contacts folders. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's contacts folders. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ContactFolder model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's contacts folders. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/ContactFolders/Item/Contacts/ContactsRequestBuilder.cs b/src/generated/Users/Item/ContactFolders/Item/Contacts/ContactsRequestBuilder.cs index 80c62a23e91..56e28b26c8d 100644 --- a/src/generated/Users/Item/ContactFolders/Item/Contacts/ContactsRequestBuilder.cs +++ b/src/generated/Users/Item/ContactFolders/Item/Contacts/ContactsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.ContactFolders.Item.Contacts.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,15 +23,14 @@ public class ContactsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ContactRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildExtensionsCommand(), - builder.BuildGetCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildPhotoCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPhotoCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); return commands; } /// @@ -45,7 +44,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string contactFolderId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactFolderId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactFolderIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactFolderIdOption, bodyOption, outputOption); return command; } /// @@ -81,7 +79,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -116,7 +114,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string contactFolderId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactFolderId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactFolderIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactFolderIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -195,31 +192,6 @@ public RequestInformation CreatePostRequestInformation(Contact body, Action - /// The contacts in the folder. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The contacts in the folder. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Contact model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The contacts in the folder. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/ContactFolders/Item/Contacts/Delta/Delta.cs b/src/generated/Users/Item/ContactFolders/Item/Contacts/Delta/Delta.cs deleted file mode 100644 index 6a0c9b10ebc..00000000000 --- a/src/generated/Users/Item/ContactFolders/Item/Contacts/Delta/Delta.cs +++ /dev/null @@ -1,155 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.ContactFolders.Item.Contacts.Delta { - public class Delta : OutlookItem, IParsable { - /// The name of the contact's assistant. - public string AssistantName { get; set; } - /// The contact's birthday. The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time. For example, midnight UTC on Jan 1, 2014 is 2014-01-01T00:00:00Z - public DateTimeOffset? Birthday { get; set; } - /// The contact's business address. - public PhysicalAddress BusinessAddress { get; set; } - /// The business home page of the contact. - public string BusinessHomePage { get; set; } - /// The contact's business phone numbers. - public List BusinessPhones { get; set; } - /// The names of the contact's children. - public List Children { get; set; } - /// The name of the contact's company. - public string CompanyName { get; set; } - /// The contact's department. - public string Department { get; set; } - /// The contact's display name. You can specify the display name in a create or update operation. Note that later updates to other properties may cause an automatically generated value to overwrite the displayName value you have specified. To preserve a pre-existing value, always include it as displayName in an update operation. - public string DisplayName { get; set; } - /// The contact's email addresses. - public List EmailAddresses { get; set; } - /// The collection of open extensions defined for the contact. Nullable. - public List Extensions { get; set; } - /// The name the contact is filed under. - public string FileAs { get; set; } - /// The contact's generation. - public string Generation { get; set; } - /// The contact's given name. - public string GivenName { get; set; } - /// The contact's home address. - public PhysicalAddress HomeAddress { get; set; } - /// The contact's home phone numbers. - public List HomePhones { get; set; } - public List ImAddresses { get; set; } - public string Initials { get; set; } - public string JobTitle { get; set; } - public string Manager { get; set; } - public string MiddleName { get; set; } - public string MobilePhone { get; set; } - /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public string NickName { get; set; } - public string OfficeLocation { get; set; } - public PhysicalAddress OtherAddress { get; set; } - public string ParentFolderId { get; set; } - public string PersonalNotes { get; set; } - /// Optional contact picture. You can get or set a photo for a contact. - public ProfilePhoto Photo { get; set; } - public string Profession { get; set; } - /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public string SpouseName { get; set; } - public string Surname { get; set; } - public string Title { get; set; } - public string YomiCompanyName { get; set; } - public string YomiGivenName { get; set; } - public string YomiSurname { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"assistantName", (o,n) => { (o as Delta).AssistantName = n.GetStringValue(); } }, - {"birthday", (o,n) => { (o as Delta).Birthday = n.GetDateTimeOffsetValue(); } }, - {"businessAddress", (o,n) => { (o as Delta).BusinessAddress = n.GetObjectValue(); } }, - {"businessHomePage", (o,n) => { (o as Delta).BusinessHomePage = n.GetStringValue(); } }, - {"businessPhones", (o,n) => { (o as Delta).BusinessPhones = n.GetCollectionOfPrimitiveValues().ToList(); } }, - {"children", (o,n) => { (o as Delta).Children = n.GetCollectionOfPrimitiveValues().ToList(); } }, - {"companyName", (o,n) => { (o as Delta).CompanyName = n.GetStringValue(); } }, - {"department", (o,n) => { (o as Delta).Department = n.GetStringValue(); } }, - {"displayName", (o,n) => { (o as Delta).DisplayName = n.GetStringValue(); } }, - {"emailAddresses", (o,n) => { (o as Delta).EmailAddresses = n.GetCollectionOfObjectValues().ToList(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"fileAs", (o,n) => { (o as Delta).FileAs = n.GetStringValue(); } }, - {"generation", (o,n) => { (o as Delta).Generation = n.GetStringValue(); } }, - {"givenName", (o,n) => { (o as Delta).GivenName = n.GetStringValue(); } }, - {"homeAddress", (o,n) => { (o as Delta).HomeAddress = n.GetObjectValue(); } }, - {"homePhones", (o,n) => { (o as Delta).HomePhones = n.GetCollectionOfPrimitiveValues().ToList(); } }, - {"imAddresses", (o,n) => { (o as Delta).ImAddresses = n.GetCollectionOfPrimitiveValues().ToList(); } }, - {"initials", (o,n) => { (o as Delta).Initials = n.GetStringValue(); } }, - {"jobTitle", (o,n) => { (o as Delta).JobTitle = n.GetStringValue(); } }, - {"manager", (o,n) => { (o as Delta).Manager = n.GetStringValue(); } }, - {"middleName", (o,n) => { (o as Delta).MiddleName = n.GetStringValue(); } }, - {"mobilePhone", (o,n) => { (o as Delta).MobilePhone = n.GetStringValue(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"nickName", (o,n) => { (o as Delta).NickName = n.GetStringValue(); } }, - {"officeLocation", (o,n) => { (o as Delta).OfficeLocation = n.GetStringValue(); } }, - {"otherAddress", (o,n) => { (o as Delta).OtherAddress = n.GetObjectValue(); } }, - {"parentFolderId", (o,n) => { (o as Delta).ParentFolderId = n.GetStringValue(); } }, - {"personalNotes", (o,n) => { (o as Delta).PersonalNotes = n.GetStringValue(); } }, - {"photo", (o,n) => { (o as Delta).Photo = n.GetObjectValue(); } }, - {"profession", (o,n) => { (o as Delta).Profession = n.GetStringValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"spouseName", (o,n) => { (o as Delta).SpouseName = n.GetStringValue(); } }, - {"surname", (o,n) => { (o as Delta).Surname = n.GetStringValue(); } }, - {"title", (o,n) => { (o as Delta).Title = n.GetStringValue(); } }, - {"yomiCompanyName", (o,n) => { (o as Delta).YomiCompanyName = n.GetStringValue(); } }, - {"yomiGivenName", (o,n) => { (o as Delta).YomiGivenName = n.GetStringValue(); } }, - {"yomiSurname", (o,n) => { (o as Delta).YomiSurname = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteStringValue("assistantName", AssistantName); - writer.WriteDateTimeOffsetValue("birthday", Birthday); - writer.WriteObjectValue("businessAddress", BusinessAddress); - writer.WriteStringValue("businessHomePage", BusinessHomePage); - writer.WriteCollectionOfPrimitiveValues("businessPhones", BusinessPhones); - writer.WriteCollectionOfPrimitiveValues("children", Children); - writer.WriteStringValue("companyName", CompanyName); - writer.WriteStringValue("department", Department); - writer.WriteStringValue("displayName", DisplayName); - writer.WriteCollectionOfObjectValues("emailAddresses", EmailAddresses); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteStringValue("fileAs", FileAs); - writer.WriteStringValue("generation", Generation); - writer.WriteStringValue("givenName", GivenName); - writer.WriteObjectValue("homeAddress", HomeAddress); - writer.WriteCollectionOfPrimitiveValues("homePhones", HomePhones); - writer.WriteCollectionOfPrimitiveValues("imAddresses", ImAddresses); - writer.WriteStringValue("initials", Initials); - writer.WriteStringValue("jobTitle", JobTitle); - writer.WriteStringValue("manager", Manager); - writer.WriteStringValue("middleName", MiddleName); - writer.WriteStringValue("mobilePhone", MobilePhone); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteStringValue("nickName", NickName); - writer.WriteStringValue("officeLocation", OfficeLocation); - writer.WriteObjectValue("otherAddress", OtherAddress); - writer.WriteStringValue("parentFolderId", ParentFolderId); - writer.WriteStringValue("personalNotes", PersonalNotes); - writer.WriteObjectValue("photo", Photo); - writer.WriteStringValue("profession", Profession); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteStringValue("spouseName", SpouseName); - writer.WriteStringValue("surname", Surname); - writer.WriteStringValue("title", Title); - writer.WriteStringValue("yomiCompanyName", YomiCompanyName); - writer.WriteStringValue("yomiGivenName", YomiGivenName); - writer.WriteStringValue("yomiSurname", YomiSurname); - } - } -} diff --git a/src/generated/Users/Item/ContactFolders/Item/Contacts/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/ContactFolders/Item/Contacts/Delta/DeltaRequestBuilder.cs index 422f63fa548..a7225a4053b 100644 --- a/src/generated/Users/Item/ContactFolders/Item/Contacts/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/ContactFolders/Item/Contacts/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); - command.SetHandler(async (string userId, string contactFolderId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactFolderId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactFolderIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactFolderIdOption, outputOption); return command; } /// @@ -75,16 +75,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/ContactRequestBuilder.cs b/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/ContactRequestBuilder.cs index b204e9a09c2..1666c0f60f8 100644 --- a/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/ContactRequestBuilder.cs +++ b/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/ContactRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Users.Item.ContactFolders.Item.Contacts.Item.SingleValueExtendedProperties; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,7 +34,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -42,11 +42,10 @@ public Command BuildDeleteCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - command.SetHandler(async (string userId, string contactFolderId, string contactId) => { + command.SetHandler(async (string userId, string contactFolderId, string contactId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactFolderIdOption, contactIdOption); return command; @@ -54,6 +53,9 @@ public Command BuildDeleteCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Users.Item.ContactFolders.Item.Contacts.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -69,7 +71,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -87,25 +89,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string contactFolderId, string contactId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactFolderId, string contactId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactFolderIdOption, contactIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactFolderIdOption, contactIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Users.Item.ContactFolders.Item.Contacts.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -121,7 +125,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -133,14 +137,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string contactFolderId, string contactId, string body) => { + command.SetHandler(async (string userId, string contactFolderId, string contactId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactFolderIdOption, contactIdOption, bodyOption); return command; @@ -157,6 +160,9 @@ public Command BuildPhotoCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Users.Item.ContactFolders.Item.Contacts.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -228,42 +234,6 @@ public RequestInformation CreatePatchRequestInformation(Contact body, Action - /// The contacts in the folder. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The contacts in the folder. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The contacts in the folder. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Contact model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The contacts in the folder. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/Extensions/ExtensionsRequestBuilder.cs index d1599dac385..e9e4419aef7 100644 --- a/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.ContactFolders.Item.Contacts.Item.Extensions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string contactFolderId, string contactId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactFolderId, string contactId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactFolderIdOption, contactIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactFolderIdOption, contactIdOption, bodyOption, outputOption); return command; } /// @@ -80,7 +78,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string contactFolderId, string contactId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactFolderId, string contactId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -129,15 +131,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactFolderIdOption, contactIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactFolderIdOption, contactIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the contact. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the contact. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the contact. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/Extensions/Item/ExtensionRequestBuilder.cs index 0c948902ce7..57ab9c64609 100644 --- a/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -42,11 +42,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string userId, string contactFolderId, string contactId, string extensionId) => { + command.SetHandler(async (string userId, string contactFolderId, string contactId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactFolderIdOption, contactIdOption, extensionIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string contactFolderId, string contactId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactFolderId, string contactId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactFolderIdOption, contactIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactFolderIdOption, contactIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,7 +109,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string contactFolderId, string contactId, string extensionId, string body) => { + command.SetHandler(async (string userId, string contactFolderId, string contactId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactFolderIdOption, contactIdOption, extensionIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the contact. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the contact. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the contact. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the contact. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 5d1e122d0e1..abac174b95f 100644 --- a/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string contactFolderId, string contactId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string contactFolderId, string contactId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactFolderIdOption, contactIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -70,7 +69,7 @@ public Command BuildGetCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string contactFolderId, string contactId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactFolderId, string contactId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactFolderIdOption, contactIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactFolderIdOption, contactIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,7 +109,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -119,7 +117,7 @@ public Command BuildPatchCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string contactFolderId, string contactId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string contactFolderId, string contactId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactFolderIdOption, contactIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index bed0664cee1..a022f97d9cb 100644 --- a/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.ContactFolders.Item.Contacts.Item.MultiValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string contactFolderId, string contactId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactFolderId, string contactId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactFolderIdOption, contactIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactFolderIdOption, contactIdOption, bodyOption, outputOption); return command; } /// @@ -80,7 +78,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string contactFolderId, string contactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactFolderId, string contactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactFolderIdOption, contactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactFolderIdOption, contactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/Photo/PhotoRequestBuilder.cs b/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/Photo/PhotoRequestBuilder.cs index 26c60a583c0..638e7e0d8aa 100644 --- a/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/Photo/PhotoRequestBuilder.cs +++ b/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/Photo/PhotoRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.ContactFolders.Item.Contacts.Item.Photo.Value; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,7 +38,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -46,11 +46,10 @@ public Command BuildDeleteCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - command.SetHandler(async (string userId, string contactFolderId, string contactId) => { + command.SetHandler(async (string userId, string contactFolderId, string contactId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactFolderIdOption, contactIdOption); return command; @@ -66,7 +65,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -79,19 +78,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string contactFolderId, string contactId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactFolderId, string contactId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactFolderIdOption, contactIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactFolderIdOption, contactIdOption, selectOption, outputOption); return command; } /// @@ -105,7 +103,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -117,14 +115,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string contactFolderId, string contactId, string body) => { + command.SetHandler(async (string userId, string contactFolderId, string contactId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactFolderIdOption, contactIdOption, bodyOption); return command; @@ -196,42 +193,6 @@ public RequestInformation CreatePatchRequestInformation(ProfilePhoto body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Optional contact picture. You can get or set a photo for a contact. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Optional contact picture. You can get or set a photo for a contact. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Optional contact picture. You can get or set a photo for a contact. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ProfilePhoto model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Optional contact picture. You can get or set a photo for a contact. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/Photo/Value/ContentRequestBuilder.cs b/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/Photo/Value/ContentRequestBuilder.cs index 2e0720c10e6..29250163ffe 100644 --- a/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/Photo/Value/ContentRequestBuilder.cs +++ b/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/Photo/Value/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -37,24 +37,26 @@ public Command BuildGetCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string userId, string contactFolderId, string contactId, FileInfo output) => { + command.SetHandler(async (string userId, string contactFolderId, string contactId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, userIdOption, contactFolderIdOption, contactIdOption, outputOption); + }, userIdOption, contactFolderIdOption, contactIdOption, fileOption, outputOption); return command; } /// @@ -68,7 +70,7 @@ public Command BuildPutCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -80,12 +82,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string contactFolderId, string contactId, FileInfo file) => { + command.SetHandler(async (string userId, string contactFolderId, string contactId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactFolderIdOption, contactIdOption, bodyOption); return command; @@ -136,29 +137,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// The user's profile photo. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's profile photo. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 7adc36e5f7b..f4d9ac14eae 100644 --- a/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string contactFolderId, string contactId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string contactFolderId, string contactId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactFolderIdOption, contactIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -70,7 +69,7 @@ public Command BuildGetCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string contactFolderId, string contactId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactFolderId, string contactId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactFolderIdOption, contactIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactFolderIdOption, contactIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,7 +109,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -119,7 +117,7 @@ public Command BuildPatchCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string contactFolderId, string contactId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string contactFolderId, string contactId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactFolderIdOption, contactIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index f0574f57ed2..37cdc0ee3cb 100644 --- a/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/ContactFolders/Item/Contacts/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.ContactFolders.Item.Contacts.Item.SingleValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string contactFolderId, string contactId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactFolderId, string contactId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactFolderIdOption, contactIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactFolderIdOption, contactIdOption, bodyOption, outputOption); return command; } /// @@ -80,7 +78,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string contactFolderId, string contactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactFolderId, string contactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactFolderIdOption, contactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactFolderIdOption, contactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/ContactFolders/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/ContactFolders/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 185204173a9..08bb86e097b 100644 --- a/src/generated/Users/Item/ContactFolders/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/ContactFolders/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string contactFolderId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string contactFolderId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactFolderIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string contactFolderId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactFolderId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactFolderIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactFolderIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string contactFolderId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string contactFolderId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactFolderIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the contactFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the contactFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the contactFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the contactFolder. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/ContactFolders/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/ContactFolders/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index ab12b33a761..8944999ead5 100644 --- a/src/generated/Users/Item/ContactFolders/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/ContactFolders/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.ContactFolders.Item.MultiValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string contactFolderId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactFolderId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactFolderIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactFolderIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string contactFolderId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactFolderId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactFolderIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactFolderIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the contactFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the contactFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the contactFolder. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/ContactFolders/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/ContactFolders/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index b874cfaecb4..c86dadb7b4e 100644 --- a/src/generated/Users/Item/ContactFolders/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/ContactFolders/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string contactFolderId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string contactFolderId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactFolderIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string contactFolderId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactFolderId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactFolderIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactFolderIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string contactFolderId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string contactFolderId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactFolderIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the contactFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the contactFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the contactFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the contactFolder. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/ContactFolders/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/ContactFolders/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index a4b9b72a8ee..3a3f4d9f081 100644 --- a/src/generated/Users/Item/ContactFolders/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/ContactFolders/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.ContactFolders.Item.SingleValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string contactFolderId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactFolderId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactFolderIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactFolderIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var contactFolderIdOption = new Option("--contactfolder-id", description: "key: id of contactFolder") { + var contactFolderIdOption = new Option("--contact-folder-id", description: "key: id of contactFolder") { }; contactFolderIdOption.IsRequired = true; command.AddOption(contactFolderIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string contactFolderId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactFolderId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactFolderIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactFolderIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the contactFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the contactFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the contactFolder. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Contacts/ContactsRequestBuilder.cs b/src/generated/Users/Item/Contacts/ContactsRequestBuilder.cs index b4addd8df12..057e7d4a373 100644 --- a/src/generated/Users/Item/Contacts/ContactsRequestBuilder.cs +++ b/src/generated/Users/Item/Contacts/ContactsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Contacts.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,15 +23,14 @@ public class ContactsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ContactRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildExtensionsCommand(), - builder.BuildGetCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildPhotoCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPhotoCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -117,15 +119,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -186,31 +183,6 @@ public RequestInformation CreatePostRequestInformation(Contact body, Action - /// The user's contacts. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's contacts. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Contact model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's contacts. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Contacts/Delta/Delta.cs b/src/generated/Users/Item/Contacts/Delta/Delta.cs deleted file mode 100644 index f22dcc1e968..00000000000 --- a/src/generated/Users/Item/Contacts/Delta/Delta.cs +++ /dev/null @@ -1,155 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.Contacts.Delta { - public class Delta : OutlookItem, IParsable { - /// The name of the contact's assistant. - public string AssistantName { get; set; } - /// The contact's birthday. The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time. For example, midnight UTC on Jan 1, 2014 is 2014-01-01T00:00:00Z - public DateTimeOffset? Birthday { get; set; } - /// The contact's business address. - public PhysicalAddress BusinessAddress { get; set; } - /// The business home page of the contact. - public string BusinessHomePage { get; set; } - /// The contact's business phone numbers. - public List BusinessPhones { get; set; } - /// The names of the contact's children. - public List Children { get; set; } - /// The name of the contact's company. - public string CompanyName { get; set; } - /// The contact's department. - public string Department { get; set; } - /// The contact's display name. You can specify the display name in a create or update operation. Note that later updates to other properties may cause an automatically generated value to overwrite the displayName value you have specified. To preserve a pre-existing value, always include it as displayName in an update operation. - public string DisplayName { get; set; } - /// The contact's email addresses. - public List EmailAddresses { get; set; } - /// The collection of open extensions defined for the contact. Nullable. - public List Extensions { get; set; } - /// The name the contact is filed under. - public string FileAs { get; set; } - /// The contact's generation. - public string Generation { get; set; } - /// The contact's given name. - public string GivenName { get; set; } - /// The contact's home address. - public PhysicalAddress HomeAddress { get; set; } - /// The contact's home phone numbers. - public List HomePhones { get; set; } - public List ImAddresses { get; set; } - public string Initials { get; set; } - public string JobTitle { get; set; } - public string Manager { get; set; } - public string MiddleName { get; set; } - public string MobilePhone { get; set; } - /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public string NickName { get; set; } - public string OfficeLocation { get; set; } - public PhysicalAddress OtherAddress { get; set; } - public string ParentFolderId { get; set; } - public string PersonalNotes { get; set; } - /// Optional contact picture. You can get or set a photo for a contact. - public ProfilePhoto Photo { get; set; } - public string Profession { get; set; } - /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public string SpouseName { get; set; } - public string Surname { get; set; } - public string Title { get; set; } - public string YomiCompanyName { get; set; } - public string YomiGivenName { get; set; } - public string YomiSurname { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"assistantName", (o,n) => { (o as Delta).AssistantName = n.GetStringValue(); } }, - {"birthday", (o,n) => { (o as Delta).Birthday = n.GetDateTimeOffsetValue(); } }, - {"businessAddress", (o,n) => { (o as Delta).BusinessAddress = n.GetObjectValue(); } }, - {"businessHomePage", (o,n) => { (o as Delta).BusinessHomePage = n.GetStringValue(); } }, - {"businessPhones", (o,n) => { (o as Delta).BusinessPhones = n.GetCollectionOfPrimitiveValues().ToList(); } }, - {"children", (o,n) => { (o as Delta).Children = n.GetCollectionOfPrimitiveValues().ToList(); } }, - {"companyName", (o,n) => { (o as Delta).CompanyName = n.GetStringValue(); } }, - {"department", (o,n) => { (o as Delta).Department = n.GetStringValue(); } }, - {"displayName", (o,n) => { (o as Delta).DisplayName = n.GetStringValue(); } }, - {"emailAddresses", (o,n) => { (o as Delta).EmailAddresses = n.GetCollectionOfObjectValues().ToList(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"fileAs", (o,n) => { (o as Delta).FileAs = n.GetStringValue(); } }, - {"generation", (o,n) => { (o as Delta).Generation = n.GetStringValue(); } }, - {"givenName", (o,n) => { (o as Delta).GivenName = n.GetStringValue(); } }, - {"homeAddress", (o,n) => { (o as Delta).HomeAddress = n.GetObjectValue(); } }, - {"homePhones", (o,n) => { (o as Delta).HomePhones = n.GetCollectionOfPrimitiveValues().ToList(); } }, - {"imAddresses", (o,n) => { (o as Delta).ImAddresses = n.GetCollectionOfPrimitiveValues().ToList(); } }, - {"initials", (o,n) => { (o as Delta).Initials = n.GetStringValue(); } }, - {"jobTitle", (o,n) => { (o as Delta).JobTitle = n.GetStringValue(); } }, - {"manager", (o,n) => { (o as Delta).Manager = n.GetStringValue(); } }, - {"middleName", (o,n) => { (o as Delta).MiddleName = n.GetStringValue(); } }, - {"mobilePhone", (o,n) => { (o as Delta).MobilePhone = n.GetStringValue(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"nickName", (o,n) => { (o as Delta).NickName = n.GetStringValue(); } }, - {"officeLocation", (o,n) => { (o as Delta).OfficeLocation = n.GetStringValue(); } }, - {"otherAddress", (o,n) => { (o as Delta).OtherAddress = n.GetObjectValue(); } }, - {"parentFolderId", (o,n) => { (o as Delta).ParentFolderId = n.GetStringValue(); } }, - {"personalNotes", (o,n) => { (o as Delta).PersonalNotes = n.GetStringValue(); } }, - {"photo", (o,n) => { (o as Delta).Photo = n.GetObjectValue(); } }, - {"profession", (o,n) => { (o as Delta).Profession = n.GetStringValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"spouseName", (o,n) => { (o as Delta).SpouseName = n.GetStringValue(); } }, - {"surname", (o,n) => { (o as Delta).Surname = n.GetStringValue(); } }, - {"title", (o,n) => { (o as Delta).Title = n.GetStringValue(); } }, - {"yomiCompanyName", (o,n) => { (o as Delta).YomiCompanyName = n.GetStringValue(); } }, - {"yomiGivenName", (o,n) => { (o as Delta).YomiGivenName = n.GetStringValue(); } }, - {"yomiSurname", (o,n) => { (o as Delta).YomiSurname = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteStringValue("assistantName", AssistantName); - writer.WriteDateTimeOffsetValue("birthday", Birthday); - writer.WriteObjectValue("businessAddress", BusinessAddress); - writer.WriteStringValue("businessHomePage", BusinessHomePage); - writer.WriteCollectionOfPrimitiveValues("businessPhones", BusinessPhones); - writer.WriteCollectionOfPrimitiveValues("children", Children); - writer.WriteStringValue("companyName", CompanyName); - writer.WriteStringValue("department", Department); - writer.WriteStringValue("displayName", DisplayName); - writer.WriteCollectionOfObjectValues("emailAddresses", EmailAddresses); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteStringValue("fileAs", FileAs); - writer.WriteStringValue("generation", Generation); - writer.WriteStringValue("givenName", GivenName); - writer.WriteObjectValue("homeAddress", HomeAddress); - writer.WriteCollectionOfPrimitiveValues("homePhones", HomePhones); - writer.WriteCollectionOfPrimitiveValues("imAddresses", ImAddresses); - writer.WriteStringValue("initials", Initials); - writer.WriteStringValue("jobTitle", JobTitle); - writer.WriteStringValue("manager", Manager); - writer.WriteStringValue("middleName", MiddleName); - writer.WriteStringValue("mobilePhone", MobilePhone); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteStringValue("nickName", NickName); - writer.WriteStringValue("officeLocation", OfficeLocation); - writer.WriteObjectValue("otherAddress", OtherAddress); - writer.WriteStringValue("parentFolderId", ParentFolderId); - writer.WriteStringValue("personalNotes", PersonalNotes); - writer.WriteObjectValue("photo", Photo); - writer.WriteStringValue("profession", Profession); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteStringValue("spouseName", SpouseName); - writer.WriteStringValue("surname", Surname); - writer.WriteStringValue("title", Title); - writer.WriteStringValue("yomiCompanyName", YomiCompanyName); - writer.WriteStringValue("yomiGivenName", YomiGivenName); - writer.WriteStringValue("yomiSurname", YomiSurname); - } - } -} diff --git a/src/generated/Users/Item/Contacts/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/Contacts/Delta/DeltaRequestBuilder.cs index c773c909990..823b68d9f12 100644 --- a/src/generated/Users/Item/Contacts/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/Contacts/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +30,17 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Contacts/Item/ContactRequestBuilder.cs b/src/generated/Users/Item/Contacts/Item/ContactRequestBuilder.cs index a0990aa88c7..1600c7e6e1f 100644 --- a/src/generated/Users/Item/Contacts/Item/ContactRequestBuilder.cs +++ b/src/generated/Users/Item/Contacts/Item/ContactRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Users.Item.Contacts.Item.SingleValueExtendedProperties; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - command.SetHandler(async (string userId, string contactId) => { + command.SetHandler(async (string userId, string contactId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactIdOption); return command; @@ -50,6 +49,9 @@ public Command BuildDeleteCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Users.Item.Contacts.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -74,24 +76,26 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string contactId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactIdOption, selectOption, outputOption); return command; } public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Users.Item.Contacts.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -115,14 +119,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string contactId, string body) => { + command.SetHandler(async (string userId, string contactId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactIdOption, bodyOption); return command; @@ -139,6 +142,9 @@ public Command BuildPhotoCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Users.Item.Contacts.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -210,42 +216,6 @@ public RequestInformation CreatePatchRequestInformation(Contact body, Action - /// The user's contacts. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's contacts. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's contacts. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Contact model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's contacts. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/Contacts/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Users/Item/Contacts/Item/Extensions/ExtensionsRequestBuilder.cs index 10c20bdd39f..eb9e22ef588 100644 --- a/src/generated/Users/Item/Contacts/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Users/Item/Contacts/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Contacts.Item.Extensions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string contactId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactIdOption, bodyOption, outputOption); return command; } /// @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string contactId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the contact. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the contact. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the contact. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Contacts/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Users/Item/Contacts/Item/Extensions/Item/ExtensionRequestBuilder.cs index 47d737a7455..3e242bafdf2 100644 --- a/src/generated/Users/Item/Contacts/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Users/Item/Contacts/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string userId, string contactId, string extensionId) => { + command.SetHandler(async (string userId, string contactId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactIdOption, extensionIdOption); return command; @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string contactId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string contactId, string extensionId, string body) => { + command.SetHandler(async (string userId, string contactId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactIdOption, extensionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the contact. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the contact. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the contact. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the contact. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Contacts/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/Contacts/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index cc50750902a..6b5fbf7ab94 100644 --- a/src/generated/Users/Item/Contacts/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/Contacts/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string contactId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string contactId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string contactId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string contactId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string contactId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Contacts/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/Contacts/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 8c7544aa7fe..a4207c223c9 100644 --- a/src/generated/Users/Item/Contacts/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/Contacts/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Contacts.Item.MultiValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string contactId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string contactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the contact. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Contacts/Item/Photo/PhotoRequestBuilder.cs b/src/generated/Users/Item/Contacts/Item/Photo/PhotoRequestBuilder.cs index 2a62f25a326..bc72d22d3f7 100644 --- a/src/generated/Users/Item/Contacts/Item/Photo/PhotoRequestBuilder.cs +++ b/src/generated/Users/Item/Contacts/Item/Photo/PhotoRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Contacts.Item.Photo.Value; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -42,11 +42,10 @@ public Command BuildDeleteCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - command.SetHandler(async (string userId, string contactId) => { + command.SetHandler(async (string userId, string contactId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactIdOption); return command; @@ -71,19 +70,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string contactId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactIdOption, selectOption, outputOption); return command; } /// @@ -105,14 +103,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string contactId, string body) => { + command.SetHandler(async (string userId, string contactId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactIdOption, bodyOption); return command; @@ -184,42 +181,6 @@ public RequestInformation CreatePatchRequestInformation(ProfilePhoto body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Optional contact picture. You can get or set a photo for a contact. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Optional contact picture. You can get or set a photo for a contact. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Optional contact picture. You can get or set a photo for a contact. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ProfilePhoto model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Optional contact picture. You can get or set a photo for a contact. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/Contacts/Item/Photo/Value/ContentRequestBuilder.cs b/src/generated/Users/Item/Contacts/Item/Photo/Value/ContentRequestBuilder.cs index 0872c5dbe8b..cf68b89eb4d 100644 --- a/src/generated/Users/Item/Contacts/Item/Photo/Value/ContentRequestBuilder.cs +++ b/src/generated/Users/Item/Contacts/Item/Photo/Value/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,24 +33,26 @@ public Command BuildGetCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string userId, string contactId, FileInfo output) => { + command.SetHandler(async (string userId, string contactId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, userIdOption, contactIdOption, outputOption); + }, userIdOption, contactIdOption, fileOption, outputOption); return command; } /// @@ -72,12 +74,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string contactId, FileInfo file) => { + command.SetHandler(async (string userId, string contactId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactIdOption, bodyOption); return command; @@ -128,29 +129,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// The user's profile photo. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's profile photo. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Contacts/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/Contacts/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 33540af6fae..27171dd1394 100644 --- a/src/generated/Users/Item/Contacts/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/Contacts/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string contactId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string contactId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string contactId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; contactIdOption.IsRequired = true; command.AddOption(contactIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string contactId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string contactId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, contactIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Contacts/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/Contacts/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 4013dbc2eb8..14ebe7e7013 100644 --- a/src/generated/Users/Item/Contacts/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/Contacts/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Contacts.Item.SingleValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string contactId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string contactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string contactId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, contactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, contactIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the contact. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CreatedObjects/@Ref/@Ref.cs b/src/generated/Users/Item/CreatedObjects/@Ref/@Ref.cs deleted file mode 100644 index 80f7f2416a2..00000000000 --- a/src/generated/Users/Item/CreatedObjects/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.CreatedObjects.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/CreatedObjects/@Ref/RefRequestBuilder.cs b/src/generated/Users/Item/CreatedObjects/@Ref/RefRequestBuilder.cs deleted file mode 100644 index a1765e92608..00000000000 --- a/src/generated/Users/Item/CreatedObjects/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Users.Item.CreatedObjects.@Ref { - /// Builds and executes requests for operations under \users\{user-id}\createdObjects\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Directory objects that were created by the user. Read-only. Nullable. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Directory objects that were created by the user. Read-only. Nullable."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Directory objects that were created by the user. Read-only. Nullable. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Directory objects that were created by the user. Read-only. Nullable."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/createdObjects/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Directory objects that were created by the user. Read-only. Nullable. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Directory objects that were created by the user. Read-only. Nullable. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Users.Item.CreatedObjects.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Directory objects that were created by the user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Directory objects that were created by the user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Users.Item.CreatedObjects.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Directory objects that were created by the user. Read-only. Nullable. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Users/Item/CreatedObjects/@Ref/RefResponse.cs b/src/generated/Users/Item/CreatedObjects/@Ref/RefResponse.cs deleted file mode 100644 index b46fdfd3ee5..00000000000 --- a/src/generated/Users/Item/CreatedObjects/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.CreatedObjects.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/CreatedObjects/CreatedObjectsRequestBuilder.cs b/src/generated/Users/Item/CreatedObjects/CreatedObjectsRequestBuilder.cs index d7c396ad9a2..9d672a8b482 100644 --- a/src/generated/Users/Item/CreatedObjects/CreatedObjectsRequestBuilder.cs +++ b/src/generated/Users/Item/CreatedObjects/CreatedObjectsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Users.Item.CreatedObjects.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Users.Item.CreatedObjects.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Users.Item.CreatedObjects.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Directory objects that were created by the user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Directory objects that were created by the user. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/CreatedObjects/Ref/Ref.cs b/src/generated/Users/Item/CreatedObjects/Ref/Ref.cs new file mode 100644 index 00000000000..2e1cd3b439e --- /dev/null +++ b/src/generated/Users/Item/CreatedObjects/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.CreatedObjects.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/CreatedObjects/Ref/RefRequestBuilder.cs b/src/generated/Users/Item/CreatedObjects/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..163c307e6f9 --- /dev/null +++ b/src/generated/Users/Item/CreatedObjects/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Users.Item.CreatedObjects.Ref { + /// Builds and executes requests for operations under \users\{user-id}\createdObjects\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Directory objects that were created by the user. Read-only. Nullable. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Directory objects that were created by the user. Read-only. Nullable."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Directory objects that were created by the user. Read-only. Nullable. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Directory objects that were created by the user. Read-only. Nullable."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/users/{user_id}/createdObjects/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Directory objects that were created by the user. Read-only. Nullable. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Directory objects that were created by the user. Read-only. Nullable. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Users.Item.CreatedObjects.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Directory objects that were created by the user. Read-only. Nullable. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Users/Item/CreatedObjects/Ref/RefResponse.cs b/src/generated/Users/Item/CreatedObjects/Ref/RefResponse.cs new file mode 100644 index 00000000000..efacb1dce2c --- /dev/null +++ b/src/generated/Users/Item/CreatedObjects/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.CreatedObjects.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/DeviceManagementTroubleshootingEvents/DeviceManagementTroubleshootingEventsRequestBuilder.cs b/src/generated/Users/Item/DeviceManagementTroubleshootingEvents/DeviceManagementTroubleshootingEventsRequestBuilder.cs index 9b37a6ffeec..19f287251f4 100644 --- a/src/generated/Users/Item/DeviceManagementTroubleshootingEvents/DeviceManagementTroubleshootingEventsRequestBuilder.cs +++ b/src/generated/Users/Item/DeviceManagementTroubleshootingEvents/DeviceManagementTroubleshootingEventsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.DeviceManagementTroubleshootingEvents.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DeviceManagementTroubleshootingEventsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceManagementTroubleshootingEventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(DeviceManagementTroublesh requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of troubleshooting events for this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of troubleshooting events for this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceManagementTroubleshootingEvent model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of troubleshooting events for this user. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/DeviceManagementTroubleshootingEvents/Item/DeviceManagementTroubleshootingEventRequestBuilder.cs b/src/generated/Users/Item/DeviceManagementTroubleshootingEvents/Item/DeviceManagementTroubleshootingEventRequestBuilder.cs index a886aa2995c..d9f9adeead7 100644 --- a/src/generated/Users/Item/DeviceManagementTroubleshootingEvents/Item/DeviceManagementTroubleshootingEventRequestBuilder.cs +++ b/src/generated/Users/Item/DeviceManagementTroubleshootingEvents/Item/DeviceManagementTroubleshootingEventRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var deviceManagementTroubleshootingEventIdOption = new Option("--devicemanagementtroubleshootingevent-id", description: "key: id of deviceManagementTroubleshootingEvent") { + var deviceManagementTroubleshootingEventIdOption = new Option("--device-management-troubleshooting-event-id", description: "key: id of deviceManagementTroubleshootingEvent") { }; deviceManagementTroubleshootingEventIdOption.IsRequired = true; command.AddOption(deviceManagementTroubleshootingEventIdOption); - command.SetHandler(async (string userId, string deviceManagementTroubleshootingEventId) => { + command.SetHandler(async (string userId, string deviceManagementTroubleshootingEventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, deviceManagementTroubleshootingEventIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var deviceManagementTroubleshootingEventIdOption = new Option("--devicemanagementtroubleshootingevent-id", description: "key: id of deviceManagementTroubleshootingEvent") { + var deviceManagementTroubleshootingEventIdOption = new Option("--device-management-troubleshooting-event-id", description: "key: id of deviceManagementTroubleshootingEvent") { }; deviceManagementTroubleshootingEventIdOption.IsRequired = true; command.AddOption(deviceManagementTroubleshootingEventIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string deviceManagementTroubleshootingEventId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string deviceManagementTroubleshootingEventId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, deviceManagementTroubleshootingEventIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, deviceManagementTroubleshootingEventIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var deviceManagementTroubleshootingEventIdOption = new Option("--devicemanagementtroubleshootingevent-id", description: "key: id of deviceManagementTroubleshootingEvent") { + var deviceManagementTroubleshootingEventIdOption = new Option("--device-management-troubleshooting-event-id", description: "key: id of deviceManagementTroubleshootingEvent") { }; deviceManagementTroubleshootingEventIdOption.IsRequired = true; command.AddOption(deviceManagementTroubleshootingEventIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string deviceManagementTroubleshootingEventId, string body) => { + command.SetHandler(async (string userId, string deviceManagementTroubleshootingEventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, deviceManagementTroubleshootingEventIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceManagementTroubles requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of troubleshooting events for this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of troubleshooting events for this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of troubleshooting events for this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceManagementTroubleshootingEvent model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of troubleshooting events for this user. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/DirectReports/@Ref/@Ref.cs b/src/generated/Users/Item/DirectReports/@Ref/@Ref.cs deleted file mode 100644 index 44b74d2bdfc..00000000000 --- a/src/generated/Users/Item/DirectReports/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.DirectReports.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/DirectReports/@Ref/RefRequestBuilder.cs b/src/generated/Users/Item/DirectReports/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 02237de5f2a..00000000000 --- a/src/generated/Users/Item/DirectReports/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Users.Item.DirectReports.@Ref { - /// Builds and executes requests for operations under \users\{user-id}\directReports\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/directReports/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Users.Item.DirectReports.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Users.Item.DirectReports.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Users/Item/DirectReports/@Ref/RefResponse.cs b/src/generated/Users/Item/DirectReports/@Ref/RefResponse.cs deleted file mode 100644 index f39f50f7574..00000000000 --- a/src/generated/Users/Item/DirectReports/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.DirectReports.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/DirectReports/DirectReportsRequestBuilder.cs b/src/generated/Users/Item/DirectReports/DirectReportsRequestBuilder.cs index 0f47ed25839..357a82a8c78 100644 --- a/src/generated/Users/Item/DirectReports/DirectReportsRequestBuilder.cs +++ b/src/generated/Users/Item/DirectReports/DirectReportsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Users.Item.DirectReports.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Users.Item.DirectReports.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Users.Item.DirectReports.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/DirectReports/Ref/Ref.cs b/src/generated/Users/Item/DirectReports/Ref/Ref.cs new file mode 100644 index 00000000000..a9c551f95f5 --- /dev/null +++ b/src/generated/Users/Item/DirectReports/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.DirectReports.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/DirectReports/Ref/RefRequestBuilder.cs b/src/generated/Users/Item/DirectReports/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..2473ec2ab0f --- /dev/null +++ b/src/generated/Users/Item/DirectReports/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Users.Item.DirectReports.Ref { + /// Builds and executes requests for operations under \users\{user-id}\directReports\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/users/{user_id}/directReports/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Users.Item.DirectReports.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Users/Item/DirectReports/Ref/RefResponse.cs b/src/generated/Users/Item/DirectReports/Ref/RefResponse.cs new file mode 100644 index 00000000000..a6d7d273e16 --- /dev/null +++ b/src/generated/Users/Item/DirectReports/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.DirectReports.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/Drive/DriveRequestBuilder.cs b/src/generated/Users/Item/Drive/DriveRequestBuilder.cs index 7cb0f712913..0281afcefc6 100644 --- a/src/generated/Users/Item/Drive/DriveRequestBuilder.cs +++ b/src/generated/Users/Item/Drive/DriveRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,10 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + command.SetHandler(async (string userId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption); return command; @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + command.SetHandler(async (string userId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user's OneDrive. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's OneDrive. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's OneDrive. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Drive model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's OneDrive. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Drives/DrivesRequestBuilder.cs b/src/generated/Users/Item/Drives/DrivesRequestBuilder.cs index 1d176586857..8abe8d0960e 100644 --- a/src/generated/Users/Item/Drives/DrivesRequestBuilder.cs +++ b/src/generated/Users/Item/Drives/DrivesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Drives.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DrivesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DriveRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of drives available for this user. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of drives available for this user. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Drive model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of drives available for this user. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Drives/Item/DriveRequestBuilder.cs b/src/generated/Users/Item/Drives/Item/DriveRequestBuilder.cs index eba89f84dbd..78782d85123 100644 --- a/src/generated/Users/Item/Drives/Item/DriveRequestBuilder.cs +++ b/src/generated/Users/Item/Drives/Item/DriveRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; driveIdOption.IsRequired = true; command.AddOption(driveIdOption); - command.SetHandler(async (string userId, string driveId) => { + command.SetHandler(async (string userId, string driveId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, driveIdOption); return command; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string driveId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string driveId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, driveIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, driveIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string driveId, string body) => { + command.SetHandler(async (string userId, string driveId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, driveIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of drives available for this user. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of drives available for this user. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of drives available for this user. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Drive model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of drives available for this user. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Events/Delta/Delta.cs b/src/generated/Users/Item/Events/Delta/Delta.cs deleted file mode 100644 index 40e157c71f6..00000000000 --- a/src/generated/Users/Item/Events/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.Events.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Users/Item/Events/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/Events/Delta/DeltaRequestBuilder.cs index d1d177157bf..2207eebc8b9 100644 --- a/src/generated/Users/Item/Events/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +30,17 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/EventsRequestBuilder.cs b/src/generated/Users/Item/Events/EventsRequestBuilder.cs index b06cfea57d8..73fcfcbdccf 100644 --- a/src/generated/Users/Item/Events/EventsRequestBuilder.cs +++ b/src/generated/Users/Item/Events/EventsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Events.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,24 +23,23 @@ public class EventsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildAttachmentsCommand(), - builder.BuildCalendarCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildExtensionsCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildInstancesCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildAttachmentsCommand()); + commands.Add(builder.BuildCalendarCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInstancesCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -58,21 +57,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -112,7 +110,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -172,7 +169,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -190,31 +187,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The user's events. Default is to show events under the Default Calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's events. Default is to show events under the Default Calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The user's events. Default is to show events under the Default Calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Events/EventsResponse.cs b/src/generated/Users/Item/Events/EventsResponse.cs index a3e8a76d53b..e94e97d3f40 100644 --- a/src/generated/Users/Item/Events/EventsResponse.cs +++ b/src/generated/Users/Item/Events/EventsResponse.cs @@ -9,7 +9,7 @@ public class EventsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new eventsResponse and sets the default values. /// @@ -22,7 +22,7 @@ public EventsResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as EventsResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Users/Item/Events/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Accept/AcceptRequestBuilder.cs index 445b4e7187c..2b8efbf2406 100644 --- a/src/generated/Users/Item/Events/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Attachments/AttachmentsRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Attachments/AttachmentsRequestBuilder.cs index 5f699b4fc88..e02dc01dbb1 100644 --- a/src/generated/Users/Item/Events/Item/Attachments/AttachmentsRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Attachments/AttachmentsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Events.Item.Attachments.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class AttachmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttachmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } public Command BuildCreateUploadSessionCommand() { @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(Attachment body, Action - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index bdd83d09e6e..e79cc8d4342 100644 --- a/src/generated/Users/Item/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs index 62fc7e015e5..0c3d11282b2 100644 --- a/src/generated/Users/Item/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Attachments/Item/AttachmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; attachmentIdOption.IsRequired = true; command.AddOption(attachmentIdOption); - command.SetHandler(async (string userId, string eventId, string attachmentId) => { + command.SetHandler(async (string userId, string eventId, string attachmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, attachmentIdOption); return command; @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, string attachmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string attachmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, attachmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string attachmentId, string body) => { + command.SetHandler(async (string userId, string eventId, string attachmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, attachmentIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Attachment body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs index a70684d8877..1df08cbc9da 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/AllowedCalendarSharingRolesWithUser/AllowedCalendarSharingRolesWithUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,18 +37,17 @@ public Command BuildGetCommand() { }; UserOption.IsRequired = true; command.AddOption(UserOption); - command.SetHandler(async (string userId, string eventId, string User) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string User, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, UserOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, UserOption, outputOption); return command; } /// @@ -81,16 +80,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function allowedCalendarSharingRoles - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs index 4c9dad2d385..a0b365ad505 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/CalendarPermissions/CalendarPermissionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Events.Item.Calendar.CalendarPermissions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class CalendarPermissionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new CalendarPermissionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -106,7 +104,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -115,15 +117,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -178,31 +175,6 @@ public RequestInformation CreatePostRequestInformation(CalendarPermission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CalendarPermission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions of the users with whom the calendar is shared. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Events/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs index cf05dc96061..784524875b7 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/CalendarPermissions/Item/CalendarPermissionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); - command.SetHandler(async (string userId, string eventId, string calendarPermissionId) => { + command.SetHandler(async (string userId, string eventId, string calendarPermissionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, calendarPermissionIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); @@ -71,19 +70,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, string calendarPermissionId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string calendarPermissionId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, calendarPermissionIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, calendarPermissionIdOption, selectOption, outputOption); return command; } /// @@ -101,7 +99,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var calendarPermissionIdOption = new Option("--calendarpermission-id", description: "key: id of calendarPermission") { + var calendarPermissionIdOption = new Option("--calendar-permission-id", description: "key: id of calendarPermission") { }; calendarPermissionIdOption.IsRequired = true; command.AddOption(calendarPermissionIdOption); @@ -109,14 +107,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string calendarPermissionId, string body) => { + command.SetHandler(async (string userId, string eventId, string calendarPermissionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, calendarPermissionIdOption, bodyOption); return command; @@ -188,42 +185,6 @@ public RequestInformation CreatePatchRequestInformation(CalendarPermission body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The permissions of the users with whom the calendar is shared. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(CalendarPermission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The permissions of the users with whom the calendar is shared. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/Events/Item/Calendar/CalendarRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/CalendarRequestBuilder.cs index 51140b06783..fbe0f5ad9cf 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/CalendarRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/CalendarRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Users.Item.Events.Item.Calendar.SingleValueExtendedProperties; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,6 +37,9 @@ public AllowedCalendarSharingRolesWithUserRequestBuilder AllowedCalendarSharingR public Command BuildCalendarPermissionsCommand() { var command = new Command("calendar-permissions"); var builder = new ApiSdk.Users.Item.Events.Item.Calendar.CalendarPermissions.CalendarPermissionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -44,6 +47,9 @@ public Command BuildCalendarPermissionsCommand() { public Command BuildCalendarViewCommand() { var command = new Command("calendar-view"); var builder = new ApiSdk.Users.Item.Events.Item.Calendar.CalendarView.CalendarViewRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -63,11 +69,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string eventId) => { + command.SetHandler(async (string userId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption); return command; @@ -75,6 +80,9 @@ public Command BuildDeleteCommand() { public Command BuildEventsCommand() { var command = new Command("events"); var builder = new ApiSdk.Users.Item.Events.Item.Calendar.Events.EventsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -99,19 +107,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, selectOption, outputOption); return command; } public Command BuildGetScheduleCommand() { @@ -123,6 +130,9 @@ public Command BuildGetScheduleCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Users.Item.Events.Item.Calendar.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -146,14 +156,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -161,6 +170,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Users.Item.Events.Item.Calendar.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -232,42 +244,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar that contains the event. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Calendar model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar that contains the event. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/Events/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs index 831460656ca..36096481d16 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/CalendarView/CalendarViewRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Events.Item.Calendar.CalendarView.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class CalendarViewRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -114,7 +112,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -174,7 +171,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Events/Item/Calendar/CalendarView/CalendarViewResponse.cs b/src/generated/Users/Item/Events/Item/Calendar/CalendarView/CalendarViewResponse.cs index df01805fbd7..d768270ea2a 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/CalendarView/CalendarViewResponse.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/CalendarView/CalendarViewResponse.cs @@ -9,7 +9,7 @@ public class CalendarViewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new calendarViewResponse and sets the default values. /// @@ -22,7 +22,7 @@ public CalendarViewResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as CalendarViewResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as CalendarViewResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Delta/Delta.cs b/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Delta/Delta.cs deleted file mode 100644 index a527edfe547..00000000000 --- a/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.Events.Item.Calendar.CalendarView.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs index 57aab55fac1..561ca14637d 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +34,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, outputOption); return command; } /// @@ -75,16 +75,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs index 28b08cc6a46..bcf50354b33 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs index 3165e310e61..9bb90d52745 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs index 8c03fa7ea6f..0aa57e0adb9 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs index 56816bbc569..78ff3a71414 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,11 +37,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string userId, string eventId, string eventId1) => { + command.SetHandler(async (string userId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs index da9805dd7da..b172c88226f 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Users.Item.Events.Item.Calendar.CalendarView.Item.TentativelyAccept; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -63,11 +63,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string userId, string eventId, string eventId1) => { + command.SetHandler(async (string userId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option); return command; @@ -108,19 +107,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -146,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -225,7 +222,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -237,42 +234,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The calendar view for the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The calendar view for the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs index 664e7ced002..af8a4d0f91e 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index 8dc7d62921b..62736c637f3 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index e6ce56c3859..0478ce9c09f 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/CalendarView/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Calendar/Events/Delta/Delta.cs b/src/generated/Users/Item/Events/Item/Calendar/Events/Delta/Delta.cs deleted file mode 100644 index 800feb067e7..00000000000 --- a/src/generated/Users/Item/Events/Item/Calendar/Events/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.Events.Item.Calendar.Events.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Users/Item/Events/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs index 05e6bb2027f..140bd9605f8 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/Events/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +34,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, outputOption); return command; } /// @@ -75,16 +75,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Calendar/Events/EventsRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/Events/EventsRequestBuilder.cs index b5c8ccebdb2..51daab6a778 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/Events/EventsRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/Events/EventsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Events.Item.Calendar.Events.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class EventsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -114,7 +112,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -174,7 +171,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The events in the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Events/Item/Calendar/Events/EventsResponse.cs b/src/generated/Users/Item/Events/Item/Calendar/Events/EventsResponse.cs index 2e6d92b320f..43c2d5ea8bd 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/Events/EventsResponse.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/Events/EventsResponse.cs @@ -9,7 +9,7 @@ public class EventsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new eventsResponse and sets the default values. /// @@ -22,7 +22,7 @@ public EventsResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as EventsResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as EventsResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Users/Item/Events/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs index f62643d381e..205383dd06f 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/Events/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs index afa70c9b1bb..d7fdefb6760 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/Events/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs index f4bfc7a6fd5..b0835fcb3f6 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/Events/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs index 628f9139417..6791b7b3178 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,11 +37,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string userId, string eventId, string eventId1) => { + command.SetHandler(async (string userId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Calendar/Events/Item/EventRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/Events/Item/EventRequestBuilder.cs index 1dc549a9d3a..cdc5e6f4eb5 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/Events/Item/EventRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/Events/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Users.Item.Events.Item.Calendar.Events.Item.TentativelyAccept; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -63,11 +63,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string userId, string eventId, string eventId1) => { + command.SetHandler(async (string userId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option); return command; @@ -108,19 +107,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -146,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -225,7 +222,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -237,42 +234,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The events in the calendar. Navigation property. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The events in the calendar. Navigation property. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/Events/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs index c39efe66f5d..beb104370d8 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/Events/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index c83b4486152..e60281d74bf 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index 14316d8a19a..6b948549c7f 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs index b5548216d18..3fcdb177dc1 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/GetSchedule/GetScheduleRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,21 +37,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -85,18 +84,5 @@ public RequestInformation CreatePostRequestInformation(GetScheduleRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getSchedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetScheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index da38f5adcfc..6748c0bb9f3 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Events/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 28190a095a2..c267063b212 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Events.Item.Calendar.MultiValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Events/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index a9e330cb73f..dc274402cbd 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Events/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 6feccb3d437..0665b0320a3 100644 --- a/src/generated/Users/Item/Events/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Calendar/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Events.Item.Calendar.SingleValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Events/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Cancel/CancelRequestBuilder.cs index 6d4c522c7c3..7b03a6bd117 100644 --- a/src/generated/Users/Item/Events/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Decline/DeclineRequestBuilder.cs index 850b056beb3..55f7f971a23 100644 --- a/src/generated/Users/Item/Events/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Users/Item/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs index cac84832dcf..33c5aac01fc 100644 --- a/src/generated/Users/Item/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,11 +33,10 @@ public Command BuildPostCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string eventId) => { + command.SetHandler(async (string userId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/EventRequestBuilder.cs b/src/generated/Users/Item/Events/Item/EventRequestBuilder.cs index 81e8c72bff7..53b0176317c 100644 --- a/src/generated/Users/Item/Events/Item/EventRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/EventRequestBuilder.cs @@ -14,10 +14,10 @@ using ApiSdk.Users.Item.Events.Item.TentativelyAccept; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,6 +41,9 @@ public Command BuildAcceptCommand() { public Command BuildAttachmentsCommand() { var command = new Command("attachments"); var builder = new ApiSdk.Users.Item.Events.Item.Attachments.AttachmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateUploadSessionCommand()); command.AddCommand(builder.BuildListCommand()); @@ -87,11 +90,10 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string eventId) => { + command.SetHandler(async (string userId, string eventId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption); return command; @@ -105,6 +107,9 @@ public Command BuildDismissReminderCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Users.Item.Events.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -135,24 +140,26 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, selectOption, outputOption); return command; } public Command BuildInstancesCommand() { var command = new Command("instances"); var builder = new ApiSdk.Users.Item.Events.Item.Instances.InstancesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -160,6 +167,9 @@ public Command BuildInstancesCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Users.Item.Events.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -183,14 +193,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -198,6 +207,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Users.Item.Events.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -269,7 +281,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -281,42 +293,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The user's events. Default is to show events under the Default Calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's events. Default is to show events under the Default Calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's events. Default is to show events under the Default Calendar. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's events. Default is to show events under the Default Calendar. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/Events/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Extensions/ExtensionsRequestBuilder.cs index 3ab7daa6ad4..570bcf2af90 100644 --- a/src/generated/Users/Item/Events/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Events.Item.Extensions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs index 5843328ba7d..c185870a1fd 100644 --- a/src/generated/Users/Item/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string userId, string eventId, string extensionId) => { + command.SetHandler(async (string userId, string eventId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, extensionIdOption); return command; @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string extensionId, string body) => { + command.SetHandler(async (string userId, string eventId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, extensionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the event. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the event. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Events/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Forward/ForwardRequestBuilder.cs index f345b633ec9..e439b165a1b 100644 --- a/src/generated/Users/Item/Events/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Instances/Delta/Delta.cs b/src/generated/Users/Item/Events/Item/Instances/Delta/Delta.cs deleted file mode 100644 index 76b701a844a..00000000000 --- a/src/generated/Users/Item/Events/Item/Instances/Delta/Delta.cs +++ /dev/null @@ -1,165 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.Events.Item.Instances.Delta { - public class Delta : OutlookItem, IParsable { - /// true if the meeting organizer allows invitees to propose a new time when responding; otherwise false. Optional. Default is true. - public bool? AllowNewTimeProposals { get; set; } - /// The collection of FileAttachment, ItemAttachment, and referenceAttachment attachments for the event. Navigation property. Read-only. Nullable. - public List Attachments { get; set; } - /// The collection of attendees for the event. - public List Attendees { get; set; } - /// The body of the message associated with the event. It can be in HTML or text format. - public ItemBody Body { get; set; } - /// The preview of the message associated with the event. It is in text format. - public string BodyPreview { get; set; } - /// The calendar that contains the event. Navigation property. Read-only. - public ApiSdk.Models.Microsoft.Graph.Calendar Calendar { get; set; } - /// The date, time, and time zone that the event ends. By default, the end time is in UTC. - public DateTimeTimeZone End { get; set; } - /// The collection of open extensions defined for the event. Nullable. - public List Extensions { get; set; } - /// Set to true if the event has attachments. - public bool? HasAttachments { get; set; } - /// When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list. Default is false. - public bool? HideAttendees { get; set; } - /// A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring series. Read-only. - public string ICalUId { get; set; } - public Importance? Importance { get; set; } - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - public List<@Event> Instances { get; set; } - public bool? IsAllDay { get; set; } - public bool? IsCancelled { get; set; } - public bool? IsDraft { get; set; } - public bool? IsOnlineMeeting { get; set; } - public bool? IsOrganizer { get; set; } - public bool? IsReminderOn { get; set; } - public Location Location { get; set; } - public List Locations { get; set; } - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - public OnlineMeetingInfo OnlineMeeting { get; set; } - public OnlineMeetingProviderType? OnlineMeetingProvider { get; set; } - public string OnlineMeetingUrl { get; set; } - public Recipient Organizer { get; set; } - public string OriginalEndTimeZone { get; set; } - public DateTimeOffset? OriginalStart { get; set; } - public string OriginalStartTimeZone { get; set; } - public PatternedRecurrence Recurrence { get; set; } - public int? ReminderMinutesBeforeStart { get; set; } - public bool? ResponseRequested { get; set; } - public ResponseStatus ResponseStatus { get; set; } - public Sensitivity? Sensitivity { get; set; } - public string SeriesMasterId { get; set; } - public FreeBusyStatus? ShowAs { get; set; } - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - public DateTimeTimeZone Start { get; set; } - public string Subject { get; set; } - public string TransactionId { get; set; } - public EventType? Type { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"allowNewTimeProposals", (o,n) => { (o as Delta).AllowNewTimeProposals = n.GetBoolValue(); } }, - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"attendees", (o,n) => { (o as Delta).Attendees = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"calendar", (o,n) => { (o as Delta).Calendar = n.GetObjectValue(); } }, - {"end", (o,n) => { (o as Delta).End = n.GetObjectValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"hideAttendees", (o,n) => { (o as Delta).HideAttendees = n.GetBoolValue(); } }, - {"iCalUId", (o,n) => { (o as Delta).ICalUId = n.GetStringValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"instances", (o,n) => { (o as Delta).Instances = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, - {"isAllDay", (o,n) => { (o as Delta).IsAllDay = n.GetBoolValue(); } }, - {"isCancelled", (o,n) => { (o as Delta).IsCancelled = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isOnlineMeeting", (o,n) => { (o as Delta).IsOnlineMeeting = n.GetBoolValue(); } }, - {"isOrganizer", (o,n) => { (o as Delta).IsOrganizer = n.GetBoolValue(); } }, - {"isReminderOn", (o,n) => { (o as Delta).IsReminderOn = n.GetBoolValue(); } }, - {"location", (o,n) => { (o as Delta).Location = n.GetObjectValue(); } }, - {"locations", (o,n) => { (o as Delta).Locations = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"onlineMeeting", (o,n) => { (o as Delta).OnlineMeeting = n.GetObjectValue(); } }, - {"onlineMeetingProvider", (o,n) => { (o as Delta).OnlineMeetingProvider = n.GetEnumValue(); } }, - {"onlineMeetingUrl", (o,n) => { (o as Delta).OnlineMeetingUrl = n.GetStringValue(); } }, - {"organizer", (o,n) => { (o as Delta).Organizer = n.GetObjectValue(); } }, - {"originalEndTimeZone", (o,n) => { (o as Delta).OriginalEndTimeZone = n.GetStringValue(); } }, - {"originalStart", (o,n) => { (o as Delta).OriginalStart = n.GetDateTimeOffsetValue(); } }, - {"originalStartTimeZone", (o,n) => { (o as Delta).OriginalStartTimeZone = n.GetStringValue(); } }, - {"recurrence", (o,n) => { (o as Delta).Recurrence = n.GetObjectValue(); } }, - {"reminderMinutesBeforeStart", (o,n) => { (o as Delta).ReminderMinutesBeforeStart = n.GetIntValue(); } }, - {"responseRequested", (o,n) => { (o as Delta).ResponseRequested = n.GetBoolValue(); } }, - {"responseStatus", (o,n) => { (o as Delta).ResponseStatus = n.GetObjectValue(); } }, - {"sensitivity", (o,n) => { (o as Delta).Sensitivity = n.GetEnumValue(); } }, - {"seriesMasterId", (o,n) => { (o as Delta).SeriesMasterId = n.GetStringValue(); } }, - {"showAs", (o,n) => { (o as Delta).ShowAs = n.GetEnumValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"start", (o,n) => { (o as Delta).Start = n.GetObjectValue(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"transactionId", (o,n) => { (o as Delta).TransactionId = n.GetStringValue(); } }, - {"type", (o,n) => { (o as Delta).Type = n.GetEnumValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteBoolValue("allowNewTimeProposals", AllowNewTimeProposals); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("attendees", Attendees); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteObjectValue("calendar", Calendar); - writer.WriteObjectValue("end", End); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteBoolValue("hideAttendees", HideAttendees); - writer.WriteStringValue("iCalUId", ICalUId); - writer.WriteEnumValue("importance", Importance); - writer.WriteCollectionOfObjectValues<@Event>("instances", Instances); - writer.WriteBoolValue("isAllDay", IsAllDay); - writer.WriteBoolValue("isCancelled", IsCancelled); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isOnlineMeeting", IsOnlineMeeting); - writer.WriteBoolValue("isOrganizer", IsOrganizer); - writer.WriteBoolValue("isReminderOn", IsReminderOn); - writer.WriteObjectValue("location", Location); - writer.WriteCollectionOfObjectValues("locations", Locations); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteObjectValue("onlineMeeting", OnlineMeeting); - writer.WriteEnumValue("onlineMeetingProvider", OnlineMeetingProvider); - writer.WriteStringValue("onlineMeetingUrl", OnlineMeetingUrl); - writer.WriteObjectValue("organizer", Organizer); - writer.WriteStringValue("originalEndTimeZone", OriginalEndTimeZone); - writer.WriteDateTimeOffsetValue("originalStart", OriginalStart); - writer.WriteStringValue("originalStartTimeZone", OriginalStartTimeZone); - writer.WriteObjectValue("recurrence", Recurrence); - writer.WriteIntValue("reminderMinutesBeforeStart", ReminderMinutesBeforeStart); - writer.WriteBoolValue("responseRequested", ResponseRequested); - writer.WriteObjectValue("responseStatus", ResponseStatus); - writer.WriteEnumValue("sensitivity", Sensitivity); - writer.WriteStringValue("seriesMasterId", SeriesMasterId); - writer.WriteEnumValue("showAs", ShowAs); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteObjectValue("start", Start); - writer.WriteStringValue("subject", Subject); - writer.WriteStringValue("transactionId", TransactionId); - writer.WriteEnumValue("type", Type); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Users/Item/Events/Item/Instances/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Instances/Delta/DeltaRequestBuilder.cs index 0b9cb73f85e..ea3299a54de 100644 --- a/src/generated/Users/Item/Events/Item/Instances/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Instances/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,18 +34,17 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - command.SetHandler(async (string userId, string eventId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, outputOption); return command; } /// @@ -75,16 +75,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Instances/InstancesRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Instances/InstancesRequestBuilder.cs index 02e1c5fc844..19169f3ed94 100644 --- a/src/generated/Users/Item/Events/Item/Instances/InstancesRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Instances/InstancesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Events.Item.Instances.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class InstancesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new EventRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAcceptCommand(), - builder.BuildCancelCommand(), - builder.BuildDeclineCommand(), - builder.BuildDeleteCommand(), - builder.BuildDismissReminderCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSnoozeReminderCommand(), - builder.BuildTentativelyAcceptCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAcceptCommand()); + commands.Add(builder.BuildCancelCommand()); + commands.Add(builder.BuildDeclineCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDismissReminderCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSnoozeReminderCommand()); + commands.Add(builder.BuildTentativelyAcceptCommand()); return commands; } /// @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -114,7 +112,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -174,7 +171,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePostRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePostRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> PostAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Events/Item/Instances/InstancesResponse.cs b/src/generated/Users/Item/Events/Item/Instances/InstancesResponse.cs index 067dd4da10c..37448b3e244 100644 --- a/src/generated/Users/Item/Events/Item/Instances/InstancesResponse.cs +++ b/src/generated/Users/Item/Events/Item/Instances/InstancesResponse.cs @@ -9,7 +9,7 @@ public class InstancesResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string NextLink { get; set; } - public List<@Event> Value { get; set; } + public List Value { get; set; } /// /// Instantiates a new instancesResponse and sets the default values. /// @@ -22,7 +22,7 @@ public InstancesResponse() { public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"@odata.nextLink", (o,n) => { (o as InstancesResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues<@Event>().ToList(); } }, + {"value", (o,n) => { (o as InstancesResponse).Value = n.GetCollectionOfObjectValues().ToList(); } }, }; } /// @@ -32,7 +32,7 @@ public IDictionary> GetFieldDeserializers() { public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfObjectValues<@Event>("value", Value); + writer.WriteCollectionOfObjectValues("value", Value); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Users/Item/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs index c27345d79f1..3b87720bc5e 100644 --- a/src/generated/Users/Item/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Instances/Item/Accept/AcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(AcceptRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs index 50ff4efa88a..987fdb2e0c0 100644 --- a/src/generated/Users/Item/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Instances/Item/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(CancelRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CancelRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs index 30b5934a4b0..fbc9181df87 100644 --- a/src/generated/Users/Item/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Instances/Item/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs index d075ce2bd5f..b95a1b18211 100644 --- a/src/generated/Users/Item/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Instances/Item/DismissReminder/DismissReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,11 +37,10 @@ public Command BuildPostCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string userId, string eventId, string eventId1) => { + command.SetHandler(async (string userId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action dismissReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Instances/Item/EventRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Instances/Item/EventRequestBuilder.cs index e72f4e10d67..4eb66555b65 100644 --- a/src/generated/Users/Item/Events/Item/Instances/Item/EventRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Instances/Item/EventRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Users.Item.Events.Item.Instances.Item.TentativelyAccept; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -63,11 +63,10 @@ public Command BuildDeleteCommand() { }; eventId1Option.IsRequired = true; command.AddOption(eventId1Option); - command.SetHandler(async (string userId, string eventId, string eventId1) => { + command.SetHandler(async (string userId, string eventId, string eventId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option); return command; @@ -108,19 +107,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string eventId1, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync<@Event>(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, eventId1Option, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, eventId1Option, selectOption, outputOption); return command; } /// @@ -146,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue<@Event>(); + var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -225,7 +222,7 @@ public RequestInformation CreateGetRequestInformation(Action /// Request headers /// Request options /// - public RequestInformation CreatePatchRequestInformation(@Event body, Action> h = default, IEnumerable o = default) { + public RequestInformation CreatePatchRequestInformation(Event body, Action> h = default, IEnumerable o = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, @@ -237,42 +234,6 @@ public RequestInformation CreatePatchRequestInformation(@Event body, Action - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task<@Event> GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync<@Event>(requestInfo, responseHandler, cancellationToken); - } - /// - /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(@Event model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The occurrences of a recurring series, if the event is a series master. This property includes occurrences that are part of the recurrence pattern, and exceptions that have been modified, but does not include occurrences that have been cancelled from the series. Navigation property. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs index 0e548f29d49..e64bd45b030 100644 --- a/src/generated/Users/Item/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Instances/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index a6d5892ad55..b6af428c421 100644 --- a/src/generated/Users/Item/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Instances/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Users/Item/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index e6b7041f1fc..99685d23518 100644 --- a/src/generated/Users/Item/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/Instances/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string eventId1, string body) => { + command.SetHandler(async (string userId, string eventId, string eventId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, eventId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 2001807480a..9a18721e7af 100644 --- a/src/generated/Users/Item/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string eventId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index 8ef84d3b8bf..f776a75a0df 100644 --- a/src/generated/Users/Item/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Events.Item.MultiValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 7680c1ced96..f54bf3c34de 100644 --- a/src/generated/Users/Item/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; eventIdOption.IsRequired = true; command.AddOption(eventIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string eventId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 3a96b72caa8..c46a55c5985 100644 --- a/src/generated/Users/Item/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Events.Item.SingleValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string eventId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, eventIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the event. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the event. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs b/src/generated/Users/Item/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs index e516595ff15..14aaf302725 100644 --- a/src/generated/Users/Item/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/SnoozeReminder/SnoozeReminderRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(SnoozeReminderRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action snoozeReminder - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SnoozeReminderRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs b/src/generated/Users/Item/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs index 2448545b747..7e1d7b594d0 100644 --- a/src/generated/Users/Item/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Events/Item/TentativelyAccept/TentativelyAcceptRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string eventId, string body) => { + command.SetHandler(async (string userId, string eventId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, eventIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TentativelyAcceptRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tentativelyAccept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TentativelyAcceptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/ExportPersonalData/ExportPersonalDataRequestBuilder.cs b/src/generated/Users/Item/ExportPersonalData/ExportPersonalDataRequestBuilder.cs index 2337710c5a4..cb5ca0936f5 100644 --- a/src/generated/Users/Item/ExportPersonalData/ExportPersonalDataRequestBuilder.cs +++ b/src/generated/Users/Item/ExportPersonalData/ExportPersonalDataRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + command.SetHandler(async (string userId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ExportPersonalDataRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action exportPersonalData - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ExportPersonalDataRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Users/Item/Extensions/ExtensionsRequestBuilder.cs index 5fb199b35a2..5e8a36394a1 100644 --- a/src/generated/Users/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Users/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Extensions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the user. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the user. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the user. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Users/Item/Extensions/Item/ExtensionRequestBuilder.cs index fd079a4d299..8b7afc1aa02 100644 --- a/src/generated/Users/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Users/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string userId, string extensionId) => { + command.SetHandler(async (string userId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, extensionIdOption); return command; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string extensionId, string body) => { + command.SetHandler(async (string userId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, extensionIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the user. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the user. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the user. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the user. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/FindMeetingTimes/FindMeetingTimesRequestBody.cs b/src/generated/Users/Item/FindMeetingTimes/FindMeetingTimesRequestBody.cs index e19bfbc0638..c8a1d2c1501 100644 --- a/src/generated/Users/Item/FindMeetingTimes/FindMeetingTimesRequestBody.cs +++ b/src/generated/Users/Item/FindMeetingTimes/FindMeetingTimesRequestBody.cs @@ -12,7 +12,7 @@ public class FindMeetingTimesRequestBody : IParsable { public bool? IsOrganizerOptional { get; set; } public LocationConstraint LocationConstraint { get; set; } public int? MaxCandidates { get; set; } - public string MeetingDuration { get; set; } + public TimeSpan? MeetingDuration { get; set; } public double? MinimumAttendeePercentage { get; set; } public bool? ReturnSuggestionReasons { get; set; } public TimeConstraint TimeConstraint { get; set; } @@ -31,7 +31,7 @@ public IDictionary> GetFieldDeserializers() { {"isOrganizerOptional", (o,n) => { (o as FindMeetingTimesRequestBody).IsOrganizerOptional = n.GetBoolValue(); } }, {"locationConstraint", (o,n) => { (o as FindMeetingTimesRequestBody).LocationConstraint = n.GetObjectValue(); } }, {"maxCandidates", (o,n) => { (o as FindMeetingTimesRequestBody).MaxCandidates = n.GetIntValue(); } }, - {"meetingDuration", (o,n) => { (o as FindMeetingTimesRequestBody).MeetingDuration = n.GetStringValue(); } }, + {"meetingDuration", (o,n) => { (o as FindMeetingTimesRequestBody).MeetingDuration = n.GetTimeSpanValue(); } }, {"minimumAttendeePercentage", (o,n) => { (o as FindMeetingTimesRequestBody).MinimumAttendeePercentage = n.GetDoubleValue(); } }, {"returnSuggestionReasons", (o,n) => { (o as FindMeetingTimesRequestBody).ReturnSuggestionReasons = n.GetBoolValue(); } }, {"timeConstraint", (o,n) => { (o as FindMeetingTimesRequestBody).TimeConstraint = n.GetObjectValue(); } }, @@ -47,7 +47,7 @@ public void Serialize(ISerializationWriter writer) { writer.WriteBoolValue("isOrganizerOptional", IsOrganizerOptional); writer.WriteObjectValue("locationConstraint", LocationConstraint); writer.WriteIntValue("maxCandidates", MaxCandidates); - writer.WriteStringValue("meetingDuration", MeetingDuration); + writer.WriteTimeSpanValue("meetingDuration", MeetingDuration); writer.WriteDoubleValue("minimumAttendeePercentage", MinimumAttendeePercentage); writer.WriteBoolValue("returnSuggestionReasons", ReturnSuggestionReasons); writer.WriteObjectValue("timeConstraint", TimeConstraint); diff --git a/src/generated/Users/Item/FindMeetingTimes/FindMeetingTimesRequestBuilder.cs b/src/generated/Users/Item/FindMeetingTimes/FindMeetingTimesRequestBuilder.cs index ed888f49558..c4bbd8e3a63 100644 --- a/src/generated/Users/Item/FindMeetingTimes/FindMeetingTimesRequestBuilder.cs +++ b/src/generated/Users/Item/FindMeetingTimes/FindMeetingTimesRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(FindMeetingTimesRequestBo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action findMeetingTimes - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(FindMeetingTimesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes meetingTimeSuggestionsResult public class FindMeetingTimesResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/FollowedSites/@Ref/@Ref.cs b/src/generated/Users/Item/FollowedSites/@Ref/@Ref.cs deleted file mode 100644 index fd03cf29c7e..00000000000 --- a/src/generated/Users/Item/FollowedSites/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.FollowedSites.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/FollowedSites/@Ref/RefRequestBuilder.cs b/src/generated/Users/Item/FollowedSites/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 185929facc1..00000000000 --- a/src/generated/Users/Item/FollowedSites/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Users.Item.FollowedSites.@Ref { - /// Builds and executes requests for operations under \users\{user-id}\followedSites\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Get ref of followedSites from users - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Get ref of followedSites from users"; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Create new navigation property ref to followedSites for users - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Create new navigation property ref to followedSites for users"; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/followedSites/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Get ref of followedSites from users - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Create new navigation property ref to followedSites for users - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Users.Item.FollowedSites.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Get ref of followedSites from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property ref to followedSites for users - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Users.Item.FollowedSites.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Get ref of followedSites from users - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Users/Item/FollowedSites/@Ref/RefResponse.cs b/src/generated/Users/Item/FollowedSites/@Ref/RefResponse.cs deleted file mode 100644 index 7ace0f44ad3..00000000000 --- a/src/generated/Users/Item/FollowedSites/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.FollowedSites.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/FollowedSites/FollowedSitesRequestBuilder.cs b/src/generated/Users/Item/FollowedSites/FollowedSitesRequestBuilder.cs index 58fcf6bb812..d5e2f11d060 100644 --- a/src/generated/Users/Item/FollowedSites/FollowedSitesRequestBuilder.cs +++ b/src/generated/Users/Item/FollowedSites/FollowedSitesRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Users.Item.FollowedSites.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Users.Item.FollowedSites.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Users.Item.FollowedSites.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get followedSites from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get followedSites from users public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/FollowedSites/Ref/Ref.cs b/src/generated/Users/Item/FollowedSites/Ref/Ref.cs new file mode 100644 index 00000000000..ad6dd3a0bef --- /dev/null +++ b/src/generated/Users/Item/FollowedSites/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.FollowedSites.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/FollowedSites/Ref/RefRequestBuilder.cs b/src/generated/Users/Item/FollowedSites/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..d4a8e4ece3e --- /dev/null +++ b/src/generated/Users/Item/FollowedSites/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Users.Item.FollowedSites.Ref { + /// Builds and executes requests for operations under \users\{user-id}\followedSites\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Get ref of followedSites from users + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Get ref of followedSites from users"; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Create new navigation property ref to followedSites for users + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Create new navigation property ref to followedSites for users"; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/users/{user_id}/followedSites/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Get ref of followedSites from users + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Create new navigation property ref to followedSites for users + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Users.Item.FollowedSites.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Get ref of followedSites from users + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Users/Item/FollowedSites/Ref/RefResponse.cs b/src/generated/Users/Item/FollowedSites/Ref/RefResponse.cs new file mode 100644 index 00000000000..0fbe017eb4a --- /dev/null +++ b/src/generated/Users/Item/FollowedSites/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.FollowedSites.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/GetMailTips/GetMailTips.cs b/src/generated/Users/Item/GetMailTips/GetMailTips.cs deleted file mode 100644 index 278a13b9707..00000000000 --- a/src/generated/Users/Item/GetMailTips/GetMailTips.cs +++ /dev/null @@ -1,81 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.GetMailTips { - public class GetMailTips : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Mail tips for automatic reply if it has been set up by the recipient. - public AutomaticRepliesMailTips AutomaticReplies { get; set; } - /// A custom mail tip that can be set on the recipient's mailbox. - public string CustomMailTip { get; set; } - /// Whether the recipient's mailbox is restricted, for example, accepting messages from only a predefined list of senders, rejecting messages from a predefined list of senders, or accepting messages from only authenticated senders. - public bool? DeliveryRestricted { get; set; } - /// The email address of the recipient to get mailtips for. - public EmailAddress EmailAddress { get; set; } - /// Errors that occur during the getMailTips action. - public MailTipsError Error { get; set; } - /// The number of external members if the recipient is a distribution list. - public int? ExternalMemberCount { get; set; } - /// Whether sending messages to the recipient requires approval. For example, if the recipient is a large distribution list and a moderator has been set up to approve messages sent to that distribution list, or if sending messages to a recipient requires approval of the recipient's manager. - public bool? IsModerated { get; set; } - /// The mailbox full status of the recipient. - public bool? MailboxFull { get; set; } - /// The maximum message size that has been configured for the recipient's organization or mailbox. - public int? MaxMessageSize { get; set; } - /// The scope of the recipient. Possible values are: none, internal, external, externalPartner, externalNonParther. For example, an administrator can set another organization to be its 'partner'. The scope is useful if an administrator wants certain mailtips to be accessible to certain scopes. It's also useful to senders to inform them that their message may leave the organization, helping them make the correct decisions about wording, tone and content. - public RecipientScopeType? RecipientScope { get; set; } - /// Recipients suggested based on previous contexts where they appear in the same message. - public List RecipientSuggestions { get; set; } - /// The number of members if the recipient is a distribution list. - public int? TotalMemberCount { get; set; } - /// - /// Instantiates a new getMailTips and sets the default values. - /// - public GetMailTips() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"automaticReplies", (o,n) => { (o as GetMailTips).AutomaticReplies = n.GetObjectValue(); } }, - {"customMailTip", (o,n) => { (o as GetMailTips).CustomMailTip = n.GetStringValue(); } }, - {"deliveryRestricted", (o,n) => { (o as GetMailTips).DeliveryRestricted = n.GetBoolValue(); } }, - {"emailAddress", (o,n) => { (o as GetMailTips).EmailAddress = n.GetObjectValue(); } }, - {"error", (o,n) => { (o as GetMailTips).Error = n.GetObjectValue(); } }, - {"externalMemberCount", (o,n) => { (o as GetMailTips).ExternalMemberCount = n.GetIntValue(); } }, - {"isModerated", (o,n) => { (o as GetMailTips).IsModerated = n.GetBoolValue(); } }, - {"mailboxFull", (o,n) => { (o as GetMailTips).MailboxFull = n.GetBoolValue(); } }, - {"maxMessageSize", (o,n) => { (o as GetMailTips).MaxMessageSize = n.GetIntValue(); } }, - {"recipientScope", (o,n) => { (o as GetMailTips).RecipientScope = n.GetEnumValue(); } }, - {"recipientSuggestions", (o,n) => { (o as GetMailTips).RecipientSuggestions = n.GetCollectionOfObjectValues().ToList(); } }, - {"totalMemberCount", (o,n) => { (o as GetMailTips).TotalMemberCount = n.GetIntValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("automaticReplies", AutomaticReplies); - writer.WriteStringValue("customMailTip", CustomMailTip); - writer.WriteBoolValue("deliveryRestricted", DeliveryRestricted); - writer.WriteObjectValue("emailAddress", EmailAddress); - writer.WriteObjectValue("error", Error); - writer.WriteIntValue("externalMemberCount", ExternalMemberCount); - writer.WriteBoolValue("isModerated", IsModerated); - writer.WriteBoolValue("mailboxFull", MailboxFull); - writer.WriteIntValue("maxMessageSize", MaxMessageSize); - writer.WriteEnumValue("recipientScope", RecipientScope); - writer.WriteCollectionOfObjectValues("recipientSuggestions", RecipientSuggestions); - writer.WriteIntValue("totalMemberCount", TotalMemberCount); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/GetMailTips/GetMailTipsRequestBuilder.cs b/src/generated/Users/Item/GetMailTips/GetMailTipsRequestBuilder.cs index 83af595079d..1760df076b5 100644 --- a/src/generated/Users/Item/GetMailTips/GetMailTipsRequestBuilder.cs +++ b/src/generated/Users/Item/GetMailTips/GetMailTipsRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +81,5 @@ public RequestInformation CreatePostRequestInformation(GetMailTipsRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMailTips - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMailTipsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/GetManagedAppDiagnosticStatuses/GetManagedAppDiagnosticStatusesRequestBuilder.cs b/src/generated/Users/Item/GetManagedAppDiagnosticStatuses/GetManagedAppDiagnosticStatusesRequestBuilder.cs index 7592b2ae566..3f8adcf65a3 100644 --- a/src/generated/Users/Item/GetManagedAppDiagnosticStatuses/GetManagedAppDiagnosticStatusesRequestBuilder.cs +++ b/src/generated/Users/Item/GetManagedAppDiagnosticStatuses/GetManagedAppDiagnosticStatusesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +29,17 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Gets diagnostics validation status for a given user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/GetManagedAppPolicies/GetManagedAppPoliciesRequestBuilder.cs b/src/generated/Users/Item/GetManagedAppPolicies/GetManagedAppPoliciesRequestBuilder.cs index 23278b22933..4b2d077beff 100644 --- a/src/generated/Users/Item/GetManagedAppPolicies/GetManagedAppPoliciesRequestBuilder.cs +++ b/src/generated/Users/Item/GetManagedAppPolicies/GetManagedAppPoliciesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +29,17 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Gets app restrictions for a given user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs b/src/generated/Users/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs index 4b98f0612fb..838ec8d4d59 100644 --- a/src/generated/Users/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs +++ b/src/generated/Users/Item/GetMemberGroups/GetMemberGroupsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberGroupsRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberGroups - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberGroupsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs b/src/generated/Users/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs index cc6aa44315a..e74ebc1a5fe 100644 --- a/src/generated/Users/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs +++ b/src/generated/Users/Item/GetMemberObjects/GetMemberObjectsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(GetMemberObjectsRequestBo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getMemberObjects - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GetMemberObjectsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/InferenceClassification/InferenceClassificationRequestBuilder.cs b/src/generated/Users/Item/InferenceClassification/InferenceClassificationRequestBuilder.cs index 90c61053522..777577fc875 100644 --- a/src/generated/Users/Item/InferenceClassification/InferenceClassificationRequestBuilder.cs +++ b/src/generated/Users/Item/InferenceClassification/InferenceClassificationRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.InferenceClassification.Overrides; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,11 +31,10 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + command.SetHandler(async (string userId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption); return command; @@ -56,24 +55,26 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, selectOption, outputOption); return command; } public Command BuildOverridesCommand() { var command = new Command("overrides"); var builder = new ApiSdk.Users.Item.InferenceClassification.Overrides.OverridesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -93,14 +94,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + command.SetHandler(async (string userId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, bodyOption); return command; @@ -172,42 +172,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Relevance classification of the user's messages based on explicit designations which override inferred relevance or importance. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Relevance classification of the user's messages based on explicit designations which override inferred relevance or importance. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Relevance classification of the user's messages based on explicit designations which override inferred relevance or importance. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.InferenceClassification model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Relevance classification of the user's messages based on explicit designations which override inferred relevance or importance. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/InferenceClassification/Overrides/Item/InferenceClassificationOverrideRequestBuilder.cs b/src/generated/Users/Item/InferenceClassification/Overrides/Item/InferenceClassificationOverrideRequestBuilder.cs index 4773d521318..10caf0ae1d7 100644 --- a/src/generated/Users/Item/InferenceClassification/Overrides/Item/InferenceClassificationOverrideRequestBuilder.cs +++ b/src/generated/Users/Item/InferenceClassification/Overrides/Item/InferenceClassificationOverrideRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var inferenceClassificationOverrideIdOption = new Option("--inferenceclassificationoverride-id", description: "key: id of inferenceClassificationOverride") { + var inferenceClassificationOverrideIdOption = new Option("--inference-classification-override-id", description: "key: id of inferenceClassificationOverride") { }; inferenceClassificationOverrideIdOption.IsRequired = true; command.AddOption(inferenceClassificationOverrideIdOption); - command.SetHandler(async (string userId, string inferenceClassificationOverrideId) => { + command.SetHandler(async (string userId, string inferenceClassificationOverrideId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, inferenceClassificationOverrideIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var inferenceClassificationOverrideIdOption = new Option("--inferenceclassificationoverride-id", description: "key: id of inferenceClassificationOverride") { + var inferenceClassificationOverrideIdOption = new Option("--inference-classification-override-id", description: "key: id of inferenceClassificationOverride") { }; inferenceClassificationOverrideIdOption.IsRequired = true; command.AddOption(inferenceClassificationOverrideIdOption); @@ -63,19 +62,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string inferenceClassificationOverrideId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string inferenceClassificationOverrideId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, inferenceClassificationOverrideIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, inferenceClassificationOverrideIdOption, selectOption, outputOption); return command; } /// @@ -89,7 +87,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var inferenceClassificationOverrideIdOption = new Option("--inferenceclassificationoverride-id", description: "key: id of inferenceClassificationOverride") { + var inferenceClassificationOverrideIdOption = new Option("--inference-classification-override-id", description: "key: id of inferenceClassificationOverride") { }; inferenceClassificationOverrideIdOption.IsRequired = true; command.AddOption(inferenceClassificationOverrideIdOption); @@ -97,14 +95,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string inferenceClassificationOverrideId, string body) => { + command.SetHandler(async (string userId, string inferenceClassificationOverrideId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, inferenceClassificationOverrideIdOption, bodyOption); return command; @@ -176,42 +173,6 @@ public RequestInformation CreatePatchRequestInformation(InferenceClassificationO requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A set of overrides for a user to always classify messages from specific senders in certain ways: focused, or other. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A set of overrides for a user to always classify messages from specific senders in certain ways: focused, or other. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A set of overrides for a user to always classify messages from specific senders in certain ways: focused, or other. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(InferenceClassificationOverride model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A set of overrides for a user to always classify messages from specific senders in certain ways: focused, or other. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/InferenceClassification/Overrides/OverridesRequestBuilder.cs b/src/generated/Users/Item/InferenceClassification/Overrides/OverridesRequestBuilder.cs index 242ed669a66..01541a4fe06 100644 --- a/src/generated/Users/Item/InferenceClassification/Overrides/OverridesRequestBuilder.cs +++ b/src/generated/Users/Item/InferenceClassification/Overrides/OverridesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.InferenceClassification.Overrides.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class OverridesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new InferenceClassificationOverrideRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -98,7 +96,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -107,15 +109,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -170,31 +167,6 @@ public RequestInformation CreatePostRequestInformation(InferenceClassificationOv requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A set of overrides for a user to always classify messages from specific senders in certain ways: focused, or other. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A set of overrides for a user to always classify messages from specific senders in certain ways: focused, or other. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(InferenceClassificationOverride model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A set of overrides for a user to always classify messages from specific senders in certain ways: focused, or other. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Insights/InsightsRequestBuilder.cs b/src/generated/Users/Item/Insights/InsightsRequestBuilder.cs index c8f9e57f970..3a3606093d0 100644 --- a/src/generated/Users/Item/Insights/InsightsRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/InsightsRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Users.Item.Insights.Used; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,11 +33,10 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + command.SetHandler(async (string userId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption); return command; @@ -63,20 +62,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -94,14 +92,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + command.SetHandler(async (string userId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, bodyOption); return command; @@ -109,6 +106,9 @@ public Command BuildPatchCommand() { public Command BuildSharedCommand() { var command = new Command("shared"); var builder = new ApiSdk.Users.Item.Insights.Shared.SharedRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -116,6 +116,9 @@ public Command BuildSharedCommand() { public Command BuildTrendingCommand() { var command = new Command("trending"); var builder = new ApiSdk.Users.Item.Insights.Trending.TrendingRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -123,6 +126,9 @@ public Command BuildTrendingCommand() { public Command BuildUsedCommand() { var command = new Command("used"); var builder = new ApiSdk.Users.Item.Insights.Used.UsedRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -194,42 +200,6 @@ public RequestInformation CreatePatchRequestInformation(OfficeGraphInsights body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OfficeGraphInsights model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/@Ref/@Ref.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/@Ref/@Ref.cs deleted file mode 100644 index 5340b496a61..00000000000 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/@Ref/RefRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 07c123605d1..00000000000 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.@Ref { - /// Builds and executes requests for operations under \users\{user-id}\insights\shared\{sharedInsight-id}\lastSharedMethod\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Delete ref of navigation property lastSharedMethod for users - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Delete ref of navigation property lastSharedMethod for users"; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { - }; - sharedInsightIdOption.IsRequired = true; - command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userIdOption, sharedInsightIdOption); - return command; - } - /// - /// Get ref of lastSharedMethod from users - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Get ref of lastSharedMethod from users"; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { - }; - sharedInsightIdOption.IsRequired = true; - command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); - return command; - } - /// - /// Update the ref of navigation property lastSharedMethod in users - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Update the ref of navigation property lastSharedMethod in users"; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { - }; - sharedInsightIdOption.IsRequired = true; - command.AddOption(sharedInsightIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userIdOption, sharedInsightIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/shared/{sharedInsight_id}/lastSharedMethod/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Delete ref of navigation property lastSharedMethod for users - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Get ref of lastSharedMethod from users - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Update the ref of navigation property lastSharedMethod in users - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Delete ref of navigation property lastSharedMethod for users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get ref of lastSharedMethod from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the ref of navigation property lastSharedMethod in users - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs index 6e3c46138cd..73c74f92e54 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,16 +75,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs index ad988c512f1..61da7b0c763 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.CalendarSharingMessage.Accept; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/LastSharedMethodRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/LastSharedMethodRequestBuilder.cs index 875a3aebe72..bb2895ee533 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/LastSharedMethodRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/LastSharedMethodRequestBuilder.cs @@ -15,10 +15,10 @@ using ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.WorkbookRangeView; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -50,7 +50,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -64,20 +64,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sharedInsightId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildManagedAppProtectionCommand() { @@ -110,7 +109,7 @@ public Command BuildPrintJobCommand() { } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -204,18 +203,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get lastSharedMethod from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get lastSharedMethod from users public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs index 7347e2c03d1..75e526aa5ae 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.ManagedAppProtection.TargetApps; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs index 71adf5b2e9a..0170f7e4aa2 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + command.SetHandler(async (string userId, string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TargetAppsRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action targetApps - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetAppsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/MobileAppContentFile/Commit/CommitRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/MobileAppContentFile/Commit/CommitRequestBuilder.cs index 4929b523051..650ae085238 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/MobileAppContentFile/Commit/CommitRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/MobileAppContentFile/Commit/CommitRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + command.SetHandler(async (string userId, string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CommitRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Commits a file of a given app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CommitRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs index b278fe38dd6..4bb1cd5cc65 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.MobileAppContentFile.Commit; using ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.MobileAppContentFile.RenewUpload; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs index a2f6973b465..582f732a018 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + command.SetHandler(async (string userId, string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Renews the SAS URI for an application file upload. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index cbc9e15a044..f649bc0d1d4 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintDocument/PrintDocumentRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintDocument/PrintDocumentRequestBuilder.cs index 9932c6ec0db..ea20d8e85ea 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintDocument/PrintDocumentRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintDocument/PrintDocumentRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.PrintDocument.CreateUploadSession; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintJob/Abort/AbortRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintJob/Abort/AbortRequestBuilder.cs index db24d28a9ee..80badaaf5fb 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintJob/Abort/AbortRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintJob/Abort/AbortRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + command.SetHandler(async (string userId, string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AbortRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action abort - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AbortRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintJob/Cancel/CancelRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintJob/Cancel/CancelRequestBuilder.cs index 24f1aa9e2a8..037c11c7695 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintJob/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintJob/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + command.SetHandler(async (string userId, string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintJob/PrintJobRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintJob/PrintJobRequestBuilder.cs index 98d24213f42..9e2b3903a2d 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintJob/PrintJobRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintJob/PrintJobRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.PrintJob.Redirect; using ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.PrintJob.Start; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintJob/Redirect/RedirectRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintJob/Redirect/RedirectRequestBuilder.cs index 2e3fcc2c985..a7e4afc55ec 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintJob/Redirect/RedirectRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintJob/Redirect/RedirectRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(RedirectRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action redirect - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RedirectRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes printJob public class RedirectResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintJob/Start/StartRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintJob/Start/StartRequestBuilder.cs index 37c1c68d3d1..c8bf0ab7496 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintJob/Start/StartRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/PrintJob/Start/StartRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action start - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes printJobStatus public class StartResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/Ref/Ref.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/Ref/Ref.cs new file mode 100644 index 00000000000..fe7e1aac34a --- /dev/null +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/Ref/RefRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..39e74e884be --- /dev/null +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.Ref { + /// Builds and executes requests for operations under \users\{user-id}\insights\shared\{sharedInsight-id}\lastSharedMethod\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Delete ref of navigation property lastSharedMethod for users + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Delete ref of navigation property lastSharedMethod for users"; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { + }; + sharedInsightIdOption.IsRequired = true; + command.AddOption(sharedInsightIdOption); + command.SetHandler(async (string userId, string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, userIdOption, sharedInsightIdOption); + return command; + } + /// + /// Get ref of lastSharedMethod from users + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Get ref of lastSharedMethod from users"; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { + }; + sharedInsightIdOption.IsRequired = true; + command.AddOption(sharedInsightIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); + return command; + } + /// + /// Update the ref of navigation property lastSharedMethod in users + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Update the ref of navigation property lastSharedMethod in users"; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { + }; + sharedInsightIdOption.IsRequired = true; + command.AddOption(sharedInsightIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string userId, string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, userIdOption, sharedInsightIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/users/{user_id}/insights/shared/{sharedInsight_id}/lastSharedMethod/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Delete ref of navigation property lastSharedMethod for users + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Get ref of lastSharedMethod from users + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Update the ref of navigation property lastSharedMethod in users + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs index ee31ed96893..ad45db891dc 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + command.SetHandler(async (string userId, string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ApproveRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action approve - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApproveRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs index 591f12886d2..f331b13e9b0 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + command.SetHandler(async (string userId, string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs index f33438d47ab..2f2661a8a6e 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.ScheduleChangeRequest.Approve; using ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.ScheduleChangeRequest.Decline; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs index bce775f0134..e37a1b414ef 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + command.SetHandler(async (string userId, string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs index a0ac7a5d416..e65c55c292e 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + command.SetHandler(async (string userId, string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TargetAppsRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action targetApps - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetAppsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs index 063619084f8..35210454d75 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.TargetedManagedAppProtection.Assign; using ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.TargetedManagedAppProtection.TargetApps; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WindowsInformationProtection/Assign/AssignRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WindowsInformationProtection/Assign/AssignRequestBuilder.cs index 2cd0e201095..cbcf03ea862 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WindowsInformationProtection/Assign/AssignRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WindowsInformationProtection/Assign/AssignRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + command.SetHandler(async (string userId, string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs index c946003f3c5..5e6a8239706 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.WindowsInformationProtection.Assign; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs index db8e5b6f856..32f8a561ca9 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,26 +30,25 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - var anotherRangeOption = new Option("--anotherrange", description: "Usage: anotherRange={anotherRange}") { + var anotherRangeOption = new Option("--another-range", description: "Usage: anotherRange={anotherRange}") { }; anotherRangeOption.IsRequired = true; command.AddOption(anotherRangeOption); - command.SetHandler(async (string userId, string sharedInsightId, string anotherRange) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, string anotherRange, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, anotherRangeOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, anotherRangeOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function boundingRect - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class BoundingRectWithAnotherRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs index a17e4376182..16f6ffb35a0 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -42,18 +42,17 @@ public Command BuildGetCommand() { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string userId, string sharedInsightId, int? row, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, int? row, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, rowOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, rowOption, columnOption, outputOption); return command; } /// @@ -88,17 +87,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function cell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class CellWithRowWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Clear/ClearRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Clear/ClearRequestBuilder.cs index 29aa7fd8eef..08f7b059794 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Clear/ClearRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + command.SetHandler(async (string userId, string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ClearRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ClearRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs index 8548368c0d1..4dace4bf0c3 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string userId, string sharedInsightId, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, columnOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function column - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs index 9c97e1570b7..4be461230ce 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsAfter - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsAfterResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs index 3335d881af0..dd04e27430a 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string userId, string sharedInsightId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, countOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsAfter - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsAfterWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs index 681b109d7ec..5c1d2ed9490 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsBefore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsBeforeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs index 9430b9ca143..f3a6e8ee236 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string userId, string sharedInsightId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, countOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsBefore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsBeforeWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Delete/DeleteRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Delete/DeleteRequestBuilder.cs index 35e4977bcd1..23deb961ee0 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Delete/DeleteRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Delete/DeleteRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + command.SetHandler(async (string userId, string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(DeleteRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action delete - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeleteRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs index c3241832d46..b53686d5577 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function entireColumn - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class EntireColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs index 54ed0f054fe..1d988f3df15 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function entireRow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class EntireRowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Insert/InsertRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Insert/InsertRequestBuilder.cs index 0f6c17bde02..6c8a68f5e6b 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Insert/InsertRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Insert/InsertRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(InsertRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action insert - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(InsertRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class InsertResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs index a702b2c8446..1fb650bd995 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,26 +30,25 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - var anotherRangeOption = new Option("--anotherrange", description: "Usage: anotherRange={anotherRange}") { + var anotherRangeOption = new Option("--another-range", description: "Usage: anotherRange={anotherRange}") { }; anotherRangeOption.IsRequired = true; command.AddOption(anotherRangeOption); - command.SetHandler(async (string userId, string sharedInsightId, string anotherRange) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, string anotherRange, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, anotherRangeOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, anotherRangeOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function intersection - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class IntersectionWithAnotherRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/LastCell/LastCellRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/LastCell/LastCellRequestBuilder.cs index d66499e8ffe..6da0c8315ce 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/LastCell/LastCellRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/LastCell/LastCellRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function lastCell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class LastCellResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs index d0f0a7b452c..f5e32ed8175 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function lastColumn - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class LastColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/LastRow/LastRowRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/LastRow/LastRowRequestBuilder.cs index 2ea55e70415..79d3bdfeb11 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/LastRow/LastRowRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/LastRow/LastRowRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function lastRow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class LastRowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Merge/MergeRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Merge/MergeRequestBuilder.cs index e11c8f58a1b..f3013efbbda 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Merge/MergeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Merge/MergeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + command.SetHandler(async (string userId, string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(MergeRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action merge - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MergeRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs index 8f34518306e..5883c31ca4c 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,30 +30,29 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - var rowOffsetOption = new Option("--rowoffset", description: "Usage: rowOffset={rowOffset}") { + var rowOffsetOption = new Option("--row-offset", description: "Usage: rowOffset={rowOffset}") { }; rowOffsetOption.IsRequired = true; command.AddOption(rowOffsetOption); - var columnOffsetOption = new Option("--columnoffset", description: "Usage: columnOffset={columnOffset}") { + var columnOffsetOption = new Option("--column-offset", description: "Usage: columnOffset={columnOffset}") { }; columnOffsetOption.IsRequired = true; command.AddOption(columnOffsetOption); - command.SetHandler(async (string userId, string sharedInsightId, int? rowOffset, int? columnOffset) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, int? rowOffset, int? columnOffset, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, rowOffsetOption, columnOffsetOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, rowOffsetOption, columnOffsetOption, outputOption); return command; } /// @@ -88,17 +87,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function offsetRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class OffsetRangeWithRowOffsetWithColumnOffsetResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs index d2f6dfa26a2..bf81ad0fd1c 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,30 +30,29 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - var deltaRowsOption = new Option("--deltarows", description: "Usage: deltaRows={deltaRows}") { + var deltaRowsOption = new Option("--delta-rows", description: "Usage: deltaRows={deltaRows}") { }; deltaRowsOption.IsRequired = true; command.AddOption(deltaRowsOption); - var deltaColumnsOption = new Option("--deltacolumns", description: "Usage: deltaColumns={deltaColumns}") { + var deltaColumnsOption = new Option("--delta-columns", description: "Usage: deltaColumns={deltaColumns}") { }; deltaColumnsOption.IsRequired = true; command.AddOption(deltaColumnsOption); - command.SetHandler(async (string userId, string sharedInsightId, int? deltaRows, int? deltaColumns) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, int? deltaRows, int? deltaColumns, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, deltaRowsOption, deltaColumnsOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, deltaRowsOption, deltaColumnsOption, outputOption); return command; } /// @@ -88,17 +87,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function resizedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ResizedRangeWithDeltaRowsWithDeltaColumnsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs index dbf2c449f46..91c302c5c37 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; rowOption.IsRequired = true; command.AddOption(rowOption); - command.SetHandler(async (string userId, string sharedInsightId, int? row) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, int? row, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, rowOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, rowOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function row - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowWithRowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs index 2e0d964bf3c..65a39cb3bdb 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsAbove - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsAboveResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs index 97e33e981f1..68a4cfde9a3 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string userId, string sharedInsightId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, countOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsAbove - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsAboveWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs index 493b47f41f5..010dd38aaf7 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsBelow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsBelowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs index 1bae039b1e9..1f1e5f041bc 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string userId, string sharedInsightId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, countOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsBelow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsBelowWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs index 42a2afbe734..618db3f7bbe 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + command.SetHandler(async (string userId, string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action unmerge - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs index 19b6d77ce2a..7ac757acfcf 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs index ea9b59aedff..0a6545c15ae 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,26 +30,25 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - var valuesOnlyOption = new Option("--valuesonly", description: "Usage: valuesOnly={valuesOnly}") { + var valuesOnlyOption = new Option("--values-only", description: "Usage: valuesOnly={valuesOnly}") { }; valuesOnlyOption.IsRequired = true; command.AddOption(valuesOnlyOption); - command.SetHandler(async (string userId, string sharedInsightId, bool? valuesOnly) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, bool? valuesOnly, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, valuesOnlyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, valuesOnlyOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeWithValuesOnlyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs index 0d881d5f10c..aecaa366289 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function visibleView - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRangeView public class VisibleViewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/WorkbookRangeRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/WorkbookRangeRequestBuilder.cs index dafcc4705bb..aded5cfe5e4 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/WorkbookRangeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRange/WorkbookRangeRequestBuilder.cs @@ -27,10 +27,10 @@ using ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.WorkbookRange.UsedRangeWithValuesOnly; using ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.WorkbookRange.VisibleView; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFill/Clear/ClearRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFill/Clear/ClearRequestBuilder.cs index e52589df1a4..1236100e73e 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFill/Clear/ClearRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFill/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + command.SetHandler(async (string userId, string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs index 20ac5d7167e..a427bd40a0a 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.WorkbookRangeFill.Clear; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs index fb49c94bcac..1cee4632d5c 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + command.SetHandler(async (string userId, string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action autofitColumns - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs index c92597c9f2f..165c0942507 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + command.SetHandler(async (string userId, string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action autofitRows - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs index 7b61451d447..20b5269984e 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.WorkbookRangeFormat.AutofitColumns; using ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.WorkbookRangeFormat.AutofitRows; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs index a773c8ef865..cfcd854e51d 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + command.SetHandler(async (string userId, string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ApplyRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action apply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs index a01bb2fc246..d6de5d38edd 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.WorkbookRangeSort.Apply; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeView/Range/RangeRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeView/Range/RangeRequestBuilder.cs index b2fc6fa3e9c..2f50cac9d94 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeView/Range/RangeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeView/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs index edecbd773d9..968ae2dc806 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/LastSharedMethod/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Users.Item.Insights.Shared.Item.LastSharedMethod.WorkbookRangeView.Range; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/@Ref/@Ref.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/@Ref/@Ref.cs deleted file mode 100644 index 4e27b19a5a3..00000000000 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.Insights.Shared.Item.Resource.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/@Ref/RefRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/@Ref/RefRequestBuilder.cs deleted file mode 100644 index e6368befe76..00000000000 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Users.Item.Insights.Shared.Item.Resource.@Ref { - /// Builds and executes requests for operations under \users\{user-id}\insights\shared\{sharedInsight-id}\resource\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { - }; - sharedInsightIdOption.IsRequired = true; - command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userIdOption, sharedInsightIdOption); - return command; - } - /// - /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { - }; - sharedInsightIdOption.IsRequired = true; - command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); - return command; - } - /// - /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { - }; - sharedInsightIdOption.IsRequired = true; - command.AddOption(sharedInsightIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userIdOption, sharedInsightIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/shared/{sharedInsight_id}/resource/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Users.Item.Insights.Shared.Item.Resource.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Users.Item.Insights.Shared.Item.Resource.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs index 7aaf8e1b3dc..59e6ad39261 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,16 +75,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs index 21a1881a98f..0bd24b13e5a 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Users.Item.Insights.Shared.Item.Resource.CalendarSharingMessage.Accept; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs index 3617cc3f001..ea463319b38 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Users.Item.Insights.Shared.Item.Resource.ManagedAppProtection.TargetApps; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs index 6ad807171f3..4ecb74b9527 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + command.SetHandler(async (string userId, string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TargetAppsRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action targetApps - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetAppsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/MobileAppContentFile/Commit/CommitRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/MobileAppContentFile/Commit/CommitRequestBuilder.cs index 3df61f0c6af..1f7b4be46d8 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/MobileAppContentFile/Commit/CommitRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/MobileAppContentFile/Commit/CommitRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + command.SetHandler(async (string userId, string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CommitRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Commits a file of a given app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CommitRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs index 58e04713de1..6e7524c8a70 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Users.Item.Insights.Shared.Item.Resource.MobileAppContentFile.Commit; using ApiSdk.Users.Item.Insights.Shared.Item.Resource.MobileAppContentFile.RenewUpload; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs index 601e18e0c13..b23c67aa3a0 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + command.SetHandler(async (string userId, string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Renews the SAS URI for an application file upload. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index 1f999a608e8..421515f8361 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintDocument/PrintDocumentRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintDocument/PrintDocumentRequestBuilder.cs index d5e16b089c1..ec362b96a20 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintDocument/PrintDocumentRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintDocument/PrintDocumentRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Users.Item.Insights.Shared.Item.Resource.PrintDocument.CreateUploadSession; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintJob/Abort/AbortRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintJob/Abort/AbortRequestBuilder.cs index b76c0b5e5df..2d5e6a755c2 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintJob/Abort/AbortRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintJob/Abort/AbortRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + command.SetHandler(async (string userId, string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AbortRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action abort - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AbortRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintJob/Cancel/CancelRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintJob/Cancel/CancelRequestBuilder.cs index 15625a2c792..53f270a8279 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintJob/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintJob/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + command.SetHandler(async (string userId, string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintJob/PrintJobRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintJob/PrintJobRequestBuilder.cs index 3a35f3e3e7e..fd85c6102f1 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintJob/PrintJobRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintJob/PrintJobRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Insights.Shared.Item.Resource.PrintJob.Redirect; using ApiSdk.Users.Item.Insights.Shared.Item.Resource.PrintJob.Start; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintJob/Redirect/RedirectRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintJob/Redirect/RedirectRequestBuilder.cs index cc8659628a8..c10dee0b70d 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintJob/Redirect/RedirectRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintJob/Redirect/RedirectRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(RedirectRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action redirect - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RedirectRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes printJob public class RedirectResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintJob/Start/StartRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintJob/Start/StartRequestBuilder.cs index 901760934d8..011f53446e8 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintJob/Start/StartRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/PrintJob/Start/StartRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action start - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes printJobStatus public class StartResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/Ref/Ref.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/Ref/Ref.cs new file mode 100644 index 00000000000..6e470f27f25 --- /dev/null +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.Insights.Shared.Item.Resource.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/Ref/RefRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..0a5e47d5e26 --- /dev/null +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Users.Item.Insights.Shared.Item.Resource.Ref { + /// Builds and executes requests for operations under \users\{user-id}\insights\shared\{sharedInsight-id}\resource\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { + }; + sharedInsightIdOption.IsRequired = true; + command.AddOption(sharedInsightIdOption); + command.SetHandler(async (string userId, string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, userIdOption, sharedInsightIdOption); + return command; + } + /// + /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { + }; + sharedInsightIdOption.IsRequired = true; + command.AddOption(sharedInsightIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); + return command; + } + /// + /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { + }; + sharedInsightIdOption.IsRequired = true; + command.AddOption(sharedInsightIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string userId, string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, userIdOption, sharedInsightIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/users/{user_id}/insights/shared/{sharedInsight_id}/resource/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Users.Item.Insights.Shared.Item.Resource.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/ResourceRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/ResourceRequestBuilder.cs index 729df9b2402..d7839d98b6c 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/ResourceRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/ResourceRequestBuilder.cs @@ -15,10 +15,10 @@ using ApiSdk.Users.Item.Insights.Shared.Item.Resource.WorkbookRangeView; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -50,7 +50,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -64,20 +64,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sharedInsightId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildManagedAppProtectionCommand() { @@ -110,7 +109,7 @@ public Command BuildPrintJobCommand() { } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Users.Item.Insights.Shared.Item.Resource.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Users.Item.Insights.Shared.Item.Resource.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -204,18 +203,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Used for navigating to the item that was shared. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs index ce41c0378ed..00dac270dd3 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + command.SetHandler(async (string userId, string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ApproveRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action approve - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApproveRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs index b3e17d1b2fd..7d0e3bc7838 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + command.SetHandler(async (string userId, string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs index 77ff83209c9..2196c3cb305 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Users.Item.Insights.Shared.Item.Resource.ScheduleChangeRequest.Approve; using ApiSdk.Users.Item.Insights.Shared.Item.Resource.ScheduleChangeRequest.Decline; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs index fe6f4f64690..86f98edb049 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + command.SetHandler(async (string userId, string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs index 1138c9a429d..3f565cccf69 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + command.SetHandler(async (string userId, string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TargetAppsRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action targetApps - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetAppsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs index 789f53a3508..69fede619ee 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Users.Item.Insights.Shared.Item.Resource.TargetedManagedAppProtection.Assign; using ApiSdk.Users.Item.Insights.Shared.Item.Resource.TargetedManagedAppProtection.TargetApps; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WindowsInformationProtection/Assign/AssignRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WindowsInformationProtection/Assign/AssignRequestBuilder.cs index 9e1ce4c07eb..3550e974132 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WindowsInformationProtection/Assign/AssignRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WindowsInformationProtection/Assign/AssignRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + command.SetHandler(async (string userId, string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs index bb498105cf7..bb73c226e14 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Users.Item.Insights.Shared.Item.Resource.WindowsInformationProtection.Assign; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs index c19639d7936..808c3eb383b 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,26 +30,25 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - var anotherRangeOption = new Option("--anotherrange", description: "Usage: anotherRange={anotherRange}") { + var anotherRangeOption = new Option("--another-range", description: "Usage: anotherRange={anotherRange}") { }; anotherRangeOption.IsRequired = true; command.AddOption(anotherRangeOption); - command.SetHandler(async (string userId, string sharedInsightId, string anotherRange) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, string anotherRange, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, anotherRangeOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, anotherRangeOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function boundingRect - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class BoundingRectWithAnotherRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs index 6692ec2006c..be70ee8db28 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -42,18 +42,17 @@ public Command BuildGetCommand() { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string userId, string sharedInsightId, int? row, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, int? row, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, rowOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, rowOption, columnOption, outputOption); return command; } /// @@ -88,17 +87,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function cell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class CellWithRowWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/Clear/ClearRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/Clear/ClearRequestBuilder.cs index 6a7b30730bd..33d55496d1d 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/Clear/ClearRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + command.SetHandler(async (string userId, string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ClearRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ClearRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs index 1107a6e710f..1f826b0402d 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string userId, string sharedInsightId, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, columnOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function column - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs index ae9f032d463..8a793a20caa 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsAfter - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsAfterResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs index a29e1fd0a5d..5dcd664d131 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string userId, string sharedInsightId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, countOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsAfter - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsAfterWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs index 13eade25636..d495a57686c 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsBefore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsBeforeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs index d5648ec35df..158c7145881 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string userId, string sharedInsightId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, countOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsBefore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsBeforeWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/Delete/DeleteRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/Delete/DeleteRequestBuilder.cs index 586bd95a56a..a2564349b4e 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/Delete/DeleteRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/Delete/DeleteRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + command.SetHandler(async (string userId, string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(DeleteRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action delete - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeleteRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs index e103d4066ba..aa9e13fda03 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function entireColumn - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class EntireColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs index 505a088bd72..c403f5b4eb8 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function entireRow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class EntireRowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/Insert/InsertRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/Insert/InsertRequestBuilder.cs index fa2c7f53593..91141f2805a 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/Insert/InsertRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/Insert/InsertRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(InsertRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action insert - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(InsertRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class InsertResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs index 4229d97f028..439a6f8f05a 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,26 +30,25 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - var anotherRangeOption = new Option("--anotherrange", description: "Usage: anotherRange={anotherRange}") { + var anotherRangeOption = new Option("--another-range", description: "Usage: anotherRange={anotherRange}") { }; anotherRangeOption.IsRequired = true; command.AddOption(anotherRangeOption); - command.SetHandler(async (string userId, string sharedInsightId, string anotherRange) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, string anotherRange, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, anotherRangeOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, anotherRangeOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function intersection - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class IntersectionWithAnotherRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/LastCell/LastCellRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/LastCell/LastCellRequestBuilder.cs index 2f250855d63..01df0d5c760 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/LastCell/LastCellRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/LastCell/LastCellRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function lastCell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class LastCellResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs index 452f184ffbc..3769fba22a4 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function lastColumn - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class LastColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/LastRow/LastRowRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/LastRow/LastRowRequestBuilder.cs index b781f300563..d086a14f108 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/LastRow/LastRowRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/LastRow/LastRowRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function lastRow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class LastRowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/Merge/MergeRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/Merge/MergeRequestBuilder.cs index 5bbf6771c65..326154c11b6 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/Merge/MergeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/Merge/MergeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + command.SetHandler(async (string userId, string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(MergeRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action merge - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MergeRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs index 2f911dcd458..94894b2882f 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,30 +30,29 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - var rowOffsetOption = new Option("--rowoffset", description: "Usage: rowOffset={rowOffset}") { + var rowOffsetOption = new Option("--row-offset", description: "Usage: rowOffset={rowOffset}") { }; rowOffsetOption.IsRequired = true; command.AddOption(rowOffsetOption); - var columnOffsetOption = new Option("--columnoffset", description: "Usage: columnOffset={columnOffset}") { + var columnOffsetOption = new Option("--column-offset", description: "Usage: columnOffset={columnOffset}") { }; columnOffsetOption.IsRequired = true; command.AddOption(columnOffsetOption); - command.SetHandler(async (string userId, string sharedInsightId, int? rowOffset, int? columnOffset) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, int? rowOffset, int? columnOffset, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, rowOffsetOption, columnOffsetOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, rowOffsetOption, columnOffsetOption, outputOption); return command; } /// @@ -88,17 +87,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function offsetRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class OffsetRangeWithRowOffsetWithColumnOffsetResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs index 0c1bfc063f9..8ec74d2e20b 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,30 +30,29 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - var deltaRowsOption = new Option("--deltarows", description: "Usage: deltaRows={deltaRows}") { + var deltaRowsOption = new Option("--delta-rows", description: "Usage: deltaRows={deltaRows}") { }; deltaRowsOption.IsRequired = true; command.AddOption(deltaRowsOption); - var deltaColumnsOption = new Option("--deltacolumns", description: "Usage: deltaColumns={deltaColumns}") { + var deltaColumnsOption = new Option("--delta-columns", description: "Usage: deltaColumns={deltaColumns}") { }; deltaColumnsOption.IsRequired = true; command.AddOption(deltaColumnsOption); - command.SetHandler(async (string userId, string sharedInsightId, int? deltaRows, int? deltaColumns) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, int? deltaRows, int? deltaColumns, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, deltaRowsOption, deltaColumnsOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, deltaRowsOption, deltaColumnsOption, outputOption); return command; } /// @@ -88,17 +87,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function resizedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ResizedRangeWithDeltaRowsWithDeltaColumnsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs index 3984b756715..8718a7407c5 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; rowOption.IsRequired = true; command.AddOption(rowOption); - command.SetHandler(async (string userId, string sharedInsightId, int? row) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, int? row, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, rowOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, rowOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function row - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowWithRowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs index 5ddea99fb19..3274e51a57c 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsAbove - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsAboveResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs index 1f80b541899..955085d4c40 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string userId, string sharedInsightId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, countOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsAbove - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsAboveWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs index 42fb29956b1..38a97183ce3 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsBelow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsBelowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs index 6c2e046f33d..228852c777e 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string userId, string sharedInsightId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, countOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsBelow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsBelowWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs index 3ecaaca6657..e5f2184ee19 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + command.SetHandler(async (string userId, string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action unmerge - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs index 95c85811c15..7be11e07282 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs index acc4dbf83c2..1afcc206e35 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,26 +30,25 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - var valuesOnlyOption = new Option("--valuesonly", description: "Usage: valuesOnly={valuesOnly}") { + var valuesOnlyOption = new Option("--values-only", description: "Usage: valuesOnly={valuesOnly}") { }; valuesOnlyOption.IsRequired = true; command.AddOption(valuesOnlyOption); - command.SetHandler(async (string userId, string sharedInsightId, bool? valuesOnly) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, bool? valuesOnly, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, valuesOnlyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, valuesOnlyOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeWithValuesOnlyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs index 7753b28609a..792a28be70c 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function visibleView - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRangeView public class VisibleViewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/WorkbookRangeRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/WorkbookRangeRequestBuilder.cs index 7be8da11a0c..5f6e016ed83 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/WorkbookRangeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRange/WorkbookRangeRequestBuilder.cs @@ -27,10 +27,10 @@ using ApiSdk.Users.Item.Insights.Shared.Item.Resource.WorkbookRange.UsedRangeWithValuesOnly; using ApiSdk.Users.Item.Insights.Shared.Item.Resource.WorkbookRange.VisibleView; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeFill/Clear/ClearRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeFill/Clear/ClearRequestBuilder.cs index e39059b00a0..8d0f438aaa3 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeFill/Clear/ClearRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeFill/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + command.SetHandler(async (string userId, string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs index a2d80b770d4..5f9edf7173b 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Users.Item.Insights.Shared.Item.Resource.WorkbookRangeFill.Clear; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs index ceadd313a73..fd48f951876 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + command.SetHandler(async (string userId, string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action autofitColumns - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs index d22dbcf5784..3ce5be71ae3 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + command.SetHandler(async (string userId, string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action autofitRows - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs index fccf9d7c037..21fb6d0e197 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Users.Item.Insights.Shared.Item.Resource.WorkbookRangeFormat.AutofitColumns; using ApiSdk.Users.Item.Insights.Shared.Item.Resource.WorkbookRangeFormat.AutofitRows; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs index dbf14dae342..52d4005ac9d 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + command.SetHandler(async (string userId, string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ApplyRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action apply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs index 5aa8dc2a948..2e2a5a434eb 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Users.Item.Insights.Shared.Item.Resource.WorkbookRangeSort.Apply; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeView/Range/RangeRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeView/Range/RangeRequestBuilder.cs index 68fbf3f8fef..130d3dcf67e 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeView/Range/RangeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeView/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs index 33c5e033ce7..74edcc4449d 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/Resource/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Users.Item.Insights.Shared.Item.Resource.WorkbookRangeView.Range; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Shared/Item/SharedInsightRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/Item/SharedInsightRequestBuilder.cs index d2d1f0f825d..64e07e7d53c 100644 --- a/src/generated/Users/Item/Insights/Shared/Item/SharedInsightRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/Item/SharedInsightRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Insights.Shared.Item.Resource; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -32,15 +32,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); - command.SetHandler(async (string userId, string sharedInsightId) => { + command.SetHandler(async (string userId, string sharedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption); return command; @@ -56,7 +55,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -70,20 +69,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sharedInsightId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sharedInsightId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sharedInsightIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sharedInsightIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLastSharedMethodCommand() { @@ -117,7 +115,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sharedInsightIdOption = new Option("--sharedinsight-id", description: "key: id of sharedInsight") { + var sharedInsightIdOption = new Option("--shared-insight-id", description: "key: id of sharedInsight") { }; sharedInsightIdOption.IsRequired = true; command.AddOption(sharedInsightIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sharedInsightId, string body) => { + command.SetHandler(async (string userId, string sharedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sharedInsightIdOption, bodyOption); return command; @@ -224,42 +221,6 @@ public RequestInformation CreatePatchRequestInformation(SharedInsight body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SharedInsight model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Access this property from the derived type itemInsights. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Insights/Shared/SharedRequestBuilder.cs b/src/generated/Users/Item/Insights/Shared/SharedRequestBuilder.cs index efc3cf6b011..f7d2f649195 100644 --- a/src/generated/Users/Item/Insights/Shared/SharedRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Shared/SharedRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Insights.Shared.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SharedRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SharedInsightRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildLastSharedMethodCommand(), - builder.BuildPatchCommand(), - builder.BuildResourceCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildLastSharedMethodCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildResourceCommand()); return commands; } /// @@ -46,21 +45,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -109,7 +107,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -120,15 +122,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -183,31 +180,6 @@ public RequestInformation CreatePostRequestInformation(SharedInsight body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SharedInsight model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Access this property from the derived type itemInsights. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/@Ref/@Ref.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/@Ref/@Ref.cs deleted file mode 100644 index 3055387250d..00000000000 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/@Ref/RefRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 7d64e0d8346..00000000000 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.@Ref { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Used for navigating to the trending document. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Used for navigating to the trending document."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { - }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string userId, string trendingId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userIdOption, trendingIdOption); - return command; - } - /// - /// Used for navigating to the trending document. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Used for navigating to the trending document."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { - }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string userId, string trendingId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption); - return command; - } - /// - /// Used for navigating to the trending document. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Used for navigating to the trending document."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { - }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string userId, string trendingId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userIdOption, trendingIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Used for navigating to the trending document. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Used for navigating to the trending document. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Used for navigating to the trending document. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Users.Item.Insights.Trending.Item.Resource.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Used for navigating to the trending document. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used for navigating to the trending document. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used for navigating to the trending document. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Users.Item.Insights.Trending.Item.Resource.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs index d5b93866c11..a10cf25d8f1 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.CalendarSharingMessage.Accept { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.calendarSharingMessage\microsoft.graph.accept + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.calendarSharingMessage\microsoft.graph.accept public class AcceptRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,22 +30,21 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string userId, string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, outputOption); return command; } /// @@ -56,7 +55,7 @@ public Command BuildPostCommand() { public AcceptRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.calendarSharingMessage/microsoft.graph.accept"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.calendarSharingMessage/microsoft.graph.accept"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -76,16 +75,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs index 88d7ca92a47..85bf3e483dd 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs @@ -1,15 +1,15 @@ using ApiSdk.Users.Item.Insights.Trending.Item.Resource.CalendarSharingMessage.Accept; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.CalendarSharingMessage { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.calendarSharingMessage + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.calendarSharingMessage public class CalendarSharingMessageRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -31,7 +31,7 @@ public Command BuildAcceptCommand() { public CalendarSharingMessageRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.calendarSharingMessage"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.calendarSharingMessage"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs index fb27a096b34..275abfb0493 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs @@ -1,15 +1,15 @@ using ApiSdk.Users.Item.Insights.Trending.Item.Resource.ManagedAppProtection.TargetApps; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.ManagedAppProtection { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.managedAppProtection + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.managedAppProtection public class ManagedAppProtectionRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -31,7 +31,7 @@ public Command BuildTargetAppsCommand() { public ManagedAppProtectionRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.managedAppProtection"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.managedAppProtection"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs index 7cf51c7cfd2..698f580ad3b 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.ManagedAppProtection.TargetApps { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.managedAppProtection\microsoft.graph.targetApps + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.managedAppProtection\microsoft.graph.targetApps public class TargetAppsRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -29,24 +29,23 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string trendingId, string body) => { + command.SetHandler(async (string userId, string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, userIdOption, trendingIdOption, bodyOption); + }, userIdOption, trendingItemIdOption, bodyOption); return command; } /// @@ -57,7 +56,7 @@ public Command BuildPostCommand() { public TargetAppsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.managedAppProtection/microsoft.graph.targetApps"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.managedAppProtection/microsoft.graph.targetApps"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TargetAppsRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action targetApps - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetAppsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/MobileAppContentFile/Commit/CommitRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/MobileAppContentFile/Commit/CommitRequestBuilder.cs index 1d5bdcf5170..991da48d88f 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/MobileAppContentFile/Commit/CommitRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/MobileAppContentFile/Commit/CommitRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.MobileAppContentFile.Commit { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.mobileAppContentFile\microsoft.graph.commit + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.mobileAppContentFile\microsoft.graph.commit public class CommitRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -29,24 +29,23 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string trendingId, string body) => { + command.SetHandler(async (string userId, string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, userIdOption, trendingIdOption, bodyOption); + }, userIdOption, trendingItemIdOption, bodyOption); return command; } /// @@ -57,7 +56,7 @@ public Command BuildPostCommand() { public CommitRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.mobileAppContentFile/microsoft.graph.commit"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.mobileAppContentFile/microsoft.graph.commit"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CommitRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Commits a file of a given app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CommitRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs index e926b2496f0..f1375b62c4e 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs @@ -1,16 +1,16 @@ using ApiSdk.Users.Item.Insights.Trending.Item.Resource.MobileAppContentFile.Commit; using ApiSdk.Users.Item.Insights.Trending.Item.Resource.MobileAppContentFile.RenewUpload; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.MobileAppContentFile { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.mobileAppContentFile + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.mobileAppContentFile public class MobileAppContentFileRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -38,7 +38,7 @@ public Command BuildRenewUploadCommand() { public MobileAppContentFileRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.mobileAppContentFile"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.mobileAppContentFile"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs index 3e5b0ec849c..0330d8504b8 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.MobileAppContentFile.RenewUpload { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.mobileAppContentFile\microsoft.graph.renewUpload + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.mobileAppContentFile\microsoft.graph.renewUpload public class RenewUploadRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -29,17 +29,16 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string userId, string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + command.SetHandler(async (string userId, string trendingItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, userIdOption, trendingIdOption); + }, userIdOption, trendingItemIdOption); return command; } /// @@ -50,7 +49,7 @@ public Command BuildPostCommand() { public RenewUploadRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.mobileAppContentFile/microsoft.graph.renewUpload"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.mobileAppContentFile/microsoft.graph.renewUpload"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Renews the SAS URI for an application file upload. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index b89ae0a10c6..5d0cb44d362 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.PrintDocument.CreateUploadSession { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.printDocument\microsoft.graph.createUploadSession + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.printDocument\microsoft.graph.createUploadSession public class CreateUploadSessionRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,29 +30,28 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string trendingId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, bodyOption, outputOption); return command; } /// @@ -63,7 +62,7 @@ public Command BuildPostCommand() { public CreateUploadSessionRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.printDocument/microsoft.graph.createUploadSession"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.printDocument/microsoft.graph.createUploadSession"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintDocument/PrintDocumentRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintDocument/PrintDocumentRequestBuilder.cs index 53ed3d9c237..a2ea1384e93 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintDocument/PrintDocumentRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintDocument/PrintDocumentRequestBuilder.cs @@ -1,15 +1,15 @@ using ApiSdk.Users.Item.Insights.Trending.Item.Resource.PrintDocument.CreateUploadSession; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.PrintDocument { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.printDocument + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.printDocument public class PrintDocumentRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -31,7 +31,7 @@ public Command BuildCreateUploadSessionCommand() { public PrintDocumentRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.printDocument"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.printDocument"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintJob/Abort/AbortRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintJob/Abort/AbortRequestBuilder.cs index 484b33dca3f..90960d1fa31 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintJob/Abort/AbortRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintJob/Abort/AbortRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.PrintJob.Abort { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.printJob\microsoft.graph.abort + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.printJob\microsoft.graph.abort public class AbortRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -29,24 +29,23 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string trendingId, string body) => { + command.SetHandler(async (string userId, string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, userIdOption, trendingIdOption, bodyOption); + }, userIdOption, trendingItemIdOption, bodyOption); return command; } /// @@ -57,7 +56,7 @@ public Command BuildPostCommand() { public AbortRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.printJob/microsoft.graph.abort"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.printJob/microsoft.graph.abort"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AbortRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action abort - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AbortRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintJob/Cancel/CancelRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintJob/Cancel/CancelRequestBuilder.cs index de0663dda90..f448d504b35 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintJob/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintJob/Cancel/CancelRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.PrintJob.Cancel { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.printJob\microsoft.graph.cancel + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.printJob\microsoft.graph.cancel public class CancelRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -29,17 +29,16 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string userId, string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + command.SetHandler(async (string userId, string trendingItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, userIdOption, trendingIdOption); + }, userIdOption, trendingItemIdOption); return command; } /// @@ -50,7 +49,7 @@ public Command BuildPostCommand() { public CancelRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.printJob/microsoft.graph.cancel"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.printJob/microsoft.graph.cancel"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintJob/PrintJobRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintJob/PrintJobRequestBuilder.cs index 84c92542573..f94b5492d17 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintJob/PrintJobRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintJob/PrintJobRequestBuilder.cs @@ -3,16 +3,16 @@ using ApiSdk.Users.Item.Insights.Trending.Item.Resource.PrintJob.Redirect; using ApiSdk.Users.Item.Insights.Trending.Item.Resource.PrintJob.Start; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.PrintJob { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.printJob + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.printJob public class PrintJobRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -52,7 +52,7 @@ public Command BuildStartCommand() { public PrintJobRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.printJob"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.printJob"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintJob/Redirect/RedirectRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintJob/Redirect/RedirectRequestBuilder.cs index 771d74aeb7f..cadeab5aa55 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintJob/Redirect/RedirectRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintJob/Redirect/RedirectRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.PrintJob.Redirect { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.printJob\microsoft.graph.redirect + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.printJob\microsoft.graph.redirect public class RedirectRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,29 +30,28 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string trendingId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, bodyOption, outputOption); return command; } /// @@ -63,7 +62,7 @@ public Command BuildPostCommand() { public RedirectRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.printJob/microsoft.graph.redirect"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.printJob/microsoft.graph.redirect"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(RedirectRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action redirect - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RedirectRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes printJob public class RedirectResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintJob/Start/StartRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintJob/Start/StartRequestBuilder.cs index 48796b62add..dbc6012c828 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintJob/Start/StartRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/PrintJob/Start/StartRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.PrintJob.Start { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.printJob\microsoft.graph.start + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.printJob\microsoft.graph.start public class StartRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,22 +30,21 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string userId, string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, outputOption); return command; } /// @@ -56,7 +55,7 @@ public Command BuildPostCommand() { public StartRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.printJob/microsoft.graph.start"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.printJob/microsoft.graph.start"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -76,17 +75,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action start - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes printJobStatus public class StartResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/Ref/Ref.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/Ref/Ref.cs new file mode 100644 index 00000000000..27993b949a4 --- /dev/null +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/Ref/RefRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..15f248a99cb --- /dev/null +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.Ref { + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Used for navigating to the trending document. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Used for navigating to the trending document."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { + }; + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + command.SetHandler(async (string userId, string trendingItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, userIdOption, trendingItemIdOption); + return command; + } + /// + /// Used for navigating to the trending document. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Used for navigating to the trending document."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { + }; + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, outputOption); + return command; + } + /// + /// Used for navigating to the trending document. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Used for navigating to the trending document."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { + }; + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string userId, string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, userIdOption, trendingItemIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Used for navigating to the trending document. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Used for navigating to the trending document. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Used for navigating to the trending document. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Users.Item.Insights.Trending.Item.Resource.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/ResourceRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/ResourceRequestBuilder.cs index 9ce168e4937..7031e1e474b 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/ResourceRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/ResourceRequestBuilder.cs @@ -15,17 +15,17 @@ using ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRangeView; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource public class ResourceRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -50,10 +50,10 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var selectOption = new Option("--select", description: "Select properties to be returned") { Arity = ArgumentArity.ZeroOrMore }; @@ -64,20 +64,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string trendingId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildManagedAppProtectionCommand() { @@ -110,7 +109,7 @@ public Command BuildPrintJobCommand() { } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Users.Item.Insights.Trending.Item.Resource.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Users.Item.Insights.Trending.Item.Resource.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -178,7 +177,7 @@ public Command BuildWorkbookRangeViewCommand() { public ResourceRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource{?select,expand}"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource{?select,expand}"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -204,18 +203,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Used for navigating to the trending document. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Used for navigating to the trending document. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs index 29dfc662f68..b767e788251 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.ScheduleChangeRequest.Approve { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.scheduleChangeRequest\microsoft.graph.approve + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.scheduleChangeRequest\microsoft.graph.approve public class ApproveRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -29,24 +29,23 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string trendingId, string body) => { + command.SetHandler(async (string userId, string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, userIdOption, trendingIdOption, bodyOption); + }, userIdOption, trendingItemIdOption, bodyOption); return command; } /// @@ -57,7 +56,7 @@ public Command BuildPostCommand() { public ApproveRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.scheduleChangeRequest/microsoft.graph.approve"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.scheduleChangeRequest/microsoft.graph.approve"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ApproveRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action approve - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApproveRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs index 46ffd84615c..910b6c363df 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.ScheduleChangeRequest.Decline { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.scheduleChangeRequest\microsoft.graph.decline + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.scheduleChangeRequest\microsoft.graph.decline public class DeclineRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -29,24 +29,23 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string trendingId, string body) => { + command.SetHandler(async (string userId, string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, userIdOption, trendingIdOption, bodyOption); + }, userIdOption, trendingItemIdOption, bodyOption); return command; } /// @@ -57,7 +56,7 @@ public Command BuildPostCommand() { public DeclineRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.scheduleChangeRequest/microsoft.graph.decline"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.scheduleChangeRequest/microsoft.graph.decline"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs index 796a87e8d19..c0872cdaa30 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs @@ -1,16 +1,16 @@ using ApiSdk.Users.Item.Insights.Trending.Item.Resource.ScheduleChangeRequest.Approve; using ApiSdk.Users.Item.Insights.Trending.Item.Resource.ScheduleChangeRequest.Decline; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.ScheduleChangeRequest { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.scheduleChangeRequest + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.scheduleChangeRequest public class ScheduleChangeRequestRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -38,7 +38,7 @@ public Command BuildDeclineCommand() { public ScheduleChangeRequestRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.scheduleChangeRequest"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.scheduleChangeRequest"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs index 7fdf603b3e6..57a6f26f35a 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.TargetedManagedAppProtection.Assign { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.targetedManagedAppProtection\microsoft.graph.assign + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.targetedManagedAppProtection\microsoft.graph.assign public class AssignRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -29,24 +29,23 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string trendingId, string body) => { + command.SetHandler(async (string userId, string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, userIdOption, trendingIdOption, bodyOption); + }, userIdOption, trendingItemIdOption, bodyOption); return command; } /// @@ -57,7 +56,7 @@ public Command BuildPostCommand() { public AssignRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.targetedManagedAppProtection/microsoft.graph.assign"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.targetedManagedAppProtection/microsoft.graph.assign"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs index c095a007189..8e172b30762 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.TargetedManagedAppProtection.TargetApps { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.targetedManagedAppProtection\microsoft.graph.targetApps + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.targetedManagedAppProtection\microsoft.graph.targetApps public class TargetAppsRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -29,24 +29,23 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string trendingId, string body) => { + command.SetHandler(async (string userId, string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, userIdOption, trendingIdOption, bodyOption); + }, userIdOption, trendingItemIdOption, bodyOption); return command; } /// @@ -57,7 +56,7 @@ public Command BuildPostCommand() { public TargetAppsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.targetedManagedAppProtection/microsoft.graph.targetApps"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.targetedManagedAppProtection/microsoft.graph.targetApps"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TargetAppsRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action targetApps - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetAppsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs index cdd5c76d104..6268d7e89de 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs @@ -1,16 +1,16 @@ using ApiSdk.Users.Item.Insights.Trending.Item.Resource.TargetedManagedAppProtection.Assign; using ApiSdk.Users.Item.Insights.Trending.Item.Resource.TargetedManagedAppProtection.TargetApps; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.TargetedManagedAppProtection { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.targetedManagedAppProtection + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.targetedManagedAppProtection public class TargetedManagedAppProtectionRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -38,7 +38,7 @@ public Command BuildTargetAppsCommand() { public TargetedManagedAppProtectionRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.targetedManagedAppProtection"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.targetedManagedAppProtection"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WindowsInformationProtection/Assign/AssignRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WindowsInformationProtection/Assign/AssignRequestBuilder.cs index 2c6286cd1b0..a6a20ae7857 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WindowsInformationProtection/Assign/AssignRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WindowsInformationProtection/Assign/AssignRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WindowsInformationProtection.Assign { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.windowsInformationProtection\microsoft.graph.assign + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.windowsInformationProtection\microsoft.graph.assign public class AssignRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -29,24 +29,23 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string trendingId, string body) => { + command.SetHandler(async (string userId, string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, userIdOption, trendingIdOption, bodyOption); + }, userIdOption, trendingItemIdOption, bodyOption); return command; } /// @@ -57,7 +56,7 @@ public Command BuildPostCommand() { public AssignRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.windowsInformationProtection/microsoft.graph.assign"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.windowsInformationProtection/microsoft.graph.assign"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs index 97a3260a185..d03232f2024 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs @@ -1,15 +1,15 @@ using ApiSdk.Users.Item.Insights.Trending.Item.Resource.WindowsInformationProtection.Assign; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WindowsInformationProtection { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.windowsInformationProtection + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.windowsInformationProtection public class WindowsInformationProtectionRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -31,7 +31,7 @@ public Command BuildAssignCommand() { public WindowsInformationProtectionRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.windowsInformationProtection"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.windowsInformationProtection"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs index 73430a29e9c..50858dd7468 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.BoundingRectWithAnotherRange { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.boundingRect(anotherRange='{anotherRange}') + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.boundingRect(anotherRange='{anotherRange}') public class BoundingRectWithAnotherRangeRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,26 +30,25 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - var anotherRangeOption = new Option("--anotherrange", description: "Usage: anotherRange={anotherRange}") { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var anotherRangeOption = new Option("--another-range", description: "Usage: anotherRange={anotherRange}") { }; anotherRangeOption.IsRequired = true; command.AddOption(anotherRangeOption); - command.SetHandler(async (string userId, string trendingId, string anotherRange) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, string anotherRange, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption, anotherRangeOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, anotherRangeOption, outputOption); return command; } /// @@ -61,7 +60,7 @@ public Command BuildGetCommand() { public BoundingRectWithAnotherRangeRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, string anotherRange = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.boundingRect(anotherRange='{anotherRange}')"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.boundingRect(anotherRange='{anotherRange}')"; var urlTplParams = new Dictionary(pathParameters); urlTplParams.Add("anotherRange", anotherRange); PathParameters = urlTplParams; @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function boundingRect - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class BoundingRectWithAnotherRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs index 29c4a9f45e4..3835f24c1f7 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.CellWithRowWithColumn { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.cell(row={row},column={column}) + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.cell(row={row},column={column}) public class CellWithRowWithColumnRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,10 +30,10 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var rowOption = new Option("--row", description: "Usage: row={row}") { }; rowOption.IsRequired = true; @@ -42,18 +42,17 @@ public Command BuildGetCommand() { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string userId, string trendingId, int? row, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, int? row, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption, rowOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, rowOption, columnOption, outputOption); return command; } /// @@ -66,7 +65,7 @@ public Command BuildGetCommand() { public CellWithRowWithColumnRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, int? row = default, int? column = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.cell(row={row},column={column})"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.cell(row={row},column={column})"; var urlTplParams = new Dictionary(pathParameters); urlTplParams.Add("row", row); urlTplParams.Add("column", column); @@ -88,17 +87,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function cell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class CellWithRowWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/Clear/ClearRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/Clear/ClearRequestBuilder.cs index 73a0700bf5b..f71a51b4b91 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/Clear/ClearRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/Clear/ClearRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.Clear { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.clear + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.clear public class ClearRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -29,24 +29,23 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string trendingId, string body) => { + command.SetHandler(async (string userId, string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, userIdOption, trendingIdOption, bodyOption); + }, userIdOption, trendingItemIdOption, bodyOption); return command; } /// @@ -57,7 +56,7 @@ public Command BuildPostCommand() { public ClearRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.clear"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.clear"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ClearRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ClearRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs index 84dedf3315b..382e3571e1b 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.ColumnWithColumn { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.column(column={column}) + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.column(column={column}) public class ColumnWithColumnRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,26 +30,25 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var columnOption = new Option("--column", description: "Usage: column={column}") { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string userId, string trendingId, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, columnOption, outputOption); return command; } /// @@ -61,7 +60,7 @@ public Command BuildGetCommand() { public ColumnWithColumnRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, int? column = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.column(column={column})"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.column(column={column})"; var urlTplParams = new Dictionary(pathParameters); urlTplParams.Add("column", column); PathParameters = urlTplParams; @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function column - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs index 9b2c5d37cfc..0e50dde0df3 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.ColumnsAfter { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsAfter() + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsAfter() public class ColumnsAfterRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string userId, string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, outputOption); return command; } /// @@ -56,7 +55,7 @@ public Command BuildGetCommand() { public ColumnsAfterRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.columnsAfter()"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.columnsAfter()"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsAfter - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsAfterResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs index f515a45a1a2..ce9c02b98c2 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.ColumnsAfterWithCount { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsAfter(count={count}) + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsAfter(count={count}) public class ColumnsAfterWithCountRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,26 +30,25 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var countOption = new Option("--count", description: "Usage: count={count}") { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string userId, string trendingId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, countOption, outputOption); return command; } /// @@ -61,7 +60,7 @@ public Command BuildGetCommand() { public ColumnsAfterWithCountRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, int? count = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.columnsAfter(count={count})"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.columnsAfter(count={count})"; var urlTplParams = new Dictionary(pathParameters); urlTplParams.Add("count", count); PathParameters = urlTplParams; @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsAfter - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsAfterWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs index 09be4dbab49..5877edbd4e8 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.ColumnsBefore { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsBefore() + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsBefore() public class ColumnsBeforeRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string userId, string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, outputOption); return command; } /// @@ -56,7 +55,7 @@ public Command BuildGetCommand() { public ColumnsBeforeRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.columnsBefore()"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.columnsBefore()"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsBefore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsBeforeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs index 39b430219cc..663386314be 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.ColumnsBeforeWithCount { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsBefore(count={count}) + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsBefore(count={count}) public class ColumnsBeforeWithCountRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,26 +30,25 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var countOption = new Option("--count", description: "Usage: count={count}") { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string userId, string trendingId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, countOption, outputOption); return command; } /// @@ -61,7 +60,7 @@ public Command BuildGetCommand() { public ColumnsBeforeWithCountRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, int? count = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.columnsBefore(count={count})"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.columnsBefore(count={count})"; var urlTplParams = new Dictionary(pathParameters); urlTplParams.Add("count", count); PathParameters = urlTplParams; @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsBefore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsBeforeWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/Delete/DeleteRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/Delete/DeleteRequestBuilder.cs index 8278417dfe8..e2beefe7a51 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/Delete/DeleteRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/Delete/DeleteRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.Delete { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.delete + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.delete public class DeleteRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -29,24 +29,23 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string trendingId, string body) => { + command.SetHandler(async (string userId, string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, userIdOption, trendingIdOption, bodyOption); + }, userIdOption, trendingItemIdOption, bodyOption); return command; } /// @@ -57,7 +56,7 @@ public Command BuildPostCommand() { public DeleteRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.delete"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.delete"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(DeleteRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action delete - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeleteRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs index ee8d20afda6..fadff437b6a 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.EntireColumn { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.entireColumn() + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.entireColumn() public class EntireColumnRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string userId, string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, outputOption); return command; } /// @@ -56,7 +55,7 @@ public Command BuildGetCommand() { public EntireColumnRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.entireColumn()"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.entireColumn()"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function entireColumn - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class EntireColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs index 846b1b443cc..fb66f991c3a 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.EntireRow { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.entireRow() + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.entireRow() public class EntireRowRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string userId, string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, outputOption); return command; } /// @@ -56,7 +55,7 @@ public Command BuildGetCommand() { public EntireRowRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.entireRow()"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.entireRow()"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function entireRow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class EntireRowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/Insert/InsertRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/Insert/InsertRequestBuilder.cs index 0329ef4c0fc..1f970ef4c5f 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/Insert/InsertRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/Insert/InsertRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.Insert { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.insert + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.insert public class InsertRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,29 +30,28 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string trendingId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, bodyOption, outputOption); return command; } /// @@ -63,7 +62,7 @@ public Command BuildPostCommand() { public InsertRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.insert"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.insert"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(InsertRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action insert - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(InsertRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class InsertResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs index 7321440926c..1ade61ffbe3 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.IntersectionWithAnotherRange { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.intersection(anotherRange='{anotherRange}') + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.intersection(anotherRange='{anotherRange}') public class IntersectionWithAnotherRangeRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,26 +30,25 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - var anotherRangeOption = new Option("--anotherrange", description: "Usage: anotherRange={anotherRange}") { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var anotherRangeOption = new Option("--another-range", description: "Usage: anotherRange={anotherRange}") { }; anotherRangeOption.IsRequired = true; command.AddOption(anotherRangeOption); - command.SetHandler(async (string userId, string trendingId, string anotherRange) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, string anotherRange, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption, anotherRangeOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, anotherRangeOption, outputOption); return command; } /// @@ -61,7 +60,7 @@ public Command BuildGetCommand() { public IntersectionWithAnotherRangeRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, string anotherRange = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.intersection(anotherRange='{anotherRange}')"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.intersection(anotherRange='{anotherRange}')"; var urlTplParams = new Dictionary(pathParameters); urlTplParams.Add("anotherRange", anotherRange); PathParameters = urlTplParams; @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function intersection - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class IntersectionWithAnotherRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/LastCell/LastCellRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/LastCell/LastCellRequestBuilder.cs index 981436a21ba..9d3b20447b3 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/LastCell/LastCellRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/LastCell/LastCellRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.LastCell { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.lastCell() + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.lastCell() public class LastCellRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string userId, string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, outputOption); return command; } /// @@ -56,7 +55,7 @@ public Command BuildGetCommand() { public LastCellRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.lastCell()"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.lastCell()"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function lastCell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class LastCellResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs index 3ced9db252d..bd4f70a391c 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.LastColumn { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.lastColumn() + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.lastColumn() public class LastColumnRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string userId, string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, outputOption); return command; } /// @@ -56,7 +55,7 @@ public Command BuildGetCommand() { public LastColumnRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.lastColumn()"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.lastColumn()"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function lastColumn - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class LastColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/LastRow/LastRowRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/LastRow/LastRowRequestBuilder.cs index 3d2f0c8c1b9..39669f89c2a 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/LastRow/LastRowRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/LastRow/LastRowRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.LastRow { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.lastRow() + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.lastRow() public class LastRowRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string userId, string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, outputOption); return command; } /// @@ -56,7 +55,7 @@ public Command BuildGetCommand() { public LastRowRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.lastRow()"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.lastRow()"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function lastRow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class LastRowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/Merge/MergeRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/Merge/MergeRequestBuilder.cs index 37b2b3c743d..e0715a26a59 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/Merge/MergeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/Merge/MergeRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.Merge { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.merge + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.merge public class MergeRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -29,24 +29,23 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string trendingId, string body) => { + command.SetHandler(async (string userId, string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, userIdOption, trendingIdOption, bodyOption); + }, userIdOption, trendingItemIdOption, bodyOption); return command; } /// @@ -57,7 +56,7 @@ public Command BuildPostCommand() { public MergeRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.merge"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.merge"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(MergeRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action merge - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MergeRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs index 0de5f4b0592..546636c2222 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.OffsetRangeWithRowOffsetWithColumnOffset { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.offsetRange(rowOffset={rowOffset},columnOffset={columnOffset}) + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.offsetRange(rowOffset={rowOffset},columnOffset={columnOffset}) public class OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,30 +30,29 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - var rowOffsetOption = new Option("--rowoffset", description: "Usage: rowOffset={rowOffset}") { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var rowOffsetOption = new Option("--row-offset", description: "Usage: rowOffset={rowOffset}") { }; rowOffsetOption.IsRequired = true; command.AddOption(rowOffsetOption); - var columnOffsetOption = new Option("--columnoffset", description: "Usage: columnOffset={columnOffset}") { + var columnOffsetOption = new Option("--column-offset", description: "Usage: columnOffset={columnOffset}") { }; columnOffsetOption.IsRequired = true; command.AddOption(columnOffsetOption); - command.SetHandler(async (string userId, string trendingId, int? rowOffset, int? columnOffset) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, int? rowOffset, int? columnOffset, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption, rowOffsetOption, columnOffsetOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, rowOffsetOption, columnOffsetOption, outputOption); return command; } /// @@ -66,7 +65,7 @@ public Command BuildGetCommand() { public OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, int? rowOffset = default, int? columnOffset = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.offsetRange(rowOffset={rowOffset},columnOffset={columnOffset})"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.offsetRange(rowOffset={rowOffset},columnOffset={columnOffset})"; var urlTplParams = new Dictionary(pathParameters); urlTplParams.Add("rowOffset", rowOffset); urlTplParams.Add("columnOffset", columnOffset); @@ -88,17 +87,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function offsetRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class OffsetRangeWithRowOffsetWithColumnOffsetResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs index 3bfac4558e3..996ed81792c 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.ResizedRangeWithDeltaRowsWithDeltaColumns { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.resizedRange(deltaRows={deltaRows},deltaColumns={deltaColumns}) + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.resizedRange(deltaRows={deltaRows},deltaColumns={deltaColumns}) public class ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,30 +30,29 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - var deltaRowsOption = new Option("--deltarows", description: "Usage: deltaRows={deltaRows}") { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var deltaRowsOption = new Option("--delta-rows", description: "Usage: deltaRows={deltaRows}") { }; deltaRowsOption.IsRequired = true; command.AddOption(deltaRowsOption); - var deltaColumnsOption = new Option("--deltacolumns", description: "Usage: deltaColumns={deltaColumns}") { + var deltaColumnsOption = new Option("--delta-columns", description: "Usage: deltaColumns={deltaColumns}") { }; deltaColumnsOption.IsRequired = true; command.AddOption(deltaColumnsOption); - command.SetHandler(async (string userId, string trendingId, int? deltaRows, int? deltaColumns) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, int? deltaRows, int? deltaColumns, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption, deltaRowsOption, deltaColumnsOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, deltaRowsOption, deltaColumnsOption, outputOption); return command; } /// @@ -66,7 +65,7 @@ public Command BuildGetCommand() { public ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, int? deltaRows = default, int? deltaColumns = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.resizedRange(deltaRows={deltaRows},deltaColumns={deltaColumns})"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.resizedRange(deltaRows={deltaRows},deltaColumns={deltaColumns})"; var urlTplParams = new Dictionary(pathParameters); urlTplParams.Add("deltaRows", deltaRows); urlTplParams.Add("deltaColumns", deltaColumns); @@ -88,17 +87,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function resizedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ResizedRangeWithDeltaRowsWithDeltaColumnsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs index 215771ae2d6..3f7a2c9c889 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.RowWithRow { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.row(row={row}) + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.row(row={row}) public class RowWithRowRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,26 +30,25 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var rowOption = new Option("--row", description: "Usage: row={row}") { }; rowOption.IsRequired = true; command.AddOption(rowOption); - command.SetHandler(async (string userId, string trendingId, int? row) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, int? row, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption, rowOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, rowOption, outputOption); return command; } /// @@ -61,7 +60,7 @@ public Command BuildGetCommand() { public RowWithRowRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, int? row = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.row(row={row})"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.row(row={row})"; var urlTplParams = new Dictionary(pathParameters); urlTplParams.Add("row", row); PathParameters = urlTplParams; @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function row - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowWithRowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs index 31585e5316a..edbf4c84dbd 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.RowsAbove { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsAbove() + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsAbove() public class RowsAboveRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string userId, string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, outputOption); return command; } /// @@ -56,7 +55,7 @@ public Command BuildGetCommand() { public RowsAboveRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.rowsAbove()"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.rowsAbove()"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsAbove - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsAboveResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs index 4b31d55331c..cf1145c5372 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.RowsAboveWithCount { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsAbove(count={count}) + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsAbove(count={count}) public class RowsAboveWithCountRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,26 +30,25 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var countOption = new Option("--count", description: "Usage: count={count}") { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string userId, string trendingId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, countOption, outputOption); return command; } /// @@ -61,7 +60,7 @@ public Command BuildGetCommand() { public RowsAboveWithCountRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, int? count = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.rowsAbove(count={count})"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.rowsAbove(count={count})"; var urlTplParams = new Dictionary(pathParameters); urlTplParams.Add("count", count); PathParameters = urlTplParams; @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsAbove - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsAboveWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs index fc107d90396..ea987412a24 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.RowsBelow { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsBelow() + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsBelow() public class RowsBelowRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string userId, string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, outputOption); return command; } /// @@ -56,7 +55,7 @@ public Command BuildGetCommand() { public RowsBelowRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.rowsBelow()"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.rowsBelow()"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsBelow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsBelowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs index ce59ff8ab6f..e43c3950144 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.RowsBelowWithCount { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsBelow(count={count}) + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsBelow(count={count}) public class RowsBelowWithCountRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,26 +30,25 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var countOption = new Option("--count", description: "Usage: count={count}") { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string userId, string trendingId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, countOption, outputOption); return command; } /// @@ -61,7 +60,7 @@ public Command BuildGetCommand() { public RowsBelowWithCountRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, int? count = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.rowsBelow(count={count})"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.rowsBelow(count={count})"; var urlTplParams = new Dictionary(pathParameters); urlTplParams.Add("count", count); PathParameters = urlTplParams; @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsBelow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsBelowWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs index d7c425d4769..c28a7b12e45 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.Unmerge { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.unmerge + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.unmerge public class UnmergeRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -29,17 +29,16 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string userId, string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + command.SetHandler(async (string userId, string trendingItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, userIdOption, trendingIdOption); + }, userIdOption, trendingItemIdOption); return command; } /// @@ -50,7 +49,7 @@ public Command BuildPostCommand() { public UnmergeRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.unmerge"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.unmerge"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action unmerge - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs index 9ee41908cd5..f2bc447f1e5 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.UsedRange { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.usedRange() + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.usedRange() public class UsedRangeRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string userId, string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, outputOption); return command; } /// @@ -56,7 +55,7 @@ public Command BuildGetCommand() { public UsedRangeRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.usedRange()"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.usedRange()"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs index 3c9bd3937f5..5f0656ec421 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.UsedRangeWithValuesOnly { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.usedRange(valuesOnly={valuesOnly}) + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.usedRange(valuesOnly={valuesOnly}) public class UsedRangeWithValuesOnlyRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,26 +30,25 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - var valuesOnlyOption = new Option("--valuesonly", description: "Usage: valuesOnly={valuesOnly}") { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var valuesOnlyOption = new Option("--values-only", description: "Usage: valuesOnly={valuesOnly}") { }; valuesOnlyOption.IsRequired = true; command.AddOption(valuesOnlyOption); - command.SetHandler(async (string userId, string trendingId, bool? valuesOnly) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, bool? valuesOnly, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption, valuesOnlyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, valuesOnlyOption, outputOption); return command; } /// @@ -61,7 +60,7 @@ public Command BuildGetCommand() { public UsedRangeWithValuesOnlyRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter, bool? valuesOnly = default) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.usedRange(valuesOnly={valuesOnly})"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.usedRange(valuesOnly={valuesOnly})"; var urlTplParams = new Dictionary(pathParameters); urlTplParams.Add("valuesOnly", valuesOnly); PathParameters = urlTplParams; @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeWithValuesOnlyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs index 676fdcd601f..d504d1a6fd5 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.VisibleView { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.visibleView() + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.visibleView() public class VisibleViewRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string userId, string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, outputOption); return command; } /// @@ -56,7 +55,7 @@ public Command BuildGetCommand() { public VisibleViewRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange/microsoft.graph.visibleView()"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange/microsoft.graph.visibleView()"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function visibleView - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRangeView public class VisibleViewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/WorkbookRangeRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/WorkbookRangeRequestBuilder.cs index 775a42a58c3..18b7009d2f5 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/WorkbookRangeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRange/WorkbookRangeRequestBuilder.cs @@ -27,16 +27,16 @@ using ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.UsedRangeWithValuesOnly; using ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange.VisibleView; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRange { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange public class WorkbookRangeRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -45,7 +45,7 @@ public class WorkbookRangeRequestBuilder { /// Url template to use to build the URL for the current request builder private string UrlTemplate { get; set; } /// - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.boundingRect(anotherRange='{anotherRange}') + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.boundingRect(anotherRange='{anotherRange}') /// Usage: anotherRange={anotherRange} /// public BoundingRectWithAnotherRangeRequestBuilder BoundingRectWithAnotherRange(string anotherRange) { @@ -83,7 +83,7 @@ public Command BuildUnmergeCommand() { return command; } /// - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.cell(row={row},column={column}) + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.cell(row={row},column={column}) /// Usage: column={column} /// Usage: row={row} /// @@ -93,13 +93,13 @@ public CellWithRowWithColumnRequestBuilder CellWithRowWithColumn(int? row, int? return new CellWithRowWithColumnRequestBuilder(PathParameters, RequestAdapter, row, column); } /// - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsAfter() + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsAfter() /// public ColumnsAfterRequestBuilder ColumnsAfter() { return new ColumnsAfterRequestBuilder(PathParameters, RequestAdapter); } /// - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsAfter(count={count}) + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsAfter(count={count}) /// Usage: count={count} /// public ColumnsAfterWithCountRequestBuilder ColumnsAfterWithCount(int? count) { @@ -107,13 +107,13 @@ public ColumnsAfterWithCountRequestBuilder ColumnsAfterWithCount(int? count) { return new ColumnsAfterWithCountRequestBuilder(PathParameters, RequestAdapter, count); } /// - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsBefore() + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsBefore() /// public ColumnsBeforeRequestBuilder ColumnsBefore() { return new ColumnsBeforeRequestBuilder(PathParameters, RequestAdapter); } /// - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsBefore(count={count}) + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.columnsBefore(count={count}) /// Usage: count={count} /// public ColumnsBeforeWithCountRequestBuilder ColumnsBeforeWithCount(int? count) { @@ -121,7 +121,7 @@ public ColumnsBeforeWithCountRequestBuilder ColumnsBeforeWithCount(int? count) { return new ColumnsBeforeWithCountRequestBuilder(PathParameters, RequestAdapter, count); } /// - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.column(column={column}) + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.column(column={column}) /// Usage: column={column} /// public ColumnWithColumnRequestBuilder ColumnWithColumn(int? column) { @@ -136,25 +136,25 @@ public ColumnWithColumnRequestBuilder ColumnWithColumn(int? column) { public WorkbookRangeRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRange"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRange"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; } /// - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.entireColumn() + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.entireColumn() /// public EntireColumnRequestBuilder EntireColumn() { return new EntireColumnRequestBuilder(PathParameters, RequestAdapter); } /// - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.entireRow() + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.entireRow() /// public EntireRowRequestBuilder EntireRow() { return new EntireRowRequestBuilder(PathParameters, RequestAdapter); } /// - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.intersection(anotherRange='{anotherRange}') + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.intersection(anotherRange='{anotherRange}') /// Usage: anotherRange={anotherRange} /// public IntersectionWithAnotherRangeRequestBuilder IntersectionWithAnotherRange(string anotherRange) { @@ -162,25 +162,25 @@ public IntersectionWithAnotherRangeRequestBuilder IntersectionWithAnotherRange(s return new IntersectionWithAnotherRangeRequestBuilder(PathParameters, RequestAdapter, anotherRange); } /// - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.lastCell() + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.lastCell() /// public LastCellRequestBuilder LastCell() { return new LastCellRequestBuilder(PathParameters, RequestAdapter); } /// - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.lastColumn() + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.lastColumn() /// public LastColumnRequestBuilder LastColumn() { return new LastColumnRequestBuilder(PathParameters, RequestAdapter); } /// - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.lastRow() + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.lastRow() /// public LastRowRequestBuilder LastRow() { return new LastRowRequestBuilder(PathParameters, RequestAdapter); } /// - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.offsetRange(rowOffset={rowOffset},columnOffset={columnOffset}) + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.offsetRange(rowOffset={rowOffset},columnOffset={columnOffset}) /// Usage: columnOffset={columnOffset} /// Usage: rowOffset={rowOffset} /// @@ -190,7 +190,7 @@ public OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder OffsetRangeWithRow return new OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder(PathParameters, RequestAdapter, rowOffset, columnOffset); } /// - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.resizedRange(deltaRows={deltaRows},deltaColumns={deltaColumns}) + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.resizedRange(deltaRows={deltaRows},deltaColumns={deltaColumns}) /// Usage: deltaColumns={deltaColumns} /// Usage: deltaRows={deltaRows} /// @@ -200,13 +200,13 @@ public ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder ResizedRangeWithD return new ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder(PathParameters, RequestAdapter, deltaRows, deltaColumns); } /// - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsAbove() + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsAbove() /// public RowsAboveRequestBuilder RowsAbove() { return new RowsAboveRequestBuilder(PathParameters, RequestAdapter); } /// - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsAbove(count={count}) + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsAbove(count={count}) /// Usage: count={count} /// public RowsAboveWithCountRequestBuilder RowsAboveWithCount(int? count) { @@ -214,13 +214,13 @@ public RowsAboveWithCountRequestBuilder RowsAboveWithCount(int? count) { return new RowsAboveWithCountRequestBuilder(PathParameters, RequestAdapter, count); } /// - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsBelow() + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsBelow() /// public RowsBelowRequestBuilder RowsBelow() { return new RowsBelowRequestBuilder(PathParameters, RequestAdapter); } /// - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsBelow(count={count}) + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.rowsBelow(count={count}) /// Usage: count={count} /// public RowsBelowWithCountRequestBuilder RowsBelowWithCount(int? count) { @@ -228,7 +228,7 @@ public RowsBelowWithCountRequestBuilder RowsBelowWithCount(int? count) { return new RowsBelowWithCountRequestBuilder(PathParameters, RequestAdapter, count); } /// - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.row(row={row}) + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.row(row={row}) /// Usage: row={row} /// public RowWithRowRequestBuilder RowWithRow(int? row) { @@ -236,13 +236,13 @@ public RowWithRowRequestBuilder RowWithRow(int? row) { return new RowWithRowRequestBuilder(PathParameters, RequestAdapter, row); } /// - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.usedRange() + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.usedRange() /// public UsedRangeRequestBuilder UsedRange() { return new UsedRangeRequestBuilder(PathParameters, RequestAdapter); } /// - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.usedRange(valuesOnly={valuesOnly}) + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.usedRange(valuesOnly={valuesOnly}) /// Usage: valuesOnly={valuesOnly} /// public UsedRangeWithValuesOnlyRequestBuilder UsedRangeWithValuesOnly(bool? valuesOnly) { @@ -250,7 +250,7 @@ public UsedRangeWithValuesOnlyRequestBuilder UsedRangeWithValuesOnly(bool? value return new UsedRangeWithValuesOnlyRequestBuilder(PathParameters, RequestAdapter, valuesOnly); } /// - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRange\microsoft.graph.visibleView() + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRange\microsoft.graph.visibleView() /// public VisibleViewRequestBuilder VisibleView() { return new VisibleViewRequestBuilder(PathParameters, RequestAdapter); diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeFill/Clear/ClearRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeFill/Clear/ClearRequestBuilder.cs index 0f300ce7781..be4ba55fb63 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeFill/Clear/ClearRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeFill/Clear/ClearRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRangeFill.Clear { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRangeFill\microsoft.graph.clear + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRangeFill\microsoft.graph.clear public class ClearRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -29,17 +29,16 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string userId, string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + command.SetHandler(async (string userId, string trendingItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, userIdOption, trendingIdOption); + }, userIdOption, trendingItemIdOption); return command; } /// @@ -50,7 +49,7 @@ public Command BuildPostCommand() { public ClearRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRangeFill/microsoft.graph.clear"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRangeFill/microsoft.graph.clear"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs index 1725641ff33..83a3f5edfc3 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs @@ -1,15 +1,15 @@ using ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRangeFill.Clear; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRangeFill { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRangeFill + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRangeFill public class WorkbookRangeFillRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -31,7 +31,7 @@ public Command BuildClearCommand() { public WorkbookRangeFillRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRangeFill"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRangeFill"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs index 7cd82cf82c4..72db3161a3b 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRangeFormat.AutofitColumns { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRangeFormat\microsoft.graph.autofitColumns + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRangeFormat\microsoft.graph.autofitColumns public class AutofitColumnsRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -29,17 +29,16 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string userId, string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + command.SetHandler(async (string userId, string trendingItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, userIdOption, trendingIdOption); + }, userIdOption, trendingItemIdOption); return command; } /// @@ -50,7 +49,7 @@ public Command BuildPostCommand() { public AutofitColumnsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRangeFormat/microsoft.graph.autofitColumns"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRangeFormat/microsoft.graph.autofitColumns"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action autofitColumns - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs index 6a205731d51..4a55d9c0a8b 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRangeFormat.AutofitRows { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRangeFormat\microsoft.graph.autofitRows + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRangeFormat\microsoft.graph.autofitRows public class AutofitRowsRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -29,17 +29,16 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string userId, string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + command.SetHandler(async (string userId, string trendingItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, userIdOption, trendingIdOption); + }, userIdOption, trendingItemIdOption); return command; } /// @@ -50,7 +49,7 @@ public Command BuildPostCommand() { public AutofitRowsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRangeFormat/microsoft.graph.autofitRows"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRangeFormat/microsoft.graph.autofitRows"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action autofitRows - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs index bcbcc7dc49a..4715aa2d523 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs @@ -1,16 +1,16 @@ using ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRangeFormat.AutofitColumns; using ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRangeFormat.AutofitRows; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRangeFormat { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRangeFormat + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRangeFormat public class WorkbookRangeFormatRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -38,7 +38,7 @@ public Command BuildAutofitRowsCommand() { public WorkbookRangeFormatRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRangeFormat"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRangeFormat"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs index 7447378cce6..315abbb3204 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs @@ -1,16 +1,16 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRangeSort.Apply { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRangeSort\microsoft.graph.apply + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRangeSort\microsoft.graph.apply public class ApplyRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -29,24 +29,23 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); var bodyOption = new Option("--body") { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string trendingId, string body) => { + command.SetHandler(async (string userId, string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); - }, userIdOption, trendingIdOption, bodyOption); + }, userIdOption, trendingItemIdOption, bodyOption); return command; } /// @@ -57,7 +56,7 @@ public Command BuildPostCommand() { public ApplyRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRangeSort/microsoft.graph.apply"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRangeSort/microsoft.graph.apply"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ApplyRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action apply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs index 2a55ff0be13..0fe6dea3783 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs @@ -1,15 +1,15 @@ using ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRangeSort.Apply; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRangeSort { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRangeSort + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRangeSort public class WorkbookRangeSortRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -31,7 +31,7 @@ public Command BuildApplyCommand() { public WorkbookRangeSortRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRangeSort"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRangeSort"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeView/Range/RangeRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeView/Range/RangeRequestBuilder.cs index 2c09140e35c..f5a6934e1e0 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeView/Range/RangeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeView/Range/RangeRequestBuilder.cs @@ -1,17 +1,17 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRangeView.Range { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRangeView\microsoft.graph.range() + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRangeView\microsoft.graph.range() public class RangeRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string userId, string trendingId) => { + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, outputOption); return command; } /// @@ -56,7 +55,7 @@ public Command BuildGetCommand() { public RangeRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRangeView/microsoft.graph.range()"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRangeView/microsoft.graph.range()"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs index 8c04f5ba964..532aad38192 100644 --- a/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/Item/Resource/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs @@ -1,15 +1,15 @@ using ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRangeView.Range; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ApiSdk.Users.Item.Insights.Trending.Item.Resource.WorkbookRangeView { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRangeView + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRangeView public class WorkbookRangeViewRequestBuilder { /// Path parameters for the request private Dictionary PathParameters { get; set; } @@ -25,13 +25,13 @@ public class WorkbookRangeViewRequestBuilder { public WorkbookRangeViewRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}/resource/microsoft.graph.workbookRangeView"; + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}/resource/microsoft.graph.workbookRangeView"; var urlTplParams = new Dictionary(pathParameters); PathParameters = urlTplParams; RequestAdapter = requestAdapter; } /// - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id}\resource\microsoft.graph.workbookRangeView\microsoft.graph.range() + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id}\resource\microsoft.graph.workbookRangeView\microsoft.graph.range() /// public RangeRequestBuilder Range() { return new RangeRequestBuilder(PathParameters, RequestAdapter); diff --git a/src/generated/Users/Item/Insights/Trending/Item/TrendingItemRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/TrendingItemRequestBuilder.cs new file mode 100644 index 00000000000..a404482b6ac --- /dev/null +++ b/src/generated/Users/Item/Insights/Trending/Item/TrendingItemRequestBuilder.cs @@ -0,0 +1,211 @@ +using ApiSdk.Models.Microsoft.Graph; +using ApiSdk.Users.Item.Insights.Trending.Item.Resource; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Users.Item.Insights.Trending.Item { + /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trendingItem-Id} + public class TrendingItemRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Access this property from the derived type itemInsights. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Access this property from the derived type itemInsights."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { + }; + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + command.SetHandler(async (string userId, string trendingItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, userIdOption, trendingItemIdOption); + return command; + } + /// + /// Access this property from the derived type itemInsights. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Access this property from the derived type itemInsights."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { + }; + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var selectOption = new Option("--select", description: "Select properties to be returned") { + Arity = ArgumentArity.ZeroOrMore + }; + selectOption.IsRequired = false; + command.AddOption(selectOption); + var expandOption = new Option("--expand", description: "Expand related entities") { + Arity = ArgumentArity.ZeroOrMore + }; + expandOption.IsRequired = false; + command.AddOption(expandOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string trendingItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Select = select; + q.Expand = expand; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, trendingItemIdOption, selectOption, expandOption, outputOption); + return command; + } + /// + /// Access this property from the derived type itemInsights. + /// + public Command BuildPatchCommand() { + var command = new Command("patch"); + command.Description = "Access this property from the derived type itemInsights."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var trendingItemIdOption = new Option("--trending-item-id", description: "key: id of trending") { + }; + trendingItemIdOption.IsRequired = true; + command.AddOption(trendingItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string userId, string trendingItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePatchRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, userIdOption, trendingItemIdOption, bodyOption); + return command; + } + public Command BuildResourceCommand() { + var command = new Command("resource"); + var builder = new ApiSdk.Users.Item.Insights.Trending.Item.Resource.ResourceRequestBuilder(PathParameters, RequestAdapter); + command.AddCommand(builder.BuildCalendarSharingMessageCommand()); + command.AddCommand(builder.BuildGetCommand()); + command.AddCommand(builder.BuildManagedAppProtectionCommand()); + command.AddCommand(builder.BuildMobileAppContentFileCommand()); + command.AddCommand(builder.BuildPrintDocumentCommand()); + command.AddCommand(builder.BuildPrintJobCommand()); + command.AddCommand(builder.BuildRefCommand()); + command.AddCommand(builder.BuildScheduleChangeRequestCommand()); + command.AddCommand(builder.BuildTargetedManagedAppProtectionCommand()); + command.AddCommand(builder.BuildWindowsInformationProtectionCommand()); + command.AddCommand(builder.BuildWorkbookRangeCommand()); + command.AddCommand(builder.BuildWorkbookRangeFillCommand()); + command.AddCommand(builder.BuildWorkbookRangeFormatCommand()); + command.AddCommand(builder.BuildWorkbookRangeSortCommand()); + command.AddCommand(builder.BuildWorkbookRangeViewCommand()); + return command; + } + /// + /// Instantiates a new TrendingItemRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public TrendingItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trendingItem_Id}{?select,expand}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Access this property from the derived type itemInsights. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Access this property from the derived type itemInsights. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Access this property from the derived type itemInsights. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft.Graph.Trending body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PATCH, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Access this property from the derived type itemInsights. + public class GetQueryParameters : QueryParametersBase { + /// Expand related entities + public string[] Expand { get; set; } + /// Select properties to be returned + public string[] Select { get; set; } + } + } +} diff --git a/src/generated/Users/Item/Insights/Trending/Item/TrendingRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/Item/TrendingRequestBuilder.cs deleted file mode 100644 index 743d0e89f55..00000000000 --- a/src/generated/Users/Item/Insights/Trending/Item/TrendingRequestBuilder.cs +++ /dev/null @@ -1,250 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using ApiSdk.Users.Item.Insights.Trending.Item.Resource; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Users.Item.Insights.Trending.Item { - /// Builds and executes requests for operations under \users\{user-id}\insights\trending\{trending-id} - public class TrendingRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Access this property from the derived type itemInsights. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Access this property from the derived type itemInsights."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { - }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - command.SetHandler(async (string userId, string trendingId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userIdOption, trendingIdOption); - return command; - } - /// - /// Access this property from the derived type itemInsights. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Access this property from the derived type itemInsights."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { - }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string userId, string trendingId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, trendingIdOption, selectOption, expandOption); - return command; - } - /// - /// Access this property from the derived type itemInsights. - /// - public Command BuildPatchCommand() { - var command = new Command("patch"); - command.Description = "Access this property from the derived type itemInsights."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var trendingIdOption = new Option("--trending-id", description: "key: id of trending") { - }; - trendingIdOption.IsRequired = true; - command.AddOption(trendingIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string userId, string trendingId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePatchRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userIdOption, trendingIdOption, bodyOption); - return command; - } - public Command BuildResourceCommand() { - var command = new Command("resource"); - var builder = new ApiSdk.Users.Item.Insights.Trending.Item.Resource.ResourceRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildCalendarSharingMessageCommand()); - command.AddCommand(builder.BuildGetCommand()); - command.AddCommand(builder.BuildManagedAppProtectionCommand()); - command.AddCommand(builder.BuildMobileAppContentFileCommand()); - command.AddCommand(builder.BuildPrintDocumentCommand()); - command.AddCommand(builder.BuildPrintJobCommand()); - command.AddCommand(builder.BuildRefCommand()); - command.AddCommand(builder.BuildScheduleChangeRequestCommand()); - command.AddCommand(builder.BuildTargetedManagedAppProtectionCommand()); - command.AddCommand(builder.BuildWindowsInformationProtectionCommand()); - command.AddCommand(builder.BuildWorkbookRangeCommand()); - command.AddCommand(builder.BuildWorkbookRangeFillCommand()); - command.AddCommand(builder.BuildWorkbookRangeFormatCommand()); - command.AddCommand(builder.BuildWorkbookRangeSortCommand()); - command.AddCommand(builder.BuildWorkbookRangeViewCommand()); - return command; - } - /// - /// Instantiates a new TrendingRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public TrendingRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/trending/{trending_id}{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Access this property from the derived type itemInsights. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Access this property from the derived type itemInsights. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Access this property from the derived type itemInsights. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft.Graph.Trending body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PATCH, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Trending model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// Access this property from the derived type itemInsights. - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/Users/Item/Insights/Trending/TrendingRequestBuilder.cs b/src/generated/Users/Item/Insights/Trending/TrendingRequestBuilder.cs index 9236388753d..a52c2324cbd 100644 --- a/src/generated/Users/Item/Insights/Trending/TrendingRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Trending/TrendingRequestBuilder.cs @@ -1,10 +1,11 @@ using ApiSdk.Models.Microsoft.Graph; +using ApiSdk.Users.Item.Insights.Trending.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -20,11 +21,12 @@ public class TrendingRequestBuilder { /// Url template to use to build the URL for the current request builder private string UrlTemplate { get; set; } public List BuildCommand() { - var builder = new TrendingRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCreateCommand(), - builder.BuildListCommand(), - }; + var builder = new TrendingItemRequestBuilder(PathParameters, RequestAdapter); + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildResourceCommand()); return commands; } /// @@ -42,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -105,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -116,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -179,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Trending model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Access this property from the derived type itemInsights. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/@Ref/@Ref.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/@Ref/@Ref.cs deleted file mode 100644 index ca622b76ba2..00000000000 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.Insights.Used.Item.Resource.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/@Ref/RefRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 95b378409a8..00000000000 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Users.Item.Insights.Used.Item.Resource.@Ref { - /// Builds and executes requests for operations under \users\{user-id}\insights\used\{usedInsight-id}\resource\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { - }; - usedInsightIdOption.IsRequired = true; - command.AddOption(usedInsightIdOption); - command.SetHandler(async (string userId, string usedInsightId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userIdOption, usedInsightIdOption); - return command; - } - /// - /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { - }; - usedInsightIdOption.IsRequired = true; - command.AddOption(usedInsightIdOption); - command.SetHandler(async (string userId, string usedInsightId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption); - return command; - } - /// - /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { - }; - usedInsightIdOption.IsRequired = true; - command.AddOption(usedInsightIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string userId, string usedInsightId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userIdOption, usedInsightIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/insights/used/{usedInsight_id}/resource/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Users.Item.Insights.Used.Item.Resource.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Users.Item.Insights.Used.Item.Resource.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs index 38594d4c4cd..52feab8c1ef 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string userId, string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, outputOption); return command; } /// @@ -76,16 +75,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs index 69ff07772f8..19901dae466 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Users.Item.Insights.Used.Item.Resource.CalendarSharingMessage.Accept; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs index 84aa78075b4..9ea79b70f45 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/ManagedAppProtection/ManagedAppProtectionRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Users.Item.Insights.Used.Item.Resource.ManagedAppProtection.TargetApps; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs index a9c0ab33416..d0538003cc1 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/ManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string usedInsightId, string body) => { + command.SetHandler(async (string userId, string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, usedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TargetAppsRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action targetApps - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetAppsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/MobileAppContentFile/Commit/CommitRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/MobileAppContentFile/Commit/CommitRequestBuilder.cs index 4bc89860897..71a941961ef 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/MobileAppContentFile/Commit/CommitRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/MobileAppContentFile/Commit/CommitRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string usedInsightId, string body) => { + command.SetHandler(async (string userId, string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, usedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CommitRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Commits a file of a given app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CommitRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs index 897afa24036..48df215d0a3 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/MobileAppContentFile/MobileAppContentFileRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Users.Item.Insights.Used.Item.Resource.MobileAppContentFile.Commit; using ApiSdk.Users.Item.Insights.Used.Item.Resource.MobileAppContentFile.RenewUpload; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs index 9afedfec65b..37a03cf9024 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/MobileAppContentFile/RenewUpload/RenewUploadRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string userId, string usedInsightId) => { + command.SetHandler(async (string userId, string usedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, usedInsightIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Renews the SAS URI for an application file upload. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index 9372d81f56b..284ea819e36 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/PrintDocument/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string usedInsightId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/PrintDocument/PrintDocumentRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/PrintDocument/PrintDocumentRequestBuilder.cs index 55eef93adef..53a3dd9c270 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/PrintDocument/PrintDocumentRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/PrintDocument/PrintDocumentRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Users.Item.Insights.Used.Item.Resource.PrintDocument.CreateUploadSession; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/PrintJob/Abort/AbortRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/PrintJob/Abort/AbortRequestBuilder.cs index f2b94460657..1933b9ef787 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/PrintJob/Abort/AbortRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/PrintJob/Abort/AbortRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string usedInsightId, string body) => { + command.SetHandler(async (string userId, string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, usedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AbortRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action abort - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AbortRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/PrintJob/Cancel/CancelRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/PrintJob/Cancel/CancelRequestBuilder.cs index 01a87ac5198..356260c6b19 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/PrintJob/Cancel/CancelRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/PrintJob/Cancel/CancelRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string userId, string usedInsightId) => { + command.SetHandler(async (string userId, string usedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, usedInsightIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action cancel - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/PrintJob/PrintJobRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/PrintJob/PrintJobRequestBuilder.cs index 6dc9a456e18..e4458f20805 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/PrintJob/PrintJobRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/PrintJob/PrintJobRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Insights.Used.Item.Resource.PrintJob.Redirect; using ApiSdk.Users.Item.Insights.Used.Item.Resource.PrintJob.Start; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/PrintJob/Redirect/RedirectRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/PrintJob/Redirect/RedirectRequestBuilder.cs index ce8e3058fc4..0d55fa88606 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/PrintJob/Redirect/RedirectRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/PrintJob/Redirect/RedirectRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string usedInsightId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(RedirectRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action redirect - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RedirectRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes printJob public class RedirectResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/PrintJob/Start/StartRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/PrintJob/Start/StartRequestBuilder.cs index da8fbc73f7d..163851b3778 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/PrintJob/Start/StartRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/PrintJob/Start/StartRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string userId, string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action start - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes printJobStatus public class StartResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/Ref/Ref.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/Ref/Ref.cs new file mode 100644 index 00000000000..7e6d5a9dcc7 --- /dev/null +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.Insights.Used.Item.Resource.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/Ref/RefRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..a7b3f438337 --- /dev/null +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Users.Item.Insights.Used.Item.Resource.Ref { + /// Builds and executes requests for operations under \users\{user-id}\insights\used\{usedInsight-id}\resource\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { + }; + usedInsightIdOption.IsRequired = true; + command.AddOption(usedInsightIdOption); + command.SetHandler(async (string userId, string usedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, userIdOption, usedInsightIdOption); + return command; + } + /// + /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { + }; + usedInsightIdOption.IsRequired = true; + command.AddOption(usedInsightIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, outputOption); + return command; + } + /// + /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { + }; + usedInsightIdOption.IsRequired = true; + command.AddOption(usedInsightIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string userId, string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, userIdOption, usedInsightIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/users/{user_id}/insights/used/{usedInsight_id}/resource/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Users.Item.Insights.Used.Item.Resource.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/ResourceRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/ResourceRequestBuilder.cs index ae33fc6290a..685a603b199 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/ResourceRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/ResourceRequestBuilder.cs @@ -15,10 +15,10 @@ using ApiSdk.Users.Item.Insights.Used.Item.Resource.WorkbookRangeView; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -50,7 +50,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -64,20 +64,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string usedInsightId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildManagedAppProtectionCommand() { @@ -110,7 +109,7 @@ public Command BuildPrintJobCommand() { } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Users.Item.Insights.Used.Item.Resource.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Users.Item.Insights.Used.Item.Resource.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -204,18 +203,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Used for navigating to the item that was used. For file attachments, the type is fileAttachment. For linked attachments, the type is driveItem. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs index b7e687393f9..9751a8ae802 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/ScheduleChangeRequest/Approve/ApproveRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string usedInsightId, string body) => { + command.SetHandler(async (string userId, string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, usedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ApproveRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action approve - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApproveRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs index 45fcbf719df..5976394bbd2 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/ScheduleChangeRequest/Decline/DeclineRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string usedInsightId, string body) => { + command.SetHandler(async (string userId, string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, usedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(DeclineRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action decline - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeclineRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs index eac83235872..32636e51026 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/ScheduleChangeRequest/ScheduleChangeRequestRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Users.Item.Insights.Used.Item.Resource.ScheduleChangeRequest.Approve; using ApiSdk.Users.Item.Insights.Used.Item.Resource.ScheduleChangeRequest.Decline; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs index 46ac9b8a409..93901b5721e 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/TargetedManagedAppProtection/Assign/AssignRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string usedInsightId, string body) => { + command.SetHandler(async (string userId, string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, usedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs index 7f718bd3b92..ef64e1938ef 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/TargetedManagedAppProtection/TargetApps/TargetAppsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string usedInsightId, string body) => { + command.SetHandler(async (string userId, string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, usedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(TargetAppsRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action targetApps - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TargetAppsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs index d34e25459a6..c5e96248adf 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/TargetedManagedAppProtection/TargetedManagedAppProtectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Users.Item.Insights.Used.Item.Resource.TargetedManagedAppProtection.Assign; using ApiSdk.Users.Item.Insights.Used.Item.Resource.TargetedManagedAppProtection.TargetApps; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WindowsInformationProtection/Assign/AssignRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WindowsInformationProtection/Assign/AssignRequestBuilder.cs index d30c36576fe..5de450235fb 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WindowsInformationProtection/Assign/AssignRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WindowsInformationProtection/Assign/AssignRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string usedInsightId, string body) => { + command.SetHandler(async (string userId, string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, usedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(AssignRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action assign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AssignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs index 669372aee19..8665da23876 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WindowsInformationProtection/WindowsInformationProtectionRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Users.Item.Insights.Used.Item.Resource.WindowsInformationProtection.Assign; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs index 3e117367ea9..73044c96298 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/BoundingRectWithAnotherRange/BoundingRectWithAnotherRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,26 +30,25 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - var anotherRangeOption = new Option("--anotherrange", description: "Usage: anotherRange={anotherRange}") { + var anotherRangeOption = new Option("--another-range", description: "Usage: anotherRange={anotherRange}") { }; anotherRangeOption.IsRequired = true; command.AddOption(anotherRangeOption); - command.SetHandler(async (string userId, string usedInsightId, string anotherRange) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, string anotherRange, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption, anotherRangeOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, anotherRangeOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function boundingRect - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class BoundingRectWithAnotherRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs index b7e148feddc..b3cf2806a81 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -42,18 +42,17 @@ public Command BuildGetCommand() { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string userId, string usedInsightId, int? row, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, int? row, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption, rowOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, rowOption, columnOption, outputOption); return command; } /// @@ -88,17 +87,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function cell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class CellWithRowWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/Clear/ClearRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/Clear/ClearRequestBuilder.cs index 4846ba9c1aa..24a46fbb000 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/Clear/ClearRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string usedInsightId, string body) => { + command.SetHandler(async (string userId, string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, usedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ClearRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ClearRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs index cecfb278713..d62adbb948b 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/ColumnWithColumn/ColumnWithColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string userId, string usedInsightId, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, columnOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function column - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs index b4aafaa5457..3d7b3e43b05 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/ColumnsAfter/ColumnsAfterRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string userId, string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsAfter - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsAfterResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs index 4e0bad7c9cb..4f3377156de 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/ColumnsAfterWithCount/ColumnsAfterWithCountRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string userId, string usedInsightId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, countOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsAfter - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsAfterWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs index e489e93ca6c..0a9940c38e0 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/ColumnsBefore/ColumnsBeforeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string userId, string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsBefore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsBeforeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs index 043ded5ef8e..f213b75e47e 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/ColumnsBeforeWithCount/ColumnsBeforeWithCountRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string userId, string usedInsightId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, countOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function columnsBefore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ColumnsBeforeWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/Delete/DeleteRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/Delete/DeleteRequestBuilder.cs index 04e57be7a15..2c20d3b59f3 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/Delete/DeleteRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/Delete/DeleteRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string usedInsightId, string body) => { + command.SetHandler(async (string userId, string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, usedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(DeleteRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action delete - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeleteRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs index 99e9f75b354..597610dc0c8 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/EntireColumn/EntireColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string userId, string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function entireColumn - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class EntireColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs index 8eec64afc82..3951283af20 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/EntireRow/EntireRowRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string userId, string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function entireRow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class EntireRowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/Insert/InsertRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/Insert/InsertRequestBuilder.cs index 98a5897c174..6d0648da6a1 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/Insert/InsertRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/Insert/InsertRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string usedInsightId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(InsertRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action insert - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(InsertRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class InsertResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs index 337be2a0181..9466034d076 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/IntersectionWithAnotherRange/IntersectionWithAnotherRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,26 +30,25 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - var anotherRangeOption = new Option("--anotherrange", description: "Usage: anotherRange={anotherRange}") { + var anotherRangeOption = new Option("--another-range", description: "Usage: anotherRange={anotherRange}") { }; anotherRangeOption.IsRequired = true; command.AddOption(anotherRangeOption); - command.SetHandler(async (string userId, string usedInsightId, string anotherRange) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, string anotherRange, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption, anotherRangeOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, anotherRangeOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function intersection - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class IntersectionWithAnotherRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/LastCell/LastCellRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/LastCell/LastCellRequestBuilder.cs index 8e76369e813..cc15247823d 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/LastCell/LastCellRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/LastCell/LastCellRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string userId, string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function lastCell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class LastCellResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs index 397759d31cc..42ed5710dda 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/LastColumn/LastColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string userId, string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function lastColumn - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class LastColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/LastRow/LastRowRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/LastRow/LastRowRequestBuilder.cs index 27c71284a9b..d979cad1c32 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/LastRow/LastRowRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/LastRow/LastRowRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string userId, string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function lastRow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class LastRowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/Merge/MergeRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/Merge/MergeRequestBuilder.cs index bc6204a4d85..29a60fa8ce2 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/Merge/MergeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/Merge/MergeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string usedInsightId, string body) => { + command.SetHandler(async (string userId, string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, usedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(MergeRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action merge - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MergeRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs index 8f53240f35f..8b30e47772a 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/OffsetRangeWithRowOffsetWithColumnOffset/OffsetRangeWithRowOffsetWithColumnOffsetRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,30 +30,29 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - var rowOffsetOption = new Option("--rowoffset", description: "Usage: rowOffset={rowOffset}") { + var rowOffsetOption = new Option("--row-offset", description: "Usage: rowOffset={rowOffset}") { }; rowOffsetOption.IsRequired = true; command.AddOption(rowOffsetOption); - var columnOffsetOption = new Option("--columnoffset", description: "Usage: columnOffset={columnOffset}") { + var columnOffsetOption = new Option("--column-offset", description: "Usage: columnOffset={columnOffset}") { }; columnOffsetOption.IsRequired = true; command.AddOption(columnOffsetOption); - command.SetHandler(async (string userId, string usedInsightId, int? rowOffset, int? columnOffset) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, int? rowOffset, int? columnOffset, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption, rowOffsetOption, columnOffsetOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, rowOffsetOption, columnOffsetOption, outputOption); return command; } /// @@ -88,17 +87,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function offsetRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class OffsetRangeWithRowOffsetWithColumnOffsetResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs index d43debdebf5..aa9ffcb0ff6 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/ResizedRangeWithDeltaRowsWithDeltaColumns/ResizedRangeWithDeltaRowsWithDeltaColumnsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,30 +30,29 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - var deltaRowsOption = new Option("--deltarows", description: "Usage: deltaRows={deltaRows}") { + var deltaRowsOption = new Option("--delta-rows", description: "Usage: deltaRows={deltaRows}") { }; deltaRowsOption.IsRequired = true; command.AddOption(deltaRowsOption); - var deltaColumnsOption = new Option("--deltacolumns", description: "Usage: deltaColumns={deltaColumns}") { + var deltaColumnsOption = new Option("--delta-columns", description: "Usage: deltaColumns={deltaColumns}") { }; deltaColumnsOption.IsRequired = true; command.AddOption(deltaColumnsOption); - command.SetHandler(async (string userId, string usedInsightId, int? deltaRows, int? deltaColumns) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, int? deltaRows, int? deltaColumns, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption, deltaRowsOption, deltaColumnsOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, deltaRowsOption, deltaColumnsOption, outputOption); return command; } /// @@ -88,17 +87,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function resizedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ResizedRangeWithDeltaRowsWithDeltaColumnsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs index 28a3460b4ab..1d4472e078e 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/RowWithRow/RowWithRowRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; rowOption.IsRequired = true; command.AddOption(rowOption); - command.SetHandler(async (string userId, string usedInsightId, int? row) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, int? row, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption, rowOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, rowOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function row - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowWithRowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs index afe937a901f..6409d739b20 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/RowsAbove/RowsAboveRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string userId, string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsAbove - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsAboveResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs index 42d26b1ecb5..9aa6d3e9198 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/RowsAboveWithCount/RowsAboveWithCountRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string userId, string usedInsightId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, countOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsAbove - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsAboveWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs index e4ec807efd5..88dc5a1ad87 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/RowsBelow/RowsBelowRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string userId, string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsBelow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsBelowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs index a91711c278f..94878283551 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/RowsBelowWithCount/RowsBelowWithCountRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; countOption.IsRequired = true; command.AddOption(countOption); - command.SetHandler(async (string userId, string usedInsightId, int? count) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, int? count, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption, countOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, countOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function rowsBelow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RowsBelowWithCountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs index 8dd1c076988..9d76998a7a2 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/Unmerge/UnmergeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string userId, string usedInsightId) => { + command.SetHandler(async (string userId, string usedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, usedInsightIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action unmerge - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs index 731e2178842..f156a339dbe 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/UsedRange/UsedRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string userId, string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs index 4b6c70e7ea1..8765cbf9123 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,26 +30,25 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - var valuesOnlyOption = new Option("--valuesonly", description: "Usage: valuesOnly={valuesOnly}") { + var valuesOnlyOption = new Option("--values-only", description: "Usage: valuesOnly={valuesOnly}") { }; valuesOnlyOption.IsRequired = true; command.AddOption(valuesOnlyOption); - command.SetHandler(async (string userId, string usedInsightId, bool? valuesOnly) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, bool? valuesOnly, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption, valuesOnlyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, valuesOnlyOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeWithValuesOnlyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs index 1355c589a04..14ea72366f0 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/VisibleView/VisibleViewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string userId, string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function visibleView - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRangeView public class VisibleViewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/WorkbookRangeRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/WorkbookRangeRequestBuilder.cs index 6f2def7f458..1dda776b506 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/WorkbookRangeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRange/WorkbookRangeRequestBuilder.cs @@ -27,10 +27,10 @@ using ApiSdk.Users.Item.Insights.Used.Item.Resource.WorkbookRange.UsedRangeWithValuesOnly; using ApiSdk.Users.Item.Insights.Used.Item.Resource.WorkbookRange.VisibleView; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeFill/Clear/ClearRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeFill/Clear/ClearRequestBuilder.cs index faad2c4163b..195becf8838 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeFill/Clear/ClearRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeFill/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string userId, string usedInsightId) => { + command.SetHandler(async (string userId, string usedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, usedInsightIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs index 272a4cfd82b..793174f1f89 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeFill/WorkbookRangeFillRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Users.Item.Insights.Used.Item.Resource.WorkbookRangeFill.Clear; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs index 320bab9eadf..e380d9acc3f 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeFormat/AutofitColumns/AutofitColumnsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string userId, string usedInsightId) => { + command.SetHandler(async (string userId, string usedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, usedInsightIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action autofitColumns - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs index c2d2da7eeb3..6951200103d 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeFormat/AutofitRows/AutofitRowsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string userId, string usedInsightId) => { + command.SetHandler(async (string userId, string usedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, usedInsightIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action autofitRows - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs index 14c15eb6ddb..5f71413cb35 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeFormat/WorkbookRangeFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Users.Item.Insights.Used.Item.Resource.WorkbookRangeFormat.AutofitColumns; using ApiSdk.Users.Item.Insights.Used.Item.Resource.WorkbookRangeFormat.AutofitRows; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs index c719fd8e9f7..005301fd4fc 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeSort/Apply/ApplyRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string usedInsightId, string body) => { + command.SetHandler(async (string userId, string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, usedInsightIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ApplyRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action apply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs index fde151063c6..fda98556bf8 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeSort/WorkbookRangeSortRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Users.Item.Insights.Used.Item.Resource.WorkbookRangeSort.Apply; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeView/Range/RangeRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeView/Range/RangeRequestBuilder.cs index 8925230fc8e..f33f4181710 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeView/Range/RangeRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeView/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string userId, string usedInsightId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs index 16aab716175..0da1d62df16 100644 --- a/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/Resource/WorkbookRangeView/WorkbookRangeViewRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Users.Item.Insights.Used.Item.Resource.WorkbookRangeView.Range; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Insights/Used/Item/UsedInsightRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/Item/UsedInsightRequestBuilder.cs index f947db519b0..f36c646bae6 100644 --- a/src/generated/Users/Item/Insights/Used/Item/UsedInsightRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/Item/UsedInsightRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Insights.Used.Item.Resource; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,15 +31,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); - command.SetHandler(async (string userId, string usedInsightId) => { + command.SetHandler(async (string userId, string usedInsightId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, usedInsightIdOption); return command; @@ -55,7 +54,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string usedInsightId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string usedInsightId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, usedInsightIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, usedInsightIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -96,7 +94,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var usedInsightIdOption = new Option("--usedinsight-id", description: "key: id of usedInsight") { + var usedInsightIdOption = new Option("--used-insight-id", description: "key: id of usedInsight") { }; usedInsightIdOption.IsRequired = true; command.AddOption(usedInsightIdOption); @@ -104,14 +102,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string usedInsightId, string body) => { + command.SetHandler(async (string userId, string usedInsightId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, usedInsightIdOption, bodyOption); return command; @@ -203,42 +200,6 @@ public RequestInformation CreatePatchRequestInformation(UsedInsight body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(UsedInsight model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Access this property from the derived type itemInsights. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Insights/Used/UsedRequestBuilder.cs b/src/generated/Users/Item/Insights/Used/UsedRequestBuilder.cs index 63abdb604e9..d74ffd6367f 100644 --- a/src/generated/Users/Item/Insights/Used/UsedRequestBuilder.cs +++ b/src/generated/Users/Item/Insights/Used/UsedRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Insights.Used.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class UsedRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new UsedInsightRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildResourceCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildResourceCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(UsedInsight body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Access this property from the derived type itemInsights. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UsedInsight model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Access this property from the derived type itemInsights. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/JoinedTeams/Item/TeamRequestBuilder.cs b/src/generated/Users/Item/JoinedTeams/Item/TeamRequestBuilder.cs index 5d08e75a391..cc2ab6ad1da 100644 --- a/src/generated/Users/Item/JoinedTeams/Item/TeamRequestBuilder.cs +++ b/src/generated/Users/Item/JoinedTeams/Item/TeamRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; teamIdOption.IsRequired = true; command.AddOption(teamIdOption); - command.SetHandler(async (string userId, string teamId) => { + command.SetHandler(async (string userId, string teamId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, teamIdOption); return command; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string teamId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string teamId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, teamIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, teamIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string teamId, string body) => { + command.SetHandler(async (string userId, string teamId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, teamIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The Microsoft Teams teams that the user is a member of. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Microsoft Teams teams that the user is a member of. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Microsoft Teams teams that the user is a member of. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Team model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The Microsoft Teams teams that the user is a member of. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/JoinedTeams/JoinedTeamsRequestBuilder.cs b/src/generated/Users/Item/JoinedTeams/JoinedTeamsRequestBuilder.cs index 81cdc222772..f02bfd6659c 100644 --- a/src/generated/Users/Item/JoinedTeams/JoinedTeamsRequestBuilder.cs +++ b/src/generated/Users/Item/JoinedTeams/JoinedTeamsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.JoinedTeams.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class JoinedTeamsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TeamRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The Microsoft Teams teams that the user is a member of. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The Microsoft Teams teams that the user is a member of. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Team model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The Microsoft Teams teams that the user is a member of. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/LicenseDetails/Item/LicenseDetailsItemRequestBuilder.cs b/src/generated/Users/Item/LicenseDetails/Item/LicenseDetailsItemRequestBuilder.cs new file mode 100644 index 00000000000..d2e6f11c999 --- /dev/null +++ b/src/generated/Users/Item/LicenseDetails/Item/LicenseDetailsItemRequestBuilder.cs @@ -0,0 +1,190 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Users.Item.LicenseDetails.Item { + /// Builds and executes requests for operations under \users\{user-id}\licenseDetails\{licenseDetailsItem-id} + public class LicenseDetailsItemRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// A collection of this user's license details. Read-only. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "A collection of this user's license details. Read-only."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var licenseDetailsItemIdOption = new Option("--license-details-item-id", description: "key: id of licenseDetails") { + }; + licenseDetailsItemIdOption.IsRequired = true; + command.AddOption(licenseDetailsItemIdOption); + command.SetHandler(async (string userId, string licenseDetailsItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, userIdOption, licenseDetailsItemIdOption); + return command; + } + /// + /// A collection of this user's license details. Read-only. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "A collection of this user's license details. Read-only."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var licenseDetailsItemIdOption = new Option("--license-details-item-id", description: "key: id of licenseDetails") { + }; + licenseDetailsItemIdOption.IsRequired = true; + command.AddOption(licenseDetailsItemIdOption); + var selectOption = new Option("--select", description: "Select properties to be returned") { + Arity = ArgumentArity.ZeroOrMore + }; + selectOption.IsRequired = false; + command.AddOption(selectOption); + var expandOption = new Option("--expand", description: "Expand related entities") { + Arity = ArgumentArity.ZeroOrMore + }; + expandOption.IsRequired = false; + command.AddOption(expandOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string licenseDetailsItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Select = select; + q.Expand = expand; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, licenseDetailsItemIdOption, selectOption, expandOption, outputOption); + return command; + } + /// + /// A collection of this user's license details. Read-only. + /// + public Command BuildPatchCommand() { + var command = new Command("patch"); + command.Description = "A collection of this user's license details. Read-only."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var licenseDetailsItemIdOption = new Option("--license-details-item-id", description: "key: id of licenseDetails") { + }; + licenseDetailsItemIdOption.IsRequired = true; + command.AddOption(licenseDetailsItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string userId, string licenseDetailsItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePatchRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, userIdOption, licenseDetailsItemIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new LicenseDetailsItemRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public LicenseDetailsItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/users/{user_id}/licenseDetails/{licenseDetailsItem_id}{?select,expand}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// A collection of this user's license details. Read-only. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// A collection of this user's license details. Read-only. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// A collection of this user's license details. Read-only. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft.Graph.LicenseDetails body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PATCH, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// A collection of this user's license details. Read-only. + public class GetQueryParameters : QueryParametersBase { + /// Expand related entities + public string[] Expand { get; set; } + /// Select properties to be returned + public string[] Select { get; set; } + } + } +} diff --git a/src/generated/Users/Item/LicenseDetails/Item/LicenseDetailsRequestBuilder.cs b/src/generated/Users/Item/LicenseDetails/Item/LicenseDetailsRequestBuilder.cs deleted file mode 100644 index 94309d458ae..00000000000 --- a/src/generated/Users/Item/LicenseDetails/Item/LicenseDetailsRequestBuilder.cs +++ /dev/null @@ -1,229 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Users.Item.LicenseDetails.Item { - /// Builds and executes requests for operations under \users\{user-id}\licenseDetails\{licenseDetails-id} - public class LicenseDetailsRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// A collection of this user's license details. Read-only. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "A collection of this user's license details. Read-only."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var licenseDetailsIdOption = new Option("--licensedetails-id", description: "key: id of licenseDetails") { - }; - licenseDetailsIdOption.IsRequired = true; - command.AddOption(licenseDetailsIdOption); - command.SetHandler(async (string userId, string licenseDetailsId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userIdOption, licenseDetailsIdOption); - return command; - } - /// - /// A collection of this user's license details. Read-only. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "A collection of this user's license details. Read-only."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var licenseDetailsIdOption = new Option("--licensedetails-id", description: "key: id of licenseDetails") { - }; - licenseDetailsIdOption.IsRequired = true; - command.AddOption(licenseDetailsIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string userId, string licenseDetailsId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, licenseDetailsIdOption, selectOption, expandOption); - return command; - } - /// - /// A collection of this user's license details. Read-only. - /// - public Command BuildPatchCommand() { - var command = new Command("patch"); - command.Description = "A collection of this user's license details. Read-only."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var licenseDetailsIdOption = new Option("--licensedetails-id", description: "key: id of licenseDetails") { - }; - licenseDetailsIdOption.IsRequired = true; - command.AddOption(licenseDetailsIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string userId, string licenseDetailsId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePatchRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userIdOption, licenseDetailsIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new LicenseDetailsRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public LicenseDetailsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/licenseDetails/{licenseDetails_id}{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// A collection of this user's license details. Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// A collection of this user's license details. Read-only. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// A collection of this user's license details. Read-only. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft.Graph.LicenseDetails body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PATCH, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// A collection of this user's license details. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of this user's license details. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of this user's license details. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.LicenseDetails model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// A collection of this user's license details. Read-only. - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/Users/Item/LicenseDetails/LicenseDetailsRequestBuilder.cs b/src/generated/Users/Item/LicenseDetails/LicenseDetailsRequestBuilder.cs index 1268b65125e..e9dab74696b 100644 --- a/src/generated/Users/Item/LicenseDetails/LicenseDetailsRequestBuilder.cs +++ b/src/generated/Users/Item/LicenseDetails/LicenseDetailsRequestBuilder.cs @@ -1,10 +1,11 @@ using ApiSdk.Models.Microsoft.Graph; +using ApiSdk.Users.Item.LicenseDetails.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -20,11 +21,11 @@ public class LicenseDetailsRequestBuilder { /// Url template to use to build the URL for the current request builder private string UrlTemplate { get; set; } public List BuildCommand() { - var builder = new LicenseDetailsRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCreateCommand(), - builder.BuildListCommand(), - }; + var builder = new LicenseDetailsItemRequestBuilder(PathParameters, RequestAdapter); + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -105,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -116,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -179,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of this user's license details. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of this user's license details. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.LicenseDetails model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of this user's license details. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/MailFolders/Delta/Delta.cs b/src/generated/Users/Item/MailFolders/Delta/Delta.cs deleted file mode 100644 index a96b68e52dd..00000000000 --- a/src/generated/Users/Item/MailFolders/Delta/Delta.cs +++ /dev/null @@ -1,69 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.MailFolders.Delta { - public class Delta : Entity, IParsable { - /// The number of immediate child mailFolders in the current mailFolder. - public int? ChildFolderCount { get; set; } - /// The collection of child folders in the mailFolder. - public List ChildFolders { get; set; } - /// The mailFolder's display name. - public string DisplayName { get; set; } - /// Indicates whether the mailFolder is hidden. This property can be set only when creating the folder. Find more information in Hidden mail folders. - public bool? IsHidden { get; set; } - /// The collection of rules that apply to the user's Inbox folder. - public List MessageRules { get; set; } - /// The collection of messages in the mailFolder. - public List Messages { get; set; } - /// The collection of multi-value extended properties defined for the mailFolder. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - /// The unique identifier for the mailFolder's parent mailFolder. - public string ParentFolderId { get; set; } - /// The collection of single-value extended properties defined for the mailFolder. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - /// The number of items in the mailFolder. - public int? TotalItemCount { get; set; } - /// The number of items in the mailFolder marked as unread. - public int? UnreadItemCount { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"childFolderCount", (o,n) => { (o as Delta).ChildFolderCount = n.GetIntValue(); } }, - {"childFolders", (o,n) => { (o as Delta).ChildFolders = n.GetCollectionOfObjectValues().ToList(); } }, - {"displayName", (o,n) => { (o as Delta).DisplayName = n.GetStringValue(); } }, - {"isHidden", (o,n) => { (o as Delta).IsHidden = n.GetBoolValue(); } }, - {"messageRules", (o,n) => { (o as Delta).MessageRules = n.GetCollectionOfObjectValues().ToList(); } }, - {"messages", (o,n) => { (o as Delta).Messages = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"parentFolderId", (o,n) => { (o as Delta).ParentFolderId = n.GetStringValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"totalItemCount", (o,n) => { (o as Delta).TotalItemCount = n.GetIntValue(); } }, - {"unreadItemCount", (o,n) => { (o as Delta).UnreadItemCount = n.GetIntValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteIntValue("childFolderCount", ChildFolderCount); - writer.WriteCollectionOfObjectValues("childFolders", ChildFolders); - writer.WriteStringValue("displayName", DisplayName); - writer.WriteBoolValue("isHidden", IsHidden); - writer.WriteCollectionOfObjectValues("messageRules", MessageRules); - writer.WriteCollectionOfObjectValues("messages", Messages); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteStringValue("parentFolderId", ParentFolderId); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteIntValue("totalItemCount", TotalItemCount); - writer.WriteIntValue("unreadItemCount", UnreadItemCount); - } - } -} diff --git a/src/generated/Users/Item/MailFolders/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Delta/DeltaRequestBuilder.cs index b06a194c262..2c9139fc113 100644 --- a/src/generated/Users/Item/MailFolders/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +30,17 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/MailFolders/Item/ChildFolders/ChildFoldersRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/ChildFolders/ChildFoldersRequestBuilder.cs index 87c0ebae657..45d39633b03 100644 --- a/src/generated/Users/Item/MailFolders/Item/ChildFolders/ChildFoldersRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/ChildFolders/ChildFoldersRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.MailFolders.Item.ChildFolders.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,13 +23,12 @@ public class ChildFoldersRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MailFolderRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildMoveCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildMoveCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -43,7 +42,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -51,21 +50,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, bodyOption, outputOption); return command; } /// @@ -79,7 +77,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -114,7 +112,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string mailFolderId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -124,15 +126,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -193,31 +190,6 @@ public RequestInformation CreatePostRequestInformation(MailFolder body, Action - /// The collection of child folders in the mailFolder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of child folders in the mailFolder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MailFolder model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of child folders in the mailFolder. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/MailFolders/Item/ChildFolders/Delta/Delta.cs b/src/generated/Users/Item/MailFolders/Item/ChildFolders/Delta/Delta.cs deleted file mode 100644 index 1066191ab8f..00000000000 --- a/src/generated/Users/Item/MailFolders/Item/ChildFolders/Delta/Delta.cs +++ /dev/null @@ -1,69 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.MailFolders.Item.ChildFolders.Delta { - public class Delta : Entity, IParsable { - /// The number of immediate child mailFolders in the current mailFolder. - public int? ChildFolderCount { get; set; } - /// The collection of child folders in the mailFolder. - public List ChildFolders { get; set; } - /// The mailFolder's display name. - public string DisplayName { get; set; } - /// Indicates whether the mailFolder is hidden. This property can be set only when creating the folder. Find more information in Hidden mail folders. - public bool? IsHidden { get; set; } - /// The collection of rules that apply to the user's Inbox folder. - public List MessageRules { get; set; } - /// The collection of messages in the mailFolder. - public List Messages { get; set; } - /// The collection of multi-value extended properties defined for the mailFolder. Read-only. Nullable. - public List MultiValueExtendedProperties { get; set; } - /// The unique identifier for the mailFolder's parent mailFolder. - public string ParentFolderId { get; set; } - /// The collection of single-value extended properties defined for the mailFolder. Read-only. Nullable. - public List SingleValueExtendedProperties { get; set; } - /// The number of items in the mailFolder. - public int? TotalItemCount { get; set; } - /// The number of items in the mailFolder marked as unread. - public int? UnreadItemCount { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"childFolderCount", (o,n) => { (o as Delta).ChildFolderCount = n.GetIntValue(); } }, - {"childFolders", (o,n) => { (o as Delta).ChildFolders = n.GetCollectionOfObjectValues().ToList(); } }, - {"displayName", (o,n) => { (o as Delta).DisplayName = n.GetStringValue(); } }, - {"isHidden", (o,n) => { (o as Delta).IsHidden = n.GetBoolValue(); } }, - {"messageRules", (o,n) => { (o as Delta).MessageRules = n.GetCollectionOfObjectValues().ToList(); } }, - {"messages", (o,n) => { (o as Delta).Messages = n.GetCollectionOfObjectValues().ToList(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"parentFolderId", (o,n) => { (o as Delta).ParentFolderId = n.GetStringValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"totalItemCount", (o,n) => { (o as Delta).TotalItemCount = n.GetIntValue(); } }, - {"unreadItemCount", (o,n) => { (o as Delta).UnreadItemCount = n.GetIntValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteIntValue("childFolderCount", ChildFolderCount); - writer.WriteCollectionOfObjectValues("childFolders", ChildFolders); - writer.WriteStringValue("displayName", DisplayName); - writer.WriteBoolValue("isHidden", IsHidden); - writer.WriteCollectionOfObjectValues("messageRules", MessageRules); - writer.WriteCollectionOfObjectValues("messages", Messages); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteStringValue("parentFolderId", ParentFolderId); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteIntValue("totalItemCount", TotalItemCount); - writer.WriteIntValue("unreadItemCount", UnreadItemCount); - } - } -} diff --git a/src/generated/Users/Item/MailFolders/Item/ChildFolders/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/ChildFolders/Delta/DeltaRequestBuilder.cs index 6615a31df1f..bca20aed6bf 100644 --- a/src/generated/Users/Item/MailFolders/Item/ChildFolders/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/ChildFolders/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - command.SetHandler(async (string userId, string mailFolderId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, outputOption); return command; } /// @@ -75,16 +75,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/MailFolders/Item/ChildFolders/Item/Copy/CopyRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/ChildFolders/Item/Copy/CopyRequestBuilder.cs index de211369e3e..9ad2958c161 100644 --- a/src/generated/Users/Item/MailFolders/Item/ChildFolders/Item/Copy/CopyRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/ChildFolders/Item/Copy/CopyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var mailFolderId1Option = new Option("--mailfolder-id1", description: "key: id of mailFolder") { + var mailFolderId1Option = new Option("--mail-folder-id1", description: "key: id of mailFolder") { }; mailFolderId1Option.IsRequired = true; command.AddOption(mailFolderId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string mailFolderId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string mailFolderId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, mailFolderId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, mailFolderId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copy - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes mailFolder public class CopyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/MailFolders/Item/ChildFolders/Item/MailFolderRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/ChildFolders/Item/MailFolderRequestBuilder.cs index 541c82b7e89..b7d72ad5267 100644 --- a/src/generated/Users/Item/MailFolders/Item/ChildFolders/Item/MailFolderRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/ChildFolders/Item/MailFolderRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.MailFolders.Item.ChildFolders.Item.Move; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,19 +38,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var mailFolderId1Option = new Option("--mailfolder-id1", description: "key: id of mailFolder") { + var mailFolderId1Option = new Option("--mail-folder-id1", description: "key: id of mailFolder") { }; mailFolderId1Option.IsRequired = true; command.AddOption(mailFolderId1Option); - command.SetHandler(async (string userId, string mailFolderId, string mailFolderId1) => { + command.SetHandler(async (string userId, string mailFolderId, string mailFolderId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, mailFolderIdOption, mailFolderId1Option); return command; @@ -66,11 +65,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var mailFolderId1Option = new Option("--mailfolder-id1", description: "key: id of mailFolder") { + var mailFolderId1Option = new Option("--mail-folder-id1", description: "key: id of mailFolder") { }; mailFolderId1Option.IsRequired = true; command.AddOption(mailFolderId1Option); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string mailFolderId, string mailFolderId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string mailFolderId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, mailFolderId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, mailFolderId1Option, selectOption, expandOption, outputOption); return command; } public Command BuildMoveCommand() { @@ -117,11 +115,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var mailFolderId1Option = new Option("--mailfolder-id1", description: "key: id of mailFolder") { + var mailFolderId1Option = new Option("--mail-folder-id1", description: "key: id of mailFolder") { }; mailFolderId1Option.IsRequired = true; command.AddOption(mailFolderId1Option); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string mailFolderId1, string body) => { + command.SetHandler(async (string userId, string mailFolderId, string mailFolderId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, mailFolderIdOption, mailFolderId1Option, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(MailFolder body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of child folders in the mailFolder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of child folders in the mailFolder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of child folders in the mailFolder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MailFolder model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of child folders in the mailFolder. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/MailFolders/Item/ChildFolders/Item/Move/MoveRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/ChildFolders/Item/Move/MoveRequestBuilder.cs index 9b201fc29c3..0f2de1ae056 100644 --- a/src/generated/Users/Item/MailFolders/Item/ChildFolders/Item/Move/MoveRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/ChildFolders/Item/Move/MoveRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var mailFolderId1Option = new Option("--mailfolder-id1", description: "key: id of mailFolder") { + var mailFolderId1Option = new Option("--mail-folder-id1", description: "key: id of mailFolder") { }; mailFolderId1Option.IsRequired = true; command.AddOption(mailFolderId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string mailFolderId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string mailFolderId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, mailFolderId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, mailFolderId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(MoveRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action move - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MoveRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes mailFolder public class MoveResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/MailFolders/Item/Copy/CopyRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/Copy/CopyRequestBuilder.cs index 86fa26d5531..8a17f669693 100644 --- a/src/generated/Users/Item/MailFolders/Item/Copy/CopyRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/Copy/CopyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copy - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes mailFolder public class CopyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/MailFolders/Item/MailFolderRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/MailFolderRequestBuilder.cs index 4f615df8f20..81b59834427 100644 --- a/src/generated/Users/Item/MailFolders/Item/MailFolderRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/MailFolderRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Users.Item.MailFolders.Item.SingleValueExtendedProperties; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,6 +29,9 @@ public class MailFolderRequestBuilder { public Command BuildChildFoldersCommand() { var command = new Command("child-folders"); var builder = new ApiSdk.Users.Item.MailFolders.Item.ChildFolders.ChildFoldersRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -50,15 +53,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - command.SetHandler(async (string userId, string mailFolderId) => { + command.SetHandler(async (string userId, string mailFolderId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, mailFolderIdOption); return command; @@ -74,7 +76,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -83,24 +85,26 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string mailFolderId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, selectOption, outputOption); return command; } public Command BuildMessageRulesCommand() { var command = new Command("message-rules"); var builder = new ApiSdk.Users.Item.MailFolders.Item.MessageRules.MessageRulesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -108,6 +112,9 @@ public Command BuildMessageRulesCommand() { public Command BuildMessagesCommand() { var command = new Command("messages"); var builder = new ApiSdk.Users.Item.MailFolders.Item.Messages.MessagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -121,6 +128,9 @@ public Command BuildMoveCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Users.Item.MailFolders.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -136,7 +146,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -144,14 +154,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string body) => { + command.SetHandler(async (string userId, string mailFolderId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, mailFolderIdOption, bodyOption); return command; @@ -159,6 +168,9 @@ public Command BuildPatchCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Users.Item.MailFolders.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -230,42 +242,6 @@ public RequestInformation CreatePatchRequestInformation(MailFolder body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user's mail folders. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's mail folders. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's mail folders. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MailFolder model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's mail folders. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/MailFolders/Item/MessageRules/Item/MessageRuleRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/MessageRules/Item/MessageRuleRequestBuilder.cs index dd92305b1e5..85dc982fd9f 100644 --- a/src/generated/Users/Item/MailFolders/Item/MessageRules/Item/MessageRuleRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/MessageRules/Item/MessageRuleRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var messageRuleIdOption = new Option("--messagerule-id", description: "key: id of messageRule") { + var messageRuleIdOption = new Option("--message-rule-id", description: "key: id of messageRule") { }; messageRuleIdOption.IsRequired = true; command.AddOption(messageRuleIdOption); - command.SetHandler(async (string userId, string mailFolderId, string messageRuleId) => { + command.SetHandler(async (string userId, string mailFolderId, string messageRuleId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, mailFolderIdOption, messageRuleIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var messageRuleIdOption = new Option("--messagerule-id", description: "key: id of messageRule") { + var messageRuleIdOption = new Option("--message-rule-id", description: "key: id of messageRule") { }; messageRuleIdOption.IsRequired = true; command.AddOption(messageRuleIdOption); @@ -71,19 +70,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string mailFolderId, string messageRuleId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string messageRuleId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, messageRuleIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, messageRuleIdOption, selectOption, outputOption); return command; } /// @@ -97,11 +95,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var messageRuleIdOption = new Option("--messagerule-id", description: "key: id of messageRule") { + var messageRuleIdOption = new Option("--message-rule-id", description: "key: id of messageRule") { }; messageRuleIdOption.IsRequired = true; command.AddOption(messageRuleIdOption); @@ -109,14 +107,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string messageRuleId, string body) => { + command.SetHandler(async (string userId, string mailFolderId, string messageRuleId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, mailFolderIdOption, messageRuleIdOption, bodyOption); return command; @@ -188,42 +185,6 @@ public RequestInformation CreatePatchRequestInformation(MessageRule body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of rules that apply to the user's Inbox folder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of rules that apply to the user's Inbox folder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of rules that apply to the user's Inbox folder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MessageRule model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of rules that apply to the user's Inbox folder. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/MailFolders/Item/MessageRules/MessageRulesRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/MessageRules/MessageRulesRequestBuilder.cs index ceb707a3553..d78f69aa373 100644 --- a/src/generated/Users/Item/MailFolders/Item/MessageRules/MessageRulesRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/MessageRules/MessageRulesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.MailFolders.Item.MessageRules.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MessageRulesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MessageRuleRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -106,7 +104,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string mailFolderId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -115,15 +117,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -178,31 +175,6 @@ public RequestInformation CreatePostRequestInformation(MessageRule body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of rules that apply to the user's Inbox folder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of rules that apply to the user's Inbox folder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MessageRule model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of rules that apply to the user's Inbox folder. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/MailFolders/Item/Messages/Delta/Delta.cs b/src/generated/Users/Item/MailFolders/Item/Messages/Delta/Delta.cs deleted file mode 100644 index 5631bea6868..00000000000 --- a/src/generated/Users/Item/MailFolders/Item/Messages/Delta/Delta.cs +++ /dev/null @@ -1,128 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.MailFolders.Item.Messages.Delta { - public class Delta : OutlookItem, IParsable { - /// The fileAttachment and itemAttachment attachments for the message. - public List Attachments { get; set; } - /// The Bcc: recipients for the message. - public List BccRecipients { get; set; } - /// The body of the message. It can be in HTML or text format. Find out about safe HTML in a message body. - public ItemBody Body { get; set; } - /// The first 255 characters of the message body. It is in text format. If the message contains instances of mention, this property would contain a concatenation of these mentions as well. - public string BodyPreview { get; set; } - /// The Cc: recipients for the message. - public List CcRecipients { get; set; } - /// The ID of the conversation the email belongs to. - public string ConversationId { get; set; } - /// Indicates the position of the message within the conversation. - public byte[] ConversationIndex { get; set; } - /// The collection of open extensions defined for the message. Nullable. - public List Extensions { get; set; } - /// The flag value that indicates the status, start date, due date, or completion date for the message. - public FollowupFlag Flag { get; set; } - /// The owner of the mailbox from which the message is sent. In most cases, this value is the same as the sender property, except for sharing or delegation scenarios. The value must correspond to the actual mailbox used. Find out more about setting the from and sender properties of a message. - public Recipient From { get; set; } - /// Indicates whether the message has attachments. This property doesn't include inline attachments, so if a message contains only inline attachments, this property is false. To verify the existence of inline attachments, parse the body property to look for a src attribute, such as . - public bool? HasAttachments { get; set; } - public Importance? Importance { get; set; } - public InferenceClassificationType? InferenceClassification { get; set; } - public List InternetMessageHeaders { get; set; } - public string InternetMessageId { get; set; } - public bool? IsDeliveryReceiptRequested { get; set; } - public bool? IsDraft { get; set; } - public bool? IsRead { get; set; } - public bool? IsReadReceiptRequested { get; set; } - /// The collection of multi-value extended properties defined for the message. Nullable. - public List MultiValueExtendedProperties { get; set; } - public string ParentFolderId { get; set; } - public DateTimeOffset? ReceivedDateTime { get; set; } - public List ReplyTo { get; set; } - public Recipient Sender { get; set; } - public DateTimeOffset? SentDateTime { get; set; } - /// The collection of single-value extended properties defined for the message. Nullable. - public List SingleValueExtendedProperties { get; set; } - public string Subject { get; set; } - public List ToRecipients { get; set; } - public ItemBody UniqueBody { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"bccRecipients", (o,n) => { (o as Delta).BccRecipients = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"ccRecipients", (o,n) => { (o as Delta).CcRecipients = n.GetCollectionOfObjectValues().ToList(); } }, - {"conversationId", (o,n) => { (o as Delta).ConversationId = n.GetStringValue(); } }, - {"conversationIndex", (o,n) => { (o as Delta).ConversationIndex = n.GetByteArrayValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"flag", (o,n) => { (o as Delta).Flag = n.GetObjectValue(); } }, - {"from", (o,n) => { (o as Delta).From = n.GetObjectValue(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"inferenceClassification", (o,n) => { (o as Delta).InferenceClassification = n.GetEnumValue(); } }, - {"internetMessageHeaders", (o,n) => { (o as Delta).InternetMessageHeaders = n.GetCollectionOfObjectValues().ToList(); } }, - {"internetMessageId", (o,n) => { (o as Delta).InternetMessageId = n.GetStringValue(); } }, - {"isDeliveryReceiptRequested", (o,n) => { (o as Delta).IsDeliveryReceiptRequested = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isRead", (o,n) => { (o as Delta).IsRead = n.GetBoolValue(); } }, - {"isReadReceiptRequested", (o,n) => { (o as Delta).IsReadReceiptRequested = n.GetBoolValue(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"parentFolderId", (o,n) => { (o as Delta).ParentFolderId = n.GetStringValue(); } }, - {"receivedDateTime", (o,n) => { (o as Delta).ReceivedDateTime = n.GetDateTimeOffsetValue(); } }, - {"replyTo", (o,n) => { (o as Delta).ReplyTo = n.GetCollectionOfObjectValues().ToList(); } }, - {"sender", (o,n) => { (o as Delta).Sender = n.GetObjectValue(); } }, - {"sentDateTime", (o,n) => { (o as Delta).SentDateTime = n.GetDateTimeOffsetValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"toRecipients", (o,n) => { (o as Delta).ToRecipients = n.GetCollectionOfObjectValues().ToList(); } }, - {"uniqueBody", (o,n) => { (o as Delta).UniqueBody = n.GetObjectValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("bccRecipients", BccRecipients); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteCollectionOfObjectValues("ccRecipients", CcRecipients); - writer.WriteStringValue("conversationId", ConversationId); - writer.WriteByteArrayValue("conversationIndex", ConversationIndex); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteObjectValue("flag", Flag); - writer.WriteObjectValue("from", From); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteEnumValue("importance", Importance); - writer.WriteEnumValue("inferenceClassification", InferenceClassification); - writer.WriteCollectionOfObjectValues("internetMessageHeaders", InternetMessageHeaders); - writer.WriteStringValue("internetMessageId", InternetMessageId); - writer.WriteBoolValue("isDeliveryReceiptRequested", IsDeliveryReceiptRequested); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isRead", IsRead); - writer.WriteBoolValue("isReadReceiptRequested", IsReadReceiptRequested); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteStringValue("parentFolderId", ParentFolderId); - writer.WriteDateTimeOffsetValue("receivedDateTime", ReceivedDateTime); - writer.WriteCollectionOfObjectValues("replyTo", ReplyTo); - writer.WriteObjectValue("sender", Sender); - writer.WriteDateTimeOffsetValue("sentDateTime", SentDateTime); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteStringValue("subject", Subject); - writer.WriteCollectionOfObjectValues("toRecipients", ToRecipients); - writer.WriteObjectValue("uniqueBody", UniqueBody); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Users/Item/MailFolders/Item/Messages/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/Messages/Delta/DeltaRequestBuilder.cs index 36381908649..54a0a1ddf91 100644 --- a/src/generated/Users/Item/MailFolders/Item/Messages/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/Messages/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - command.SetHandler(async (string userId, string mailFolderId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, outputOption); return command; } /// @@ -75,16 +75,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/MailFolders/Item/Messages/Item/Attachments/AttachmentsRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/Messages/Item/Attachments/AttachmentsRequestBuilder.cs index 03f50c57ae8..cfb2c26ddc5 100644 --- a/src/generated/Users/Item/MailFolders/Item/Messages/Item/Attachments/AttachmentsRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/Messages/Item/Attachments/AttachmentsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.MailFolders.Item.Messages.Item.Attachments.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class AttachmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttachmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,7 +40,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, messageIdOption, bodyOption, outputOption); return command; } public Command BuildCreateUploadSessionCommand() { @@ -87,7 +85,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -126,7 +124,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string messageId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, messageIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, messageIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(Attachment body, Action - /// The fileAttachment and itemAttachment attachments for the message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The fileAttachment and itemAttachment attachments for the message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The fileAttachment and itemAttachment attachments for the message. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/MailFolders/Item/Messages/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/Messages/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index 862872b7f62..46c09362270 100644 --- a/src/generated/Users/Item/MailFolders/Item/Messages/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/Messages/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, messageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/MailFolders/Item/Messages/Item/Attachments/Item/AttachmentRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/Messages/Item/Attachments/Item/AttachmentRequestBuilder.cs index 1785e26ea6a..cebb45a2891 100644 --- a/src/generated/Users/Item/MailFolders/Item/Messages/Item/Attachments/Item/AttachmentRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/Messages/Item/Attachments/Item/AttachmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -42,11 +42,10 @@ public Command BuildDeleteCommand() { }; attachmentIdOption.IsRequired = true; command.AddOption(attachmentIdOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, string attachmentId) => { + command.SetHandler(async (string userId, string mailFolderId, string messageId, string attachmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, mailFolderIdOption, messageIdOption, attachmentIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, string attachmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string messageId, string attachmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, messageIdOption, attachmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, messageIdOption, attachmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,7 +109,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, string attachmentId, string body) => { + command.SetHandler(async (string userId, string mailFolderId, string messageId, string attachmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, mailFolderIdOption, messageIdOption, attachmentIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(Attachment body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The fileAttachment and itemAttachment attachments for the message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The fileAttachment and itemAttachment attachments for the message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The fileAttachment and itemAttachment attachments for the message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The fileAttachment and itemAttachment attachments for the message. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/MailFolders/Item/Messages/Item/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/Messages/Item/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs index 6cc71ff2ec7..48160dbd10b 100644 --- a/src/generated/Users/Item/MailFolders/Item/Messages/Item/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/Messages/Item/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -38,18 +38,17 @@ public Command BuildPostCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string messageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, messageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, messageIdOption, outputOption); return command; } /// @@ -80,16 +79,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/MailFolders/Item/Messages/Item/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/Messages/Item/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs index 89990538464..470021d2b7f 100644 --- a/src/generated/Users/Item/MailFolders/Item/Messages/Item/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/Messages/Item/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Users.Item.MailFolders.Item.Messages.Item.CalendarSharingMessage.Accept; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/MailFolders/Item/Messages/Item/Copy/CopyRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/Messages/Item/Copy/CopyRequestBuilder.cs index a5cb98ef210..8fbf764b8d7 100644 --- a/src/generated/Users/Item/MailFolders/Item/Messages/Item/Copy/CopyRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/Messages/Item/Copy/CopyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, messageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copy - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes message public class CopyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/MailFolders/Item/Messages/Item/CreateForward/CreateForwardRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/Messages/Item/CreateForward/CreateForwardRequestBuilder.cs index d936649e512..0119e856638 100644 --- a/src/generated/Users/Item/MailFolders/Item/Messages/Item/CreateForward/CreateForwardRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/Messages/Item/CreateForward/CreateForwardRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, messageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CreateForwardRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createForward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes message public class CreateForwardResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/MailFolders/Item/Messages/Item/CreateReply/CreateReplyRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/Messages/Item/CreateReply/CreateReplyRequestBuilder.cs index 0ec7bdf9b8a..b8b9a1763de 100644 --- a/src/generated/Users/Item/MailFolders/Item/Messages/Item/CreateReply/CreateReplyRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/Messages/Item/CreateReply/CreateReplyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, messageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CreateReplyRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createReply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateReplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes message public class CreateReplyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/MailFolders/Item/Messages/Item/CreateReplyAll/CreateReplyAllRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/Messages/Item/CreateReplyAll/CreateReplyAllRequestBuilder.cs index a84020b72ce..416813a6cb7 100644 --- a/src/generated/Users/Item/MailFolders/Item/Messages/Item/CreateReplyAll/CreateReplyAllRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/Messages/Item/CreateReplyAll/CreateReplyAllRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, messageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CreateReplyAllRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createReplyAll - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateReplyAllRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes message public class CreateReplyAllResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/MailFolders/Item/Messages/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/Messages/Item/Extensions/ExtensionsRequestBuilder.cs index 60902f13379..10ad26b4e65 100644 --- a/src/generated/Users/Item/MailFolders/Item/Messages/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/Messages/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.MailFolders.Item.Messages.Item.Extensions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, messageIdOption, bodyOption, outputOption); return command; } /// @@ -80,7 +78,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string messageId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -129,15 +131,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, messageIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, messageIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the message. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/MailFolders/Item/Messages/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/Messages/Item/Extensions/Item/ExtensionRequestBuilder.cs index fd40e59b951..e96a5466b49 100644 --- a/src/generated/Users/Item/MailFolders/Item/Messages/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/Messages/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -42,11 +42,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, string extensionId) => { + command.SetHandler(async (string userId, string mailFolderId, string messageId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, mailFolderIdOption, messageIdOption, extensionIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string messageId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, messageIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, messageIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,7 +109,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, string extensionId, string body) => { + command.SetHandler(async (string userId, string mailFolderId, string messageId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, mailFolderIdOption, messageIdOption, extensionIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the message. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/MailFolders/Item/Messages/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/Messages/Item/Forward/ForwardRequestBuilder.cs index 9294dea765c..3dc1d460947 100644 --- a/src/generated/Users/Item/MailFolders/Item/Messages/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/Messages/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, string body) => { + command.SetHandler(async (string userId, string mailFolderId, string messageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, mailFolderIdOption, messageIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/MailFolders/Item/Messages/Item/MessageRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/Messages/Item/MessageRequestBuilder.cs index 6206e71da82..e2730a9fc4b 100644 --- a/src/generated/Users/Item/MailFolders/Item/Messages/Item/MessageRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/Messages/Item/MessageRequestBuilder.cs @@ -16,10 +16,10 @@ using ApiSdk.Users.Item.MailFolders.Item.Messages.Item.Value; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,6 +37,9 @@ public class MessageRequestBuilder { public Command BuildAttachmentsCommand() { var command = new Command("attachments"); var builder = new ApiSdk.Users.Item.MailFolders.Item.Messages.Item.Attachments.AttachmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateUploadSessionCommand()); command.AddCommand(builder.BuildListCommand()); @@ -90,7 +93,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -98,11 +101,10 @@ public Command BuildDeleteCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId) => { + command.SetHandler(async (string userId, string mailFolderId, string messageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, mailFolderIdOption, messageIdOption); return command; @@ -110,6 +112,9 @@ public Command BuildDeleteCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Users.Item.MailFolders.Item.Messages.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -131,7 +136,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -149,20 +154,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string messageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, messageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, messageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildMoveCommand() { @@ -174,6 +178,9 @@ public Command BuildMoveCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Users.Item.MailFolders.Item.Messages.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -189,7 +196,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -201,14 +208,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, string body) => { + command.SetHandler(async (string userId, string mailFolderId, string messageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, mailFolderIdOption, messageIdOption, bodyOption); return command; @@ -234,6 +240,9 @@ public Command BuildSendCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Users.Item.MailFolders.Item.Messages.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -305,42 +314,6 @@ public RequestInformation CreatePatchRequestInformation(Message body, Action - /// The collection of messages in the mailFolder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of messages in the mailFolder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of messages in the mailFolder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Message model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of messages in the mailFolder. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/MailFolders/Item/Messages/Item/Move/MoveRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/Messages/Item/Move/MoveRequestBuilder.cs index f45bba8568d..1097bd324a4 100644 --- a/src/generated/Users/Item/MailFolders/Item/Messages/Item/Move/MoveRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/Messages/Item/Move/MoveRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, messageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(MoveRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action move - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MoveRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes message public class MoveResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/MailFolders/Item/Messages/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/Messages/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 6781d28d4bc..72d6eb9ac14 100644 --- a/src/generated/Users/Item/MailFolders/Item/Messages/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/Messages/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string mailFolderId, string messageId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, mailFolderIdOption, messageIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -70,7 +69,7 @@ public Command BuildGetCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string messageId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, messageIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, messageIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,7 +109,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -119,7 +117,7 @@ public Command BuildPatchCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string mailFolderId, string messageId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, mailFolderIdOption, messageIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the message. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/MailFolders/Item/Messages/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/Messages/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index d7fcc56f0bc..f86b61acd1d 100644 --- a/src/generated/Users/Item/MailFolders/Item/Messages/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/Messages/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.MailFolders.Item.Messages.Item.MultiValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, messageIdOption, bodyOption, outputOption); return command; } /// @@ -80,7 +78,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string messageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, messageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, messageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the message. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/MailFolders/Item/Messages/Item/Reply/ReplyRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/Messages/Item/Reply/ReplyRequestBuilder.cs index ed0e6b8a5da..90b45ad1a3e 100644 --- a/src/generated/Users/Item/MailFolders/Item/Messages/Item/Reply/ReplyRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/Messages/Item/Reply/ReplyRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, string body) => { + command.SetHandler(async (string userId, string mailFolderId, string messageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, mailFolderIdOption, messageIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ReplyRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action reply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ReplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/MailFolders/Item/Messages/Item/ReplyAll/ReplyAllRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/Messages/Item/ReplyAll/ReplyAllRequestBuilder.cs index 90d700d2798..3f49e5b5855 100644 --- a/src/generated/Users/Item/MailFolders/Item/Messages/Item/ReplyAll/ReplyAllRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/Messages/Item/ReplyAll/ReplyAllRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, string body) => { + command.SetHandler(async (string userId, string mailFolderId, string messageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, mailFolderIdOption, messageIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ReplyAllRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action replyAll - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ReplyAllRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/MailFolders/Item/Messages/Item/Send/SendRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/Messages/Item/Send/SendRequestBuilder.cs index a75ab8ef115..a85a08171e2 100644 --- a/src/generated/Users/Item/MailFolders/Item/Messages/Item/Send/SendRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/Messages/Item/Send/SendRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -37,11 +37,10 @@ public Command BuildPostCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId) => { + command.SetHandler(async (string userId, string mailFolderId, string messageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, mailFolderIdOption, messageIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action send - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/MailFolders/Item/Messages/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/Messages/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 0590abbcc72..ec378503386 100644 --- a/src/generated/Users/Item/MailFolders/Item/Messages/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/Messages/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string mailFolderId, string messageId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, mailFolderIdOption, messageIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -70,7 +69,7 @@ public Command BuildGetCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string messageId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, messageIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, messageIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,7 +109,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -119,7 +117,7 @@ public Command BuildPatchCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string mailFolderId, string messageId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, mailFolderIdOption, messageIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the message. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/MailFolders/Item/Messages/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/Messages/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 47bda7e0bc2..4a0b0b220b2 100644 --- a/src/generated/Users/Item/MailFolders/Item/Messages/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/Messages/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.MailFolders.Item.Messages.Item.SingleValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, messageIdOption, bodyOption, outputOption); return command; } /// @@ -80,7 +78,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string messageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, messageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, messageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the message. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/MailFolders/Item/Messages/Item/Value/ContentRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/Messages/Item/Value/ContentRequestBuilder.cs index e0fb409e987..2dd17f29a8b 100644 --- a/src/generated/Users/Item/MailFolders/Item/Messages/Item/Value/ContentRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/Messages/Item/Value/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -37,24 +37,26 @@ public Command BuildGetCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, FileInfo output) => { + command.SetHandler(async (string userId, string mailFolderId, string messageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, userIdOption, mailFolderIdOption, messageIdOption, outputOption); + }, userIdOption, mailFolderIdOption, messageIdOption, fileOption, outputOption); return command; } /// @@ -68,7 +70,7 @@ public Command BuildPutCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -80,12 +82,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string messageId, FileInfo file) => { + command.SetHandler(async (string userId, string mailFolderId, string messageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, mailFolderIdOption, messageIdOption, bodyOption); return command; @@ -136,29 +137,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property messages from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property messages in users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/MailFolders/Item/Messages/MessagesRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/Messages/MessagesRequestBuilder.cs index c9846076451..6a387339181 100644 --- a/src/generated/Users/Item/MailFolders/Item/Messages/MessagesRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/Messages/MessagesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.MailFolders.Item.Messages.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,26 +23,25 @@ public class MessagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MessageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAttachmentsCommand(), - builder.BuildCalendarSharingMessageCommand(), - builder.BuildContentCommand(), - builder.BuildCopyCommand(), - builder.BuildCreateForwardCommand(), - builder.BuildCreateReplyAllCommand(), - builder.BuildCreateReplyCommand(), - builder.BuildDeleteCommand(), - builder.BuildExtensionsCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildMoveCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildReplyAllCommand(), - builder.BuildReplyCommand(), - builder.BuildSendCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAttachmentsCommand()); + commands.Add(builder.BuildCalendarSharingMessageCommand()); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyCommand()); + commands.Add(builder.BuildCreateForwardCommand()); + commands.Add(builder.BuildCreateReplyAllCommand()); + commands.Add(builder.BuildCreateReplyCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildMoveCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildReplyAllCommand()); + commands.Add(builder.BuildReplyCommand()); + commands.Add(builder.BuildSendCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); return commands; } /// @@ -56,7 +55,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -64,21 +63,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, bodyOption, outputOption); return command; } /// @@ -92,7 +90,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -131,7 +129,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string mailFolderId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -142,15 +144,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -211,31 +208,6 @@ public RequestInformation CreatePostRequestInformation(Message body, Action - /// The collection of messages in the mailFolder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of messages in the mailFolder. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Message model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of messages in the mailFolder. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/MailFolders/Item/Move/MoveRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/Move/MoveRequestBuilder.cs index 6044f7f4ba7..7c4d53c3f14 100644 --- a/src/generated/Users/Item/MailFolders/Item/Move/MoveRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/Move/MoveRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(MoveRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action move - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MoveRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes mailFolder public class MoveResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/MailFolders/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index 2bb716f4629..d40ee4c6cc4 100644 --- a/src/generated/Users/Item/MailFolders/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string mailFolderId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string mailFolderId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, mailFolderIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string mailFolderId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string mailFolderId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, mailFolderIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the mailFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the mailFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the mailFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the mailFolder. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/MailFolders/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index a2bafa29176..07a99989220 100644 --- a/src/generated/Users/Item/MailFolders/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.MailFolders.Item.MultiValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string mailFolderId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the mailFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the mailFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the mailFolder. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/MailFolders/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index 6ca142e66b1..9a2b4bcaf3c 100644 --- a/src/generated/Users/Item/MailFolders/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string mailFolderId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string mailFolderId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, mailFolderIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string mailFolderId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string mailFolderId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, mailFolderIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the mailFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the mailFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the mailFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the mailFolder. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/MailFolders/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/MailFolders/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index e993b9a3e73..76ca8d9d1f4 100644 --- a/src/generated/Users/Item/MailFolders/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.MailFolders.Item.SingleValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string mailFolderId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var mailFolderIdOption = new Option("--mailfolder-id", description: "key: id of mailFolder") { + var mailFolderIdOption = new Option("--mail-folder-id", description: "key: id of mailFolder") { }; mailFolderIdOption.IsRequired = true; command.AddOption(mailFolderIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string mailFolderId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string mailFolderId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, mailFolderIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, mailFolderIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the mailFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the mailFolder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the mailFolder. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/MailFolders/MailFoldersRequestBuilder.cs b/src/generated/Users/Item/MailFolders/MailFoldersRequestBuilder.cs index f2fae86591f..9e340d61cc8 100644 --- a/src/generated/Users/Item/MailFolders/MailFoldersRequestBuilder.cs +++ b/src/generated/Users/Item/MailFolders/MailFoldersRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.MailFolders.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,18 +23,17 @@ public class MailFoldersRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MailFolderRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildChildFoldersCommand(), - builder.BuildCopyCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildMessageRulesCommand(), - builder.BuildMessagesCommand(), - builder.BuildMoveCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildChildFoldersCommand()); + commands.Add(builder.BuildCopyCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildMessageRulesCommand()); + commands.Add(builder.BuildMessagesCommand()); + commands.Add(builder.BuildMoveCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); return commands; } /// @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -106,7 +104,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -115,15 +117,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(MailFolder body, Action - /// The user's mail folders. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's mail folders. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MailFolder model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's mail folders. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/ManagedAppRegistrations/@Ref/@Ref.cs b/src/generated/Users/Item/ManagedAppRegistrations/@Ref/@Ref.cs deleted file mode 100644 index 61fa305263c..00000000000 --- a/src/generated/Users/Item/ManagedAppRegistrations/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.ManagedAppRegistrations.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/ManagedAppRegistrations/@Ref/RefRequestBuilder.cs b/src/generated/Users/Item/ManagedAppRegistrations/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 5ac7c9642b2..00000000000 --- a/src/generated/Users/Item/ManagedAppRegistrations/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Users.Item.ManagedAppRegistrations.@Ref { - /// Builds and executes requests for operations under \users\{user-id}\managedAppRegistrations\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Zero or more managed app registrations that belong to the user. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Zero or more managed app registrations that belong to the user."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Zero or more managed app registrations that belong to the user. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Zero or more managed app registrations that belong to the user."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/managedAppRegistrations/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Zero or more managed app registrations that belong to the user. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Zero or more managed app registrations that belong to the user. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Users.Item.ManagedAppRegistrations.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Zero or more managed app registrations that belong to the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Zero or more managed app registrations that belong to the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Users.Item.ManagedAppRegistrations.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Zero or more managed app registrations that belong to the user. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Users/Item/ManagedAppRegistrations/@Ref/RefResponse.cs b/src/generated/Users/Item/ManagedAppRegistrations/@Ref/RefResponse.cs deleted file mode 100644 index 108e71a4607..00000000000 --- a/src/generated/Users/Item/ManagedAppRegistrations/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.ManagedAppRegistrations.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/ManagedAppRegistrations/GetUserIdsWithFlaggedAppRegistration/GetUserIdsWithFlaggedAppRegistrationRequestBuilder.cs b/src/generated/Users/Item/ManagedAppRegistrations/GetUserIdsWithFlaggedAppRegistration/GetUserIdsWithFlaggedAppRegistrationRequestBuilder.cs index 3d6ef57641b..28db8c273c8 100644 --- a/src/generated/Users/Item/ManagedAppRegistrations/GetUserIdsWithFlaggedAppRegistration/GetUserIdsWithFlaggedAppRegistrationRequestBuilder.cs +++ b/src/generated/Users/Item/ManagedAppRegistrations/GetUserIdsWithFlaggedAppRegistration/GetUserIdsWithFlaggedAppRegistrationRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +29,17 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfPrimitiveValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getUserIdsWithFlaggedAppRegistration - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/ManagedAppRegistrations/ManagedAppRegistrationsRequestBuilder.cs b/src/generated/Users/Item/ManagedAppRegistrations/ManagedAppRegistrationsRequestBuilder.cs index 608fc805aca..e465bd2ef59 100644 --- a/src/generated/Users/Item/ManagedAppRegistrations/ManagedAppRegistrationsRequestBuilder.cs +++ b/src/generated/Users/Item/ManagedAppRegistrations/ManagedAppRegistrationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.ManagedAppRegistrations.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -66,7 +66,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -77,20 +81,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Users.Item.ManagedAppRegistrations.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Users.Item.ManagedAppRegistrations.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -130,18 +129,6 @@ public RequestInformation CreateGetRequestInformation(Action return requestInfo; } /// - /// Zero or more managed app registrations that belong to the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \users\{user-id}\managedAppRegistrations\microsoft.graph.getUserIdsWithFlaggedAppRegistration() /// public GetUserIdsWithFlaggedAppRegistrationRequestBuilder GetUserIdsWithFlaggedAppRegistration() { diff --git a/src/generated/Users/Item/ManagedAppRegistrations/Ref/Ref.cs b/src/generated/Users/Item/ManagedAppRegistrations/Ref/Ref.cs new file mode 100644 index 00000000000..8d04155aed7 --- /dev/null +++ b/src/generated/Users/Item/ManagedAppRegistrations/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.ManagedAppRegistrations.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/ManagedAppRegistrations/Ref/RefRequestBuilder.cs b/src/generated/Users/Item/ManagedAppRegistrations/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..9e96c8a5806 --- /dev/null +++ b/src/generated/Users/Item/ManagedAppRegistrations/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Users.Item.ManagedAppRegistrations.Ref { + /// Builds and executes requests for operations under \users\{user-id}\managedAppRegistrations\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Zero or more managed app registrations that belong to the user. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Zero or more managed app registrations that belong to the user."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Zero or more managed app registrations that belong to the user. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Zero or more managed app registrations that belong to the user."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/users/{user_id}/managedAppRegistrations/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Zero or more managed app registrations that belong to the user. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Zero or more managed app registrations that belong to the user. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Users.Item.ManagedAppRegistrations.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Zero or more managed app registrations that belong to the user. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Users/Item/ManagedAppRegistrations/Ref/RefResponse.cs b/src/generated/Users/Item/ManagedAppRegistrations/Ref/RefResponse.cs new file mode 100644 index 00000000000..c08e7aec237 --- /dev/null +++ b/src/generated/Users/Item/ManagedAppRegistrations/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.ManagedAppRegistrations.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/ManagedDevices/Item/BypassActivationLock/BypassActivationLockRequestBuilder.cs b/src/generated/Users/Item/ManagedDevices/Item/BypassActivationLock/BypassActivationLockRequestBuilder.cs index fcef65259ca..8fdaca00f53 100644 --- a/src/generated/Users/Item/ManagedDevices/Item/BypassActivationLock/BypassActivationLockRequestBuilder.cs +++ b/src/generated/Users/Item/ManagedDevices/Item/BypassActivationLock/BypassActivationLockRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string userId, string managedDeviceId) => { + command.SetHandler(async (string userId, string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, managedDeviceIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Bypass activation lock - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/ManagedDevices/Item/CleanWindowsDevice/CleanWindowsDeviceRequestBuilder.cs b/src/generated/Users/Item/ManagedDevices/Item/CleanWindowsDevice/CleanWindowsDeviceRequestBuilder.cs index e5351ffa8cf..2efe5919afb 100644 --- a/src/generated/Users/Item/ManagedDevices/Item/CleanWindowsDevice/CleanWindowsDeviceRequestBuilder.cs +++ b/src/generated/Users/Item/ManagedDevices/Item/CleanWindowsDevice/CleanWindowsDeviceRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string managedDeviceId, string body) => { + command.SetHandler(async (string userId, string managedDeviceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, managedDeviceIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(CleanWindowsDeviceRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Clean Windows device - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CleanWindowsDeviceRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/ManagedDevices/Item/DeleteUserFromSharedAppleDevice/DeleteUserFromSharedAppleDeviceRequestBuilder.cs b/src/generated/Users/Item/ManagedDevices/Item/DeleteUserFromSharedAppleDevice/DeleteUserFromSharedAppleDeviceRequestBuilder.cs index 755f1a999fd..12d8760c0d0 100644 --- a/src/generated/Users/Item/ManagedDevices/Item/DeleteUserFromSharedAppleDevice/DeleteUserFromSharedAppleDeviceRequestBuilder.cs +++ b/src/generated/Users/Item/ManagedDevices/Item/DeleteUserFromSharedAppleDevice/DeleteUserFromSharedAppleDeviceRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string managedDeviceId, string body) => { + command.SetHandler(async (string userId, string managedDeviceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, managedDeviceIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(DeleteUserFromSharedApple requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete user from shared Apple device - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeleteUserFromSharedAppleDeviceRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/ManagedDevices/Item/DeviceCategory/DeviceCategoryRequestBuilder.cs b/src/generated/Users/Item/ManagedDevices/Item/DeviceCategory/DeviceCategoryRequestBuilder.cs index 955113cd368..b511186081b 100644 --- a/src/generated/Users/Item/ManagedDevices/Item/DeviceCategory/DeviceCategoryRequestBuilder.cs +++ b/src/generated/Users/Item/ManagedDevices/Item/DeviceCategory/DeviceCategoryRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string userId, string managedDeviceId) => { + command.SetHandler(async (string userId, string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, managedDeviceIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string managedDeviceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string managedDeviceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, managedDeviceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, managedDeviceIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string managedDeviceId, string body) => { + command.SetHandler(async (string userId, string managedDeviceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, managedDeviceIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Device category - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device category - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device category - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DeviceCategory model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Device category public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/ManagedDevices/Item/DeviceCompliancePolicyStates/DeviceCompliancePolicyStatesRequestBuilder.cs b/src/generated/Users/Item/ManagedDevices/Item/DeviceCompliancePolicyStates/DeviceCompliancePolicyStatesRequestBuilder.cs index 66afdff2fa7..3c3b6c6a2bc 100644 --- a/src/generated/Users/Item/ManagedDevices/Item/DeviceCompliancePolicyStates/DeviceCompliancePolicyStatesRequestBuilder.cs +++ b/src/generated/Users/Item/ManagedDevices/Item/DeviceCompliancePolicyStates/DeviceCompliancePolicyStatesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.ManagedDevices.Item.DeviceCompliancePolicyStates.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DeviceCompliancePolicyStatesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceCompliancePolicyStateRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string managedDeviceId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string managedDeviceId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, managedDeviceIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, managedDeviceIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string managedDeviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string managedDeviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, managedDeviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, managedDeviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(DeviceCompliancePolicySta requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Device compliance policy states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device compliance policy states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceCompliancePolicyState model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Device compliance policy states for this device. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/ManagedDevices/Item/DeviceCompliancePolicyStates/Item/DeviceCompliancePolicyStateRequestBuilder.cs b/src/generated/Users/Item/ManagedDevices/Item/DeviceCompliancePolicyStates/Item/DeviceCompliancePolicyStateRequestBuilder.cs index a33733da1a2..71e553a6972 100644 --- a/src/generated/Users/Item/ManagedDevices/Item/DeviceCompliancePolicyStates/Item/DeviceCompliancePolicyStateRequestBuilder.cs +++ b/src/generated/Users/Item/ManagedDevices/Item/DeviceCompliancePolicyStates/Item/DeviceCompliancePolicyStateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - var deviceCompliancePolicyStateIdOption = new Option("--devicecompliancepolicystate-id", description: "key: id of deviceCompliancePolicyState") { + var deviceCompliancePolicyStateIdOption = new Option("--device-compliance-policy-state-id", description: "key: id of deviceCompliancePolicyState") { }; deviceCompliancePolicyStateIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyStateIdOption); - command.SetHandler(async (string userId, string managedDeviceId, string deviceCompliancePolicyStateId) => { + command.SetHandler(async (string userId, string managedDeviceId, string deviceCompliancePolicyStateId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, managedDeviceIdOption, deviceCompliancePolicyStateIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - var deviceCompliancePolicyStateIdOption = new Option("--devicecompliancepolicystate-id", description: "key: id of deviceCompliancePolicyState") { + var deviceCompliancePolicyStateIdOption = new Option("--device-compliance-policy-state-id", description: "key: id of deviceCompliancePolicyState") { }; deviceCompliancePolicyStateIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyStateIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string managedDeviceId, string deviceCompliancePolicyStateId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string managedDeviceId, string deviceCompliancePolicyStateId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, managedDeviceIdOption, deviceCompliancePolicyStateIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, managedDeviceIdOption, deviceCompliancePolicyStateIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - var deviceCompliancePolicyStateIdOption = new Option("--devicecompliancepolicystate-id", description: "key: id of deviceCompliancePolicyState") { + var deviceCompliancePolicyStateIdOption = new Option("--device-compliance-policy-state-id", description: "key: id of deviceCompliancePolicyState") { }; deviceCompliancePolicyStateIdOption.IsRequired = true; command.AddOption(deviceCompliancePolicyStateIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string managedDeviceId, string deviceCompliancePolicyStateId, string body) => { + command.SetHandler(async (string userId, string managedDeviceId, string deviceCompliancePolicyStateId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, managedDeviceIdOption, deviceCompliancePolicyStateIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceCompliancePolicySt requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Device compliance policy states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device compliance policy states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device compliance policy states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceCompliancePolicyState model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Device compliance policy states for this device. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/ManagedDevices/Item/DeviceConfigurationStates/DeviceConfigurationStatesRequestBuilder.cs b/src/generated/Users/Item/ManagedDevices/Item/DeviceConfigurationStates/DeviceConfigurationStatesRequestBuilder.cs index 7f0198fceb2..15e2206a77e 100644 --- a/src/generated/Users/Item/ManagedDevices/Item/DeviceConfigurationStates/DeviceConfigurationStatesRequestBuilder.cs +++ b/src/generated/Users/Item/ManagedDevices/Item/DeviceConfigurationStates/DeviceConfigurationStatesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.ManagedDevices.Item.DeviceConfigurationStates.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class DeviceConfigurationStatesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DeviceConfigurationStateRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string managedDeviceId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string managedDeviceId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, managedDeviceIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, managedDeviceIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string managedDeviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string managedDeviceId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, managedDeviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, managedDeviceIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(DeviceConfigurationState requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Device configuration states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device configuration states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeviceConfigurationState model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Device configuration states for this device. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/ManagedDevices/Item/DeviceConfigurationStates/Item/DeviceConfigurationStateRequestBuilder.cs b/src/generated/Users/Item/ManagedDevices/Item/DeviceConfigurationStates/Item/DeviceConfigurationStateRequestBuilder.cs index f3a2b96105c..e8151ece768 100644 --- a/src/generated/Users/Item/ManagedDevices/Item/DeviceConfigurationStates/Item/DeviceConfigurationStateRequestBuilder.cs +++ b/src/generated/Users/Item/ManagedDevices/Item/DeviceConfigurationStates/Item/DeviceConfigurationStateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - var deviceConfigurationStateIdOption = new Option("--deviceconfigurationstate-id", description: "key: id of deviceConfigurationState") { + var deviceConfigurationStateIdOption = new Option("--device-configuration-state-id", description: "key: id of deviceConfigurationState") { }; deviceConfigurationStateIdOption.IsRequired = true; command.AddOption(deviceConfigurationStateIdOption); - command.SetHandler(async (string userId, string managedDeviceId, string deviceConfigurationStateId) => { + command.SetHandler(async (string userId, string managedDeviceId, string deviceConfigurationStateId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, managedDeviceIdOption, deviceConfigurationStateIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - var deviceConfigurationStateIdOption = new Option("--deviceconfigurationstate-id", description: "key: id of deviceConfigurationState") { + var deviceConfigurationStateIdOption = new Option("--device-configuration-state-id", description: "key: id of deviceConfigurationState") { }; deviceConfigurationStateIdOption.IsRequired = true; command.AddOption(deviceConfigurationStateIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string managedDeviceId, string deviceConfigurationStateId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string managedDeviceId, string deviceConfigurationStateId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, managedDeviceIdOption, deviceConfigurationStateIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, managedDeviceIdOption, deviceConfigurationStateIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - var deviceConfigurationStateIdOption = new Option("--deviceconfigurationstate-id", description: "key: id of deviceConfigurationState") { + var deviceConfigurationStateIdOption = new Option("--device-configuration-state-id", description: "key: id of deviceConfigurationState") { }; deviceConfigurationStateIdOption.IsRequired = true; command.AddOption(deviceConfigurationStateIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string managedDeviceId, string deviceConfigurationStateId, string body) => { + command.SetHandler(async (string userId, string managedDeviceId, string deviceConfigurationStateId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, managedDeviceIdOption, deviceConfigurationStateIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(DeviceConfigurationState requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Device configuration states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device configuration states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Device configuration states for this device. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DeviceConfigurationState model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Device configuration states for this device. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/ManagedDevices/Item/DisableLostMode/DisableLostModeRequestBuilder.cs b/src/generated/Users/Item/ManagedDevices/Item/DisableLostMode/DisableLostModeRequestBuilder.cs index 76961ba102c..bac30e3c2b6 100644 --- a/src/generated/Users/Item/ManagedDevices/Item/DisableLostMode/DisableLostModeRequestBuilder.cs +++ b/src/generated/Users/Item/ManagedDevices/Item/DisableLostMode/DisableLostModeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string userId, string managedDeviceId) => { + command.SetHandler(async (string userId, string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, managedDeviceIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Disable lost mode - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/ManagedDevices/Item/LocateDevice/LocateDeviceRequestBuilder.cs b/src/generated/Users/Item/ManagedDevices/Item/LocateDevice/LocateDeviceRequestBuilder.cs index cfee5c9dd3a..c09abae5578 100644 --- a/src/generated/Users/Item/ManagedDevices/Item/LocateDevice/LocateDeviceRequestBuilder.cs +++ b/src/generated/Users/Item/ManagedDevices/Item/LocateDevice/LocateDeviceRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string userId, string managedDeviceId) => { + command.SetHandler(async (string userId, string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, managedDeviceIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Locate a device - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/ManagedDevices/Item/LogoutSharedAppleDeviceActiveUser/LogoutSharedAppleDeviceActiveUserRequestBuilder.cs b/src/generated/Users/Item/ManagedDevices/Item/LogoutSharedAppleDeviceActiveUser/LogoutSharedAppleDeviceActiveUserRequestBuilder.cs index ea51ab79235..56659a5efab 100644 --- a/src/generated/Users/Item/ManagedDevices/Item/LogoutSharedAppleDeviceActiveUser/LogoutSharedAppleDeviceActiveUserRequestBuilder.cs +++ b/src/generated/Users/Item/ManagedDevices/Item/LogoutSharedAppleDeviceActiveUser/LogoutSharedAppleDeviceActiveUserRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string userId, string managedDeviceId) => { + command.SetHandler(async (string userId, string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, managedDeviceIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Logout shared Apple device active user - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/ManagedDevices/Item/ManagedDeviceRequestBuilder.cs b/src/generated/Users/Item/ManagedDevices/Item/ManagedDeviceRequestBuilder.cs index 4ec687e6817..3569fe8a211 100644 --- a/src/generated/Users/Item/ManagedDevices/Item/ManagedDeviceRequestBuilder.cs +++ b/src/generated/Users/Item/ManagedDevices/Item/ManagedDeviceRequestBuilder.cs @@ -22,10 +22,10 @@ using ApiSdk.Users.Item.ManagedDevices.Item.Wipe; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -63,15 +63,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string userId, string managedDeviceId) => { + command.SetHandler(async (string userId, string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, managedDeviceIdOption); return command; @@ -93,6 +92,9 @@ public Command BuildDeviceCategoryCommand() { public Command BuildDeviceCompliancePolicyStatesCommand() { var command = new Command("device-compliance-policy-states"); var builder = new ApiSdk.Users.Item.ManagedDevices.Item.DeviceCompliancePolicyStates.DeviceCompliancePolicyStatesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -100,6 +102,9 @@ public Command BuildDeviceCompliancePolicyStatesCommand() { public Command BuildDeviceConfigurationStatesCommand() { var command = new Command("device-configuration-states"); var builder = new ApiSdk.Users.Item.ManagedDevices.Item.DeviceConfigurationStates.DeviceConfigurationStatesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -121,7 +126,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -135,20 +140,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string managedDeviceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string managedDeviceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, managedDeviceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, managedDeviceIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLocateDeviceCommand() { @@ -174,7 +178,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -182,14 +186,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string managedDeviceId, string body) => { + command.SetHandler(async (string userId, string managedDeviceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, managedDeviceIdOption, bodyOption); return command; @@ -333,42 +336,6 @@ public RequestInformation CreatePatchRequestInformation(ManagedDevice body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The managed devices associated with the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The managed devices associated with the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The managed devices associated with the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ManagedDevice model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The managed devices associated with the user. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/ManagedDevices/Item/RebootNow/RebootNowRequestBuilder.cs b/src/generated/Users/Item/ManagedDevices/Item/RebootNow/RebootNowRequestBuilder.cs index 4c27a6c1f74..54f5c4bfce1 100644 --- a/src/generated/Users/Item/ManagedDevices/Item/RebootNow/RebootNowRequestBuilder.cs +++ b/src/generated/Users/Item/ManagedDevices/Item/RebootNow/RebootNowRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string userId, string managedDeviceId) => { + command.SetHandler(async (string userId, string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, managedDeviceIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Reboot device - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/ManagedDevices/Item/RecoverPasscode/RecoverPasscodeRequestBuilder.cs b/src/generated/Users/Item/ManagedDevices/Item/RecoverPasscode/RecoverPasscodeRequestBuilder.cs index 91ec085197b..3e8003024f3 100644 --- a/src/generated/Users/Item/ManagedDevices/Item/RecoverPasscode/RecoverPasscodeRequestBuilder.cs +++ b/src/generated/Users/Item/ManagedDevices/Item/RecoverPasscode/RecoverPasscodeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string userId, string managedDeviceId) => { + command.SetHandler(async (string userId, string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, managedDeviceIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Recover passcode - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/ManagedDevices/Item/RemoteLock/RemoteLockRequestBuilder.cs b/src/generated/Users/Item/ManagedDevices/Item/RemoteLock/RemoteLockRequestBuilder.cs index b2e11e4c062..1b9e5252336 100644 --- a/src/generated/Users/Item/ManagedDevices/Item/RemoteLock/RemoteLockRequestBuilder.cs +++ b/src/generated/Users/Item/ManagedDevices/Item/RemoteLock/RemoteLockRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string userId, string managedDeviceId) => { + command.SetHandler(async (string userId, string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, managedDeviceIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Remote lock - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/ManagedDevices/Item/RequestRemoteAssistance/RequestRemoteAssistanceRequestBuilder.cs b/src/generated/Users/Item/ManagedDevices/Item/RequestRemoteAssistance/RequestRemoteAssistanceRequestBuilder.cs index 00d5e38d30d..aff05311eb6 100644 --- a/src/generated/Users/Item/ManagedDevices/Item/RequestRemoteAssistance/RequestRemoteAssistanceRequestBuilder.cs +++ b/src/generated/Users/Item/ManagedDevices/Item/RequestRemoteAssistance/RequestRemoteAssistanceRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string userId, string managedDeviceId) => { + command.SetHandler(async (string userId, string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, managedDeviceIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Request remote assistance - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/ManagedDevices/Item/ResetPasscode/ResetPasscodeRequestBuilder.cs b/src/generated/Users/Item/ManagedDevices/Item/ResetPasscode/ResetPasscodeRequestBuilder.cs index 036577e6b38..f18826bde79 100644 --- a/src/generated/Users/Item/ManagedDevices/Item/ResetPasscode/ResetPasscodeRequestBuilder.cs +++ b/src/generated/Users/Item/ManagedDevices/Item/ResetPasscode/ResetPasscodeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string userId, string managedDeviceId) => { + command.SetHandler(async (string userId, string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, managedDeviceIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Reset passcode - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/ManagedDevices/Item/Retire/RetireRequestBuilder.cs b/src/generated/Users/Item/ManagedDevices/Item/Retire/RetireRequestBuilder.cs index ab63983a9f6..543ca90b7e3 100644 --- a/src/generated/Users/Item/ManagedDevices/Item/Retire/RetireRequestBuilder.cs +++ b/src/generated/Users/Item/ManagedDevices/Item/Retire/RetireRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string userId, string managedDeviceId) => { + command.SetHandler(async (string userId, string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, managedDeviceIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Retire a device - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/ManagedDevices/Item/ShutDown/ShutDownRequestBuilder.cs b/src/generated/Users/Item/ManagedDevices/Item/ShutDown/ShutDownRequestBuilder.cs index f888f652016..057990ca7e1 100644 --- a/src/generated/Users/Item/ManagedDevices/Item/ShutDown/ShutDownRequestBuilder.cs +++ b/src/generated/Users/Item/ManagedDevices/Item/ShutDown/ShutDownRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string userId, string managedDeviceId) => { + command.SetHandler(async (string userId, string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, managedDeviceIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Shut down device - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/ManagedDevices/Item/SyncDevice/SyncDeviceRequestBuilder.cs b/src/generated/Users/Item/ManagedDevices/Item/SyncDevice/SyncDeviceRequestBuilder.cs index 76fbb1f6125..9386982c727 100644 --- a/src/generated/Users/Item/ManagedDevices/Item/SyncDevice/SyncDeviceRequestBuilder.cs +++ b/src/generated/Users/Item/ManagedDevices/Item/SyncDevice/SyncDeviceRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string userId, string managedDeviceId) => { + command.SetHandler(async (string userId, string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, managedDeviceIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action syncDevice - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/ManagedDevices/Item/UpdateWindowsDeviceAccount/UpdateWindowsDeviceAccountRequestBuilder.cs b/src/generated/Users/Item/ManagedDevices/Item/UpdateWindowsDeviceAccount/UpdateWindowsDeviceAccountRequestBuilder.cs index 1e246c6d13d..5b9b4cbbd8c 100644 --- a/src/generated/Users/Item/ManagedDevices/Item/UpdateWindowsDeviceAccount/UpdateWindowsDeviceAccountRequestBuilder.cs +++ b/src/generated/Users/Item/ManagedDevices/Item/UpdateWindowsDeviceAccount/UpdateWindowsDeviceAccountRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string managedDeviceId, string body) => { + command.SetHandler(async (string userId, string managedDeviceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, managedDeviceIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(UpdateWindowsDeviceAccoun requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action updateWindowsDeviceAccount - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UpdateWindowsDeviceAccountRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/ManagedDevices/Item/WindowsDefenderScan/WindowsDefenderScanRequestBuilder.cs b/src/generated/Users/Item/ManagedDevices/Item/WindowsDefenderScan/WindowsDefenderScanRequestBuilder.cs index 665e207e5fd..ea395e7a97f 100644 --- a/src/generated/Users/Item/ManagedDevices/Item/WindowsDefenderScan/WindowsDefenderScanRequestBuilder.cs +++ b/src/generated/Users/Item/ManagedDevices/Item/WindowsDefenderScan/WindowsDefenderScanRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string managedDeviceId, string body) => { + command.SetHandler(async (string userId, string managedDeviceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, managedDeviceIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(WindowsDefenderScanReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action windowsDefenderScan - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WindowsDefenderScanRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/ManagedDevices/Item/WindowsDefenderUpdateSignatures/WindowsDefenderUpdateSignaturesRequestBuilder.cs b/src/generated/Users/Item/ManagedDevices/Item/WindowsDefenderUpdateSignatures/WindowsDefenderUpdateSignaturesRequestBuilder.cs index 1b687d57667..295c55e0643 100644 --- a/src/generated/Users/Item/ManagedDevices/Item/WindowsDefenderUpdateSignatures/WindowsDefenderUpdateSignaturesRequestBuilder.cs +++ b/src/generated/Users/Item/ManagedDevices/Item/WindowsDefenderUpdateSignatures/WindowsDefenderUpdateSignaturesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,14 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); - command.SetHandler(async (string userId, string managedDeviceId) => { + command.SetHandler(async (string userId, string managedDeviceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, managedDeviceIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action windowsDefenderUpdateSignatures - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/ManagedDevices/Item/Wipe/WipeRequestBuilder.cs b/src/generated/Users/Item/ManagedDevices/Item/Wipe/WipeRequestBuilder.cs index c81a1ff8022..4c40edc8fc8 100644 --- a/src/generated/Users/Item/ManagedDevices/Item/Wipe/WipeRequestBuilder.cs +++ b/src/generated/Users/Item/ManagedDevices/Item/Wipe/WipeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var managedDeviceIdOption = new Option("--manageddevice-id", description: "key: id of managedDevice") { + var managedDeviceIdOption = new Option("--managed-device-id", description: "key: id of managedDevice") { }; managedDeviceIdOption.IsRequired = true; command.AddOption(managedDeviceIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string managedDeviceId, string body) => { + command.SetHandler(async (string userId, string managedDeviceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, managedDeviceIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(WipeRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Wipe a device - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WipeRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/ManagedDevices/ManagedDevicesRequestBuilder.cs b/src/generated/Users/Item/ManagedDevices/ManagedDevicesRequestBuilder.cs index 8642b346c55..5a8b0d05094 100644 --- a/src/generated/Users/Item/ManagedDevices/ManagedDevicesRequestBuilder.cs +++ b/src/generated/Users/Item/ManagedDevices/ManagedDevicesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.ManagedDevices.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,32 +22,31 @@ public class ManagedDevicesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ManagedDeviceRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildBypassActivationLockCommand(), - builder.BuildCleanWindowsDeviceCommand(), - builder.BuildDeleteCommand(), - builder.BuildDeleteUserFromSharedAppleDeviceCommand(), - builder.BuildDeviceCategoryCommand(), - builder.BuildDeviceCompliancePolicyStatesCommand(), - builder.BuildDeviceConfigurationStatesCommand(), - builder.BuildDisableLostModeCommand(), - builder.BuildGetCommand(), - builder.BuildLocateDeviceCommand(), - builder.BuildLogoutSharedAppleDeviceActiveUserCommand(), - builder.BuildPatchCommand(), - builder.BuildRebootNowCommand(), - builder.BuildRecoverPasscodeCommand(), - builder.BuildRemoteLockCommand(), - builder.BuildRequestRemoteAssistanceCommand(), - builder.BuildResetPasscodeCommand(), - builder.BuildRetireCommand(), - builder.BuildShutDownCommand(), - builder.BuildSyncDeviceCommand(), - builder.BuildUpdateWindowsDeviceAccountCommand(), - builder.BuildWindowsDefenderScanCommand(), - builder.BuildWindowsDefenderUpdateSignaturesCommand(), - builder.BuildWipeCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildBypassActivationLockCommand()); + commands.Add(builder.BuildCleanWindowsDeviceCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDeleteUserFromSharedAppleDeviceCommand()); + commands.Add(builder.BuildDeviceCategoryCommand()); + commands.Add(builder.BuildDeviceCompliancePolicyStatesCommand()); + commands.Add(builder.BuildDeviceConfigurationStatesCommand()); + commands.Add(builder.BuildDisableLostModeCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildLocateDeviceCommand()); + commands.Add(builder.BuildLogoutSharedAppleDeviceActiveUserCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRebootNowCommand()); + commands.Add(builder.BuildRecoverPasscodeCommand()); + commands.Add(builder.BuildRemoteLockCommand()); + commands.Add(builder.BuildRequestRemoteAssistanceCommand()); + commands.Add(builder.BuildResetPasscodeCommand()); + commands.Add(builder.BuildRetireCommand()); + commands.Add(builder.BuildShutDownCommand()); + commands.Add(builder.BuildSyncDeviceCommand()); + commands.Add(builder.BuildUpdateWindowsDeviceAccountCommand()); + commands.Add(builder.BuildWindowsDefenderScanCommand()); + commands.Add(builder.BuildWindowsDefenderUpdateSignaturesCommand()); + commands.Add(builder.BuildWipeCommand()); return commands; } /// @@ -65,21 +64,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -128,7 +126,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -139,15 +141,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -202,31 +199,6 @@ public RequestInformation CreatePostRequestInformation(ManagedDevice body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The managed devices associated with the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The managed devices associated with the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ManagedDevice model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The managed devices associated with the user. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Manager/@Ref/@Ref.cs b/src/generated/Users/Item/Manager/@Ref/@Ref.cs deleted file mode 100644 index bd01b837e86..00000000000 --- a/src/generated/Users/Item/Manager/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.Manager.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/Manager/@Ref/RefRequestBuilder.cs b/src/generated/Users/Item/Manager/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 253864fdcac..00000000000 --- a/src/generated/Users/Item/Manager/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Users.Item.Manager.@Ref { - /// Builds and executes requests for operations under \users\{user-id}\manager\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userIdOption); - return command; - } - /// - /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption); - return command; - } - /// - /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/manager/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Users.Item.Manager.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Users.Item.Manager.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Users/Item/Manager/ManagerRequestBuilder.cs b/src/generated/Users/Item/Manager/ManagerRequestBuilder.cs index 871bfd2c6d4..dfc67de7b7f 100644 --- a/src/generated/Users/Item/Manager/ManagerRequestBuilder.cs +++ b/src/generated/Users/Item/Manager/ManagerRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Manager.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Users.Item.Manager.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Users.Item.Manager.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Manager/Ref/Ref.cs b/src/generated/Users/Item/Manager/Ref/Ref.cs new file mode 100644 index 00000000000..0ccdcb4ef0e --- /dev/null +++ b/src/generated/Users/Item/Manager/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.Manager.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/Manager/Ref/RefRequestBuilder.cs b/src/generated/Users/Item/Manager/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..60d22f2484d --- /dev/null +++ b/src/generated/Users/Item/Manager/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Users.Item.Manager.Ref { + /// Builds and executes requests for operations under \users\{user-id}\manager\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + command.SetHandler(async (string userId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, userIdOption); + return command; + } + /// + /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, outputOption); + return command; + } + /// + /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string userId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, userIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/users/{user_id}/manager/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.). Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Users.Item.Manager.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Users/Item/MemberOf/@Ref/@Ref.cs b/src/generated/Users/Item/MemberOf/@Ref/@Ref.cs deleted file mode 100644 index 30b6e2df511..00000000000 --- a/src/generated/Users/Item/MemberOf/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.MemberOf.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/MemberOf/@Ref/RefRequestBuilder.cs b/src/generated/Users/Item/MemberOf/@Ref/RefRequestBuilder.cs deleted file mode 100644 index fcaf4dbf234..00000000000 --- a/src/generated/Users/Item/MemberOf/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Users.Item.MemberOf.@Ref { - /// Builds and executes requests for operations under \users\{user-id}\memberOf\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/memberOf/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Users.Item.MemberOf.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Users.Item.MemberOf.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Users/Item/MemberOf/@Ref/RefResponse.cs b/src/generated/Users/Item/MemberOf/@Ref/RefResponse.cs deleted file mode 100644 index 922ebff6668..00000000000 --- a/src/generated/Users/Item/MemberOf/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.MemberOf.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/MemberOf/MemberOfRequestBuilder.cs b/src/generated/Users/Item/MemberOf/MemberOfRequestBuilder.cs index f2941f7d240..4c5b08f7c89 100644 --- a/src/generated/Users/Item/MemberOf/MemberOfRequestBuilder.cs +++ b/src/generated/Users/Item/MemberOf/MemberOfRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Users.Item.MemberOf.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Users.Item.MemberOf.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Users.Item.MemberOf.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/MemberOf/Ref/Ref.cs b/src/generated/Users/Item/MemberOf/Ref/Ref.cs new file mode 100644 index 00000000000..a080bb4a222 --- /dev/null +++ b/src/generated/Users/Item/MemberOf/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.MemberOf.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/MemberOf/Ref/RefRequestBuilder.cs b/src/generated/Users/Item/MemberOf/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..e4a32534cd4 --- /dev/null +++ b/src/generated/Users/Item/MemberOf/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Users.Item.MemberOf.Ref { + /// Builds and executes requests for operations under \users\{user-id}\memberOf\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/users/{user_id}/memberOf/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Users.Item.MemberOf.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Users/Item/MemberOf/Ref/RefResponse.cs b/src/generated/Users/Item/MemberOf/Ref/RefResponse.cs new file mode 100644 index 00000000000..33c78dbf264 --- /dev/null +++ b/src/generated/Users/Item/MemberOf/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.MemberOf.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/Messages/Delta/Delta.cs b/src/generated/Users/Item/Messages/Delta/Delta.cs deleted file mode 100644 index 7c614096b9e..00000000000 --- a/src/generated/Users/Item/Messages/Delta/Delta.cs +++ /dev/null @@ -1,128 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.Messages.Delta { - public class Delta : OutlookItem, IParsable { - /// The fileAttachment and itemAttachment attachments for the message. - public List Attachments { get; set; } - /// The Bcc: recipients for the message. - public List BccRecipients { get; set; } - /// The body of the message. It can be in HTML or text format. Find out about safe HTML in a message body. - public ItemBody Body { get; set; } - /// The first 255 characters of the message body. It is in text format. If the message contains instances of mention, this property would contain a concatenation of these mentions as well. - public string BodyPreview { get; set; } - /// The Cc: recipients for the message. - public List CcRecipients { get; set; } - /// The ID of the conversation the email belongs to. - public string ConversationId { get; set; } - /// Indicates the position of the message within the conversation. - public byte[] ConversationIndex { get; set; } - /// The collection of open extensions defined for the message. Nullable. - public List Extensions { get; set; } - /// The flag value that indicates the status, start date, due date, or completion date for the message. - public FollowupFlag Flag { get; set; } - /// The owner of the mailbox from which the message is sent. In most cases, this value is the same as the sender property, except for sharing or delegation scenarios. The value must correspond to the actual mailbox used. Find out more about setting the from and sender properties of a message. - public Recipient From { get; set; } - /// Indicates whether the message has attachments. This property doesn't include inline attachments, so if a message contains only inline attachments, this property is false. To verify the existence of inline attachments, parse the body property to look for a src attribute, such as . - public bool? HasAttachments { get; set; } - public Importance? Importance { get; set; } - public InferenceClassificationType? InferenceClassification { get; set; } - public List InternetMessageHeaders { get; set; } - public string InternetMessageId { get; set; } - public bool? IsDeliveryReceiptRequested { get; set; } - public bool? IsDraft { get; set; } - public bool? IsRead { get; set; } - public bool? IsReadReceiptRequested { get; set; } - /// The collection of multi-value extended properties defined for the message. Nullable. - public List MultiValueExtendedProperties { get; set; } - public string ParentFolderId { get; set; } - public DateTimeOffset? ReceivedDateTime { get; set; } - public List ReplyTo { get; set; } - public Recipient Sender { get; set; } - public DateTimeOffset? SentDateTime { get; set; } - /// The collection of single-value extended properties defined for the message. Nullable. - public List SingleValueExtendedProperties { get; set; } - public string Subject { get; set; } - public List ToRecipients { get; set; } - public ItemBody UniqueBody { get; set; } - public string WebLink { get; set; } - /// - /// The deserialization information for the current model - /// - public new IDictionary> GetFieldDeserializers() { - return new Dictionary>(base.GetFieldDeserializers()) { - {"attachments", (o,n) => { (o as Delta).Attachments = n.GetCollectionOfObjectValues().ToList(); } }, - {"bccRecipients", (o,n) => { (o as Delta).BccRecipients = n.GetCollectionOfObjectValues().ToList(); } }, - {"body", (o,n) => { (o as Delta).Body = n.GetObjectValue(); } }, - {"bodyPreview", (o,n) => { (o as Delta).BodyPreview = n.GetStringValue(); } }, - {"ccRecipients", (o,n) => { (o as Delta).CcRecipients = n.GetCollectionOfObjectValues().ToList(); } }, - {"conversationId", (o,n) => { (o as Delta).ConversationId = n.GetStringValue(); } }, - {"conversationIndex", (o,n) => { (o as Delta).ConversationIndex = n.GetByteArrayValue(); } }, - {"extensions", (o,n) => { (o as Delta).Extensions = n.GetCollectionOfObjectValues().ToList(); } }, - {"flag", (o,n) => { (o as Delta).Flag = n.GetObjectValue(); } }, - {"from", (o,n) => { (o as Delta).From = n.GetObjectValue(); } }, - {"hasAttachments", (o,n) => { (o as Delta).HasAttachments = n.GetBoolValue(); } }, - {"importance", (o,n) => { (o as Delta).Importance = n.GetEnumValue(); } }, - {"inferenceClassification", (o,n) => { (o as Delta).InferenceClassification = n.GetEnumValue(); } }, - {"internetMessageHeaders", (o,n) => { (o as Delta).InternetMessageHeaders = n.GetCollectionOfObjectValues().ToList(); } }, - {"internetMessageId", (o,n) => { (o as Delta).InternetMessageId = n.GetStringValue(); } }, - {"isDeliveryReceiptRequested", (o,n) => { (o as Delta).IsDeliveryReceiptRequested = n.GetBoolValue(); } }, - {"isDraft", (o,n) => { (o as Delta).IsDraft = n.GetBoolValue(); } }, - {"isRead", (o,n) => { (o as Delta).IsRead = n.GetBoolValue(); } }, - {"isReadReceiptRequested", (o,n) => { (o as Delta).IsReadReceiptRequested = n.GetBoolValue(); } }, - {"multiValueExtendedProperties", (o,n) => { (o as Delta).MultiValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"parentFolderId", (o,n) => { (o as Delta).ParentFolderId = n.GetStringValue(); } }, - {"receivedDateTime", (o,n) => { (o as Delta).ReceivedDateTime = n.GetDateTimeOffsetValue(); } }, - {"replyTo", (o,n) => { (o as Delta).ReplyTo = n.GetCollectionOfObjectValues().ToList(); } }, - {"sender", (o,n) => { (o as Delta).Sender = n.GetObjectValue(); } }, - {"sentDateTime", (o,n) => { (o as Delta).SentDateTime = n.GetDateTimeOffsetValue(); } }, - {"singleValueExtendedProperties", (o,n) => { (o as Delta).SingleValueExtendedProperties = n.GetCollectionOfObjectValues().ToList(); } }, - {"subject", (o,n) => { (o as Delta).Subject = n.GetStringValue(); } }, - {"toRecipients", (o,n) => { (o as Delta).ToRecipients = n.GetCollectionOfObjectValues().ToList(); } }, - {"uniqueBody", (o,n) => { (o as Delta).UniqueBody = n.GetObjectValue(); } }, - {"webLink", (o,n) => { (o as Delta).WebLink = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public new void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - base.Serialize(writer); - writer.WriteCollectionOfObjectValues("attachments", Attachments); - writer.WriteCollectionOfObjectValues("bccRecipients", BccRecipients); - writer.WriteObjectValue("body", Body); - writer.WriteStringValue("bodyPreview", BodyPreview); - writer.WriteCollectionOfObjectValues("ccRecipients", CcRecipients); - writer.WriteStringValue("conversationId", ConversationId); - writer.WriteByteArrayValue("conversationIndex", ConversationIndex); - writer.WriteCollectionOfObjectValues("extensions", Extensions); - writer.WriteObjectValue("flag", Flag); - writer.WriteObjectValue("from", From); - writer.WriteBoolValue("hasAttachments", HasAttachments); - writer.WriteEnumValue("importance", Importance); - writer.WriteEnumValue("inferenceClassification", InferenceClassification); - writer.WriteCollectionOfObjectValues("internetMessageHeaders", InternetMessageHeaders); - writer.WriteStringValue("internetMessageId", InternetMessageId); - writer.WriteBoolValue("isDeliveryReceiptRequested", IsDeliveryReceiptRequested); - writer.WriteBoolValue("isDraft", IsDraft); - writer.WriteBoolValue("isRead", IsRead); - writer.WriteBoolValue("isReadReceiptRequested", IsReadReceiptRequested); - writer.WriteCollectionOfObjectValues("multiValueExtendedProperties", MultiValueExtendedProperties); - writer.WriteStringValue("parentFolderId", ParentFolderId); - writer.WriteDateTimeOffsetValue("receivedDateTime", ReceivedDateTime); - writer.WriteCollectionOfObjectValues("replyTo", ReplyTo); - writer.WriteObjectValue("sender", Sender); - writer.WriteDateTimeOffsetValue("sentDateTime", SentDateTime); - writer.WriteCollectionOfObjectValues("singleValueExtendedProperties", SingleValueExtendedProperties); - writer.WriteStringValue("subject", Subject); - writer.WriteCollectionOfObjectValues("toRecipients", ToRecipients); - writer.WriteObjectValue("uniqueBody", UniqueBody); - writer.WriteStringValue("webLink", WebLink); - } - } -} diff --git a/src/generated/Users/Item/Messages/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/Messages/Delta/DeltaRequestBuilder.cs index ebe340e692e..ac9e860722c 100644 --- a/src/generated/Users/Item/Messages/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/Messages/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +30,17 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Messages/Item/Attachments/AttachmentsRequestBuilder.cs b/src/generated/Users/Item/Messages/Item/Attachments/AttachmentsRequestBuilder.cs index 302bb7ce5d0..f2e7b0e53a0 100644 --- a/src/generated/Users/Item/Messages/Item/Attachments/AttachmentsRequestBuilder.cs +++ b/src/generated/Users/Item/Messages/Item/Attachments/AttachmentsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Messages.Item.Attachments.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,11 +23,10 @@ public class AttachmentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttachmentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, messageIdOption, bodyOption, outputOption); return command; } public Command BuildCreateUploadSessionCommand() { @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string messageId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string messageId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, messageIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, messageIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(Attachment body, Action - /// The fileAttachment and itemAttachment attachments for the message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The fileAttachment and itemAttachment attachments for the message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The fileAttachment and itemAttachment attachments for the message. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Messages/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Users/Item/Messages/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index 6e1cfaf5bab..6cfd3385542 100644 --- a/src/generated/Users/Item/Messages/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Users/Item/Messages/Item/Attachments/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, messageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Messages/Item/Attachments/Item/AttachmentRequestBuilder.cs b/src/generated/Users/Item/Messages/Item/Attachments/Item/AttachmentRequestBuilder.cs index 1fbfb85a789..3586d217673 100644 --- a/src/generated/Users/Item/Messages/Item/Attachments/Item/AttachmentRequestBuilder.cs +++ b/src/generated/Users/Item/Messages/Item/Attachments/Item/AttachmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; attachmentIdOption.IsRequired = true; command.AddOption(attachmentIdOption); - command.SetHandler(async (string userId, string messageId, string attachmentId) => { + command.SetHandler(async (string userId, string messageId, string attachmentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, messageIdOption, attachmentIdOption); return command; @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string messageId, string attachmentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string messageId, string attachmentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, messageIdOption, attachmentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, messageIdOption, attachmentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string messageId, string attachmentId, string body) => { + command.SetHandler(async (string userId, string messageId, string attachmentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, messageIdOption, attachmentIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Attachment body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The fileAttachment and itemAttachment attachments for the message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The fileAttachment and itemAttachment attachments for the message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The fileAttachment and itemAttachment attachments for the message. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Attachment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The fileAttachment and itemAttachment attachments for the message. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Messages/Item/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs b/src/generated/Users/Item/Messages/Item/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs index c5799fb5061..29cb622dd43 100644 --- a/src/generated/Users/Item/Messages/Item/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs +++ b/src/generated/Users/Item/Messages/Item/CalendarSharingMessage/Accept/AcceptRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,18 +34,17 @@ public Command BuildPostCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - command.SetHandler(async (string userId, string messageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string messageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, messageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, messageIdOption, outputOption); return command; } /// @@ -76,16 +75,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action accept - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Messages/Item/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs b/src/generated/Users/Item/Messages/Item/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs index 7e6e1776a00..8a8a0c08164 100644 --- a/src/generated/Users/Item/Messages/Item/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs +++ b/src/generated/Users/Item/Messages/Item/CalendarSharingMessage/CalendarSharingMessageRequestBuilder.cs @@ -1,9 +1,9 @@ using ApiSdk.Users.Item.Messages.Item.CalendarSharingMessage.Accept; using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; diff --git a/src/generated/Users/Item/Messages/Item/Copy/CopyRequestBuilder.cs b/src/generated/Users/Item/Messages/Item/Copy/CopyRequestBuilder.cs index 10fd5a4aadf..588af07a0fe 100644 --- a/src/generated/Users/Item/Messages/Item/Copy/CopyRequestBuilder.cs +++ b/src/generated/Users/Item/Messages/Item/Copy/CopyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, messageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copy - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes message public class CopyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Messages/Item/CreateForward/CreateForwardRequestBuilder.cs b/src/generated/Users/Item/Messages/Item/CreateForward/CreateForwardRequestBuilder.cs index 33906070fa0..62c678e727d 100644 --- a/src/generated/Users/Item/Messages/Item/CreateForward/CreateForwardRequestBuilder.cs +++ b/src/generated/Users/Item/Messages/Item/CreateForward/CreateForwardRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, messageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CreateForwardRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createForward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes message public class CreateForwardResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Messages/Item/CreateReply/CreateReplyRequestBuilder.cs b/src/generated/Users/Item/Messages/Item/CreateReply/CreateReplyRequestBuilder.cs index 58320246613..49ce5bedf5b 100644 --- a/src/generated/Users/Item/Messages/Item/CreateReply/CreateReplyRequestBuilder.cs +++ b/src/generated/Users/Item/Messages/Item/CreateReply/CreateReplyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, messageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CreateReplyRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createReply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateReplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes message public class CreateReplyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Messages/Item/CreateReplyAll/CreateReplyAllRequestBuilder.cs b/src/generated/Users/Item/Messages/Item/CreateReplyAll/CreateReplyAllRequestBuilder.cs index ab15bd3fe5e..8477bbd8330 100644 --- a/src/generated/Users/Item/Messages/Item/CreateReplyAll/CreateReplyAllRequestBuilder.cs +++ b/src/generated/Users/Item/Messages/Item/CreateReplyAll/CreateReplyAllRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, messageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CreateReplyAllRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createReplyAll - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateReplyAllRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes message public class CreateReplyAllResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Messages/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Users/Item/Messages/Item/Extensions/ExtensionsRequestBuilder.cs index ab3e829e47d..e1a4b01f93b 100644 --- a/src/generated/Users/Item/Messages/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Users/Item/Messages/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Messages.Item.Extensions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, messageIdOption, bodyOption, outputOption); return command; } /// @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string messageId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string messageId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, messageIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, messageIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the message. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Messages/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Users/Item/Messages/Item/Extensions/Item/ExtensionRequestBuilder.cs index 0c15187c350..8ef6e4104e9 100644 --- a/src/generated/Users/Item/Messages/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Users/Item/Messages/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string userId, string messageId, string extensionId) => { + command.SetHandler(async (string userId, string messageId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, messageIdOption, extensionIdOption); return command; @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string messageId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string messageId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, messageIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, messageIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string messageId, string extensionId, string body) => { + command.SetHandler(async (string userId, string messageId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, messageIdOption, extensionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the message. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Messages/Item/Forward/ForwardRequestBuilder.cs b/src/generated/Users/Item/Messages/Item/Forward/ForwardRequestBuilder.cs index 0226fc9521f..472ab9b5038 100644 --- a/src/generated/Users/Item/Messages/Item/Forward/ForwardRequestBuilder.cs +++ b/src/generated/Users/Item/Messages/Item/Forward/ForwardRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string messageId, string body) => { + command.SetHandler(async (string userId, string messageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, messageIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ForwardRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action forward - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ForwardRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Messages/Item/MessageRequestBuilder.cs b/src/generated/Users/Item/Messages/Item/MessageRequestBuilder.cs index 1f317eba9a6..806c2fbdcd4 100644 --- a/src/generated/Users/Item/Messages/Item/MessageRequestBuilder.cs +++ b/src/generated/Users/Item/Messages/Item/MessageRequestBuilder.cs @@ -16,10 +16,10 @@ using ApiSdk.Users.Item.Messages.Item.Value; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,6 +37,9 @@ public class MessageRequestBuilder { public Command BuildAttachmentsCommand() { var command = new Command("attachments"); var builder = new ApiSdk.Users.Item.Messages.Item.Attachments.AttachmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateUploadSessionCommand()); command.AddCommand(builder.BuildListCommand()); @@ -94,11 +97,10 @@ public Command BuildDeleteCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - command.SetHandler(async (string userId, string messageId) => { + command.SetHandler(async (string userId, string messageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, messageIdOption); return command; @@ -106,6 +108,9 @@ public Command BuildDeleteCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Users.Item.Messages.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -136,19 +141,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string messageId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string messageId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, messageIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, messageIdOption, selectOption, outputOption); return command; } public Command BuildMoveCommand() { @@ -160,6 +164,9 @@ public Command BuildMoveCommand() { public Command BuildMultiValueExtendedPropertiesCommand() { var command = new Command("multi-value-extended-properties"); var builder = new ApiSdk.Users.Item.Messages.Item.MultiValueExtendedProperties.MultiValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -183,14 +190,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string messageId, string body) => { + command.SetHandler(async (string userId, string messageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, messageIdOption, bodyOption); return command; @@ -216,6 +222,9 @@ public Command BuildSendCommand() { public Command BuildSingleValueExtendedPropertiesCommand() { var command = new Command("single-value-extended-properties"); var builder = new ApiSdk.Users.Item.Messages.Item.SingleValueExtendedProperties.SingleValueExtendedPropertiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -287,42 +296,6 @@ public RequestInformation CreatePatchRequestInformation(Message body, Action - /// The messages in a mailbox or folder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The messages in a mailbox or folder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The messages in a mailbox or folder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Message model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The messages in a mailbox or folder. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/Messages/Item/Move/MoveRequestBuilder.cs b/src/generated/Users/Item/Messages/Item/Move/MoveRequestBuilder.cs index f4ddc896ab5..4eb87235c2b 100644 --- a/src/generated/Users/Item/Messages/Item/Move/MoveRequestBuilder.cs +++ b/src/generated/Users/Item/Messages/Item/Move/MoveRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, messageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(MoveRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action move - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MoveRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes message public class MoveResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Messages/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/Messages/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs index fa0dcd8675f..fde8c3c895d 100644 --- a/src/generated/Users/Item/Messages/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/Messages/Item/MultiValueExtendedProperties/Item/MultiValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string messageId, string multiValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string messageId, string multiValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, messageIdOption, multiValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string messageId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string messageId, string multiValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, messageIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, messageIdOption, multiValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var multiValueLegacyExtendedPropertyIdOption = new Option("--multivaluelegacyextendedproperty-id", description: "key: id of multiValueLegacyExtendedProperty") { + var multiValueLegacyExtendedPropertyIdOption = new Option("--multi-value-legacy-extended-property-id", description: "key: id of multiValueLegacyExtendedProperty") { }; multiValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(multiValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string messageId, string multiValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string messageId, string multiValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, messageIdOption, multiValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(MultiValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the message. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Messages/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/Messages/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs index a43865b90b6..3a42d0291e8 100644 --- a/src/generated/Users/Item/Messages/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/Messages/Item/MultiValueExtendedProperties/MultiValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Messages.Item.MultiValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MultiValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MultiValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, messageIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string messageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string messageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, messageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, messageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(MultiValueLegacyExtendedP requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of multi-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of multi-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of multi-value extended properties defined for the message. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Messages/Item/Reply/ReplyRequestBuilder.cs b/src/generated/Users/Item/Messages/Item/Reply/ReplyRequestBuilder.cs index 07d0c993207..e3d247e7ca3 100644 --- a/src/generated/Users/Item/Messages/Item/Reply/ReplyRequestBuilder.cs +++ b/src/generated/Users/Item/Messages/Item/Reply/ReplyRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string messageId, string body) => { + command.SetHandler(async (string userId, string messageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, messageIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ReplyRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action reply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ReplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Messages/Item/ReplyAll/ReplyAllRequestBuilder.cs b/src/generated/Users/Item/Messages/Item/ReplyAll/ReplyAllRequestBuilder.cs index cc0ae78e03d..cd9fe445d4a 100644 --- a/src/generated/Users/Item/Messages/Item/ReplyAll/ReplyAllRequestBuilder.cs +++ b/src/generated/Users/Item/Messages/Item/ReplyAll/ReplyAllRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string messageId, string body) => { + command.SetHandler(async (string userId, string messageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, messageIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ReplyAllRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action replyAll - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ReplyAllRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Messages/Item/Send/SendRequestBuilder.cs b/src/generated/Users/Item/Messages/Item/Send/SendRequestBuilder.cs index 4372e45a8c7..2faf4956c43 100644 --- a/src/generated/Users/Item/Messages/Item/Send/SendRequestBuilder.cs +++ b/src/generated/Users/Item/Messages/Item/Send/SendRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,11 +33,10 @@ public Command BuildPostCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - command.SetHandler(async (string userId, string messageId) => { + command.SetHandler(async (string userId, string messageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, messageIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action send - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Messages/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs b/src/generated/Users/Item/Messages/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs index c393dc02f0b..799b05375e1 100644 --- a/src/generated/Users/Item/Messages/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs +++ b/src/generated/Users/Item/Messages/Item/SingleValueExtendedProperties/Item/SingleValueLegacyExtendedPropertyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); - command.SetHandler(async (string userId, string messageId, string singleValueLegacyExtendedPropertyId) => { + command.SetHandler(async (string userId, string messageId, string singleValueLegacyExtendedPropertyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, messageIdOption, singleValueLegacyExtendedPropertyIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string messageId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string messageId, string singleValueLegacyExtendedPropertyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, messageIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, messageIdOption, singleValueLegacyExtendedPropertyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var singleValueLegacyExtendedPropertyIdOption = new Option("--singlevaluelegacyextendedproperty-id", description: "key: id of singleValueLegacyExtendedProperty") { + var singleValueLegacyExtendedPropertyIdOption = new Option("--single-value-legacy-extended-property-id", description: "key: id of singleValueLegacyExtendedProperty") { }; singleValueLegacyExtendedPropertyIdOption.IsRequired = true; command.AddOption(singleValueLegacyExtendedPropertyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string messageId, string singleValueLegacyExtendedPropertyId, string body) => { + command.SetHandler(async (string userId, string messageId, string singleValueLegacyExtendedPropertyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, messageIdOption, singleValueLegacyExtendedPropertyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SingleValueLegacyExtende requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the message. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Messages/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs b/src/generated/Users/Item/Messages/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs index 4172199d39f..792293590b3 100644 --- a/src/generated/Users/Item/Messages/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs +++ b/src/generated/Users/Item/Messages/Item/SingleValueExtendedProperties/SingleValueExtendedPropertiesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Messages.Item.SingleValueExtendedProperties.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SingleValueExtendedPropertiesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SingleValueLegacyExtendedPropertyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string messageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string messageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, messageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, messageIdOption, bodyOption, outputOption); return command; } /// @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string messageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string messageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, messageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, messageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SingleValueLegacyExtended requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of single-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of single-value extended properties defined for the message. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SingleValueLegacyExtendedProperty model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of single-value extended properties defined for the message. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Messages/Item/Value/ContentRequestBuilder.cs b/src/generated/Users/Item/Messages/Item/Value/ContentRequestBuilder.cs index 2a939823068..009c6f4ea0e 100644 --- a/src/generated/Users/Item/Messages/Item/Value/ContentRequestBuilder.cs +++ b/src/generated/Users/Item/Messages/Item/Value/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,24 +33,26 @@ public Command BuildGetCommand() { }; messageIdOption.IsRequired = true; command.AddOption(messageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string userId, string messageId, FileInfo output) => { + command.SetHandler(async (string userId, string messageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, userIdOption, messageIdOption, outputOption); + }, userIdOption, messageIdOption, fileOption, outputOption); return command; } /// @@ -72,12 +74,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string messageId, FileInfo file) => { + command.SetHandler(async (string userId, string messageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, messageIdOption, bodyOption); return command; @@ -128,29 +129,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property messages from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property messages in users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Messages/MessagesRequestBuilder.cs b/src/generated/Users/Item/Messages/MessagesRequestBuilder.cs index 17e52322902..8a9a6f9386c 100644 --- a/src/generated/Users/Item/Messages/MessagesRequestBuilder.cs +++ b/src/generated/Users/Item/Messages/MessagesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Messages.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,26 +23,25 @@ public class MessagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MessageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAttachmentsCommand(), - builder.BuildCalendarSharingMessageCommand(), - builder.BuildContentCommand(), - builder.BuildCopyCommand(), - builder.BuildCreateForwardCommand(), - builder.BuildCreateReplyAllCommand(), - builder.BuildCreateReplyCommand(), - builder.BuildDeleteCommand(), - builder.BuildExtensionsCommand(), - builder.BuildForwardCommand(), - builder.BuildGetCommand(), - builder.BuildMoveCommand(), - builder.BuildMultiValueExtendedPropertiesCommand(), - builder.BuildPatchCommand(), - builder.BuildReplyAllCommand(), - builder.BuildReplyCommand(), - builder.BuildSendCommand(), - builder.BuildSingleValueExtendedPropertiesCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAttachmentsCommand()); + commands.Add(builder.BuildCalendarSharingMessageCommand()); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyCommand()); + commands.Add(builder.BuildCreateForwardCommand()); + commands.Add(builder.BuildCreateReplyAllCommand()); + commands.Add(builder.BuildCreateReplyCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildForwardCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildMoveCommand()); + commands.Add(builder.BuildMultiValueExtendedPropertiesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildReplyAllCommand()); + commands.Add(builder.BuildReplyCommand()); + commands.Add(builder.BuildSendCommand()); + commands.Add(builder.BuildSingleValueExtendedPropertiesCommand()); return commands; } /// @@ -60,21 +59,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(Message body, Action - /// The messages in a mailbox or folder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The messages in a mailbox or folder. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Message model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The messages in a mailbox or folder. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Oauth2PermissionGrants/@Ref/@Ref.cs b/src/generated/Users/Item/Oauth2PermissionGrants/@Ref/@Ref.cs deleted file mode 100644 index 45bd5fd1aac..00000000000 --- a/src/generated/Users/Item/Oauth2PermissionGrants/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.Oauth2PermissionGrants.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/Oauth2PermissionGrants/@Ref/RefRequestBuilder.cs b/src/generated/Users/Item/Oauth2PermissionGrants/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 67895a2cced..00000000000 --- a/src/generated/Users/Item/Oauth2PermissionGrants/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Users.Item.Oauth2PermissionGrants.@Ref { - /// Builds and executes requests for operations under \users\{user-id}\oauth2PermissionGrants\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Get ref of oauth2PermissionGrants from users - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Get ref of oauth2PermissionGrants from users"; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Create new navigation property ref to oauth2PermissionGrants for users - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Create new navigation property ref to oauth2PermissionGrants for users"; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/oauth2PermissionGrants/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Get ref of oauth2PermissionGrants from users - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Create new navigation property ref to oauth2PermissionGrants for users - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Users.Item.Oauth2PermissionGrants.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Get ref of oauth2PermissionGrants from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property ref to oauth2PermissionGrants for users - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Users.Item.Oauth2PermissionGrants.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Get ref of oauth2PermissionGrants from users - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Users/Item/Oauth2PermissionGrants/@Ref/RefResponse.cs b/src/generated/Users/Item/Oauth2PermissionGrants/@Ref/RefResponse.cs deleted file mode 100644 index 14413f84b96..00000000000 --- a/src/generated/Users/Item/Oauth2PermissionGrants/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.Oauth2PermissionGrants.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/Oauth2PermissionGrants/Oauth2PermissionGrantsRequestBuilder.cs b/src/generated/Users/Item/Oauth2PermissionGrants/Oauth2PermissionGrantsRequestBuilder.cs index ddea3a7f55a..c3bb4fd94c0 100644 --- a/src/generated/Users/Item/Oauth2PermissionGrants/Oauth2PermissionGrantsRequestBuilder.cs +++ b/src/generated/Users/Item/Oauth2PermissionGrants/Oauth2PermissionGrantsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Users.Item.Oauth2PermissionGrants.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Users.Item.Oauth2PermissionGrants.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Users.Item.Oauth2PermissionGrants.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get oauth2PermissionGrants from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get oauth2PermissionGrants from users public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Oauth2PermissionGrants/Ref/Ref.cs b/src/generated/Users/Item/Oauth2PermissionGrants/Ref/Ref.cs new file mode 100644 index 00000000000..3c866a87c4d --- /dev/null +++ b/src/generated/Users/Item/Oauth2PermissionGrants/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.Oauth2PermissionGrants.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/Oauth2PermissionGrants/Ref/RefRequestBuilder.cs b/src/generated/Users/Item/Oauth2PermissionGrants/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..c5d26e7a35d --- /dev/null +++ b/src/generated/Users/Item/Oauth2PermissionGrants/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Users.Item.Oauth2PermissionGrants.Ref { + /// Builds and executes requests for operations under \users\{user-id}\oauth2PermissionGrants\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Get ref of oauth2PermissionGrants from users + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Get ref of oauth2PermissionGrants from users"; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Create new navigation property ref to oauth2PermissionGrants for users + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Create new navigation property ref to oauth2PermissionGrants for users"; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/users/{user_id}/oauth2PermissionGrants/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Get ref of oauth2PermissionGrants from users + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Create new navigation property ref to oauth2PermissionGrants for users + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Users.Item.Oauth2PermissionGrants.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Get ref of oauth2PermissionGrants from users + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Users/Item/Oauth2PermissionGrants/Ref/RefResponse.cs b/src/generated/Users/Item/Oauth2PermissionGrants/Ref/RefResponse.cs new file mode 100644 index 00000000000..a55c4ce3bb2 --- /dev/null +++ b/src/generated/Users/Item/Oauth2PermissionGrants/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.Oauth2PermissionGrants.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/Onenote/Notebooks/GetNotebookFromWebUrl/GetNotebookFromWebUrlRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/GetNotebookFromWebUrl/GetNotebookFromWebUrlRequestBuilder.cs index 1a15b13a537..9c1af3e86d3 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/GetNotebookFromWebUrl/GetNotebookFromWebUrlRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/GetNotebookFromWebUrl/GetNotebookFromWebUrlRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(GetNotebookFromWebUrlRequ requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action getNotebookFromWebUrl - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GetNotebookFromWebUrlRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes CopyNotebookModel public class GetNotebookFromWebUrlResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Notebooks/GetRecentNotebooksWithIncludePersonalNotebooks/GetRecentNotebooksWithIncludePersonalNotebooksRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/GetRecentNotebooksWithIncludePersonalNotebooks/GetRecentNotebooksWithIncludePersonalNotebooksRequestBuilder.cs index 242c2d09da4..53b7a2aed44 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/GetRecentNotebooksWithIncludePersonalNotebooks/GetRecentNotebooksWithIncludePersonalNotebooksRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/GetRecentNotebooksWithIncludePersonalNotebooks/GetRecentNotebooksWithIncludePersonalNotebooksRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,22 +29,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var includePersonalNotebooksOption = new Option("--includepersonalnotebooks", description: "Usage: includePersonalNotebooks={includePersonalNotebooks}") { + var includePersonalNotebooksOption = new Option("--include-personal-notebooks", description: "Usage: includePersonalNotebooks={includePersonalNotebooks}") { }; includePersonalNotebooksOption.IsRequired = true; command.AddOption(includePersonalNotebooksOption); - command.SetHandler(async (string userId, bool? includePersonalNotebooks) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, bool? includePersonalNotebooks, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, includePersonalNotebooksOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, includePersonalNotebooksOption, outputOption); return command; } /// @@ -77,16 +76,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getRecentNotebooks - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/CopyNotebook/CopyNotebookRequestBuilder.cs index 5947145283f..cace2508a6b 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/NotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/NotebookRequestBuilder.cs index 5d4b4efedf4..647baa1a09e 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/NotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/NotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Users.Item.Onenote.Notebooks.Item.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -43,11 +43,10 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - command.SetHandler(async (string userId, string notebookId) => { + command.SetHandler(async (string userId, string notebookId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption); return command; @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string body) => { + command.SetHandler(async (string userId, string notebookId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, bodyOption); return command; @@ -127,6 +124,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Users.Item.Onenote.Notebooks.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,6 +134,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Users.Item.Onenote.Notebooks.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -205,42 +208,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index a152d4e65f2..65fce23418b 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,7 +34,7 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 3f081cfae1c..b16d6c3dfd7 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Notebooks.Item.SectionGroups.Item.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,15 +41,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId) => { + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, sectionGroupIdOption); return command; @@ -69,7 +68,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -114,7 +112,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string body) => { + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, sectionGroupIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index b25e784053c..c1e1b8bcc87 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId) => { + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, sectionGroupIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,7 +105,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string body) => { + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, sectionGroupIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index 0c76e876289..44da88ac138 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Users.Item.Onenote.Notebooks.Item.SectionGroups.Item.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId) => { + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, sectionGroupIdOption); return command; @@ -66,7 +65,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -80,20 +79,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -128,7 +126,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -136,14 +134,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string body) => { + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, sectionGroupIdOption, bodyOption); return command; @@ -151,6 +148,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Users.Item.Onenote.Notebooks.Item.SectionGroups.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -158,6 +158,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Users.Item.Onenote.Notebooks.Item.SectionGroups.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -229,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index df9d1332425..49196c83bc6 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -66,11 +65,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -115,11 +113,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs index 2835f6f64a9..68bfc035806 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Notebooks.Item.SectionGroups.Item.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,7 +43,7 @@ public Command BuildCreateCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildListCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index f2d94d376a1..0defbdba317 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 9ad5b39c777..3f0711e4c5a 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index ff1e87fdc67..8bb1fad49da 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Users.Item.Onenote.Notebooks.Item.SectionGroups.Item.Sections.Item.ParentSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -51,19 +51,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -83,11 +82,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -101,25 +100,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Users.Item.Onenote.Notebooks.Item.SectionGroups.Item.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -156,11 +157,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -168,14 +169,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -247,42 +247,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index 1f6d11e4d06..06d6e3109ff 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,36 +33,38 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo output) => { + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); + }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, fileOption, outputOption); return command; } /// @@ -80,15 +82,15 @@ public Command BuildPutCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -96,12 +98,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file) => { + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -152,29 +153,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index e323e795394..de7e6093c6d 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,15 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -50,21 +50,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -98,19 +97,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index 56938c4a7f7..e0207c599db 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Users.Item.Onenote.Notebooks.Item.SectionGroups.Item.Sections.Item.Pages.Item.Preview; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -53,23 +53,22 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -89,15 +88,15 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -111,20 +110,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -167,15 +165,15 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -183,14 +181,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -263,42 +260,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \users\{user-id}\onenote\notebooks\{notebook-id}\sectionGroups\{sectionGroup-id}\sections\{onenoteSection-id}\pages\{onenotePage-id}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index f97d19b56ea..2852f4f83ef 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,15 +33,15 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -49,14 +49,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -92,18 +91,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index f01a9657e51..4c612be65bc 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,15 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -50,21 +50,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -98,19 +97,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index af3b85f6631..8d0a2aa70f8 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Notebooks.Item.SectionGroups.Item.Sections.Item.Pages.Item.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,23 +41,22 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -77,15 +76,15 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -99,20 +98,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -130,15 +128,15 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -146,14 +144,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -225,42 +222,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 2e94c270ff6..af870e70d4c 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,15 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -50,21 +50,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -98,19 +97,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index e6130b4afec..e8345a15ff3 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,15 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -50,21 +50,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -98,19 +97,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs index f0a075a57a3..ee62f76026f 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Onenote.Notebooks.Item.SectionGroups.Item.Sections.Item.Pages.Item.ParentSection.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -48,23 +48,22 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -84,15 +83,15 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -106,20 +105,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -137,15 +135,15 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -153,14 +151,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -232,42 +229,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index a47db7890ee..de48263edf4 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,30 +34,29 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); return command; } /// @@ -88,17 +87,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs index 010f6633534..10ff63af584 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Notebooks.Item.SectionGroups.Item.Sections.Item.Pages.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -49,11 +48,11 @@ public Command BuildCreateCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -61,21 +60,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -93,11 +91,11 @@ public Command BuildListCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -136,7 +134,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -147,15 +149,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -210,31 +207,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 1749776a779..a08a949ee4c 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index c9c719d2fbc..9d9189ea752 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Notebooks.Item.SectionGroups.Item.Sections.Item.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,19 +41,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -73,11 +72,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -91,20 +90,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -122,11 +120,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 489ac7b193c..b169535f3e0 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -66,11 +65,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,11 +113,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/SectionsRequestBuilder.cs index 391654b5e6c..981b13595d5 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Notebooks.Item.SectionGroups.Item.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -49,7 +48,7 @@ public Command BuildCreateCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -57,21 +56,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -89,7 +87,7 @@ public Command BuildListCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -128,7 +126,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -139,15 +141,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -202,31 +199,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/SectionGroupsRequestBuilder.cs index 3bf0dc5beab..ec51775296f 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Notebooks.Item.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, bodyOption, outputOption); return command; } /// @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -130,15 +132,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -193,31 +190,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index a839585d778..670c6a081cc 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,7 +34,7 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 662f68cccd6..9971395db4c 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,7 +34,7 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index 3f8da06a265..51a5fcb9660 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Users.Item.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -51,15 +51,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, onenoteSectionIdOption); return command; @@ -79,7 +78,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -93,25 +92,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Users.Item.Onenote.Notebooks.Item.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -131,7 +132,6 @@ public Command BuildParentSectionGroupCommand() { command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); command.AddCommand(builder.BuildPatchCommand()); command.AddCommand(builder.BuildSectionGroupsCommand()); command.AddCommand(builder.BuildSectionsCommand()); @@ -152,7 +152,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -160,14 +160,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -239,42 +238,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index 523744c4128..270a21167a3 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,32 +33,34 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, FileInfo output) => { + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); + }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, fileOption, outputOption); return command; } /// @@ -76,11 +78,11 @@ public Command BuildPutCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -88,12 +90,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, FileInfo file) => { + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -144,29 +145,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 94e079902e3..a3c4787872d 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index 2b15d842ddb..5d0ec78f5f7 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Users.Item.Onenote.Notebooks.Item.Sections.Item.Pages.Item.Preview; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -53,19 +53,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -85,11 +84,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -103,20 +102,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -159,11 +157,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -171,14 +169,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -251,42 +248,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \users\{user-id}\onenote\notebooks\{notebook-id}\sections\{onenoteSection-id}\pages\{onenotePage-id}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index 7c634334825..fcc846013d1 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,11 +33,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index c4e06de1b09..b88386cf994 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index eec67a23cc4..c903685cc1f 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Notebooks.Item.Sections.Item.Pages.Item.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,19 +41,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -73,11 +72,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -91,20 +90,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -122,11 +120,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 041609f5f0b..a48d153d53a 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 7e157fd049f..00b915a8f5c 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs index 53b9be58955..3511b58907f 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Onenote.Notebooks.Item.Sections.Item.Pages.Item.ParentSection.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -48,19 +48,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -80,11 +79,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -129,11 +127,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index bf9369a2bbd..8a8573c05e6 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,26 +34,25 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenotePageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/PagesRequestBuilder.cs index edc8f14df56..5def280eac8 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Notebooks.Item.Sections.Item.Pages.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -49,7 +48,7 @@ public Command BuildCreateCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -57,21 +56,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -89,7 +87,7 @@ public Command BuildListCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -128,7 +126,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -139,15 +141,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -202,31 +199,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 6d57572c35d..9e198cf74d1 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,7 +34,7 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 277c473bf34..df4430fc9ec 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Notebooks.Item.Sections.Item.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,15 +41,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, onenoteSectionIdOption); return command; @@ -69,7 +68,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -114,7 +112,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index dcfa06093eb..f5697fd45f5 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,7 +34,7 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs index adb8de29a65..9e662d410a3 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,15 +41,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, onenoteSectionIdOption); return command; @@ -69,7 +68,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -114,7 +112,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs deleted file mode 100644 index 9969a16da60..00000000000 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ /dev/null @@ -1,241 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Users.Item.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup.ParentSectionGroup { - /// Builds and executes requests for operations under \users\{user-id}\onenote\notebooks\{notebook-id}\sections\{onenoteSection-id}\parentSectionGroup\parentSectionGroup - public class ParentSectionGroupRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var notebookIdOption = new Option("--notebook-id", description: "key: id of notebook") { - }; - notebookIdOption.IsRequired = true; - command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var notebookIdOption = new Option("--notebook-id", description: "key: id of notebook") { - }; - notebookIdOption.IsRequired = true; - command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildPatchCommand() { - var command = new Command("patch"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var notebookIdOption = new Option("--notebook-id", description: "key: id of notebook") { - }; - notebookIdOption.IsRequired = true; - command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePatchRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new ParentSectionGroupRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public ParentSectionGroupRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/onenote/notebooks/{notebook_id}/sections/{onenoteSection_id}/parentSectionGroup/parentSectionGroup{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePatchRequestInformation(SectionGroup body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PATCH, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// The section group that contains the section group. Read-only. - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index d29c63c2291..2656129f4bb 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Users.Item.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,15 +37,14 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, onenoteSectionIdOption); return command; @@ -65,7 +64,7 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -79,20 +78,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -104,18 +102,6 @@ public Command BuildParentNotebookCommand() { command.AddCommand(builder.BuildPatchCommand()); return command; } - public Command BuildParentSectionGroupCommand() { - var command = new Command("parent-section-group"); - var builder = new ApiSdk.Users.Item.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup.ParentSectionGroupRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildDeleteCommand()); - command.AddCommand(builder.BuildGetCommand()); - command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); - command.AddCommand(builder.BuildPatchCommand()); - command.AddCommand(builder.BuildSectionGroupsCommand()); - command.AddCommand(builder.BuildSectionsCommand()); - return command; - } /// /// The section group that contains the section. Read-only. /// @@ -131,7 +117,7 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -139,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -154,6 +139,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Users.Item.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -161,6 +149,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Users.Item.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -232,42 +223,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs index 69e25e528de..2b0371db234 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -66,11 +65,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,11 +113,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs index a5b84b65d04..f143f20eab7 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,7 +43,7 @@ public Command BuildCreateCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildListCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 1407b4c16e9..35090fdf670 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 1c0f8aca868..c47edc6ebe8 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,11 @@ public Command BuildPostCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs index 4dcb5c74669..5a35ac6ae0f 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -48,19 +48,18 @@ public Command BuildDeleteCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenoteSectionId1) => { + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option); return command; @@ -80,11 +79,11 @@ public Command BuildGetCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -129,11 +127,11 @@ public Command BuildPatchCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, notebookIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs index 0173cd2fa45..deab0b7d195 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Notebooks.Item.Sections.Item.ParentSectionGroup.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -46,7 +45,7 @@ public Command BuildCreateCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,7 +84,7 @@ public Command BuildListCommand() { }; notebookIdOption.IsRequired = true; command.AddOption(notebookIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -125,7 +123,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/SectionsRequestBuilder.cs index 65205939efb..5c3aa519a44 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Notebooks.Item.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string notebookId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, bodyOption, outputOption); return command; } /// @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string notebookId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string notebookId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, notebookIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, notebookIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -194,31 +191,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Notebooks/NotebooksRequestBuilder.cs b/src/generated/Users/Item/Onenote/Notebooks/NotebooksRequestBuilder.cs index a3741500d7f..d127b164cdf 100644 --- a/src/generated/Users/Item/Onenote/Notebooks/NotebooksRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Notebooks/NotebooksRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Users.Item.Onenote.Notebooks.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -24,14 +24,13 @@ public class NotebooksRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new NotebookRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyNotebookCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyNotebookCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } public Command BuildGetNotebookFromWebUrlCommand() { @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -129,15 +131,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -193,18 +190,6 @@ public RequestInformation CreatePostRequestInformation(Notebook body, Action - /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \users\{user-id}\onenote\notebooks\microsoft.graph.getRecentNotebooks(includePersonalNotebooks={includePersonalNotebooks}) /// Usage: includePersonalNotebooks={includePersonalNotebooks} /// @@ -212,19 +197,6 @@ public GetRecentNotebooksWithIncludePersonalNotebooksRequestBuilder GetRecentNot _ = includePersonalNotebooks ?? throw new ArgumentNullException(nameof(includePersonalNotebooks)); return new GetRecentNotebooksWithIncludePersonalNotebooksRequestBuilder(PathParameters, RequestAdapter, includePersonalNotebooks); } - /// - /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/OnenoteRequestBuilder.cs b/src/generated/Users/Item/Onenote/OnenoteRequestBuilder.cs index ef73b921e89..b0e64cb0e5d 100644 --- a/src/generated/Users/Item/Onenote/OnenoteRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/OnenoteRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Users.Item.Onenote.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -36,11 +36,10 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + command.SetHandler(async (string userId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption); return command; @@ -66,25 +65,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildNotebooksCommand() { var command = new Command("notebooks"); var builder = new ApiSdk.Users.Item.Onenote.Notebooks.NotebooksRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildGetNotebookFromWebUrlCommand()); command.AddCommand(builder.BuildListCommand()); @@ -93,6 +94,9 @@ public Command BuildNotebooksCommand() { public Command BuildOperationsCommand() { var command = new Command("operations"); var builder = new ApiSdk.Users.Item.Onenote.Operations.OperationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -100,6 +104,9 @@ public Command BuildOperationsCommand() { public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Users.Item.Onenote.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -119,14 +126,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + command.SetHandler(async (string userId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, bodyOption); return command; @@ -134,6 +140,9 @@ public Command BuildPatchCommand() { public Command BuildResourcesCommand() { var command = new Command("resources"); var builder = new ApiSdk.Users.Item.Onenote.Resources.ResourcesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -141,6 +150,9 @@ public Command BuildResourcesCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Users.Item.Onenote.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -148,6 +160,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Users.Item.Onenote.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -219,42 +234,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Onenote model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Operations/Item/OnenoteOperationRequestBuilder.cs b/src/generated/Users/Item/Onenote/Operations/Item/OnenoteOperationRequestBuilder.cs index 238b6710c6a..e1b7e07b589 100644 --- a/src/generated/Users/Item/Onenote/Operations/Item/OnenoteOperationRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Operations/Item/OnenoteOperationRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteOperationIdOption = new Option("--onenoteoperation-id", description: "key: id of onenoteOperation") { + var onenoteOperationIdOption = new Option("--onenote-operation-id", description: "key: id of onenoteOperation") { }; onenoteOperationIdOption.IsRequired = true; command.AddOption(onenoteOperationIdOption); - command.SetHandler(async (string userId, string onenoteOperationId) => { + command.SetHandler(async (string userId, string onenoteOperationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteOperationIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteOperationIdOption = new Option("--onenoteoperation-id", description: "key: id of onenoteOperation") { + var onenoteOperationIdOption = new Option("--onenote-operation-id", description: "key: id of onenoteOperation") { }; onenoteOperationIdOption.IsRequired = true; command.AddOption(onenoteOperationIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteOperationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteOperationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteOperationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteOperationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteOperationIdOption = new Option("--onenoteoperation-id", description: "key: id of onenoteOperation") { + var onenoteOperationIdOption = new Option("--onenote-operation-id", description: "key: id of onenoteOperation") { }; onenoteOperationIdOption.IsRequired = true; command.AddOption(onenoteOperationIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteOperationId, string body) => { + command.SetHandler(async (string userId, string onenoteOperationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteOperationIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteOperation body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteOperation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Operations/OperationsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Operations/OperationsRequestBuilder.cs index 35d64154be8..30cb7a79898 100644 --- a/src/generated/Users/Item/Onenote/Operations/OperationsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Operations/OperationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Operations.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class OperationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteOperationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteOperation body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteOperation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The status of OneNote operations. Getting an operations collection is not supported, but you can get the status of long-running operations if the Operation-Location header is returned in the response. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/Content/ContentRequestBuilder.cs index a7150c0053a..e656ca38a9c 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,28 +29,30 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string userId, string onenotePageId, FileInfo output) => { + command.SetHandler(async (string userId, string onenotePageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, userIdOption, onenotePageIdOption, outputOption); + }, userIdOption, onenotePageIdOption, fileOption, outputOption); return command; } /// @@ -64,7 +66,7 @@ public Command BuildPutCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -72,12 +74,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, FileInfo file) => { + command.SetHandler(async (string userId, string onenotePageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, bodyOption); return command; @@ -128,29 +129,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Onenote/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 2b2f49754a8..6434db89768 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/OnenotePageRequestBuilder.cs index 5564fdb958c..8ec37d9da4b 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/OnenotePageRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.Preview; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -49,15 +49,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string onenotePageId) => { + command.SetHandler(async (string userId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption); return command; @@ -73,7 +72,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -87,20 +86,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -144,7 +142,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -152,14 +150,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, bodyOption); return command; @@ -232,42 +229,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The pages in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The pages in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The pages in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \users\{user-id}\onenote\pages\{onenotePage-id}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Users/Item/Onenote/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index 3f604455297..41537735e4b 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,7 +29,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 7e98c4ca4e3..318c32f702d 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 6051ba9e4a5..8ef14e2fccd 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,15 +39,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string onenotePageId) => { + command.SetHandler(async (string userId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,7 +102,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, bodyOption); return command; @@ -127,6 +124,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,6 +134,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -205,42 +208,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index b919401be08..312679be78f 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 8088d816ba9..dce3ad05e89 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,19 +37,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -65,11 +64,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,11 +108,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 344b48f43b4..d997f4b3657 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index b0ab032e2f2..5fef4a9a2e6 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -62,11 +61,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -80,20 +79,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -124,11 +122,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -136,14 +134,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -151,6 +148,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -158,6 +158,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -229,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index 0a06694d052..8ad4c691e45 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs index c686d153fc6..8dff7aac9fa 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,11 +39,11 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -80,11 +78,11 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 1910fdb62ea..bdfa102ec9b 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 5794da37b49..3342b50c537 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index 547ec6c64fe..cc32aad09d5 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.Sections.Item.ParentSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,23 +47,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -79,15 +78,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -101,25 +100,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -152,15 +153,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -168,14 +169,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -247,42 +247,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index 9a64b084761..d0f38054ed1 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,40 +29,42 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, FileInfo output) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, outputOption); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, fileOption, outputOption); return command; } /// @@ -76,19 +78,19 @@ public Command BuildPutCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -96,12 +98,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, FileInfo file) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); return command; @@ -152,29 +153,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 27b6b46f4d0..0716eb279ae 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,19 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -50,21 +50,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption, outputOption); return command; } /// @@ -98,19 +97,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index ea8b6745fee..2179440a6cd 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.Sections.Item.Pages.Item.Preview; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,27 +47,26 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option); return command; @@ -83,19 +82,19 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -109,20 +108,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -142,19 +140,19 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -162,14 +160,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); return command; @@ -242,42 +239,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \users\{user-id}\onenote\pages\{onenotePage-id}\parentNotebook\sectionGroups\{sectionGroup-id}\sections\{onenoteSection-id}\pages\{onenotePage-id1}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index 52d17e7badf..196c57c4122 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,19 +29,19 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -49,14 +49,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); return command; @@ -92,18 +91,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index d683af4c6e0..8fdff7f472d 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,34 +30,33 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string onenotePageId1, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageId1Option, outputOption); return command; } /// @@ -88,17 +87,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs index 0f2106be8a0..88ddb0db95a 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.Sections.Item.Pages.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -43,15 +42,15 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -59,21 +58,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -87,15 +85,15 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -134,7 +132,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -145,15 +147,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -208,31 +205,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 6ec067b15f4..d5ed535d97e 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 5c0201771fb..4d479fb9f13 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.Sections.Item.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,23 +37,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -69,15 +68,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -91,20 +90,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -118,15 +116,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 37dd8b84123..bd64f78ff74 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs index 7cc2271767f..318e2ea51de 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,11 +44,11 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -57,21 +56,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -85,11 +83,11 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -128,7 +126,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -139,15 +141,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -202,31 +199,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index 45402a112b5..5dc42cdb934 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -44,7 +43,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -80,7 +78,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -130,15 +132,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -193,31 +190,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index bb16cd95f33..11286a580bb 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 4e447e5d5fe..f0e4d6f522c 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index c5ddca11b0f..268cee33bcb 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,19 +47,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -75,11 +74,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -93,25 +92,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -131,7 +132,6 @@ public Command BuildParentSectionGroupCommand() { command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); command.AddCommand(builder.BuildPatchCommand()); command.AddCommand(builder.BuildSectionGroupsCommand()); command.AddCommand(builder.BuildSectionsCommand()); @@ -148,11 +148,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -160,14 +160,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -239,42 +238,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index 33020685bf2..3247cb35299 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,36 +29,38 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string onenotePageId1, FileInfo output) => { + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string onenotePageId1, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, outputOption); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, fileOption, outputOption); return command; } /// @@ -72,15 +74,15 @@ public Command BuildPutCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -88,12 +90,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string onenotePageId1, FileInfo file) => { + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string onenotePageId1, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); return command; @@ -144,29 +145,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 6b7309ae137..3b65d3cf553 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string onenotePageId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string onenotePageId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index ec1fa2b1858..94670f8843c 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.Pages.Item.Preview; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,23 +47,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string onenotePageId1) => { + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string onenotePageId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option); return command; @@ -79,15 +78,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -101,20 +100,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string onenotePageId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string onenotePageId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -134,15 +132,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -150,14 +148,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string onenotePageId1, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string onenotePageId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); return command; @@ -230,42 +227,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \users\{user-id}\onenote\pages\{onenotePage-id}\parentNotebook\sections\{onenoteSection-id}\pages\{onenotePage-id1}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index 97807a1e89b..371e602fecf 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,15 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string onenotePageId1, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string onenotePageId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index 2790f4e623b..2e9f5c58b11 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,30 +30,29 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string onenotePageId1) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string onenotePageId1, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, onenotePageId1Option, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs index 52d92183269..fa67db890b4 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.Pages.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -43,11 +42,11 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -55,21 +54,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -83,11 +81,11 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -126,7 +124,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -137,15 +139,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -200,31 +197,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index ce6ab0cb2dc..024fa956d4b 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 9b5c8555b4b..d2154af2537 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,19 +37,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -65,11 +64,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,11 +108,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index cda026e10a2..ceb58178a4a 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs index c9a5410992a..cd62b2978ab 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,19 +37,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -65,11 +64,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,11 +108,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs deleted file mode 100644 index 9e5cebb7377..00000000000 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ /dev/null @@ -1,241 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup.ParentSectionGroup { - /// Builds and executes requests for operations under \users\{user-id}\onenote\pages\{onenotePage-id}\parentNotebook\sections\{onenoteSection-id}\parentSectionGroup\parentSectionGroup - public class ParentSectionGroupRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { - }; - onenotePageIdOption.IsRequired = true; - command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { - }; - onenotePageIdOption.IsRequired = true; - command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildPatchCommand() { - var command = new Command("patch"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { - }; - onenotePageIdOption.IsRequired = true; - command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePatchRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new ParentSectionGroupRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public ParentSectionGroupRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/onenote/pages/{onenotePage_id}/parentNotebook/sections/{onenoteSection_id}/parentSectionGroup/parentSectionGroup{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePatchRequestInformation(SectionGroup body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PATCH, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// The section group that contains the section group. Read-only. - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 0c6cc6c7d50..5d7d7bc25d4 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,19 +33,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -61,11 +60,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -79,20 +78,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -104,18 +102,6 @@ public Command BuildParentNotebookCommand() { command.AddCommand(builder.BuildPatchCommand()); return command; } - public Command BuildParentSectionGroupCommand() { - var command = new Command("parent-section-group"); - var builder = new ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup.ParentSectionGroupRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildDeleteCommand()); - command.AddCommand(builder.BuildGetCommand()); - command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); - command.AddCommand(builder.BuildPatchCommand()); - command.AddCommand(builder.BuildSectionGroupsCommand()); - command.AddCommand(builder.BuildSectionsCommand()); - return command; - } /// /// The section group that contains the section. Read-only. /// @@ -127,11 +113,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -139,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -154,6 +139,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -161,6 +149,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -232,42 +223,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs index 04f42e97588..50325a25773 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs index 365c55dead8..681da7f6ca8 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,11 +39,11 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -80,11 +78,11 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 5c8e6a4902d..fc0232cb832 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index c2db80999e9..0a1965c0482 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs index 6625e5d9a89..aebc5952bba 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,23 +44,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1) => { + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option); return command; @@ -76,15 +75,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -125,15 +123,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs index 81610c9d35e..7e01d268c99 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item.ParentSectionGroup.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,11 +41,11 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -82,11 +80,11 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -125,7 +123,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs index 3e9c08c0750..35743258cc9 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentNotebook.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,7 +44,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -81,7 +79,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -194,31 +191,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 46581502062..6dd18e21d8d 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 733bcc504ee..ce894b2bf92 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/Pages/Item/Content/ContentRequestBuilder.cs index 514ad56ca9f..9b86d9e37c5 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,32 +29,34 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string userId, string onenotePageId, string onenotePageId1, FileInfo output) => { + command.SetHandler(async (string userId, string onenotePageId, string onenotePageId1, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, userIdOption, onenotePageIdOption, onenotePageId1Option, outputOption); + }, userIdOption, onenotePageIdOption, onenotePageId1Option, fileOption, outputOption); return command; } /// @@ -68,11 +70,11 @@ public Command BuildPutCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -80,12 +82,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenotePageId1, FileInfo file) => { + command.SetHandler(async (string userId, string onenotePageId, string onenotePageId1, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, onenotePageId1Option, bodyOption); return command; @@ -136,29 +137,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index a1d25c278b9..6cf96c3a513 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenotePageId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenotePageId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenotePageId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenotePageId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePageRequestBuilder.cs index b86a8f138f9..7969e8b24a1 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePageRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.Pages.Item.Preview; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,19 +47,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - command.SetHandler(async (string userId, string onenotePageId, string onenotePageId1) => { + command.SetHandler(async (string userId, string onenotePageId, string onenotePageId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, onenotePageId1Option); return command; @@ -75,11 +74,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -93,20 +92,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string onenotePageId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenotePageId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenotePageId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenotePageId1Option, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -126,11 +124,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -138,14 +136,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenotePageId1, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string onenotePageId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, onenotePageId1Option, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \users\{user-id}\onenote\pages\{onenotePage-id}\parentSection\pages\{onenotePage-id1}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index 225fb888b6d..71183de759e 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenotePageId1, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string onenotePageId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, onenotePageId1Option, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/Pages/Item/Preview/PreviewRequestBuilder.cs index 82c1007d77c..b374fa47b24 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,26 +30,25 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenotePageId1Option = new Option("--onenotepage-id1", description: "key: id of onenotePage") { + var onenotePageId1Option = new Option("--onenote-page-id1", description: "key: id of onenotePage") { }; onenotePageId1Option.IsRequired = true; command.AddOption(onenotePageId1Option); - command.SetHandler(async (string userId, string onenotePageId, string onenotePageId1) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenotePageId1, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenotePageId1Option); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenotePageId1Option, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/Pages/PagesRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/Pages/PagesRequestBuilder.cs index 07be5ac1cb9..303b5a1a03b 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/Pages/PagesRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.Pages.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -43,7 +42,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -51,21 +50,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -79,7 +77,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -129,15 +131,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -192,31 +189,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 3bb058df685..ca4d027b55f 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/ParentNotebookRequestBuilder.cs index dacf033db81..7a00053be10 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,15 +39,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string onenotePageId) => { + command.SetHandler(async (string userId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,7 +102,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, bodyOption); return command; @@ -127,6 +124,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,6 +134,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -205,42 +208,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index d965e9cd905..5ac76501dd0 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 66a47c46d02..05fa3670405 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.SectionGroups.Item.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,19 +37,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -65,11 +64,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,11 +108,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 85af2b215f0..2200dfcd5c7 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index 5bcc98b3dc8..416fa14b9f0 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.SectionGroups.Item.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -62,11 +61,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -80,20 +79,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -124,11 +122,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -136,14 +134,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -151,6 +148,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.SectionGroups.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -158,6 +158,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.SectionGroups.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -229,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index 09c3a06d1ae..3f9fd25277e 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs index 765d7b4e609..3126b1c3525 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.SectionGroups.Item.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,11 +39,11 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -80,11 +78,11 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 7992c95d195..cdc6f56e583 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index f047f96288e..38214842259 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index 1c1a39dc33d..16952811ef4 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.SectionGroups.Item.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,23 +44,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -76,15 +75,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -125,15 +123,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs index 10803f52a7e..a0061fe774b 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.SectionGroups.Item.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,11 +41,11 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -82,11 +80,11 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -125,7 +123,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index 653b4bffcf6..9f07aa31909 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -44,7 +43,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -80,7 +78,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -130,15 +132,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -193,31 +190,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index a7e97182fe4..bcd7169daa7 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 0752d94c409..189c1f1340d 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index 92821274a72..5f7a100872a 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,19 +44,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -72,11 +71,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -117,11 +115,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/SectionsRequestBuilder.cs index c0d981c0760..b3cc180b303 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentNotebook.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,7 +41,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -78,7 +76,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -117,7 +115,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 63e4c2ddcc1..8301e332282 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs index 4cfdee6ecd7..d7bef673bf8 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.ParentNotebook.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,15 +39,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string onenotePageId) => { + command.SetHandler(async (string userId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,7 +102,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, bodyOption); return command; @@ -127,6 +124,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,6 +134,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -205,42 +208,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index 3359b5c2294..9b801dbf662 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index 18151492166..3f1dc50ff13 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.ParentNotebook.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 51b2abadc23..87e1a40e9be 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index ed9049f6399..b45d872b87f 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index 54a6136f28d..201b05b4149 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.ParentNotebook.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,19 +44,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -72,11 +71,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -117,11 +115,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs index a5d448d7630..28b7cd6ca7e 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.ParentNotebook.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,7 +41,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -78,7 +76,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -117,7 +115,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs deleted file mode 100644 index 8c1bac39781..00000000000 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ /dev/null @@ -1,229 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.ParentSectionGroup { - /// Builds and executes requests for operations under \users\{user-id}\onenote\pages\{onenotePage-id}\parentSection\parentSectionGroup\parentSectionGroup - public class ParentSectionGroupRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { - }; - onenotePageIdOption.IsRequired = true; - command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string onenotePageId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userIdOption, onenotePageIdOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { - }; - onenotePageIdOption.IsRequired = true; - command.AddOption(onenotePageIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, selectOption, expandOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildPatchCommand() { - var command = new Command("patch"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { - }; - onenotePageIdOption.IsRequired = true; - command.AddOption(onenotePageIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePatchRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userIdOption, onenotePageIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new ParentSectionGroupRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public ParentSectionGroupRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/onenote/pages/{onenotePage_id}/parentSection/parentSectionGroup/parentSectionGroup{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePatchRequestInformation(SectionGroup body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PATCH, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// The section group that contains the section group. Read-only. - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 6d46ba775cf..d0c78eab0c0 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,15 +33,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string onenotePageId) => { + command.SetHandler(async (string userId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption); return command; @@ -57,7 +56,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -71,20 +70,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -98,18 +96,6 @@ public Command BuildParentNotebookCommand() { command.AddCommand(builder.BuildSectionsCommand()); return command; } - public Command BuildParentSectionGroupCommand() { - var command = new Command("parent-section-group"); - var builder = new ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.ParentSectionGroupRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildDeleteCommand()); - command.AddCommand(builder.BuildGetCommand()); - command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); - command.AddCommand(builder.BuildPatchCommand()); - command.AddCommand(builder.BuildSectionGroupsCommand()); - command.AddCommand(builder.BuildSectionsCommand()); - return command; - } /// /// The section group that contains the section. Read-only. /// @@ -121,7 +107,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -129,14 +115,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, bodyOption); return command; @@ -144,6 +129,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -151,6 +139,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -222,42 +213,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs index f448196ddc1..18d05597d49 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs index db55fb50c80..13b629651eb 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index f0766f284b5..5c4cef5b198 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 6f41d1b1531..92bfdfb7faf 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs index 3664e3195f0..9f3c0694eb4 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,19 +44,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, onenoteSectionIdOption); return command; @@ -72,11 +71,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -117,11 +115,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/SectionsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/SectionsRequestBuilder.cs index 006bcaee9be..68ec341e572 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionGroup/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,7 +41,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -78,7 +76,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -117,7 +115,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs index aa42f720b35..e0f9f5e0021 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.ParentSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,15 +47,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string onenotePageId) => { + command.SetHandler(async (string userId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption); return command; @@ -71,7 +70,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -85,25 +84,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Users.Item.Onenote.Pages.Item.ParentSection.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -125,7 +126,6 @@ public Command BuildParentSectionGroupCommand() { command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); command.AddCommand(builder.BuildPatchCommand()); command.AddCommand(builder.BuildSectionGroupsCommand()); command.AddCommand(builder.BuildSectionsCommand()); @@ -142,7 +142,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -150,14 +150,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenotePageId, string body) => { + command.SetHandler(async (string userId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenotePageIdOption, bodyOption); return command; @@ -229,42 +228,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/Item/Preview/PreviewRequestBuilder.cs index 8c201626d3f..7d216f55085 100644 --- a/src/generated/Users/Item/Onenote/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string onenotePageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenotePageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenotePageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenotePageIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Pages/PagesRequestBuilder.cs b/src/generated/Users/Item/Onenote/Pages/PagesRequestBuilder.cs index 599daeed980..a85865e88d5 100644 --- a/src/generated/Users/Item/Onenote/Pages/PagesRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Pages.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -112,7 +110,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -186,31 +183,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The pages in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The pages in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The pages in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Resources/Item/Content/ContentRequestBuilder.cs b/src/generated/Users/Item/Onenote/Resources/Item/Content/ContentRequestBuilder.cs index bdb4a1fc471..1d121985ff6 100644 --- a/src/generated/Users/Item/Onenote/Resources/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Resources/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,28 +29,30 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteResourceIdOption = new Option("--onenoteresource-id", description: "key: id of onenoteResource") { + var onenoteResourceIdOption = new Option("--onenote-resource-id", description: "key: id of onenoteResource") { }; onenoteResourceIdOption.IsRequired = true; command.AddOption(onenoteResourceIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string userId, string onenoteResourceId, FileInfo output) => { + command.SetHandler(async (string userId, string onenoteResourceId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, userIdOption, onenoteResourceIdOption, outputOption); + }, userIdOption, onenoteResourceIdOption, fileOption, outputOption); return command; } /// @@ -64,7 +66,7 @@ public Command BuildPutCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteResourceIdOption = new Option("--onenoteresource-id", description: "key: id of onenoteResource") { + var onenoteResourceIdOption = new Option("--onenote-resource-id", description: "key: id of onenoteResource") { }; onenoteResourceIdOption.IsRequired = true; command.AddOption(onenoteResourceIdOption); @@ -72,12 +74,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteResourceId, FileInfo file) => { + command.SetHandler(async (string userId, string onenoteResourceId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteResourceIdOption, bodyOption); return command; @@ -128,29 +129,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property resources from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property resources in users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Onenote/Resources/Item/OnenoteResourceRequestBuilder.cs b/src/generated/Users/Item/Onenote/Resources/Item/OnenoteResourceRequestBuilder.cs index d4d563f2b84..8852ed2cc5b 100644 --- a/src/generated/Users/Item/Onenote/Resources/Item/OnenoteResourceRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Resources/Item/OnenoteResourceRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Resources.Item.Content; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteResourceIdOption = new Option("--onenoteresource-id", description: "key: id of onenoteResource") { + var onenoteResourceIdOption = new Option("--onenote-resource-id", description: "key: id of onenoteResource") { }; onenoteResourceIdOption.IsRequired = true; command.AddOption(onenoteResourceIdOption); - command.SetHandler(async (string userId, string onenoteResourceId) => { + command.SetHandler(async (string userId, string onenoteResourceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteResourceIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteResourceIdOption = new Option("--onenoteresource-id", description: "key: id of onenoteResource") { + var onenoteResourceIdOption = new Option("--onenote-resource-id", description: "key: id of onenoteResource") { }; onenoteResourceIdOption.IsRequired = true; command.AddOption(onenoteResourceIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteResourceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteResourceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteResourceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteResourceIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,7 +101,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteResourceIdOption = new Option("--onenoteresource-id", description: "key: id of onenoteResource") { + var onenoteResourceIdOption = new Option("--onenote-resource-id", description: "key: id of onenoteResource") { }; onenoteResourceIdOption.IsRequired = true; command.AddOption(onenoteResourceIdOption); @@ -111,14 +109,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteResourceId, string body) => { + command.SetHandler(async (string userId, string onenoteResourceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteResourceIdOption, bodyOption); return command; @@ -190,42 +187,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteResource body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Resources/ResourcesRequestBuilder.cs b/src/generated/Users/Item/Onenote/Resources/ResourcesRequestBuilder.cs index 4b5c8042313..66ef4883f9a 100644 --- a/src/generated/Users/Item/Onenote/Resources/ResourcesRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Resources/ResourcesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Resources.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class ResourcesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteResourceRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteResource body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The image and other file resources in OneNote pages. Getting a resources collection is not supported, but you can get the binary content of a specific resource. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 4fb101ad7ba..89bbda8d944 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 1fdf2b173ab..3510958fad3 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Users.Item.Onenote.SectionGroups.Item.ParentNotebook.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,15 +39,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string userId, string sectionGroupId) => { + command.SetHandler(async (string userId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,7 +102,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string body) => { + command.SetHandler(async (string userId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, bodyOption); return command; @@ -127,6 +124,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Users.Item.Onenote.SectionGroups.Item.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,6 +134,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Users.Item.Onenote.SectionGroups.Item.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -205,42 +208,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index dfe3e3afc08..283360284d9 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string userId, string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string userId, string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string userId, string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index d29d530d0d4..a96a55978e8 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.SectionGroups.Item.ParentNotebook.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 5ba0b49f8bf..9c416c553c8 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 1811b36b655..e127f250886 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index 456c5826c06..eeafa7948e1 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Users.Item.Onenote.SectionGroups.Item.ParentNotebook.Sections.Item.ParentSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,19 +47,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -75,11 +74,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -93,25 +92,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Users.Item.Onenote.SectionGroups.Item.ParentNotebook.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -144,11 +145,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -156,14 +157,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -235,42 +235,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index c60d86ca30e..254637c5b6d 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,36 +29,38 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo output) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, fileOption, outputOption); return command; } /// @@ -72,15 +74,15 @@ public Command BuildPutCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -88,12 +90,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -144,29 +145,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 5b7d854fe52..ca6d0ee3920 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index 8e2c0a01f84..6eb75664029 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Users.Item.Onenote.SectionGroups.Item.ParentNotebook.Sections.Item.Pages.Item.Preview; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -49,23 +49,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -81,15 +80,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -103,20 +102,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -155,15 +153,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -171,14 +169,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -251,42 +248,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \users\{user-id}\onenote\sectionGroups\{sectionGroup-id}\parentNotebook\sections\{onenoteSection-id}\pages\{onenotePage-id}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index 5395c03d1d5..dfa055bbe23 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,15 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 8a8a6d927cc..0301ea26861 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index f68ce741295..e1e5f1f3735 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.SectionGroups.Item.ParentNotebook.Sections.Item.Pages.Item.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,23 +37,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -69,15 +68,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -91,20 +90,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -118,15 +116,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs index feb4995bafd..86e01d4168d 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 5482e6be7be..3882a2bc0a6 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs index 3ef5e4bc6b8..55c17b17aa5 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Onenote.SectionGroups.Item.ParentNotebook.Sections.Item.Pages.Item.ParentSection.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,23 +44,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -76,15 +75,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -125,15 +123,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index 123e4851ef7..3d87a6d60a8 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,30 +30,29 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs index 7343dd61af6..3f46358f9fd 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.SectionGroups.Item.ParentNotebook.Sections.Item.Pages.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,11 +44,11 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -57,21 +56,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -85,11 +83,11 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -128,7 +126,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -139,15 +141,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -202,31 +199,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 85db5fa8708..1080fc75781 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index c9aacfdb72d..22daba9fa0b 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.SectionGroups.Item.ParentNotebook.Sections.Item.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,19 +37,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -65,11 +64,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,11 +108,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 45fd8f2ffcf..cb292ee5d50 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs index 18cbc241e05..5c977558151 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.SectionGroups.Item.ParentNotebook.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,7 +44,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -81,7 +79,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -194,31 +191,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index fcc32da18d4..02539d68112 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string userId, string sectionGroupId) => { + command.SetHandler(async (string userId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string body) => { + command.SetHandler(async (string userId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/SectionGroupRequestBuilder.cs index 2ea07329e0e..6dd2780b62d 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Users.Item.Onenote.SectionGroups.Item.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string userId, string sectionGroupId) => { + command.SetHandler(async (string userId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption); return command; @@ -58,7 +57,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -72,20 +71,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -118,7 +116,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -126,14 +124,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string body) => { + command.SetHandler(async (string userId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, bodyOption); return command; @@ -141,6 +138,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Users.Item.Onenote.SectionGroups.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -148,6 +148,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Users.Item.Onenote.SectionGroups.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -219,42 +222,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index 44cdf1a602e..91b00b1dd84 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string userId, string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string userId, string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string userId, string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs index a7960fe2851..04640ee85e2 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.SectionGroups.Item.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 90c1150227a..7c5fc0e3b15 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 488967bc1ca..12d9469fcd5 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index 220365e060e..1bfc6d3fa6c 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Users.Item.Onenote.SectionGroups.Item.Sections.Item.ParentSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,19 +47,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -75,11 +74,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -93,25 +92,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Users.Item.Onenote.SectionGroups.Item.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -146,11 +147,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -158,14 +159,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -237,42 +237,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index c51241973dc..597501b1038 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,36 +29,38 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo output) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, fileOption, outputOption); return command; } /// @@ -72,15 +74,15 @@ public Command BuildPutCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -88,12 +90,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -144,29 +145,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 1a195ede27d..40ca598c37c 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index 03107ea4a35..928f5f1e66d 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Users.Item.Onenote.SectionGroups.Item.Sections.Item.Pages.Item.Preview; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -49,23 +49,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -81,15 +80,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -103,20 +102,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -157,15 +155,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -173,14 +171,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -253,42 +250,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \users\{user-id}\onenote\sectionGroups\{sectionGroup-id}\sections\{onenoteSection-id}\pages\{onenotePage-id}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index d3e1a2f82ef..9ccf6780c04 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,15 +29,15 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 3adefb21079..eff20f266e5 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 0aac60ec719..1fdbc7dfa16 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Users.Item.Onenote.SectionGroups.Item.Sections.Item.Pages.Item.ParentNotebook.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,23 +39,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -71,15 +70,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -93,20 +92,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -120,15 +118,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -136,14 +134,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -151,6 +148,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Users.Item.Onenote.SectionGroups.Item.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -158,6 +158,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Users.Item.Onenote.SectionGroups.Item.Sections.Item.Pages.Item.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -229,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index 576c3722ff6..f8a453b90d7 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,27 +30,26 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string sectionGroupId1) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupId1Option); return command; @@ -66,19 +65,19 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -92,20 +91,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -119,19 +117,19 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -139,14 +137,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string sectionGroupId1, string body) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupId1Option, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index 967c0c68bcb..0d6ad15373a 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.SectionGroups.Item.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,15 +39,15 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -84,15 +82,15 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -131,7 +129,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -142,15 +144,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -205,31 +202,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index c92648c7354..7ae8602eac6 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,19 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -50,21 +50,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -98,19 +97,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index d00430f6d66..e53d0c97c9b 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,19 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -50,21 +50,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -98,19 +97,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index ec90a4d6c80..d8deceff4a3 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Onenote.SectionGroups.Item.Sections.Item.Pages.Item.ParentNotebook.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,27 +44,26 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option); return command; @@ -80,19 +79,19 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -106,20 +105,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -133,19 +131,19 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -153,14 +151,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -232,42 +229,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs index c77ec2cdc07..c4688018639 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.SectionGroups.Item.Sections.Item.Pages.Item.ParentNotebook.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,15 +41,15 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -58,21 +57,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -86,15 +84,15 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -133,7 +131,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -144,15 +146,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -207,31 +204,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs index ecee0e5546b..88f8af931de 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 65c2dc78115..fe6879357bb 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs index c6c20aa07f8..8d9b9d005b6 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Onenote.SectionGroups.Item.Sections.Item.Pages.Item.ParentSection.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,23 +44,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -76,15 +75,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -125,15 +123,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index 6a4bc2ed184..42d19e811b9 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,30 +30,29 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenotePageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs index eaeb3770afc..8e53249ae8d 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.SectionGroups.Item.Sections.Item.Pages.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,11 +44,11 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -57,21 +56,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -85,11 +83,11 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -128,7 +126,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -139,15 +141,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -202,31 +199,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 2cc3c7e23d1..2f56aec8b62 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index f1f0a2b223f..c4d3f130089 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Users.Item.Onenote.SectionGroups.Item.Sections.Item.ParentNotebook.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,19 +39,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -67,11 +66,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -85,20 +84,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -112,11 +110,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -124,14 +122,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -139,6 +136,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Users.Item.Onenote.SectionGroups.Item.Sections.Item.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -146,6 +146,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Users.Item.Onenote.SectionGroups.Item.Sections.Item.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -217,42 +220,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index 8ede00ef052..022b823cc70 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string sectionGroupId1) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, sectionGroupId1Option); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string sectionGroupId1, string body) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, sectionGroupId1Option, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index 58813271367..d0b6a4fa773 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.SectionGroups.Item.Sections.Item.ParentNotebook.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,11 +39,11 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -80,11 +78,11 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index f43c367c752..8874f9742fa 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index f260f40d95f..53cb449cc9f 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index 5e843b0740f..663d8808248 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Onenote.SectionGroups.Item.Sections.Item.ParentNotebook.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,23 +44,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option); return command; @@ -76,15 +75,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -125,15 +123,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs index 8ced69ebf3d..ef5ea59f377 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.SectionGroups.Item.Sections.Item.ParentNotebook.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,11 +41,11 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -82,11 +80,11 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -125,7 +123,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index dca870b15dc..7a5d9c7f983 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string sectionGroupId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, sectionGroupIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/SectionsRequestBuilder.cs index 3204e46a0fe..7eadf022579 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.SectionGroups.Item.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,7 +44,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -81,7 +79,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -194,31 +191,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Users/Item/Onenote/SectionGroups/SectionGroupsRequestBuilder.cs index 7fdc0828623..872c7bd1d09 100644 --- a/src/generated/Users/Item/Onenote/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -122,15 +124,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -185,31 +182,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 7e28a5dc0ec..4067573a99e 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 733394080b3..f8a0c71494f 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/OnenoteSectionRequestBuilder.cs index 5197c94d780..e0a0ef8b209 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.ParentSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -47,15 +47,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption); return command; @@ -71,7 +70,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -85,25 +84,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildPagesCommand() { var command = new Command("pages"); var builder = new ApiSdk.Users.Item.Onenote.Sections.Item.Pages.PagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -125,7 +126,6 @@ public Command BuildParentSectionGroupCommand() { command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); command.AddCommand(builder.BuildPatchCommand()); command.AddCommand(builder.BuildSectionGroupsCommand()); command.AddCommand(builder.BuildSectionsCommand()); @@ -142,7 +142,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -150,14 +150,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -229,42 +228,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs index decaa19c294..89c148a8bdf 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,32 +29,34 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, FileInfo output) => { + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, fileOption, outputOption); return command; } /// @@ -68,11 +70,11 @@ public Command BuildPutCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -80,12 +82,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, FileInfo file) => { + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -136,29 +137,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property pages from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property pages in users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs index 4996112da8a..8d9ec195d2d 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/CopyToSection/CopyToSectionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSection - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs index f701de6fa62..7e99cab0359 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/OnenotePageRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.Pages.Item.Preview; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -49,19 +49,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -77,11 +76,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -95,20 +94,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildOnenotePatchContentCommand() { @@ -149,11 +147,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -161,14 +159,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -241,42 +238,6 @@ public RequestInformation CreatePatchRequestInformation(OnenotePage body, Action return requestInfo; } /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \users\{user-id}\onenote\sections\{onenoteSection-id}\pages\{onenotePage-id}\microsoft.graph.preview() /// public PreviewRequestBuilder Preview() { diff --git a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs index 3cd75c811f8..7e1b0b50cbb 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/OnenotePatchContent/OnenotePatchContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(OnenotePatchContentReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action onenotePatchContent - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePatchContentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index f43da0e7941..c49bba3ee08 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index b3b103ec8e6..16d59e8c423 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,19 +39,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -67,11 +66,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -85,20 +84,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -112,11 +110,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -124,14 +122,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -139,6 +136,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Users.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -146,6 +146,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Users.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -217,42 +220,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index 0ad29bc9b8b..786f19ada58 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index cedcfd5702a..c7bc710586c 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.Item.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,23 +37,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -69,15 +68,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -91,20 +90,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -118,15 +116,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index f1dbbc11adb..3c1856feba7 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index b3a6fc18472..e12b2a6c29a 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.Item.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,23 +34,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId) => { + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption); return command; @@ -66,15 +65,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -88,20 +87,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -132,15 +130,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -148,14 +146,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body) => { + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); return command; @@ -163,6 +160,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Users.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -170,6 +170,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Users.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -241,42 +244,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index ac7b8d407a7..c8f7f2d0ff7 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,27 +30,26 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -66,19 +65,19 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -92,20 +91,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -119,19 +117,19 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -139,14 +137,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs index b6b29f4cef5..b2356524f40 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.Item.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,15 +39,15 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -84,15 +82,15 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -131,7 +129,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -142,15 +144,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -205,31 +202,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 6a5b4d5a075..c320eee947d 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,19 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -50,21 +50,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -98,19 +97,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index ac07bc722fd..d2753dd99a1 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,19 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -50,21 +50,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -98,19 +97,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index 4938944c147..4f5d25bc0f4 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.Item.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,27 +44,26 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1) => { + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option); return command; @@ -80,19 +79,19 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -106,20 +105,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -133,19 +131,19 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -153,14 +151,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -232,42 +229,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs index 3457b801797..10b1b77fe79 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.Item.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,15 +41,15 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -58,21 +57,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -86,15 +84,15 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -133,7 +131,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -144,15 +146,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -207,31 +204,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index 10af63b8b1f..362f3d1abaa 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -44,11 +43,11 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -84,11 +82,11 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -127,7 +125,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -138,15 +140,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -201,31 +198,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 76603915e3d..354ac2117d1 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index a295eff38c0..7ebce137581 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index 21dedcfc536..1cf9f57fc12 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,23 +44,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1) => { + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option); return command; @@ -76,15 +75,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -125,15 +123,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs index c14e0236b41..4712457dad9 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.Pages.Item.ParentNotebook.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,11 +41,11 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -82,11 +80,11 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -125,7 +123,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 941d233f322..d62a2ed8cbc 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 7e71c3566a5..7ef172bff1b 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentSection/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs index 555136206bb..b63678cb776 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/ParentSection/ParentSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.Pages.Item.ParentSection.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,19 +44,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId) => { + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, onenotePageIdOption); return command; @@ -72,11 +71,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -117,11 +115,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string body) => { + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section that contains the page. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section that contains the page. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs index 50e4d4d29aa..ca3c3be36f4 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/Pages/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,26 +30,25 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenotePageIdOption = new Option("--onenotepage-id", description: "key: id of onenotePage") { + var onenotePageIdOption = new Option("--onenote-page-id", description: "key: id of onenotePage") { }; onenotePageIdOption.IsRequired = true; command.AddOption(onenotePageIdOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenotePageId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenotePageIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenotePageIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenotePagePreview public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Sections/Item/Pages/PagesRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/Pages/PagesRequestBuilder.cs index ba3a451515c..1d4c62fcbe4 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/Pages/PagesRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/Pages/PagesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.Pages.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class PagesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenotePageRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildCopyToSectionCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildOnenotePatchContentCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyToSectionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildOnenotePatchContentCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,7 +44,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -53,21 +52,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -81,7 +79,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -120,7 +118,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -131,15 +133,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -194,31 +191,6 @@ public RequestInformation CreatePostRequestInformation(OnenotePage body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of pages in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenotePage model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of pages in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index d04c907c494..48f478968cd 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index eccadf27adf..311172517d2 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.ParentNotebook.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,15 +39,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,7 +102,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -127,6 +124,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Users.Item.Onenote.Sections.Item.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,6 +134,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Users.Item.Onenote.Sections.Item.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -205,42 +208,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index f5e6bb4ac7e..47bcd86c299 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs index 992923cc92a..ce8819b3187 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.ParentNotebook.SectionGroups.Item.ParentNotebook.CopyNotebook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -37,19 +37,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -65,11 +64,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,11 +108,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 2e6aba2c55e..265a2fe7881 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index 1d1c12e6181..2ead7a88a3a 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.ParentNotebook.SectionGroups.Item.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -62,11 +61,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -80,20 +79,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -124,11 +122,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -136,14 +134,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -151,6 +148,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Users.Item.Onenote.Sections.Item.ParentNotebook.SectionGroups.Item.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -158,6 +158,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Users.Item.Onenote.Sections.Item.ParentNotebook.SectionGroups.Item.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -229,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs index 091ad918c53..525db21ab62 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string sectionGroupId1) => { + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string sectionGroupId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, sectionGroupId1Option); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string sectionGroupId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, sectionGroupId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var sectionGroupId1Option = new Option("--sectiongroup-id1", description: "key: id of sectionGroup") { + var sectionGroupId1Option = new Option("--section-group-id1", description: "key: id of sectionGroup") { }; sectionGroupId1Option.IsRequired = true; command.AddOption(sectionGroupId1Option); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string sectionGroupId1, string body) => { + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string sectionGroupId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, sectionGroupId1Option, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs index 36e93310f62..8156f540857 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.ParentNotebook.SectionGroups.Item.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,11 +39,11 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -80,11 +78,11 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 1c0b389eba8..8f463619109 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index d30f80a8ff4..2ebc8367d4a 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,15 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -46,21 +46,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -94,19 +93,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs index 10ee73c9667..57c3dcd42f8 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.ParentNotebook.SectionGroups.Item.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,23 +44,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1) => { + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option); return command; @@ -76,15 +75,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -98,20 +97,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -125,15 +123,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -141,14 +139,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs index 047eb9781f3..9a47b58ec2d 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/Item/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.ParentNotebook.SectionGroups.Item.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,11 +41,11 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -54,21 +53,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption, outputOption); return command; } /// @@ -82,11 +80,11 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -125,7 +123,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -199,31 +196,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index d4aeb615086..b205b37bd6d 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.ParentNotebook.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - builder.BuildSectionGroupsCommand(), - builder.BuildSectionsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSectionGroupsCommand()); + commands.Add(builder.BuildSectionsCommand()); return commands; } /// @@ -44,7 +43,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -80,7 +78,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -130,15 +132,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -193,31 +190,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index c52174500a5..2a97c0142db 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index c77642e0711..bb2a35ec84b 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index ad6095e0624..fadf22992fe 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.ParentNotebook.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,19 +44,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1) => { + command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, onenoteSectionId1Option); return command; @@ -72,11 +71,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -117,11 +115,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs index 7764901c874..626bda93510 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.ParentNotebook.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,7 +41,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -78,7 +76,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -117,7 +115,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs index b2dff94d714..06a732583ba 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/CopyNotebook/CopyNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(CopyNotebookRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs index 5c7e729e223..a5ce28feb4b 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/ParentNotebookRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.ParentSectionGroup.ParentNotebook.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,15 +39,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption); return command; @@ -63,7 +62,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,7 +102,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -127,6 +124,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Users.Item.Onenote.Sections.Item.ParentSectionGroup.ParentNotebook.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -134,6 +134,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Users.Item.Onenote.Sections.Item.ParentSectionGroup.ParentNotebook.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -205,42 +208,6 @@ public RequestInformation CreatePatchRequestInformation(Notebook body, Action - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The notebook that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Notebook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The notebook that contains the section group. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs index 2a0da2b3073..7cfc2a9f5aa 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs index fb9c1894844..d8ebdb7f007 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.ParentSectionGroup.ParentNotebook.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index fd8d0180e50..8c16d811e69 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 148fc419878..5803923bf7a 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs index d536c5fb57b..afa9562d34e 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.ParentSectionGroup.ParentNotebook.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,19 +44,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1) => { + command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, onenoteSectionId1Option); return command; @@ -72,11 +71,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -117,11 +115,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs index c6558064584..e6f90dd43dd 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentNotebook/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.ParentSectionGroup.ParentNotebook.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,7 +41,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -78,7 +76,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -117,7 +115,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the notebook. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the notebook. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs deleted file mode 100644 index 06c823c7991..00000000000 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ /dev/null @@ -1,229 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Users.Item.Onenote.Sections.Item.ParentSectionGroup.ParentSectionGroup { - /// Builds and executes requests for operations under \users\{user-id}\onenote\sections\{onenoteSection-id}\parentSectionGroup\parentSectionGroup - public class ParentSectionGroupRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string onenoteSectionId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userIdOption, onenoteSectionIdOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - var selectOption = new Option("--select", description: "Select properties to be returned") { - Arity = ArgumentArity.ZeroOrMore - }; - selectOption.IsRequired = false; - command.AddOption(selectOption); - var expandOption = new Option("--expand", description: "Expand related entities") { - Arity = ArgumentArity.ZeroOrMore - }; - expandOption.IsRequired = false; - command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string[] select, string[] expand) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Select = select; - q.Expand = expand; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, selectOption, expandOption); - return command; - } - /// - /// The section group that contains the section group. Read-only. - /// - public Command BuildPatchCommand() { - var command = new Command("patch"); - command.Description = "The section group that contains the section group. Read-only."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { - }; - onenoteSectionIdOption.IsRequired = true; - command.AddOption(onenoteSectionIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePatchRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userIdOption, onenoteSectionIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new ParentSectionGroupRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public ParentSectionGroupRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/onenote/sections/{onenoteSection_id}/parentSectionGroup/parentSectionGroup{?select,expand}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePatchRequestInformation(SectionGroup body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PATCH, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section group. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// The section group that contains the section group. Read-only. - public class GetQueryParameters : QueryParametersBase { - /// Expand related entities - public string[] Expand { get; set; } - /// Select properties to be returned - public string[] Select { get; set; } - } - } -} diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs index 0ed6d95b75c..55c3f9d1c0e 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/ParentSectionGroupRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.ParentSectionGroup.Sections; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,15 +33,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - command.SetHandler(async (string userId, string onenoteSectionId) => { + command.SetHandler(async (string userId, string onenoteSectionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption); return command; @@ -57,7 +56,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -71,20 +70,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildParentNotebookCommand() { @@ -98,18 +96,6 @@ public Command BuildParentNotebookCommand() { command.AddCommand(builder.BuildSectionsCommand()); return command; } - public Command BuildParentSectionGroupCommand() { - var command = new Command("parent-section-group"); - var builder = new ApiSdk.Users.Item.Onenote.Sections.Item.ParentSectionGroup.ParentSectionGroupRequestBuilder(PathParameters, RequestAdapter); - command.AddCommand(builder.BuildDeleteCommand()); - command.AddCommand(builder.BuildGetCommand()); - command.AddCommand(builder.BuildParentNotebookCommand()); - command.AddCommand(builder.BuildParentSectionGroupCommand()); - command.AddCommand(builder.BuildPatchCommand()); - command.AddCommand(builder.BuildSectionGroupsCommand()); - command.AddCommand(builder.BuildSectionsCommand()); - return command; - } /// /// The section group that contains the section. Read-only. /// @@ -121,7 +107,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -129,14 +115,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string body) => { + command.SetHandler(async (string userId, string onenoteSectionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, bodyOption); return command; @@ -144,6 +129,9 @@ public Command BuildPatchCommand() { public Command BuildSectionGroupsCommand() { var command = new Command("section-groups"); var builder = new ApiSdk.Users.Item.Onenote.Sections.Item.ParentSectionGroup.SectionGroups.SectionGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -151,6 +139,9 @@ public Command BuildSectionGroupsCommand() { public Command BuildSectionsCommand() { var command = new Command("sections"); var builder = new ApiSdk.Users.Item.Onenote.Sections.Item.ParentSectionGroup.Sections.SectionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -222,42 +213,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section group that contains the section. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section group that contains the section. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs index d0f86ec3745..87e99673f32 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/Item/SectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId) => { + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var sectionGroupIdOption = new Option("--sectiongroup-id", description: "key: id of sectionGroup") { + var sectionGroupIdOption = new Option("--section-group-id", description: "key: id of sectionGroup") { }; sectionGroupIdOption.IsRequired = true; command.AddOption(sectionGroupIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string body) => { + command.SetHandler(async (string userId, string onenoteSectionId, string sectionGroupId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, sectionGroupIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(SectionGroup body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs index bb1bab8b394..9a666047579 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/SectionGroups/SectionGroupsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.ParentSectionGroup.SectionGroups.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SectionGroupsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SectionGroupRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(SectionGroup body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The section groups in the section. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SectionGroup model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The section groups in the section. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs index 46df050da95..32eca8e7e59 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToNotebook/CopyToNotebookRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToNotebookRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToNotebook - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToNotebookRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToNotebookResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs index 8b4c83690dc..ac54c255770 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/CopyToSectionGroup/CopyToSectionGroupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -42,21 +42,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption, outputOption); return command; } /// @@ -90,19 +89,6 @@ public RequestInformation CreatePostRequestInformation(CopyToSectionGroupRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copyToSectionGroup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyToSectionGroupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onenoteOperation public class CopyToSectionGroupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs index 61870ae60d1..6b7eadbce80 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/Item/OnenoteSectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.ParentSectionGroup.Sections.Item.CopyToSectionGroup; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -44,19 +44,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); - command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1) => { + command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, onenoteSectionId1Option); return command; @@ -72,11 +71,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, onenoteSectionId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -117,11 +115,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); - var onenoteSectionId1Option = new Option("--onenotesection-id1", description: "key: id of onenoteSection") { + var onenoteSectionId1Option = new Option("--onenote-section-id1", description: "key: id of onenoteSection") { }; onenoteSectionId1Option.IsRequired = true; command.AddOption(onenoteSectionId1Option); @@ -129,14 +127,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1, string body) => { + command.SetHandler(async (string userId, string onenoteSectionId, string onenoteSectionId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onenoteSectionIdOption, onenoteSectionId1Option, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(OnenoteSection body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs index e4c7b564427..c986344263a 100644 --- a/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/Item/ParentSectionGroup/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item.ParentSectionGroup.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -42,7 +41,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -50,21 +49,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onenoteSectionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, bodyOption, outputOption); return command; } /// @@ -78,7 +76,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onenoteSectionIdOption = new Option("--onenotesection-id", description: "key: id of onenoteSection") { + var onenoteSectionIdOption = new Option("--onenote-section-id", description: "key: id of onenoteSection") { }; onenoteSectionIdOption.IsRequired = true; command.AddOption(onenoteSectionIdOption); @@ -117,7 +115,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onenoteSectionId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -128,15 +130,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onenoteSectionIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,31 +188,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in the section group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in the section group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Onenote/Sections/SectionsRequestBuilder.cs b/src/generated/Users/Item/Onenote/Sections/SectionsRequestBuilder.cs index 3e042ed255c..28471c5d290 100644 --- a/src/generated/Users/Item/Onenote/Sections/SectionsRequestBuilder.cs +++ b/src/generated/Users/Item/Onenote/Sections/SectionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Onenote.Sections.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,16 +22,15 @@ public class SectionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnenoteSectionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildCopyToNotebookCommand(), - builder.BuildCopyToSectionGroupCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPagesCommand(), - builder.BuildParentNotebookCommand(), - builder.BuildParentSectionGroupCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildCopyToNotebookCommand()); + commands.Add(builder.BuildCopyToSectionGroupCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPagesCommand()); + commands.Add(builder.BuildParentNotebookCommand()); + commands.Add(builder.BuildParentSectionGroupCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -112,7 +110,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -123,15 +125,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -186,31 +183,6 @@ public RequestInformation CreatePostRequestInformation(OnenoteSection body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnenoteSection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The sections in all OneNote notebooks that are owned by the user or group. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/OnlineMeetings/CreateOrGet/CreateOrGetRequestBuilder.cs b/src/generated/Users/Item/OnlineMeetings/CreateOrGet/CreateOrGetRequestBuilder.cs index 2bd05b562a8..ef1cffa3830 100644 --- a/src/generated/Users/Item/OnlineMeetings/CreateOrGet/CreateOrGetRequestBuilder.cs +++ b/src/generated/Users/Item/OnlineMeetings/CreateOrGet/CreateOrGetRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CreateOrGetRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createOrGet - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateOrGetRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes onlineMeeting public class CreateOrGetResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/OnlineMeetings/Item/AttendanceReports/AttendanceReportsRequestBuilder.cs b/src/generated/Users/Item/OnlineMeetings/Item/AttendanceReports/AttendanceReportsRequestBuilder.cs index e4f073b4bf7..56d6523ff1f 100644 --- a/src/generated/Users/Item/OnlineMeetings/Item/AttendanceReports/AttendanceReportsRequestBuilder.cs +++ b/src/generated/Users/Item/OnlineMeetings/Item/AttendanceReports/AttendanceReportsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.OnlineMeetings.Item.AttendanceReports.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class AttendanceReportsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new MeetingAttendanceReportRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAttendanceRecordsCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAttendanceRecordsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -41,7 +40,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onlineMeetingId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onlineMeetingId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onlineMeetingIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onlineMeetingIdOption, bodyOption, outputOption); return command; } /// @@ -77,7 +75,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); @@ -116,7 +114,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onlineMeetingId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onlineMeetingId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -127,15 +129,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onlineMeetingIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onlineMeetingIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -190,31 +187,6 @@ public RequestInformation CreatePostRequestInformation(MeetingAttendanceReport b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The attendance reports of an online meeting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The attendance reports of an online meeting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MeetingAttendanceReport model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The attendance reports of an online meeting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/OnlineMeetings/Item/AttendanceReports/Item/AttendanceRecords/AttendanceRecordsRequestBuilder.cs b/src/generated/Users/Item/OnlineMeetings/Item/AttendanceReports/Item/AttendanceRecords/AttendanceRecordsRequestBuilder.cs index 529625c540f..e568c20fe67 100644 --- a/src/generated/Users/Item/OnlineMeetings/Item/AttendanceReports/Item/AttendanceRecords/AttendanceRecordsRequestBuilder.cs +++ b/src/generated/Users/Item/OnlineMeetings/Item/AttendanceReports/Item/AttendanceRecords/AttendanceRecordsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.OnlineMeetings.Item.AttendanceReports.Item.AttendanceRecords.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class AttendanceRecordsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new AttendanceRecordRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,11 +39,11 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - var meetingAttendanceReportIdOption = new Option("--meetingattendancereport-id", description: "key: id of meetingAttendanceReport") { + var meetingAttendanceReportIdOption = new Option("--meeting-attendance-report-id", description: "key: id of meetingAttendanceReport") { }; meetingAttendanceReportIdOption.IsRequired = true; command.AddOption(meetingAttendanceReportIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onlineMeetingId, string meetingAttendanceReportId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onlineMeetingId, string meetingAttendanceReportId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onlineMeetingIdOption, meetingAttendanceReportIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onlineMeetingIdOption, meetingAttendanceReportIdOption, bodyOption, outputOption); return command; } /// @@ -80,11 +78,11 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - var meetingAttendanceReportIdOption = new Option("--meetingattendancereport-id", description: "key: id of meetingAttendanceReport") { + var meetingAttendanceReportIdOption = new Option("--meeting-attendance-report-id", description: "key: id of meetingAttendanceReport") { }; meetingAttendanceReportIdOption.IsRequired = true; command.AddOption(meetingAttendanceReportIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onlineMeetingId, string meetingAttendanceReportId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onlineMeetingId, string meetingAttendanceReportId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onlineMeetingIdOption, meetingAttendanceReportIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onlineMeetingIdOption, meetingAttendanceReportIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(AttendanceRecord body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of attendance records of an attendance report. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of attendance records of an attendance report. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AttendanceRecord model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// List of attendance records of an attendance report. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/OnlineMeetings/Item/AttendanceReports/Item/AttendanceRecords/Item/AttendanceRecordRequestBuilder.cs b/src/generated/Users/Item/OnlineMeetings/Item/AttendanceReports/Item/AttendanceRecords/Item/AttendanceRecordRequestBuilder.cs index 9702ba5ca66..2dc37e19f08 100644 --- a/src/generated/Users/Item/OnlineMeetings/Item/AttendanceReports/Item/AttendanceRecords/Item/AttendanceRecordRequestBuilder.cs +++ b/src/generated/Users/Item/OnlineMeetings/Item/AttendanceReports/Item/AttendanceRecords/Item/AttendanceRecordRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - var meetingAttendanceReportIdOption = new Option("--meetingattendancereport-id", description: "key: id of meetingAttendanceReport") { + var meetingAttendanceReportIdOption = new Option("--meeting-attendance-report-id", description: "key: id of meetingAttendanceReport") { }; meetingAttendanceReportIdOption.IsRequired = true; command.AddOption(meetingAttendanceReportIdOption); - var attendanceRecordIdOption = new Option("--attendancerecord-id", description: "key: id of attendanceRecord") { + var attendanceRecordIdOption = new Option("--attendance-record-id", description: "key: id of attendanceRecord") { }; attendanceRecordIdOption.IsRequired = true; command.AddOption(attendanceRecordIdOption); - command.SetHandler(async (string userId, string onlineMeetingId, string meetingAttendanceReportId, string attendanceRecordId) => { + command.SetHandler(async (string userId, string onlineMeetingId, string meetingAttendanceReportId, string attendanceRecordId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onlineMeetingIdOption, meetingAttendanceReportIdOption, attendanceRecordIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - var meetingAttendanceReportIdOption = new Option("--meetingattendancereport-id", description: "key: id of meetingAttendanceReport") { + var meetingAttendanceReportIdOption = new Option("--meeting-attendance-report-id", description: "key: id of meetingAttendanceReport") { }; meetingAttendanceReportIdOption.IsRequired = true; command.AddOption(meetingAttendanceReportIdOption); - var attendanceRecordIdOption = new Option("--attendancerecord-id", description: "key: id of attendanceRecord") { + var attendanceRecordIdOption = new Option("--attendance-record-id", description: "key: id of attendanceRecord") { }; attendanceRecordIdOption.IsRequired = true; command.AddOption(attendanceRecordIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onlineMeetingId, string meetingAttendanceReportId, string attendanceRecordId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onlineMeetingId, string meetingAttendanceReportId, string attendanceRecordId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onlineMeetingIdOption, meetingAttendanceReportIdOption, attendanceRecordIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onlineMeetingIdOption, meetingAttendanceReportIdOption, attendanceRecordIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - var meetingAttendanceReportIdOption = new Option("--meetingattendancereport-id", description: "key: id of meetingAttendanceReport") { + var meetingAttendanceReportIdOption = new Option("--meeting-attendance-report-id", description: "key: id of meetingAttendanceReport") { }; meetingAttendanceReportIdOption.IsRequired = true; command.AddOption(meetingAttendanceReportIdOption); - var attendanceRecordIdOption = new Option("--attendancerecord-id", description: "key: id of attendanceRecord") { + var attendanceRecordIdOption = new Option("--attendance-record-id", description: "key: id of attendanceRecord") { }; attendanceRecordIdOption.IsRequired = true; command.AddOption(attendanceRecordIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onlineMeetingId, string meetingAttendanceReportId, string attendanceRecordId, string body) => { + command.SetHandler(async (string userId, string onlineMeetingId, string meetingAttendanceReportId, string attendanceRecordId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onlineMeetingIdOption, meetingAttendanceReportIdOption, attendanceRecordIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(AttendanceRecord body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// List of attendance records of an attendance report. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of attendance records of an attendance report. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// List of attendance records of an attendance report. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(AttendanceRecord model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// List of attendance records of an attendance report. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/OnlineMeetings/Item/AttendanceReports/Item/MeetingAttendanceReportRequestBuilder.cs b/src/generated/Users/Item/OnlineMeetings/Item/AttendanceReports/Item/MeetingAttendanceReportRequestBuilder.cs index 5caf45b60ee..f65077dc575 100644 --- a/src/generated/Users/Item/OnlineMeetings/Item/AttendanceReports/Item/MeetingAttendanceReportRequestBuilder.cs +++ b/src/generated/Users/Item/OnlineMeetings/Item/AttendanceReports/Item/MeetingAttendanceReportRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.OnlineMeetings.Item.AttendanceReports.Item.AttendanceRecords; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,6 +23,9 @@ public class MeetingAttendanceReportRequestBuilder { public Command BuildAttendanceRecordsCommand() { var command = new Command("attendance-records"); var builder = new ApiSdk.Users.Item.OnlineMeetings.Item.AttendanceReports.Item.AttendanceRecords.AttendanceRecordsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -38,19 +41,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - var meetingAttendanceReportIdOption = new Option("--meetingattendancereport-id", description: "key: id of meetingAttendanceReport") { + var meetingAttendanceReportIdOption = new Option("--meeting-attendance-report-id", description: "key: id of meetingAttendanceReport") { }; meetingAttendanceReportIdOption.IsRequired = true; command.AddOption(meetingAttendanceReportIdOption); - command.SetHandler(async (string userId, string onlineMeetingId, string meetingAttendanceReportId) => { + command.SetHandler(async (string userId, string onlineMeetingId, string meetingAttendanceReportId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onlineMeetingIdOption, meetingAttendanceReportIdOption); return command; @@ -66,11 +68,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - var meetingAttendanceReportIdOption = new Option("--meetingattendancereport-id", description: "key: id of meetingAttendanceReport") { + var meetingAttendanceReportIdOption = new Option("--meeting-attendance-report-id", description: "key: id of meetingAttendanceReport") { }; meetingAttendanceReportIdOption.IsRequired = true; command.AddOption(meetingAttendanceReportIdOption); @@ -84,20 +86,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onlineMeetingId, string meetingAttendanceReportId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onlineMeetingId, string meetingAttendanceReportId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onlineMeetingIdOption, meetingAttendanceReportIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onlineMeetingIdOption, meetingAttendanceReportIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,11 +112,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - var meetingAttendanceReportIdOption = new Option("--meetingattendancereport-id", description: "key: id of meetingAttendanceReport") { + var meetingAttendanceReportIdOption = new Option("--meeting-attendance-report-id", description: "key: id of meetingAttendanceReport") { }; meetingAttendanceReportIdOption.IsRequired = true; command.AddOption(meetingAttendanceReportIdOption); @@ -123,14 +124,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onlineMeetingId, string meetingAttendanceReportId, string body) => { + command.SetHandler(async (string userId, string onlineMeetingId, string meetingAttendanceReportId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onlineMeetingIdOption, meetingAttendanceReportIdOption, bodyOption); return command; @@ -202,42 +202,6 @@ public RequestInformation CreatePatchRequestInformation(MeetingAttendanceReport requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The attendance reports of an online meeting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The attendance reports of an online meeting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The attendance reports of an online meeting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(MeetingAttendanceReport model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The attendance reports of an online meeting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/OnlineMeetings/Item/AttendeeReport/AttendeeReportRequestBuilder.cs b/src/generated/Users/Item/OnlineMeetings/Item/AttendeeReport/AttendeeReportRequestBuilder.cs index ae579d46b7f..cd2ba7cd2a6 100644 --- a/src/generated/Users/Item/OnlineMeetings/Item/AttendeeReport/AttendeeReportRequestBuilder.cs +++ b/src/generated/Users/Item/OnlineMeetings/Item/AttendeeReport/AttendeeReportRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,28 +29,30 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string userId, string onlineMeetingId, FileInfo output) => { + command.SetHandler(async (string userId, string onlineMeetingId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, userIdOption, onlineMeetingIdOption, outputOption); + }, userIdOption, onlineMeetingIdOption, fileOption, outputOption); return command; } /// @@ -64,7 +66,7 @@ public Command BuildPutCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); @@ -72,12 +74,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onlineMeetingId, FileInfo file) => { + command.SetHandler(async (string userId, string onlineMeetingId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onlineMeetingIdOption, bodyOption); return command; @@ -128,29 +129,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property onlineMeetings from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property onlineMeetings in users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/OnlineMeetings/Item/OnlineMeetingRequestBuilder.cs b/src/generated/Users/Item/OnlineMeetings/Item/OnlineMeetingRequestBuilder.cs index a940111efc1..6e3114e4e94 100644 --- a/src/generated/Users/Item/OnlineMeetings/Item/OnlineMeetingRequestBuilder.cs +++ b/src/generated/Users/Item/OnlineMeetings/Item/OnlineMeetingRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.OnlineMeetings.Item.AttendeeReport; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -24,6 +24,9 @@ public class OnlineMeetingRequestBuilder { public Command BuildAttendanceReportsCommand() { var command = new Command("attendance-reports"); var builder = new ApiSdk.Users.Item.OnlineMeetings.Item.AttendanceReports.AttendanceReportsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -46,15 +49,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); - command.SetHandler(async (string userId, string onlineMeetingId) => { + command.SetHandler(async (string userId, string onlineMeetingId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onlineMeetingIdOption); return command; @@ -70,7 +72,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); @@ -84,20 +86,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string onlineMeetingId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string onlineMeetingId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, onlineMeetingIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, onlineMeetingIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,7 +112,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var onlineMeetingIdOption = new Option("--onlinemeeting-id", description: "key: id of onlineMeeting") { + var onlineMeetingIdOption = new Option("--online-meeting-id", description: "key: id of onlineMeeting") { }; onlineMeetingIdOption.IsRequired = true; command.AddOption(onlineMeetingIdOption); @@ -119,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string onlineMeetingId, string body) => { + command.SetHandler(async (string userId, string onlineMeetingId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, onlineMeetingIdOption, bodyOption); return command; @@ -198,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(OnlineMeeting body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property onlineMeetings for users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get onlineMeetings from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property onlineMeetings in users - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OnlineMeeting model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get onlineMeetings from users public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/OnlineMeetings/OnlineMeetingsRequestBuilder.cs b/src/generated/Users/Item/OnlineMeetings/OnlineMeetingsRequestBuilder.cs index 774c4ccbbdc..409cb2f3351 100644 --- a/src/generated/Users/Item/OnlineMeetings/OnlineMeetingsRequestBuilder.cs +++ b/src/generated/Users/Item/OnlineMeetings/OnlineMeetingsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.OnlineMeetings.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,13 +23,12 @@ public class OnlineMeetingsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OnlineMeetingRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAttendanceReportsCommand(), - builder.BuildAttendeeReportCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAttendanceReportsCommand()); + commands.Add(builder.BuildAttendeeReportCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -47,21 +46,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } public Command BuildCreateOrGetCommand() { @@ -116,7 +114,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -127,15 +129,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -190,31 +187,6 @@ public RequestInformation CreatePostRequestInformation(OnlineMeeting body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get onlineMeetings from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to onlineMeetings for users - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OnlineMeeting model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get onlineMeetings from users public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Outlook/MasterCategories/Item/OutlookCategoryRequestBuilder.cs b/src/generated/Users/Item/Outlook/MasterCategories/Item/OutlookCategoryRequestBuilder.cs index dd8fb59fdc3..ac9173ab016 100644 --- a/src/generated/Users/Item/Outlook/MasterCategories/Item/OutlookCategoryRequestBuilder.cs +++ b/src/generated/Users/Item/Outlook/MasterCategories/Item/OutlookCategoryRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var outlookCategoryIdOption = new Option("--outlookcategory-id", description: "key: id of outlookCategory") { + var outlookCategoryIdOption = new Option("--outlook-category-id", description: "key: id of outlookCategory") { }; outlookCategoryIdOption.IsRequired = true; command.AddOption(outlookCategoryIdOption); - command.SetHandler(async (string userId, string outlookCategoryId) => { + command.SetHandler(async (string userId, string outlookCategoryId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, outlookCategoryIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var outlookCategoryIdOption = new Option("--outlookcategory-id", description: "key: id of outlookCategory") { + var outlookCategoryIdOption = new Option("--outlook-category-id", description: "key: id of outlookCategory") { }; outlookCategoryIdOption.IsRequired = true; command.AddOption(outlookCategoryIdOption); @@ -63,19 +62,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string outlookCategoryId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string outlookCategoryId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, outlookCategoryIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, outlookCategoryIdOption, selectOption, outputOption); return command; } /// @@ -89,7 +87,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var outlookCategoryIdOption = new Option("--outlookcategory-id", description: "key: id of outlookCategory") { + var outlookCategoryIdOption = new Option("--outlook-category-id", description: "key: id of outlookCategory") { }; outlookCategoryIdOption.IsRequired = true; command.AddOption(outlookCategoryIdOption); @@ -97,14 +95,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string outlookCategoryId, string body) => { + command.SetHandler(async (string userId, string outlookCategoryId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, outlookCategoryIdOption, bodyOption); return command; @@ -176,42 +173,6 @@ public RequestInformation CreatePatchRequestInformation(OutlookCategory body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A list of categories defined for the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A list of categories defined for the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A list of categories defined for the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OutlookCategory model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A list of categories defined for the user. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/Outlook/MasterCategories/MasterCategoriesRequestBuilder.cs b/src/generated/Users/Item/Outlook/MasterCategories/MasterCategoriesRequestBuilder.cs index 206374d542f..90b8fe41cbc 100644 --- a/src/generated/Users/Item/Outlook/MasterCategories/MasterCategoriesRequestBuilder.cs +++ b/src/generated/Users/Item/Outlook/MasterCategories/MasterCategoriesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Outlook.MasterCategories.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class MasterCategoriesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new OutlookCategoryRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -98,7 +96,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -107,15 +109,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -170,31 +167,6 @@ public RequestInformation CreatePostRequestInformation(OutlookCategory body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A list of categories defined for the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A list of categories defined for the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OutlookCategory model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A list of categories defined for the user. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Outlook/OutlookRequestBuilder.cs b/src/generated/Users/Item/Outlook/OutlookRequestBuilder.cs index 3135cbdf18e..a1e74ed7a13 100644 --- a/src/generated/Users/Item/Outlook/OutlookRequestBuilder.cs +++ b/src/generated/Users/Item/Outlook/OutlookRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Users.Item.Outlook.SupportedTimeZonesWithTimeZoneStandard; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + command.SetHandler(async (string userId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption); return command; @@ -59,24 +58,26 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, selectOption, outputOption); return command; } public Command BuildMasterCategoriesCommand() { var command = new Command("master-categories"); var builder = new ApiSdk.Users.Item.Outlook.MasterCategories.MasterCategoriesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -96,14 +97,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + command.SetHandler(async (string userId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, bodyOption); return command; @@ -176,42 +176,6 @@ public RequestInformation CreatePatchRequestInformation(OutlookUser body, Action return requestInfo; } /// - /// Selective Outlook services available to the user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Selective Outlook services available to the user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Selective Outlook services available to the user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(OutlookUser model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \users\{user-id}\outlook\microsoft.graph.supportedLanguages() /// public SupportedLanguagesRequestBuilder SupportedLanguages() { diff --git a/src/generated/Users/Item/Outlook/SupportedLanguages/SupportedLanguages.cs b/src/generated/Users/Item/Outlook/SupportedLanguages/SupportedLanguages.cs deleted file mode 100644 index ce9085ff9e3..00000000000 --- a/src/generated/Users/Item/Outlook/SupportedLanguages/SupportedLanguages.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.Outlook.SupportedLanguages { - public class SupportedLanguages : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// A name representing the user's locale in natural language, for example, 'English (United States)'. - public string DisplayName { get; set; } - /// A locale representation for the user, which includes the user's preferred language and country/region. For example, 'en-us'. The language component follows 2-letter codes as defined in ISO 639-1, and the country component follows 2-letter codes as defined in ISO 3166-1 alpha-2. - public string Locale { get; set; } - /// - /// Instantiates a new supportedLanguages and sets the default values. - /// - public SupportedLanguages() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"displayName", (o,n) => { (o as SupportedLanguages).DisplayName = n.GetStringValue(); } }, - {"locale", (o,n) => { (o as SupportedLanguages).Locale = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("displayName", DisplayName); - writer.WriteStringValue("locale", Locale); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/Outlook/SupportedLanguages/SupportedLanguagesRequestBuilder.cs b/src/generated/Users/Item/Outlook/SupportedLanguages/SupportedLanguagesRequestBuilder.cs index 30057ef34ab..a58589e1ec1 100644 --- a/src/generated/Users/Item/Outlook/SupportedLanguages/SupportedLanguagesRequestBuilder.cs +++ b/src/generated/Users/Item/Outlook/SupportedLanguages/SupportedLanguagesRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +30,17 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function supportedLanguages - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Outlook/SupportedTimeZones/SupportedTimeZones.cs b/src/generated/Users/Item/Outlook/SupportedTimeZones/SupportedTimeZones.cs deleted file mode 100644 index cf2c9f9abd7..00000000000 --- a/src/generated/Users/Item/Outlook/SupportedTimeZones/SupportedTimeZones.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.Outlook.SupportedTimeZones { - public class SupportedTimeZones : IParsable { - /// An identifier for the time zone. - public string @Alias { get; set; } - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// A display string that represents the time zone. - public string DisplayName { get; set; } - /// - /// Instantiates a new supportedTimeZones and sets the default values. - /// - public SupportedTimeZones() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"alias", (o,n) => { (o as SupportedTimeZones).@Alias = n.GetStringValue(); } }, - {"displayName", (o,n) => { (o as SupportedTimeZones).DisplayName = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("alias", @Alias); - writer.WriteStringValue("displayName", DisplayName); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/Outlook/SupportedTimeZones/SupportedTimeZonesRequestBuilder.cs b/src/generated/Users/Item/Outlook/SupportedTimeZones/SupportedTimeZonesRequestBuilder.cs index 20bd6d3bd8a..573f4db046a 100644 --- a/src/generated/Users/Item/Outlook/SupportedTimeZones/SupportedTimeZonesRequestBuilder.cs +++ b/src/generated/Users/Item/Outlook/SupportedTimeZones/SupportedTimeZonesRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +30,17 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, outputOption); return command; } /// @@ -71,16 +71,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function supportedTimeZones - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Outlook/SupportedTimeZonesWithTimeZoneStandard/SupportedTimeZonesWithTimeZoneStandard.cs b/src/generated/Users/Item/Outlook/SupportedTimeZonesWithTimeZoneStandard/SupportedTimeZonesWithTimeZoneStandard.cs deleted file mode 100644 index 841e2977d57..00000000000 --- a/src/generated/Users/Item/Outlook/SupportedTimeZonesWithTimeZoneStandard/SupportedTimeZonesWithTimeZoneStandard.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.Outlook.SupportedTimeZonesWithTimeZoneStandard { - public class SupportedTimeZonesWithTimeZoneStandard : IParsable { - /// An identifier for the time zone. - public string @Alias { get; set; } - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// A display string that represents the time zone. - public string DisplayName { get; set; } - /// - /// Instantiates a new supportedTimeZonesWithTimeZoneStandard and sets the default values. - /// - public SupportedTimeZonesWithTimeZoneStandard() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"alias", (o,n) => { (o as SupportedTimeZonesWithTimeZoneStandard).@Alias = n.GetStringValue(); } }, - {"displayName", (o,n) => { (o as SupportedTimeZonesWithTimeZoneStandard).DisplayName = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("alias", @Alias); - writer.WriteStringValue("displayName", DisplayName); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/Outlook/SupportedTimeZonesWithTimeZoneStandard/SupportedTimeZonesWithTimeZoneStandardRequestBuilder.cs b/src/generated/Users/Item/Outlook/SupportedTimeZonesWithTimeZoneStandard/SupportedTimeZonesWithTimeZoneStandardRequestBuilder.cs index f57d7b0ea22..11755d02157 100644 --- a/src/generated/Users/Item/Outlook/SupportedTimeZonesWithTimeZoneStandard/SupportedTimeZonesWithTimeZoneStandardRequestBuilder.cs +++ b/src/generated/Users/Item/Outlook/SupportedTimeZonesWithTimeZoneStandard/SupportedTimeZonesWithTimeZoneStandardRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,22 +30,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var TimeZoneStandardOption = new Option("--timezonestandard", description: "Usage: TimeZoneStandard={TimeZoneStandard}") { + var TimeZoneStandardOption = new Option("--time-zone-standard", description: "Usage: TimeZoneStandard={TimeZoneStandard}") { }; TimeZoneStandardOption.IsRequired = true; command.AddOption(TimeZoneStandardOption); - command.SetHandler(async (string userId, object TimeZoneStandard) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, object TimeZoneStandard, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, TimeZoneStandardOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, TimeZoneStandardOption, outputOption); return command; } /// @@ -77,16 +77,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function supportedTimeZones - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/OwnedDevices/@Ref/@Ref.cs b/src/generated/Users/Item/OwnedDevices/@Ref/@Ref.cs deleted file mode 100644 index 40f0c3705e3..00000000000 --- a/src/generated/Users/Item/OwnedDevices/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.OwnedDevices.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/OwnedDevices/@Ref/RefRequestBuilder.cs b/src/generated/Users/Item/OwnedDevices/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 450b31dd539..00000000000 --- a/src/generated/Users/Item/OwnedDevices/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Users.Item.OwnedDevices.@Ref { - /// Builds and executes requests for operations under \users\{user-id}\ownedDevices\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Devices that are owned by the user. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Devices that are owned by the user. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/ownedDevices/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Users.Item.OwnedDevices.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Users.Item.OwnedDevices.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Users/Item/OwnedDevices/@Ref/RefResponse.cs b/src/generated/Users/Item/OwnedDevices/@Ref/RefResponse.cs deleted file mode 100644 index 94665421005..00000000000 --- a/src/generated/Users/Item/OwnedDevices/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.OwnedDevices.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/OwnedDevices/OwnedDevicesRequestBuilder.cs b/src/generated/Users/Item/OwnedDevices/OwnedDevicesRequestBuilder.cs index 9dd447aa5dc..008c55d91da 100644 --- a/src/generated/Users/Item/OwnedDevices/OwnedDevicesRequestBuilder.cs +++ b/src/generated/Users/Item/OwnedDevices/OwnedDevicesRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Users.Item.OwnedDevices.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Users.Item.OwnedDevices.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Users.Item.OwnedDevices.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/OwnedDevices/Ref/Ref.cs b/src/generated/Users/Item/OwnedDevices/Ref/Ref.cs new file mode 100644 index 00000000000..a9bbb23ad6b --- /dev/null +++ b/src/generated/Users/Item/OwnedDevices/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.OwnedDevices.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/OwnedDevices/Ref/RefRequestBuilder.cs b/src/generated/Users/Item/OwnedDevices/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..ad88826c78d --- /dev/null +++ b/src/generated/Users/Item/OwnedDevices/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Users.Item.OwnedDevices.Ref { + /// Builds and executes requests for operations under \users\{user-id}\ownedDevices\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Devices that are owned by the user. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Devices that are owned by the user. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/users/{user_id}/ownedDevices/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Users.Item.OwnedDevices.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Devices that are owned by the user. Read-only. Nullable. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Users/Item/OwnedDevices/Ref/RefResponse.cs b/src/generated/Users/Item/OwnedDevices/Ref/RefResponse.cs new file mode 100644 index 00000000000..b93a790f2df --- /dev/null +++ b/src/generated/Users/Item/OwnedDevices/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.OwnedDevices.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/OwnedObjects/@Ref/@Ref.cs b/src/generated/Users/Item/OwnedObjects/@Ref/@Ref.cs deleted file mode 100644 index fc61bda4072..00000000000 --- a/src/generated/Users/Item/OwnedObjects/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.OwnedObjects.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/OwnedObjects/@Ref/RefRequestBuilder.cs b/src/generated/Users/Item/OwnedObjects/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 632bc2b0098..00000000000 --- a/src/generated/Users/Item/OwnedObjects/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Users.Item.OwnedObjects.@Ref { - /// Builds and executes requests for operations under \users\{user-id}\ownedObjects\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Directory objects that are owned by the user. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Directory objects that are owned by the user. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/ownedObjects/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Users.Item.OwnedObjects.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Users.Item.OwnedObjects.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Users/Item/OwnedObjects/@Ref/RefResponse.cs b/src/generated/Users/Item/OwnedObjects/@Ref/RefResponse.cs deleted file mode 100644 index 22e6dfd3c6f..00000000000 --- a/src/generated/Users/Item/OwnedObjects/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.OwnedObjects.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/OwnedObjects/OwnedObjectsRequestBuilder.cs b/src/generated/Users/Item/OwnedObjects/OwnedObjectsRequestBuilder.cs index aafc047c9a4..957c0ca5313 100644 --- a/src/generated/Users/Item/OwnedObjects/OwnedObjectsRequestBuilder.cs +++ b/src/generated/Users/Item/OwnedObjects/OwnedObjectsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Users.Item.OwnedObjects.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Users.Item.OwnedObjects.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Users.Item.OwnedObjects.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/OwnedObjects/Ref/Ref.cs b/src/generated/Users/Item/OwnedObjects/Ref/Ref.cs new file mode 100644 index 00000000000..aabf9cb85c3 --- /dev/null +++ b/src/generated/Users/Item/OwnedObjects/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.OwnedObjects.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/OwnedObjects/Ref/RefRequestBuilder.cs b/src/generated/Users/Item/OwnedObjects/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..da46c3e3d15 --- /dev/null +++ b/src/generated/Users/Item/OwnedObjects/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Users.Item.OwnedObjects.Ref { + /// Builds and executes requests for operations under \users\{user-id}\ownedObjects\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Directory objects that are owned by the user. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Directory objects that are owned by the user. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/users/{user_id}/ownedObjects/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Users.Item.OwnedObjects.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Directory objects that are owned by the user. Read-only. Nullable. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Users/Item/OwnedObjects/Ref/RefResponse.cs b/src/generated/Users/Item/OwnedObjects/Ref/RefResponse.cs new file mode 100644 index 00000000000..d707a8d817f --- /dev/null +++ b/src/generated/Users/Item/OwnedObjects/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.OwnedObjects.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/People/Item/PersonRequestBuilder.cs b/src/generated/Users/Item/People/Item/PersonRequestBuilder.cs index f42487518e7..a7e463dee30 100644 --- a/src/generated/Users/Item/People/Item/PersonRequestBuilder.cs +++ b/src/generated/Users/Item/People/Item/PersonRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; personIdOption.IsRequired = true; command.AddOption(personIdOption); - command.SetHandler(async (string userId, string personId) => { + command.SetHandler(async (string userId, string personId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, personIdOption); return command; @@ -63,19 +62,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string personId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string personId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, personIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, personIdOption, selectOption, outputOption); return command; } /// @@ -97,14 +95,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string personId, string body) => { + command.SetHandler(async (string userId, string personId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, personIdOption, bodyOption); return command; @@ -176,42 +173,6 @@ public RequestInformation CreatePatchRequestInformation(Person body, Action - /// Read-only. The most relevant people to the user. The collection is ordered by their relevance to the user, which is determined by the user's communication, collaboration and business relationships. A person is an aggregation of information from across mail, contacts and social networks. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. The most relevant people to the user. The collection is ordered by their relevance to the user, which is determined by the user's communication, collaboration and business relationships. A person is an aggregation of information from across mail, contacts and social networks. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. The most relevant people to the user. The collection is ordered by their relevance to the user, which is determined by the user's communication, collaboration and business relationships. A person is an aggregation of information from across mail, contacts and social networks. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Person model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. The most relevant people to the user. The collection is ordered by their relevance to the user, which is determined by the user's communication, collaboration and business relationships. A person is an aggregation of information from across mail, contacts and social networks. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/People/PeopleRequestBuilder.cs b/src/generated/Users/Item/People/PeopleRequestBuilder.cs index fd6b845e37b..8e60faee3d5 100644 --- a/src/generated/Users/Item/People/PeopleRequestBuilder.cs +++ b/src/generated/Users/Item/People/PeopleRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.People.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class PeopleRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PersonRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -102,7 +100,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -112,15 +114,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -175,31 +172,6 @@ public RequestInformation CreatePostRequestInformation(Person body, Action - /// Read-only. The most relevant people to the user. The collection is ordered by their relevance to the user, which is determined by the user's communication, collaboration and business relationships. A person is an aggregation of information from across mail, contacts and social networks. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. The most relevant people to the user. The collection is ordered by their relevance to the user, which is determined by the user's communication, collaboration and business relationships. A person is an aggregation of information from across mail, contacts and social networks. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Person model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. The most relevant people to the user. The collection is ordered by their relevance to the user, which is determined by the user's communication, collaboration and business relationships. A person is an aggregation of information from across mail, contacts and social networks. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Photo/PhotoRequestBuilder.cs b/src/generated/Users/Item/Photo/PhotoRequestBuilder.cs index 4328169507f..5e66d9c8a87 100644 --- a/src/generated/Users/Item/Photo/PhotoRequestBuilder.cs +++ b/src/generated/Users/Item/Photo/PhotoRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Photo.Value; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + command.SetHandler(async (string userId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption); return command; @@ -63,19 +62,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, selectOption, outputOption); return command; } /// @@ -93,14 +91,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + command.SetHandler(async (string userId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, bodyOption); return command; @@ -172,42 +169,6 @@ public RequestInformation CreatePatchRequestInformation(ProfilePhoto body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The user's profile photo. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's profile photo. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's profile photo. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ProfilePhoto model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The user's profile photo. Read-only. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/Photo/Value/ContentRequestBuilder.cs b/src/generated/Users/Item/Photo/Value/ContentRequestBuilder.cs index 690424caea0..306c5e640d9 100644 --- a/src/generated/Users/Item/Photo/Value/ContentRequestBuilder.cs +++ b/src/generated/Users/Item/Photo/Value/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,24 +29,26 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string userId, FileInfo output) => { + command.SetHandler(async (string userId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, userIdOption, outputOption); + }, userIdOption, fileOption, outputOption); return command; } /// @@ -64,12 +66,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, FileInfo file) => { + command.SetHandler(async (string userId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, bodyOption); return command; @@ -120,29 +121,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// The user's profile photo. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The user's profile photo. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Photos/Item/ProfilePhotoRequestBuilder.cs b/src/generated/Users/Item/Photos/Item/ProfilePhotoRequestBuilder.cs index fc498c8a5fd..bd1b500c32a 100644 --- a/src/generated/Users/Item/Photos/Item/ProfilePhotoRequestBuilder.cs +++ b/src/generated/Users/Item/Photos/Item/ProfilePhotoRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Photos.Item.Value; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var profilePhotoIdOption = new Option("--profilephoto-id", description: "key: id of profilePhoto") { + var profilePhotoIdOption = new Option("--profile-photo-id", description: "key: id of profilePhoto") { }; profilePhotoIdOption.IsRequired = true; command.AddOption(profilePhotoIdOption); - command.SetHandler(async (string userId, string profilePhotoId) => { + command.SetHandler(async (string userId, string profilePhotoId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, profilePhotoIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var profilePhotoIdOption = new Option("--profilephoto-id", description: "key: id of profilePhoto") { + var profilePhotoIdOption = new Option("--profile-photo-id", description: "key: id of profilePhoto") { }; profilePhotoIdOption.IsRequired = true; command.AddOption(profilePhotoIdOption); @@ -71,19 +70,18 @@ public Command BuildGetCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, string profilePhotoId, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string profilePhotoId, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, profilePhotoIdOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, profilePhotoIdOption, selectOption, outputOption); return command; } /// @@ -97,7 +95,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var profilePhotoIdOption = new Option("--profilephoto-id", description: "key: id of profilePhoto") { + var profilePhotoIdOption = new Option("--profile-photo-id", description: "key: id of profilePhoto") { }; profilePhotoIdOption.IsRequired = true; command.AddOption(profilePhotoIdOption); @@ -105,14 +103,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string profilePhotoId, string body) => { + command.SetHandler(async (string userId, string profilePhotoId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, profilePhotoIdOption, bodyOption); return command; @@ -184,42 +181,6 @@ public RequestInformation CreatePatchRequestInformation(ProfilePhoto body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ProfilePhoto model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Select properties to be returned diff --git a/src/generated/Users/Item/Photos/Item/Value/ContentRequestBuilder.cs b/src/generated/Users/Item/Photos/Item/Value/ContentRequestBuilder.cs index 8b1a76e3d52..b25bdd58ce8 100644 --- a/src/generated/Users/Item/Photos/Item/Value/ContentRequestBuilder.cs +++ b/src/generated/Users/Item/Photos/Item/Value/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,28 +29,30 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var profilePhotoIdOption = new Option("--profilephoto-id", description: "key: id of profilePhoto") { + var profilePhotoIdOption = new Option("--profile-photo-id", description: "key: id of profilePhoto") { }; profilePhotoIdOption.IsRequired = true; command.AddOption(profilePhotoIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string userId, string profilePhotoId, FileInfo output) => { + command.SetHandler(async (string userId, string profilePhotoId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, userIdOption, profilePhotoIdOption, outputOption); + }, userIdOption, profilePhotoIdOption, fileOption, outputOption); return command; } /// @@ -64,7 +66,7 @@ public Command BuildPutCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var profilePhotoIdOption = new Option("--profilephoto-id", description: "key: id of profilePhoto") { + var profilePhotoIdOption = new Option("--profile-photo-id", description: "key: id of profilePhoto") { }; profilePhotoIdOption.IsRequired = true; command.AddOption(profilePhotoIdOption); @@ -72,12 +74,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string profilePhotoId, FileInfo file) => { + command.SetHandler(async (string userId, string profilePhotoId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, profilePhotoIdOption, bodyOption); return command; @@ -128,29 +129,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// Get media content for the navigation property photos from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update media content for the navigation property photos in users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Photos/PhotosRequestBuilder.cs b/src/generated/Users/Item/Photos/PhotosRequestBuilder.cs index aaf72d7d71b..02465d8b282 100644 --- a/src/generated/Users/Item/Photos/PhotosRequestBuilder.cs +++ b/src/generated/Users/Item/Photos/PhotosRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Photos.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class PhotosRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ProfilePhotoRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -99,7 +97,11 @@ public Command BuildListCommand() { }; selectOption.IsRequired = false; command.AddOption(selectOption); - command.SetHandler(async (string userId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string filter, bool? count, string[] orderby, string[] select, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -108,15 +110,10 @@ public Command BuildListCommand() { q.Orderby = orderby; q.Select = select; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, filterOption, countOption, orderbyOption, selectOption, outputOption); return command; } /// @@ -171,31 +168,6 @@ public RequestInformation CreatePostRequestInformation(ProfilePhoto body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ProfilePhoto model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Planner/PlannerRequestBuilder.cs b/src/generated/Users/Item/Planner/PlannerRequestBuilder.cs index 2b93f8484ef..9849167e49e 100644 --- a/src/generated/Users/Item/Planner/PlannerRequestBuilder.cs +++ b/src/generated/Users/Item/Planner/PlannerRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Planner.Tasks; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -32,11 +32,10 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + command.SetHandler(async (string userId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption); return command; @@ -62,20 +61,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -93,14 +91,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + command.SetHandler(async (string userId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, bodyOption); return command; @@ -108,6 +105,9 @@ public Command BuildPatchCommand() { public Command BuildPlansCommand() { var command = new Command("plans"); var builder = new ApiSdk.Users.Item.Planner.Plans.PlansRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -115,6 +115,9 @@ public Command BuildPlansCommand() { public Command BuildTasksCommand() { var command = new Command("tasks"); var builder = new ApiSdk.Users.Item.Planner.Tasks.TasksRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -186,42 +189,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerUser body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Selective Planner services available to the user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Selective Planner services available to the user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Selective Planner services available to the user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerUser model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Selective Planner services available to the user. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Planner/Plans/Item/Buckets/BucketsRequestBuilder.cs b/src/generated/Users/Item/Planner/Plans/Item/Buckets/BucketsRequestBuilder.cs index 05d26ec602d..e11d8bf7721 100644 --- a/src/generated/Users/Item/Planner/Plans/Item/Buckets/BucketsRequestBuilder.cs +++ b/src/generated/Users/Item/Planner/Plans/Item/Buckets/BucketsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Planner.Plans.Item.Buckets.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class BucketsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PlannerBucketRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildTasksCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildTasksCommand()); return commands; } /// @@ -41,7 +40,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -49,21 +48,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string plannerPlanId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string plannerPlanId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, plannerPlanIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, plannerPlanIdOption, bodyOption, outputOption); return command; } /// @@ -77,7 +75,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -116,7 +114,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string plannerPlanId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string plannerPlanId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -127,15 +129,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, plannerPlanIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, plannerPlanIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -190,31 +187,6 @@ public RequestInformation CreatePostRequestInformation(PlannerBucket body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of buckets in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of buckets in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PlannerBucket model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of buckets in the plan. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/PlannerBucketRequestBuilder.cs b/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/PlannerBucketRequestBuilder.cs index 78b8e63bdb8..a1189ef06e0 100644 --- a/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/PlannerBucketRequestBuilder.cs +++ b/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/PlannerBucketRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Planner.Plans.Item.Buckets.Item.Tasks; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,19 +31,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId) => { + command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerPlanIdOption, plannerBucketIdOption); return command; @@ -59,11 +58,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, plannerPlanIdOption, plannerBucketIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, plannerPlanIdOption, plannerBucketIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,11 +102,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); @@ -116,14 +114,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string body) => { + command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerPlanIdOption, plannerBucketIdOption, bodyOption); return command; @@ -131,6 +128,9 @@ public Command BuildPatchCommand() { public Command BuildTasksCommand() { var command = new Command("tasks"); var builder = new ApiSdk.Users.Item.Planner.Plans.Item.Buckets.Item.Tasks.TasksRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -202,42 +202,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerBucket body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of buckets in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of buckets in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of buckets in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerBucket model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of buckets in the plan. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs b/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs index bc42774567e..dc25c48f392 100644 --- a/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId) => { + command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string body) => { + command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerAssignedToTaskBoa requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerAssignedToTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs b/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs index 62572d9067e..dc37489234a 100644 --- a/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId) => { + command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string body) => { + command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerBucketTaskBoardTa requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerBucketTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/Details/DetailsRequestBuilder.cs b/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/Details/DetailsRequestBuilder.cs index 8177d9a0df5..305042e5a7e 100644 --- a/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/Details/DetailsRequestBuilder.cs +++ b/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/Details/DetailsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId) => { + command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string body) => { + command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerTaskDetails body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerTaskDetails model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Additional details about the task. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/PlannerTaskRequestBuilder.cs b/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/PlannerTaskRequestBuilder.cs index 5c19b436feb..ab34facab83 100644 --- a/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/PlannerTaskRequestBuilder.cs +++ b/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/PlannerTaskRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Users.Item.Planner.Plans.Item.Buckets.Item.Tasks.Item.ProgressTaskBoardFormat; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -50,23 +50,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId) => { + command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption); return command; @@ -90,15 +89,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -112,20 +111,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -139,15 +137,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -155,14 +153,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string body) => { + command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, bodyOption); return command; @@ -242,42 +239,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerTask body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. The collection of tasks in the bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. The collection of tasks in the bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. The collection of tasks in the bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. The collection of tasks in the bucket. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs b/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs index ae9591e1e95..33f0250ed47 100644 --- a/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId) => { + command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string body) => { + command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerPlanIdOption, plannerBucketIdOption, plannerTaskIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerProgressTaskBoard requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerProgressTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/Tasks/TasksRequestBuilder.cs b/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/Tasks/TasksRequestBuilder.cs index 547f6676d52..d05dca82ad2 100644 --- a/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/Tasks/TasksRequestBuilder.cs +++ b/src/generated/Users/Item/Planner/Plans/Item/Buckets/Item/Tasks/TasksRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Planner.Plans.Item.Buckets.Item.Tasks.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class TasksRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PlannerTaskRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAssignedToTaskBoardFormatCommand(), - builder.BuildBucketTaskBoardFormatCommand(), - builder.BuildDeleteCommand(), - builder.BuildDetailsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildProgressTaskBoardFormatCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAssignedToTaskBoardFormatCommand()); + commands.Add(builder.BuildBucketTaskBoardFormatCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDetailsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildProgressTaskBoardFormatCommand()); return commands; } /// @@ -44,11 +43,11 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, plannerPlanIdOption, plannerBucketIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, plannerPlanIdOption, plannerBucketIdOption, bodyOption, outputOption); return command; } /// @@ -84,11 +82,11 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerBucketIdOption = new Option("--plannerbucket-id", description: "key: id of plannerBucket") { + var plannerBucketIdOption = new Option("--planner-bucket-id", description: "key: id of plannerBucket") { }; plannerBucketIdOption.IsRequired = true; command.AddOption(plannerBucketIdOption); @@ -127,7 +125,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string plannerPlanId, string plannerBucketId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -138,15 +140,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, plannerPlanIdOption, plannerBucketIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, plannerPlanIdOption, plannerBucketIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -201,31 +198,6 @@ public RequestInformation CreatePostRequestInformation(PlannerTask body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. The collection of tasks in the bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. The collection of tasks in the bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PlannerTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. The collection of tasks in the bucket. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Planner/Plans/Item/Details/DetailsRequestBuilder.cs b/src/generated/Users/Item/Planner/Plans/Item/Details/DetailsRequestBuilder.cs index 08d57b56e26..786e6fe3229 100644 --- a/src/generated/Users/Item/Planner/Plans/Item/Details/DetailsRequestBuilder.cs +++ b/src/generated/Users/Item/Planner/Plans/Item/Details/DetailsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - command.SetHandler(async (string userId, string plannerPlanId) => { + command.SetHandler(async (string userId, string plannerPlanId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerPlanIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string plannerPlanId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string plannerPlanId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, plannerPlanIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, plannerPlanIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string plannerPlanId, string body) => { + command.SetHandler(async (string userId, string plannerPlanId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerPlanIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerPlanDetails body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Additional details about the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Additional details about the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Additional details about the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerPlanDetails model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Additional details about the plan. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Planner/Plans/Item/PlannerPlanRequestBuilder.cs b/src/generated/Users/Item/Planner/Plans/Item/PlannerPlanRequestBuilder.cs index fd707b0f3c7..b0218004947 100644 --- a/src/generated/Users/Item/Planner/Plans/Item/PlannerPlanRequestBuilder.cs +++ b/src/generated/Users/Item/Planner/Plans/Item/PlannerPlanRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Users.Item.Planner.Plans.Item.Tasks; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,6 +25,9 @@ public class PlannerPlanRequestBuilder { public Command BuildBucketsCommand() { var command = new Command("buckets"); var builder = new ApiSdk.Users.Item.Planner.Plans.Item.Buckets.BucketsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -40,15 +43,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - command.SetHandler(async (string userId, string plannerPlanId) => { + command.SetHandler(async (string userId, string plannerPlanId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerPlanIdOption); return command; @@ -72,7 +74,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -86,20 +88,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string plannerPlanId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string plannerPlanId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, plannerPlanIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, plannerPlanIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -113,7 +114,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -121,14 +122,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string plannerPlanId, string body) => { + command.SetHandler(async (string userId, string plannerPlanId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerPlanIdOption, bodyOption); return command; @@ -136,6 +136,9 @@ public Command BuildPatchCommand() { public Command BuildTasksCommand() { var command = new Command("tasks"); var builder = new ApiSdk.Users.Item.Planner.Plans.Item.Tasks.TasksRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -207,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerPlan body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Returns the plannerTasks assigned to the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns the plannerTasks assigned to the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns the plannerTasks assigned to the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerPlan model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Returns the plannerTasks assigned to the user. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Planner/Plans/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs b/src/generated/Users/Item/Planner/Plans/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs index 665f0191e31..0be00338ebe 100644 --- a/src/generated/Users/Item/Planner/Plans/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Users/Item/Planner/Plans/Item/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId) => { + command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerPlanIdOption, plannerTaskIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId, string body) => { + command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerPlanIdOption, plannerTaskIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerAssignedToTaskBoa requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerAssignedToTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Planner/Plans/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs b/src/generated/Users/Item/Planner/Plans/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs index 3276627b98f..3fd6562708c 100644 --- a/src/generated/Users/Item/Planner/Plans/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Users/Item/Planner/Plans/Item/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId) => { + command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerPlanIdOption, plannerTaskIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId, string body) => { + command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerPlanIdOption, plannerTaskIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerBucketTaskBoardTa requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerBucketTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Planner/Plans/Item/Tasks/Item/Details/DetailsRequestBuilder.cs b/src/generated/Users/Item/Planner/Plans/Item/Tasks/Item/Details/DetailsRequestBuilder.cs index dd27c104be5..4241c97cef5 100644 --- a/src/generated/Users/Item/Planner/Plans/Item/Tasks/Item/Details/DetailsRequestBuilder.cs +++ b/src/generated/Users/Item/Planner/Plans/Item/Tasks/Item/Details/DetailsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId) => { + command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerPlanIdOption, plannerTaskIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId, string body) => { + command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerPlanIdOption, plannerTaskIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerTaskDetails body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerTaskDetails model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Additional details about the task. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Planner/Plans/Item/Tasks/Item/PlannerTaskRequestBuilder.cs b/src/generated/Users/Item/Planner/Plans/Item/Tasks/Item/PlannerTaskRequestBuilder.cs index 8aa6eb99dd5..aac0037f181 100644 --- a/src/generated/Users/Item/Planner/Plans/Item/Tasks/Item/PlannerTaskRequestBuilder.cs +++ b/src/generated/Users/Item/Planner/Plans/Item/Tasks/Item/PlannerTaskRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Users.Item.Planner.Plans.Item.Tasks.Item.ProgressTaskBoardFormat; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -50,19 +50,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId) => { + command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerPlanIdOption, plannerTaskIdOption); return command; @@ -86,11 +85,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -104,20 +103,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -131,11 +129,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -143,14 +141,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId, string body) => { + command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerPlanIdOption, plannerTaskIdOption, bodyOption); return command; @@ -230,42 +227,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerTask body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of tasks in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of tasks in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of tasks in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of tasks in the plan. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Planner/Plans/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs b/src/generated/Users/Item/Planner/Plans/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs index 5ba73eda921..82a576658de 100644 --- a/src/generated/Users/Item/Planner/Plans/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Users/Item/Planner/Plans/Item/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,19 +30,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId) => { + command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerPlanIdOption, plannerTaskIdOption); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, plannerPlanIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,11 +101,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId, string body) => { + command.SetHandler(async (string userId, string plannerPlanId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerPlanIdOption, plannerTaskIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerProgressTaskBoard requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerProgressTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Planner/Plans/Item/Tasks/TasksRequestBuilder.cs b/src/generated/Users/Item/Planner/Plans/Item/Tasks/TasksRequestBuilder.cs index a08e0a0f2b8..dfe68bc14e4 100644 --- a/src/generated/Users/Item/Planner/Plans/Item/Tasks/TasksRequestBuilder.cs +++ b/src/generated/Users/Item/Planner/Plans/Item/Tasks/TasksRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Planner.Plans.Item.Tasks.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class TasksRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PlannerTaskRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAssignedToTaskBoardFormatCommand(), - builder.BuildBucketTaskBoardFormatCommand(), - builder.BuildDeleteCommand(), - builder.BuildDetailsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildProgressTaskBoardFormatCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAssignedToTaskBoardFormatCommand()); + commands.Add(builder.BuildBucketTaskBoardFormatCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDetailsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildProgressTaskBoardFormatCommand()); return commands; } /// @@ -44,7 +43,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string plannerPlanId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string plannerPlanId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, plannerPlanIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, plannerPlanIdOption, bodyOption, outputOption); return command; } /// @@ -80,7 +78,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerPlanIdOption = new Option("--plannerplan-id", description: "key: id of plannerPlan") { + var plannerPlanIdOption = new Option("--planner-plan-id", description: "key: id of plannerPlan") { }; plannerPlanIdOption.IsRequired = true; command.AddOption(plannerPlanIdOption); @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string plannerPlanId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string plannerPlanId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -130,15 +132,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, plannerPlanIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, plannerPlanIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -193,31 +190,6 @@ public RequestInformation CreatePostRequestInformation(PlannerTask body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of tasks in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of tasks in the plan. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PlannerTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of tasks in the plan. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Planner/Plans/PlansRequestBuilder.cs b/src/generated/Users/Item/Planner/Plans/PlansRequestBuilder.cs index 10246a73be9..e718d3741ef 100644 --- a/src/generated/Users/Item/Planner/Plans/PlansRequestBuilder.cs +++ b/src/generated/Users/Item/Planner/Plans/PlansRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Planner.Plans.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,14 +22,13 @@ public class PlansRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PlannerPlanRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildBucketsCommand(), - builder.BuildDeleteCommand(), - builder.BuildDetailsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildTasksCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildBucketsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDetailsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildTasksCommand()); return commands; } /// @@ -47,21 +46,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -110,7 +108,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -184,31 +181,6 @@ public RequestInformation CreatePostRequestInformation(PlannerPlan body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Returns the plannerTasks assigned to the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns the plannerTasks assigned to the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PlannerPlan model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Returns the plannerTasks assigned to the user. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Planner/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs b/src/generated/Users/Item/Planner/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs index 93303537400..e5e16f629ef 100644 --- a/src/generated/Users/Item/Planner/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Users/Item/Planner/Tasks/Item/AssignedToTaskBoardFormat/AssignedToTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string userId, string plannerTaskId) => { + command.SetHandler(async (string userId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerTaskIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string plannerTaskId, string body) => { + command.SetHandler(async (string userId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerTaskIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerAssignedToTaskBoa requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerAssignedToTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by assignedTo. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Planner/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs b/src/generated/Users/Item/Planner/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs index 7c684f5ecae..0590986c49a 100644 --- a/src/generated/Users/Item/Planner/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Users/Item/Planner/Tasks/Item/BucketTaskBoardFormat/BucketTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string userId, string plannerTaskId) => { + command.SetHandler(async (string userId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerTaskIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string plannerTaskId, string body) => { + command.SetHandler(async (string userId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerTaskIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerBucketTaskBoardTa requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerBucketTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by bucket. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Planner/Tasks/Item/Details/DetailsRequestBuilder.cs b/src/generated/Users/Item/Planner/Tasks/Item/Details/DetailsRequestBuilder.cs index 3595848d20f..4540771e387 100644 --- a/src/generated/Users/Item/Planner/Tasks/Item/Details/DetailsRequestBuilder.cs +++ b/src/generated/Users/Item/Planner/Tasks/Item/Details/DetailsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string userId, string plannerTaskId) => { + command.SetHandler(async (string userId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerTaskIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string plannerTaskId, string body) => { + command.SetHandler(async (string userId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerTaskIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerTaskDetails body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Additional details about the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerTaskDetails model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Additional details about the task. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Planner/Tasks/Item/PlannerTaskRequestBuilder.cs b/src/generated/Users/Item/Planner/Tasks/Item/PlannerTaskRequestBuilder.cs index 9e6f3d55457..b395c612b82 100644 --- a/src/generated/Users/Item/Planner/Tasks/Item/PlannerTaskRequestBuilder.cs +++ b/src/generated/Users/Item/Planner/Tasks/Item/PlannerTaskRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Users.Item.Planner.Tasks.Item.ProgressTaskBoardFormat; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -50,15 +50,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string userId, string plannerTaskId) => { + command.SetHandler(async (string userId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerTaskIdOption); return command; @@ -82,7 +81,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -96,20 +95,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -123,7 +121,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -131,14 +129,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string plannerTaskId, string body) => { + command.SetHandler(async (string userId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerTaskIdOption, bodyOption); return command; @@ -218,42 +215,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerTask body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Returns the plannerTasks assigned to the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns the plannerTasks assigned to the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns the plannerTasks assigned to the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Returns the plannerTasks assigned to the user. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Planner/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs b/src/generated/Users/Item/Planner/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs index 4e2c28eeb5b..fc8b2cb5149 100644 --- a/src/generated/Users/Item/Planner/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs +++ b/src/generated/Users/Item/Planner/Tasks/Item/ProgressTaskBoardFormat/ProgressTaskBoardFormatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); - command.SetHandler(async (string userId, string plannerTaskId) => { + command.SetHandler(async (string userId, string plannerTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerTaskIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string plannerTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string plannerTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, plannerTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, plannerTaskIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var plannerTaskIdOption = new Option("--plannertask-id", description: "key: id of plannerTask") { + var plannerTaskIdOption = new Option("--planner-task-id", description: "key: id of plannerTask") { }; plannerTaskIdOption.IsRequired = true; command.AddOption(plannerTaskIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string plannerTaskId, string body) => { + command.SetHandler(async (string userId, string plannerTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, plannerTaskIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(PlannerProgressTaskBoard requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(PlannerProgressTaskBoardTaskFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Used to render the task correctly in the task board view when grouped by progress. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Planner/Tasks/TasksRequestBuilder.cs b/src/generated/Users/Item/Planner/Tasks/TasksRequestBuilder.cs index 6e89cbe5baa..1c3339f23c5 100644 --- a/src/generated/Users/Item/Planner/Tasks/TasksRequestBuilder.cs +++ b/src/generated/Users/Item/Planner/Tasks/TasksRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Planner.Tasks.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,15 +22,14 @@ public class TasksRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PlannerTaskRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAssignedToTaskBoardFormatCommand(), - builder.BuildBucketTaskBoardFormatCommand(), - builder.BuildDeleteCommand(), - builder.BuildDetailsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildProgressTaskBoardFormatCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAssignedToTaskBoardFormatCommand()); + commands.Add(builder.BuildBucketTaskBoardFormatCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDetailsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildProgressTaskBoardFormatCommand()); return commands; } /// @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -111,7 +109,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -122,15 +124,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -185,31 +182,6 @@ public RequestInformation CreatePostRequestInformation(PlannerTask body, Action< requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. Returns the plannerTasks assigned to the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. Returns the plannerTasks assigned to the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PlannerTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. Returns the plannerTasks assigned to the user. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Presence/ClearPresence/ClearPresenceRequestBuilder.cs b/src/generated/Users/Item/Presence/ClearPresence/ClearPresenceRequestBuilder.cs index 2e29ff6a6e0..1d70468cfbb 100644 --- a/src/generated/Users/Item/Presence/ClearPresence/ClearPresenceRequestBuilder.cs +++ b/src/generated/Users/Item/Presence/ClearPresence/ClearPresenceRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + command.SetHandler(async (string userId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ClearPresenceRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action clearPresence - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ClearPresenceRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Presence/PresenceRequestBuilder.cs b/src/generated/Users/Item/Presence/PresenceRequestBuilder.cs index 1f19a6fc4f0..b9fa994547c 100644 --- a/src/generated/Users/Item/Presence/PresenceRequestBuilder.cs +++ b/src/generated/Users/Item/Presence/PresenceRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Presence.SetPresence; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + command.SetHandler(async (string userId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption); return command; @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,14 +97,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + command.SetHandler(async (string userId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, bodyOption); return command; @@ -184,42 +181,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property presence for users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get presence from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property presence in users - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Presence model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get presence from users public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Presence/SetPresence/SetPresenceRequestBody.cs b/src/generated/Users/Item/Presence/SetPresence/SetPresenceRequestBody.cs index 00901b7e3bd..c7f952ae04a 100644 --- a/src/generated/Users/Item/Presence/SetPresence/SetPresenceRequestBody.cs +++ b/src/generated/Users/Item/Presence/SetPresence/SetPresenceRequestBody.cs @@ -9,7 +9,7 @@ public class SetPresenceRequestBody : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public string Availability { get; set; } - public string ExpirationDuration { get; set; } + public TimeSpan? ExpirationDuration { get; set; } public string SessionId { get; set; } /// /// Instantiates a new setPresenceRequestBody and sets the default values. @@ -24,7 +24,7 @@ public IDictionary> GetFieldDeserializers() { return new Dictionary> { {"activity", (o,n) => { (o as SetPresenceRequestBody).Activity = n.GetStringValue(); } }, {"availability", (o,n) => { (o as SetPresenceRequestBody).Availability = n.GetStringValue(); } }, - {"expirationDuration", (o,n) => { (o as SetPresenceRequestBody).ExpirationDuration = n.GetStringValue(); } }, + {"expirationDuration", (o,n) => { (o as SetPresenceRequestBody).ExpirationDuration = n.GetTimeSpanValue(); } }, {"sessionId", (o,n) => { (o as SetPresenceRequestBody).SessionId = n.GetStringValue(); } }, }; } @@ -36,7 +36,7 @@ public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStringValue("activity", Activity); writer.WriteStringValue("availability", Availability); - writer.WriteStringValue("expirationDuration", ExpirationDuration); + writer.WriteTimeSpanValue("expirationDuration", ExpirationDuration); writer.WriteStringValue("sessionId", SessionId); writer.WriteAdditionalData(AdditionalData); } diff --git a/src/generated/Users/Item/Presence/SetPresence/SetPresenceRequestBuilder.cs b/src/generated/Users/Item/Presence/SetPresence/SetPresenceRequestBuilder.cs index c05bf9f24a0..3729f9659b9 100644 --- a/src/generated/Users/Item/Presence/SetPresence/SetPresenceRequestBuilder.cs +++ b/src/generated/Users/Item/Presence/SetPresence/SetPresenceRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + command.SetHandler(async (string userId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(SetPresenceRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setPresence - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetPresenceRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/RegisteredDevices/@Ref/@Ref.cs b/src/generated/Users/Item/RegisteredDevices/@Ref/@Ref.cs deleted file mode 100644 index 79c9fa9d057..00000000000 --- a/src/generated/Users/Item/RegisteredDevices/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.RegisteredDevices.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/RegisteredDevices/@Ref/RefRequestBuilder.cs b/src/generated/Users/Item/RegisteredDevices/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 43149c5a1eb..00000000000 --- a/src/generated/Users/Item/RegisteredDevices/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Users.Item.RegisteredDevices.@Ref { - /// Builds and executes requests for operations under \users\{user-id}\registeredDevices\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Devices that are registered for the user. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Devices that are registered for the user. Read-only. Nullable. Supports $expand."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/registeredDevices/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Users.Item.RegisteredDevices.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Users.Item.RegisteredDevices.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Users/Item/RegisteredDevices/@Ref/RefResponse.cs b/src/generated/Users/Item/RegisteredDevices/@Ref/RefResponse.cs deleted file mode 100644 index 061265efbf5..00000000000 --- a/src/generated/Users/Item/RegisteredDevices/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.RegisteredDevices.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/RegisteredDevices/Ref/Ref.cs b/src/generated/Users/Item/RegisteredDevices/Ref/Ref.cs new file mode 100644 index 00000000000..cf5977b435e --- /dev/null +++ b/src/generated/Users/Item/RegisteredDevices/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.RegisteredDevices.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/RegisteredDevices/Ref/RefRequestBuilder.cs b/src/generated/Users/Item/RegisteredDevices/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..87f491dbdd4 --- /dev/null +++ b/src/generated/Users/Item/RegisteredDevices/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Users.Item.RegisteredDevices.Ref { + /// Builds and executes requests for operations under \users\{user-id}\registeredDevices\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Devices that are registered for the user. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Devices that are registered for the user. Read-only. Nullable. Supports $expand."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/users/{user_id}/registeredDevices/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Users.Item.RegisteredDevices.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Users/Item/RegisteredDevices/Ref/RefResponse.cs b/src/generated/Users/Item/RegisteredDevices/Ref/RefResponse.cs new file mode 100644 index 00000000000..aeeab216e49 --- /dev/null +++ b/src/generated/Users/Item/RegisteredDevices/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.RegisteredDevices.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/RegisteredDevices/RegisteredDevicesRequestBuilder.cs b/src/generated/Users/Item/RegisteredDevices/RegisteredDevicesRequestBuilder.cs index fa89fec000e..4f424cae442 100644 --- a/src/generated/Users/Item/RegisteredDevices/RegisteredDevicesRequestBuilder.cs +++ b/src/generated/Users/Item/RegisteredDevices/RegisteredDevicesRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Users.Item.RegisteredDevices.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Users.Item.RegisteredDevices.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Users.Item.RegisteredDevices.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Devices that are registered for the user. Read-only. Nullable. Supports $expand. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/ReminderViewWithStartDateTimeWithEndDateTime/ReminderViewWithStartDateTimeWithEndDateTime.cs b/src/generated/Users/Item/ReminderViewWithStartDateTimeWithEndDateTime/ReminderViewWithStartDateTimeWithEndDateTime.cs deleted file mode 100644 index d8075b6f216..00000000000 --- a/src/generated/Users/Item/ReminderViewWithStartDateTimeWithEndDateTime/ReminderViewWithStartDateTimeWithEndDateTime.cs +++ /dev/null @@ -1,65 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.ReminderViewWithStartDateTimeWithEndDateTime { - public class ReminderViewWithStartDateTimeWithEndDateTime : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Identifies the version of the reminder. Every time the reminder is changed, changeKey changes as well. This allows Exchange to apply changes to the correct version of the object. - public string ChangeKey { get; set; } - /// The date, time and time zone that the event ends. - public DateTimeTimeZone EventEndTime { get; set; } - /// The unique ID of the event. Read only. - public string EventId { get; set; } - /// The location of the event. - public Location EventLocation { get; set; } - /// The date, time, and time zone that the event starts. - public DateTimeTimeZone EventStartTime { get; set; } - /// The text of the event's subject line. - public string EventSubject { get; set; } - /// The URL to open the event in Outlook on the web.The event will open in the browser if you are logged in to your mailbox via Outlook on the web. You will be prompted to login if you are not already logged in with the browser.This URL cannot be accessed from within an iFrame. - public string EventWebLink { get; set; } - /// The date, time, and time zone that the reminder is set to occur. - public DateTimeTimeZone ReminderFireTime { get; set; } - /// - /// Instantiates a new reminderViewWithStartDateTimeWithEndDateTime and sets the default values. - /// - public ReminderViewWithStartDateTimeWithEndDateTime() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"changeKey", (o,n) => { (o as ReminderViewWithStartDateTimeWithEndDateTime).ChangeKey = n.GetStringValue(); } }, - {"eventEndTime", (o,n) => { (o as ReminderViewWithStartDateTimeWithEndDateTime).EventEndTime = n.GetObjectValue(); } }, - {"eventId", (o,n) => { (o as ReminderViewWithStartDateTimeWithEndDateTime).EventId = n.GetStringValue(); } }, - {"eventLocation", (o,n) => { (o as ReminderViewWithStartDateTimeWithEndDateTime).EventLocation = n.GetObjectValue(); } }, - {"eventStartTime", (o,n) => { (o as ReminderViewWithStartDateTimeWithEndDateTime).EventStartTime = n.GetObjectValue(); } }, - {"eventSubject", (o,n) => { (o as ReminderViewWithStartDateTimeWithEndDateTime).EventSubject = n.GetStringValue(); } }, - {"eventWebLink", (o,n) => { (o as ReminderViewWithStartDateTimeWithEndDateTime).EventWebLink = n.GetStringValue(); } }, - {"reminderFireTime", (o,n) => { (o as ReminderViewWithStartDateTimeWithEndDateTime).ReminderFireTime = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("changeKey", ChangeKey); - writer.WriteObjectValue("eventEndTime", EventEndTime); - writer.WriteStringValue("eventId", EventId); - writer.WriteObjectValue("eventLocation", EventLocation); - writer.WriteObjectValue("eventStartTime", EventStartTime); - writer.WriteStringValue("eventSubject", EventSubject); - writer.WriteStringValue("eventWebLink", EventWebLink); - writer.WriteObjectValue("reminderFireTime", ReminderFireTime); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/ReminderViewWithStartDateTimeWithEndDateTime/ReminderViewWithStartDateTimeWithEndDateTimeRequestBuilder.cs b/src/generated/Users/Item/ReminderViewWithStartDateTimeWithEndDateTime/ReminderViewWithStartDateTimeWithEndDateTimeRequestBuilder.cs index 7d7cd9d4196..0d5208be3a4 100644 --- a/src/generated/Users/Item/ReminderViewWithStartDateTimeWithEndDateTime/ReminderViewWithStartDateTimeWithEndDateTimeRequestBuilder.cs +++ b/src/generated/Users/Item/ReminderViewWithStartDateTimeWithEndDateTime/ReminderViewWithStartDateTimeWithEndDateTimeRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,26 +30,25 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var StartDateTimeOption = new Option("--startdatetime", description: "Usage: StartDateTime={StartDateTime}") { + var StartDateTimeOption = new Option("--start-date-time", description: "Usage: StartDateTime={StartDateTime}") { }; StartDateTimeOption.IsRequired = true; command.AddOption(StartDateTimeOption); - var EndDateTimeOption = new Option("--enddatetime", description: "Usage: EndDateTime={EndDateTime}") { + var EndDateTimeOption = new Option("--end-date-time", description: "Usage: EndDateTime={EndDateTime}") { }; EndDateTimeOption.IsRequired = true; command.AddOption(EndDateTimeOption); - command.SetHandler(async (string userId, string StartDateTime, string EndDateTime) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string StartDateTime, string EndDateTime, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, StartDateTimeOption, EndDateTimeOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, StartDateTimeOption, EndDateTimeOption, outputOption); return command; } /// @@ -83,16 +83,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function reminderView - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/RemoveAllDevicesFromManagement/RemoveAllDevicesFromManagementRequestBuilder.cs b/src/generated/Users/Item/RemoveAllDevicesFromManagement/RemoveAllDevicesFromManagementRequestBuilder.cs index 517e3664767..eb40482a1ac 100644 --- a/src/generated/Users/Item/RemoveAllDevicesFromManagement/RemoveAllDevicesFromManagementRequestBuilder.cs +++ b/src/generated/Users/Item/RemoveAllDevicesFromManagement/RemoveAllDevicesFromManagementRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,11 +29,10 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + command.SetHandler(async (string userId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Retire all devices from management for this user - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/ReprocessLicenseAssignment/ReprocessLicenseAssignmentRequestBuilder.cs b/src/generated/Users/Item/ReprocessLicenseAssignment/ReprocessLicenseAssignmentRequestBuilder.cs index f75ebfbba45..d760333ef67 100644 --- a/src/generated/Users/Item/ReprocessLicenseAssignment/ReprocessLicenseAssignmentRequestBuilder.cs +++ b/src/generated/Users/Item/ReprocessLicenseAssignment/ReprocessLicenseAssignmentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action reprocessLicenseAssignment - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes user public class ReprocessLicenseAssignmentResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/Restore/RestoreRequestBuilder.cs b/src/generated/Users/Item/Restore/RestoreRequestBuilder.cs index ab152bf389c..8253718e2ce 100644 --- a/src/generated/Users/Item/Restore/RestoreRequestBuilder.cs +++ b/src/generated/Users/Item/Restore/RestoreRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,18 +30,17 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action restore - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes directoryObject public class RestoreResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Users/Item/RevokeSignInSessions/RevokeSignInSessionsRequestBuilder.cs b/src/generated/Users/Item/RevokeSignInSessions/RevokeSignInSessionsRequestBuilder.cs index 8fff433efa7..ed51eb47cfd 100644 --- a/src/generated/Users/Item/RevokeSignInSessions/RevokeSignInSessionsRequestBuilder.cs +++ b/src/generated/Users/Item/RevokeSignInSessions/RevokeSignInSessionsRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +29,17 @@ public Command BuildPostCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteBoolValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action revokeSignInSessions - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/ScopedRoleMemberOf/Item/ScopedRoleMembershipRequestBuilder.cs b/src/generated/Users/Item/ScopedRoleMemberOf/Item/ScopedRoleMembershipRequestBuilder.cs index 98dbafc2b8b..a1317196fef 100644 --- a/src/generated/Users/Item/ScopedRoleMemberOf/Item/ScopedRoleMembershipRequestBuilder.cs +++ b/src/generated/Users/Item/ScopedRoleMemberOf/Item/ScopedRoleMembershipRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,15 +30,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var scopedRoleMembershipIdOption = new Option("--scopedrolemembership-id", description: "key: id of scopedRoleMembership") { + var scopedRoleMembershipIdOption = new Option("--scoped-role-membership-id", description: "key: id of scopedRoleMembership") { }; scopedRoleMembershipIdOption.IsRequired = true; command.AddOption(scopedRoleMembershipIdOption); - command.SetHandler(async (string userId, string scopedRoleMembershipId) => { + command.SetHandler(async (string userId, string scopedRoleMembershipId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, scopedRoleMembershipIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var scopedRoleMembershipIdOption = new Option("--scopedrolemembership-id", description: "key: id of scopedRoleMembership") { + var scopedRoleMembershipIdOption = new Option("--scoped-role-membership-id", description: "key: id of scopedRoleMembership") { }; scopedRoleMembershipIdOption.IsRequired = true; command.AddOption(scopedRoleMembershipIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string scopedRoleMembershipId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string scopedRoleMembershipId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, scopedRoleMembershipIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, scopedRoleMembershipIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -95,7 +93,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var scopedRoleMembershipIdOption = new Option("--scopedrolemembership-id", description: "key: id of scopedRoleMembership") { + var scopedRoleMembershipIdOption = new Option("--scoped-role-membership-id", description: "key: id of scopedRoleMembership") { }; scopedRoleMembershipIdOption.IsRequired = true; command.AddOption(scopedRoleMembershipIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string scopedRoleMembershipId, string body) => { + command.SetHandler(async (string userId, string scopedRoleMembershipId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, scopedRoleMembershipIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ScopedRoleMembership bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The scoped-role administrative unit memberships for this user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The scoped-role administrative unit memberships for this user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The scoped-role administrative unit memberships for this user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ScopedRoleMembership model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The scoped-role administrative unit memberships for this user. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/ScopedRoleMemberOf/ScopedRoleMemberOfRequestBuilder.cs b/src/generated/Users/Item/ScopedRoleMemberOf/ScopedRoleMemberOfRequestBuilder.cs index 22df4efcf60..55b13d82bb3 100644 --- a/src/generated/Users/Item/ScopedRoleMemberOf/ScopedRoleMemberOfRequestBuilder.cs +++ b/src/generated/Users/Item/ScopedRoleMemberOf/ScopedRoleMemberOfRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.ScopedRoleMemberOf.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ScopedRoleMemberOfRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ScopedRoleMembershipRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ScopedRoleMembership body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The scoped-role administrative unit memberships for this user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The scoped-role administrative unit memberships for this user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ScopedRoleMembership model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The scoped-role administrative unit memberships for this user. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/SendMail/SendMailRequestBuilder.cs b/src/generated/Users/Item/SendMail/SendMailRequestBuilder.cs index 7a5c2fe73bb..ec27e032551 100644 --- a/src/generated/Users/Item/SendMail/SendMailRequestBuilder.cs +++ b/src/generated/Users/Item/SendMail/SendMailRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + command.SetHandler(async (string userId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(SendMailRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action sendMail - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SendMailRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Settings/SettingsRequestBuilder.cs b/src/generated/Users/Item/Settings/SettingsRequestBuilder.cs index 270da64b362..e066028fefb 100644 --- a/src/generated/Users/Item/Settings/SettingsRequestBuilder.cs +++ b/src/generated/Users/Item/Settings/SettingsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Settings.ShiftPreferences; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,11 +31,10 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + command.SetHandler(async (string userId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption); return command; @@ -61,20 +60,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -92,14 +90,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + command.SetHandler(async (string userId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, bodyOption); return command; @@ -179,42 +176,6 @@ public RequestInformation CreatePatchRequestInformation(UserSettings body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(UserSettings model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Settings/ShiftPreferences/ShiftPreferencesRequestBuilder.cs b/src/generated/Users/Item/Settings/ShiftPreferences/ShiftPreferencesRequestBuilder.cs index c10551a0b90..ec5695ae580 100644 --- a/src/generated/Users/Item/Settings/ShiftPreferences/ShiftPreferencesRequestBuilder.cs +++ b/src/generated/Users/Item/Settings/ShiftPreferences/ShiftPreferencesRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,10 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + command.SetHandler(async (string userId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption); return command; @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + command.SetHandler(async (string userId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The shift preferences for the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The shift preferences for the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The shift preferences for the user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.ShiftPreferences model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The shift preferences for the user. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Teamwork/InstalledApps/InstalledAppsRequestBuilder.cs b/src/generated/Users/Item/Teamwork/InstalledApps/InstalledAppsRequestBuilder.cs index dcbedf6346e..5512e44e9cf 100644 --- a/src/generated/Users/Item/Teamwork/InstalledApps/InstalledAppsRequestBuilder.cs +++ b/src/generated/Users/Item/Teamwork/InstalledApps/InstalledAppsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Teamwork.InstalledApps.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class InstalledAppsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new UserScopeTeamsAppInstallationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildChatCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildChatCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(UserScopeTeamsAppInstalla requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The apps installed in the personal scope of this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The apps installed in the personal scope of this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UserScopeTeamsAppInstallation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The apps installed in the personal scope of this user. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Teamwork/InstalledApps/Item/Chat/@Ref/@Ref.cs b/src/generated/Users/Item/Teamwork/InstalledApps/Item/Chat/@Ref/@Ref.cs deleted file mode 100644 index 8c75f3b6856..00000000000 --- a/src/generated/Users/Item/Teamwork/InstalledApps/Item/Chat/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.Teamwork.InstalledApps.Item.Chat.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/Teamwork/InstalledApps/Item/Chat/@Ref/RefRequestBuilder.cs b/src/generated/Users/Item/Teamwork/InstalledApps/Item/Chat/@Ref/RefRequestBuilder.cs deleted file mode 100644 index ebf6d1fcab8..00000000000 --- a/src/generated/Users/Item/Teamwork/InstalledApps/Item/Chat/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Users.Item.Teamwork.InstalledApps.Item.Chat.@Ref { - /// Builds and executes requests for operations under \users\{user-id}\teamwork\installedApps\{userScopeTeamsAppInstallation-id}\chat\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// The chat between the user and Teams app. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "The chat between the user and Teams app."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var userScopeTeamsAppInstallationIdOption = new Option("--userscopeteamsappinstallation-id", description: "key: id of userScopeTeamsAppInstallation") { - }; - userScopeTeamsAppInstallationIdOption.IsRequired = true; - command.AddOption(userScopeTeamsAppInstallationIdOption); - command.SetHandler(async (string userId, string userScopeTeamsAppInstallationId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userIdOption, userScopeTeamsAppInstallationIdOption); - return command; - } - /// - /// The chat between the user and Teams app. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "The chat between the user and Teams app."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var userScopeTeamsAppInstallationIdOption = new Option("--userscopeteamsappinstallation-id", description: "key: id of userScopeTeamsAppInstallation") { - }; - userScopeTeamsAppInstallationIdOption.IsRequired = true; - command.AddOption(userScopeTeamsAppInstallationIdOption); - command.SetHandler(async (string userId, string userScopeTeamsAppInstallationId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, userScopeTeamsAppInstallationIdOption); - return command; - } - /// - /// The chat between the user and Teams app. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "The chat between the user and Teams app."; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var userScopeTeamsAppInstallationIdOption = new Option("--userscopeteamsappinstallation-id", description: "key: id of userScopeTeamsAppInstallation") { - }; - userScopeTeamsAppInstallationIdOption.IsRequired = true; - command.AddOption(userScopeTeamsAppInstallationIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string userId, string userScopeTeamsAppInstallationId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, userIdOption, userScopeTeamsAppInstallationIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/teamwork/installedApps/{userScopeTeamsAppInstallation_id}/chat/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// The chat between the user and Teams app. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The chat between the user and Teams app. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The chat between the user and Teams app. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Users.Item.Teamwork.InstalledApps.Item.Chat.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// The chat between the user and Teams app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The chat between the user and Teams app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The chat between the user and Teams app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Users.Item.Teamwork.InstalledApps.Item.Chat.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Users/Item/Teamwork/InstalledApps/Item/Chat/ChatRequestBuilder.cs b/src/generated/Users/Item/Teamwork/InstalledApps/Item/Chat/ChatRequestBuilder.cs index e94f4599572..2a3fa3eb0b7 100644 --- a/src/generated/Users/Item/Teamwork/InstalledApps/Item/Chat/ChatRequestBuilder.cs +++ b/src/generated/Users/Item/Teamwork/InstalledApps/Item/Chat/ChatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Teamwork.InstalledApps.Item.Chat.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,7 +31,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var userScopeTeamsAppInstallationIdOption = new Option("--userscopeteamsappinstallation-id", description: "key: id of userScopeTeamsAppInstallation") { + var userScopeTeamsAppInstallationIdOption = new Option("--user-scope-teams-app-installation-id", description: "key: id of userScopeTeamsAppInstallation") { }; userScopeTeamsAppInstallationIdOption.IsRequired = true; command.AddOption(userScopeTeamsAppInstallationIdOption); @@ -45,25 +45,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string userScopeTeamsAppInstallationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string userScopeTeamsAppInstallationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, userScopeTeamsAppInstallationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, userScopeTeamsAppInstallationIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Users.Item.Teamwork.InstalledApps.Item.Chat.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Users.Item.Teamwork.InstalledApps.Item.Chat.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -103,18 +102,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The chat between the user and Teams app. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The chat between the user and Teams app. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Teamwork/InstalledApps/Item/Chat/Ref/Ref.cs b/src/generated/Users/Item/Teamwork/InstalledApps/Item/Chat/Ref/Ref.cs new file mode 100644 index 00000000000..080cf26637c --- /dev/null +++ b/src/generated/Users/Item/Teamwork/InstalledApps/Item/Chat/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.Teamwork.InstalledApps.Item.Chat.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/Teamwork/InstalledApps/Item/Chat/Ref/RefRequestBuilder.cs b/src/generated/Users/Item/Teamwork/InstalledApps/Item/Chat/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..df1ad493be8 --- /dev/null +++ b/src/generated/Users/Item/Teamwork/InstalledApps/Item/Chat/Ref/RefRequestBuilder.cs @@ -0,0 +1,164 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Users.Item.Teamwork.InstalledApps.Item.Chat.Ref { + /// Builds and executes requests for operations under \users\{user-id}\teamwork\installedApps\{userScopeTeamsAppInstallation-id}\chat\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// The chat between the user and Teams app. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "The chat between the user and Teams app."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var userScopeTeamsAppInstallationIdOption = new Option("--user-scope-teams-app-installation-id", description: "key: id of userScopeTeamsAppInstallation") { + }; + userScopeTeamsAppInstallationIdOption.IsRequired = true; + command.AddOption(userScopeTeamsAppInstallationIdOption); + command.SetHandler(async (string userId, string userScopeTeamsAppInstallationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, userIdOption, userScopeTeamsAppInstallationIdOption); + return command; + } + /// + /// The chat between the user and Teams app. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "The chat between the user and Teams app."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var userScopeTeamsAppInstallationIdOption = new Option("--user-scope-teams-app-installation-id", description: "key: id of userScopeTeamsAppInstallation") { + }; + userScopeTeamsAppInstallationIdOption.IsRequired = true; + command.AddOption(userScopeTeamsAppInstallationIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string userScopeTeamsAppInstallationId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, userScopeTeamsAppInstallationIdOption, outputOption); + return command; + } + /// + /// The chat between the user and Teams app. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "The chat between the user and Teams app."; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var userScopeTeamsAppInstallationIdOption = new Option("--user-scope-teams-app-installation-id", description: "key: id of userScopeTeamsAppInstallation") { + }; + userScopeTeamsAppInstallationIdOption.IsRequired = true; + command.AddOption(userScopeTeamsAppInstallationIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string userId, string userScopeTeamsAppInstallationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, userIdOption, userScopeTeamsAppInstallationIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/users/{user_id}/teamwork/installedApps/{userScopeTeamsAppInstallation_id}/chat/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// The chat between the user and Teams app. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The chat between the user and Teams app. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// The chat between the user and Teams app. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Users.Item.Teamwork.InstalledApps.Item.Chat.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Users/Item/Teamwork/InstalledApps/Item/UserScopeTeamsAppInstallationRequestBuilder.cs b/src/generated/Users/Item/Teamwork/InstalledApps/Item/UserScopeTeamsAppInstallationRequestBuilder.cs index 2ba69a98f8f..d8af258ecfe 100644 --- a/src/generated/Users/Item/Teamwork/InstalledApps/Item/UserScopeTeamsAppInstallationRequestBuilder.cs +++ b/src/generated/Users/Item/Teamwork/InstalledApps/Item/UserScopeTeamsAppInstallationRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Teamwork.InstalledApps.Item.Chat; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -38,15 +38,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var userScopeTeamsAppInstallationIdOption = new Option("--userscopeteamsappinstallation-id", description: "key: id of userScopeTeamsAppInstallation") { + var userScopeTeamsAppInstallationIdOption = new Option("--user-scope-teams-app-installation-id", description: "key: id of userScopeTeamsAppInstallation") { }; userScopeTeamsAppInstallationIdOption.IsRequired = true; command.AddOption(userScopeTeamsAppInstallationIdOption); - command.SetHandler(async (string userId, string userScopeTeamsAppInstallationId) => { + command.SetHandler(async (string userId, string userScopeTeamsAppInstallationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, userScopeTeamsAppInstallationIdOption); return command; @@ -62,7 +61,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var userScopeTeamsAppInstallationIdOption = new Option("--userscopeteamsappinstallation-id", description: "key: id of userScopeTeamsAppInstallation") { + var userScopeTeamsAppInstallationIdOption = new Option("--user-scope-teams-app-installation-id", description: "key: id of userScopeTeamsAppInstallation") { }; userScopeTeamsAppInstallationIdOption.IsRequired = true; command.AddOption(userScopeTeamsAppInstallationIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string userScopeTeamsAppInstallationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string userScopeTeamsAppInstallationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, userScopeTeamsAppInstallationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, userScopeTeamsAppInstallationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,7 +101,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var userScopeTeamsAppInstallationIdOption = new Option("--userscopeteamsappinstallation-id", description: "key: id of userScopeTeamsAppInstallation") { + var userScopeTeamsAppInstallationIdOption = new Option("--user-scope-teams-app-installation-id", description: "key: id of userScopeTeamsAppInstallation") { }; userScopeTeamsAppInstallationIdOption.IsRequired = true; command.AddOption(userScopeTeamsAppInstallationIdOption); @@ -111,14 +109,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string userScopeTeamsAppInstallationId, string body) => { + command.SetHandler(async (string userId, string userScopeTeamsAppInstallationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, userScopeTeamsAppInstallationIdOption, bodyOption); return command; @@ -190,42 +187,6 @@ public RequestInformation CreatePatchRequestInformation(UserScopeTeamsAppInstall requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The apps installed in the personal scope of this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The apps installed in the personal scope of this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The apps installed in the personal scope of this user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(UserScopeTeamsAppInstallation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The apps installed in the personal scope of this user. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Teamwork/SendActivityNotification/SendActivityNotificationRequestBuilder.cs b/src/generated/Users/Item/Teamwork/SendActivityNotification/SendActivityNotificationRequestBuilder.cs index df66a765e5f..3e226e5dabf 100644 --- a/src/generated/Users/Item/Teamwork/SendActivityNotification/SendActivityNotificationRequestBuilder.cs +++ b/src/generated/Users/Item/Teamwork/SendActivityNotification/SendActivityNotificationRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + command.SetHandler(async (string userId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(SendActivityNotificationR requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action sendActivityNotification - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SendActivityNotificationRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Teamwork/TeamworkRequestBuilder.cs b/src/generated/Users/Item/Teamwork/TeamworkRequestBuilder.cs index 6af2b1e52a7..4e596053f1d 100644 --- a/src/generated/Users/Item/Teamwork/TeamworkRequestBuilder.cs +++ b/src/generated/Users/Item/Teamwork/TeamworkRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Teamwork.SendActivityNotification; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -32,11 +32,10 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + command.SetHandler(async (string userId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption); return command; @@ -62,25 +61,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildInstalledAppsCommand() { var command = new Command("installed-apps"); var builder = new ApiSdk.Users.Item.Teamwork.InstalledApps.InstalledAppsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -100,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + command.SetHandler(async (string userId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, bodyOption); return command; @@ -185,42 +185,6 @@ public RequestInformation CreatePatchRequestInformation(UserTeamwork body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A container for Microsoft Teams features available for the user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A container for Microsoft Teams features available for the user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A container for Microsoft Teams features available for the user. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(UserTeamwork model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A container for Microsoft Teams features available for the user. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Todo/Lists/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/Todo/Lists/Delta/DeltaRequestBuilder.cs index 3089949c677..ba1d2b21911 100644 --- a/src/generated/Users/Item/Todo/Lists/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/Todo/Lists/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,18 +29,17 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Todo/Lists/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Users/Item/Todo/Lists/Item/Extensions/ExtensionsRequestBuilder.cs index 0273175110a..68ef97ee9c4 100644 --- a/src/generated/Users/Item/Todo/Lists/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Users/Item/Todo/Lists/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Todo.Lists.Item.Extensions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,7 +39,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string todoTaskListId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string todoTaskListId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, todoTaskListIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, todoTaskListIdOption, bodyOption, outputOption); return command; } /// @@ -76,7 +74,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string todoTaskListId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string todoTaskListId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, todoTaskListIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, todoTaskListIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the task list. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the task list. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the task list. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Todo/Lists/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Users/Item/Todo/Lists/Item/Extensions/Item/ExtensionRequestBuilder.cs index 6202d7c0cf5..7b94de318ad 100644 --- a/src/generated/Users/Item/Todo/Lists/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Users/Item/Todo/Lists/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,7 +30,7 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); @@ -38,11 +38,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string userId, string todoTaskListId, string extensionId) => { + command.SetHandler(async (string userId, string todoTaskListId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, todoTaskListIdOption, extensionIdOption); return command; @@ -58,7 +57,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string todoTaskListId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string todoTaskListId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, todoTaskListIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, todoTaskListIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -103,7 +101,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string todoTaskListId, string extensionId, string body) => { + command.SetHandler(async (string userId, string todoTaskListId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, todoTaskListIdOption, extensionIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the task list. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the task list. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the task list. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the task list. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Todo/Lists/Item/Tasks/Delta/DeltaRequestBuilder.cs b/src/generated/Users/Item/Todo/Lists/Item/Tasks/Delta/DeltaRequestBuilder.cs index 60c339fe487..41bd26ca421 100644 --- a/src/generated/Users/Item/Todo/Lists/Item/Tasks/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Users/Item/Todo/Lists/Item/Tasks/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,22 +29,21 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - command.SetHandler(async (string userId, string todoTaskListId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string todoTaskListId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, todoTaskListIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, todoTaskListIdOption, outputOption); return command; } /// @@ -75,16 +74,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/Todo/Lists/Item/Tasks/Item/Extensions/ExtensionsRequestBuilder.cs b/src/generated/Users/Item/Todo/Lists/Item/Tasks/Item/Extensions/ExtensionsRequestBuilder.cs index 437297e90b4..913d77f4705 100644 --- a/src/generated/Users/Item/Todo/Lists/Item/Tasks/Item/Extensions/ExtensionsRequestBuilder.cs +++ b/src/generated/Users/Item/Todo/Lists/Item/Tasks/Item/Extensions/ExtensionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Todo.Lists.Item.Tasks.Item.Extensions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ExtensionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ExtensionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,11 +39,11 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - var todoTaskIdOption = new Option("--todotask-id", description: "key: id of todoTask") { + var todoTaskIdOption = new Option("--todo-task-id", description: "key: id of todoTask") { }; todoTaskIdOption.IsRequired = true; command.AddOption(todoTaskIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string todoTaskListId, string todoTaskId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string todoTaskListId, string todoTaskId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, todoTaskListIdOption, todoTaskIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, todoTaskListIdOption, todoTaskIdOption, bodyOption, outputOption); return command; } /// @@ -80,11 +78,11 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - var todoTaskIdOption = new Option("--todotask-id", description: "key: id of todoTask") { + var todoTaskIdOption = new Option("--todo-task-id", description: "key: id of todoTask") { }; todoTaskIdOption.IsRequired = true; command.AddOption(todoTaskIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string todoTaskListId, string todoTaskId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string todoTaskListId, string todoTaskId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, todoTaskListIdOption, todoTaskIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, todoTaskListIdOption, todoTaskIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(Extension body, Action - /// The collection of open extensions defined for the task. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the task. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the task. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Todo/Lists/Item/Tasks/Item/Extensions/Item/ExtensionRequestBuilder.cs b/src/generated/Users/Item/Todo/Lists/Item/Tasks/Item/Extensions/Item/ExtensionRequestBuilder.cs index 56b2dee2b38..d314af8821c 100644 --- a/src/generated/Users/Item/Todo/Lists/Item/Tasks/Item/Extensions/Item/ExtensionRequestBuilder.cs +++ b/src/generated/Users/Item/Todo/Lists/Item/Tasks/Item/Extensions/Item/ExtensionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,11 +30,11 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - var todoTaskIdOption = new Option("--todotask-id", description: "key: id of todoTask") { + var todoTaskIdOption = new Option("--todo-task-id", description: "key: id of todoTask") { }; todoTaskIdOption.IsRequired = true; command.AddOption(todoTaskIdOption); @@ -42,11 +42,10 @@ public Command BuildDeleteCommand() { }; extensionIdOption.IsRequired = true; command.AddOption(extensionIdOption); - command.SetHandler(async (string userId, string todoTaskListId, string todoTaskId, string extensionId) => { + command.SetHandler(async (string userId, string todoTaskListId, string todoTaskId, string extensionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, todoTaskListIdOption, todoTaskIdOption, extensionIdOption); return command; @@ -62,11 +61,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - var todoTaskIdOption = new Option("--todotask-id", description: "key: id of todoTask") { + var todoTaskIdOption = new Option("--todo-task-id", description: "key: id of todoTask") { }; todoTaskIdOption.IsRequired = true; command.AddOption(todoTaskIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string todoTaskListId, string todoTaskId, string extensionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string todoTaskListId, string todoTaskId, string extensionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, todoTaskListIdOption, todoTaskIdOption, extensionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, todoTaskListIdOption, todoTaskIdOption, extensionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,11 +109,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - var todoTaskIdOption = new Option("--todotask-id", description: "key: id of todoTask") { + var todoTaskIdOption = new Option("--todo-task-id", description: "key: id of todoTask") { }; todoTaskIdOption.IsRequired = true; command.AddOption(todoTaskIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string todoTaskListId, string todoTaskId, string extensionId, string body) => { + command.SetHandler(async (string userId, string todoTaskListId, string todoTaskId, string extensionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, todoTaskListIdOption, todoTaskIdOption, extensionIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(Extension body, Action - /// The collection of open extensions defined for the task. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the task. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The collection of open extensions defined for the task. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Extension model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The collection of open extensions defined for the task. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Todo/Lists/Item/Tasks/Item/LinkedResources/Item/LinkedResourceRequestBuilder.cs b/src/generated/Users/Item/Todo/Lists/Item/Tasks/Item/LinkedResources/Item/LinkedResourceRequestBuilder.cs index 8ceb58ee13f..117997d9dd4 100644 --- a/src/generated/Users/Item/Todo/Lists/Item/Tasks/Item/LinkedResources/Item/LinkedResourceRequestBuilder.cs +++ b/src/generated/Users/Item/Todo/Lists/Item/Tasks/Item/LinkedResources/Item/LinkedResourceRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - var todoTaskIdOption = new Option("--todotask-id", description: "key: id of todoTask") { + var todoTaskIdOption = new Option("--todo-task-id", description: "key: id of todoTask") { }; todoTaskIdOption.IsRequired = true; command.AddOption(todoTaskIdOption); - var linkedResourceIdOption = new Option("--linkedresource-id", description: "key: id of linkedResource") { + var linkedResourceIdOption = new Option("--linked-resource-id", description: "key: id of linkedResource") { }; linkedResourceIdOption.IsRequired = true; command.AddOption(linkedResourceIdOption); - command.SetHandler(async (string userId, string todoTaskListId, string todoTaskId, string linkedResourceId) => { + command.SetHandler(async (string userId, string todoTaskListId, string todoTaskId, string linkedResourceId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, todoTaskListIdOption, todoTaskIdOption, linkedResourceIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - var todoTaskIdOption = new Option("--todotask-id", description: "key: id of todoTask") { + var todoTaskIdOption = new Option("--todo-task-id", description: "key: id of todoTask") { }; todoTaskIdOption.IsRequired = true; command.AddOption(todoTaskIdOption); - var linkedResourceIdOption = new Option("--linkedresource-id", description: "key: id of linkedResource") { + var linkedResourceIdOption = new Option("--linked-resource-id", description: "key: id of linkedResource") { }; linkedResourceIdOption.IsRequired = true; command.AddOption(linkedResourceIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string todoTaskListId, string todoTaskId, string linkedResourceId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string todoTaskListId, string todoTaskId, string linkedResourceId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, todoTaskListIdOption, todoTaskIdOption, linkedResourceIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, todoTaskListIdOption, todoTaskIdOption, linkedResourceIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -111,15 +109,15 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - var todoTaskIdOption = new Option("--todotask-id", description: "key: id of todoTask") { + var todoTaskIdOption = new Option("--todo-task-id", description: "key: id of todoTask") { }; todoTaskIdOption.IsRequired = true; command.AddOption(todoTaskIdOption); - var linkedResourceIdOption = new Option("--linkedresource-id", description: "key: id of linkedResource") { + var linkedResourceIdOption = new Option("--linked-resource-id", description: "key: id of linkedResource") { }; linkedResourceIdOption.IsRequired = true; command.AddOption(linkedResourceIdOption); @@ -127,14 +125,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string todoTaskListId, string todoTaskId, string linkedResourceId, string body) => { + command.SetHandler(async (string userId, string todoTaskListId, string todoTaskId, string linkedResourceId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, todoTaskListIdOption, todoTaskIdOption, linkedResourceIdOption, bodyOption); return command; @@ -206,42 +203,6 @@ public RequestInformation CreatePatchRequestInformation(LinkedResource body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of resources linked to the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of resources linked to the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of resources linked to the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(LinkedResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of resources linked to the task. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Todo/Lists/Item/Tasks/Item/LinkedResources/LinkedResourcesRequestBuilder.cs b/src/generated/Users/Item/Todo/Lists/Item/Tasks/Item/LinkedResources/LinkedResourcesRequestBuilder.cs index 10985ddacc4..ec5c0de2821 100644 --- a/src/generated/Users/Item/Todo/Lists/Item/Tasks/Item/LinkedResources/LinkedResourcesRequestBuilder.cs +++ b/src/generated/Users/Item/Todo/Lists/Item/Tasks/Item/LinkedResources/LinkedResourcesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Todo.Lists.Item.Tasks.Item.LinkedResources.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class LinkedResourcesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new LinkedResourceRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -40,11 +39,11 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - var todoTaskIdOption = new Option("--todotask-id", description: "key: id of todoTask") { + var todoTaskIdOption = new Option("--todo-task-id", description: "key: id of todoTask") { }; todoTaskIdOption.IsRequired = true; command.AddOption(todoTaskIdOption); @@ -52,21 +51,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string todoTaskListId, string todoTaskId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string todoTaskListId, string todoTaskId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, todoTaskListIdOption, todoTaskIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, todoTaskListIdOption, todoTaskIdOption, bodyOption, outputOption); return command; } /// @@ -80,11 +78,11 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - var todoTaskIdOption = new Option("--todotask-id", description: "key: id of todoTask") { + var todoTaskIdOption = new Option("--todo-task-id", description: "key: id of todoTask") { }; todoTaskIdOption.IsRequired = true; command.AddOption(todoTaskIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string todoTaskListId, string todoTaskId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string todoTaskListId, string todoTaskId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, todoTaskListIdOption, todoTaskIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, todoTaskListIdOption, todoTaskIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -197,31 +194,6 @@ public RequestInformation CreatePostRequestInformation(LinkedResource body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of resources linked to the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of resources linked to the task. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(LinkedResource model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of resources linked to the task. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Todo/Lists/Item/Tasks/Item/TodoTaskRequestBuilder.cs b/src/generated/Users/Item/Todo/Lists/Item/Tasks/Item/TodoTaskRequestBuilder.cs index 21b807861f3..04b1250690c 100644 --- a/src/generated/Users/Item/Todo/Lists/Item/Tasks/Item/TodoTaskRequestBuilder.cs +++ b/src/generated/Users/Item/Todo/Lists/Item/Tasks/Item/TodoTaskRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Todo.Lists.Item.Tasks.Item.LinkedResources; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -32,19 +32,18 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - var todoTaskIdOption = new Option("--todotask-id", description: "key: id of todoTask") { + var todoTaskIdOption = new Option("--todo-task-id", description: "key: id of todoTask") { }; todoTaskIdOption.IsRequired = true; command.AddOption(todoTaskIdOption); - command.SetHandler(async (string userId, string todoTaskListId, string todoTaskId) => { + command.SetHandler(async (string userId, string todoTaskListId, string todoTaskId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, todoTaskListIdOption, todoTaskIdOption); return command; @@ -52,6 +51,9 @@ public Command BuildDeleteCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Users.Item.Todo.Lists.Item.Tasks.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -67,11 +69,11 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - var todoTaskIdOption = new Option("--todotask-id", description: "key: id of todoTask") { + var todoTaskIdOption = new Option("--todo-task-id", description: "key: id of todoTask") { }; todoTaskIdOption.IsRequired = true; command.AddOption(todoTaskIdOption); @@ -85,25 +87,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string todoTaskListId, string todoTaskId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string todoTaskListId, string todoTaskId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, todoTaskListIdOption, todoTaskIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, todoTaskListIdOption, todoTaskIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLinkedResourcesCommand() { var command = new Command("linked-resources"); var builder = new ApiSdk.Users.Item.Todo.Lists.Item.Tasks.Item.LinkedResources.LinkedResourcesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -119,11 +123,11 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - var todoTaskIdOption = new Option("--todotask-id", description: "key: id of todoTask") { + var todoTaskIdOption = new Option("--todo-task-id", description: "key: id of todoTask") { }; todoTaskIdOption.IsRequired = true; command.AddOption(todoTaskIdOption); @@ -131,14 +135,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string todoTaskListId, string todoTaskId, string body) => { + command.SetHandler(async (string userId, string todoTaskListId, string todoTaskId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, todoTaskListIdOption, todoTaskIdOption, bodyOption); return command; @@ -210,42 +213,6 @@ public RequestInformation CreatePatchRequestInformation(TodoTask body, Action - /// The tasks in this task list. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The tasks in this task list. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The tasks in this task list. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(TodoTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The tasks in this task list. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Todo/Lists/Item/Tasks/TasksRequestBuilder.cs b/src/generated/Users/Item/Todo/Lists/Item/Tasks/TasksRequestBuilder.cs index 24f591cc7ac..422eced1150 100644 --- a/src/generated/Users/Item/Todo/Lists/Item/Tasks/TasksRequestBuilder.cs +++ b/src/generated/Users/Item/Todo/Lists/Item/Tasks/TasksRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Todo.Lists.Item.Tasks.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,13 +23,12 @@ public class TasksRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TodoTaskRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildExtensionsCommand(), - builder.BuildGetCommand(), - builder.BuildLinkedResourcesCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildLinkedResourcesCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -43,7 +42,7 @@ public Command BuildCreateCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); @@ -51,21 +50,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string todoTaskListId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string todoTaskListId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, todoTaskListIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, todoTaskListIdOption, bodyOption, outputOption); return command; } /// @@ -79,7 +77,7 @@ public Command BuildListCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string todoTaskListId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string todoTaskListId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -129,15 +131,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, todoTaskListIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, todoTaskListIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -198,31 +195,6 @@ public RequestInformation CreatePostRequestInformation(TodoTask body, Action - /// The tasks in this task list. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The tasks in this task list. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TodoTask model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The tasks in this task list. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Todo/Lists/Item/TodoTaskListRequestBuilder.cs b/src/generated/Users/Item/Todo/Lists/Item/TodoTaskListRequestBuilder.cs index a1a5c41ae0e..3a91feda43d 100644 --- a/src/generated/Users/Item/Todo/Lists/Item/TodoTaskListRequestBuilder.cs +++ b/src/generated/Users/Item/Todo/Lists/Item/TodoTaskListRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Todo.Lists.Item.Tasks; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -32,15 +32,14 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); - command.SetHandler(async (string userId, string todoTaskListId) => { + command.SetHandler(async (string userId, string todoTaskListId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, todoTaskListIdOption); return command; @@ -48,6 +47,9 @@ public Command BuildDeleteCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Users.Item.Todo.Lists.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -63,7 +65,7 @@ public Command BuildGetCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); @@ -77,20 +79,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string todoTaskListId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string todoTaskListId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, todoTaskListIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, todoTaskListIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,7 +105,7 @@ public Command BuildPatchCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - var todoTaskListIdOption = new Option("--todotasklist-id", description: "key: id of todoTaskList") { + var todoTaskListIdOption = new Option("--todo-task-list-id", description: "key: id of todoTaskList") { }; todoTaskListIdOption.IsRequired = true; command.AddOption(todoTaskListIdOption); @@ -112,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string todoTaskListId, string body) => { + command.SetHandler(async (string userId, string todoTaskListId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, todoTaskListIdOption, bodyOption); return command; @@ -127,6 +127,9 @@ public Command BuildPatchCommand() { public Command BuildTasksCommand() { var command = new Command("tasks"); var builder = new ApiSdk.Users.Item.Todo.Lists.Item.Tasks.TasksRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -198,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(TodoTaskList body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The task lists in the users mailbox. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The task lists in the users mailbox. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The task lists in the users mailbox. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(TodoTaskList model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The task lists in the users mailbox. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/Todo/Lists/ListsRequestBuilder.cs b/src/generated/Users/Item/Todo/Lists/ListsRequestBuilder.cs index 592e96e7649..fd9bdf76302 100644 --- a/src/generated/Users/Item/Todo/Lists/ListsRequestBuilder.cs +++ b/src/generated/Users/Item/Todo/Lists/ListsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Users.Item.Todo.Lists.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,13 +23,12 @@ public class ListsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new TodoTaskListRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildExtensionsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildTasksCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildTasksCommand()); return commands; } /// @@ -47,21 +46,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -110,7 +108,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -121,15 +123,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -190,31 +187,6 @@ public RequestInformation CreatePostRequestInformation(TodoTaskList body, Action public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// The task lists in the users mailbox. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The task lists in the users mailbox. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TodoTaskList model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The task lists in the users mailbox. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/Todo/TodoRequestBuilder.cs b/src/generated/Users/Item/Todo/TodoRequestBuilder.cs index 7ab37a70f57..759917d620d 100644 --- a/src/generated/Users/Item/Todo/TodoRequestBuilder.cs +++ b/src/generated/Users/Item/Todo/TodoRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Users.Item.Todo.Lists; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,11 +31,10 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + command.SetHandler(async (string userId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption); return command; @@ -61,25 +60,27 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildListsCommand() { var command = new Command("lists"); var builder = new ApiSdk.Users.Item.Todo.Lists.ListsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -99,14 +100,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + command.SetHandler(async (string userId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, bodyOption); return command; @@ -178,42 +178,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the To Do services available to a user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the To Do services available to a user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the To Do services available to a user. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Todo model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the To Do services available to a user. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Users/Item/TransitiveMemberOf/@Ref/@Ref.cs b/src/generated/Users/Item/TransitiveMemberOf/@Ref/@Ref.cs deleted file mode 100644 index 4fc648f783e..00000000000 --- a/src/generated/Users/Item/TransitiveMemberOf/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.TransitiveMemberOf.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/TransitiveMemberOf/@Ref/RefRequestBuilder.cs b/src/generated/Users/Item/TransitiveMemberOf/@Ref/RefRequestBuilder.cs deleted file mode 100644 index 2e02709dbf3..00000000000 --- a/src/generated/Users/Item/TransitiveMemberOf/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,202 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Users.Item.TransitiveMemberOf.@Ref { - /// Builds and executes requests for operations under \users\{user-id}\transitiveMemberOf\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Get ref of transitiveMemberOf from users - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Get ref of transitiveMemberOf from users"; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var topOption = new Option("--top", description: "Show only the first n items") { - }; - topOption.IsRequired = false; - command.AddOption(topOption); - var skipOption = new Option("--skip", description: "Skip the first n items") { - }; - skipOption.IsRequired = false; - command.AddOption(skipOption); - var searchOption = new Option("--search", description: "Search items by search phrases") { - }; - searchOption.IsRequired = false; - command.AddOption(searchOption); - var filterOption = new Option("--filter", description: "Filter items by property values") { - }; - filterOption.IsRequired = false; - command.AddOption(filterOption); - var countOption = new Option("--count", description: "Include count of items") { - }; - countOption.IsRequired = false; - command.AddOption(countOption); - var orderbyOption = new Option("--orderby", description: "Order items by property values") { - Arity = ArgumentArity.ZeroOrMore - }; - orderbyOption.IsRequired = false; - command.AddOption(orderbyOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby) => { - var requestInfo = CreateGetRequestInformation(q => { - q.Top = top; - q.Skip = skip; - if (!String.IsNullOrEmpty(search)) q.Search = search; - if (!String.IsNullOrEmpty(filter)) q.Filter = filter; - q.Count = count; - q.Orderby = orderby; - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption); - return command; - } - /// - /// Create new navigation property ref to transitiveMemberOf for users - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Create new navigation property ref to transitiveMemberOf for users"; - // Create options for all the parameters - var userIdOption = new Option("--user-id", description: "key: id of user") { - }; - userIdOption.IsRequired = true; - command.AddOption(userIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/users/{user_id}/transitiveMemberOf/$ref{?top,skip,search,filter,count,orderby}"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Get ref of transitiveMemberOf from users - /// Request headers - /// Request options - /// Request query parameters - /// - public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - if (q != null) { - var qParams = new GetQueryParameters(); - q.Invoke(qParams); - qParams.AddQueryParameters(requestInfo.QueryParameters); - } - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Create new navigation property ref to transitiveMemberOf for users - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(ApiSdk.Users.Item.TransitiveMemberOf.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Get ref of transitiveMemberOf from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property ref to transitiveMemberOf for users - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Users.Item.TransitiveMemberOf.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Get ref of transitiveMemberOf from users - public class GetQueryParameters : QueryParametersBase { - /// Include count of items - public bool? Count { get; set; } - /// Filter items by property values - public string Filter { get; set; } - /// Order items by property values - public string[] Orderby { get; set; } - /// Search items by search phrases - public string Search { get; set; } - /// Skip the first n items - public int? Skip { get; set; } - /// Show only the first n items - public int? Top { get; set; } - } - } -} diff --git a/src/generated/Users/Item/TransitiveMemberOf/@Ref/RefResponse.cs b/src/generated/Users/Item/TransitiveMemberOf/@Ref/RefResponse.cs deleted file mode 100644 index 3b098a5bce2..00000000000 --- a/src/generated/Users/Item/TransitiveMemberOf/@Ref/RefResponse.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.TransitiveMemberOf.@Ref { - public class RefResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string NextLink { get; set; } - public List Value { get; set; } - /// - /// Instantiates a new refResponse and sets the default values. - /// - public RefResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, - {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("@odata.nextLink", NextLink); - writer.WriteCollectionOfPrimitiveValues("value", Value); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/TransitiveMemberOf/Ref/Ref.cs b/src/generated/Users/Item/TransitiveMemberOf/Ref/Ref.cs new file mode 100644 index 00000000000..71761573da8 --- /dev/null +++ b/src/generated/Users/Item/TransitiveMemberOf/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.TransitiveMemberOf.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/TransitiveMemberOf/Ref/RefRequestBuilder.cs b/src/generated/Users/Item/TransitiveMemberOf/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..ff8d262ea0f --- /dev/null +++ b/src/generated/Users/Item/TransitiveMemberOf/Ref/RefRequestBuilder.cs @@ -0,0 +1,175 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Users.Item.TransitiveMemberOf.Ref { + /// Builds and executes requests for operations under \users\{user-id}\transitiveMemberOf\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Get ref of transitiveMemberOf from users + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Get ref of transitiveMemberOf from users"; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var topOption = new Option("--top", description: "Show only the first n items") { + }; + topOption.IsRequired = false; + command.AddOption(topOption); + var skipOption = new Option("--skip", description: "Skip the first n items") { + }; + skipOption.IsRequired = false; + command.AddOption(skipOption); + var searchOption = new Option("--search", description: "Search items by search phrases") { + }; + searchOption.IsRequired = false; + command.AddOption(searchOption); + var filterOption = new Option("--filter", description: "Filter items by property values") { + }; + filterOption.IsRequired = false; + command.AddOption(filterOption); + var countOption = new Option("--count", description: "Include count of items") { + }; + countOption.IsRequired = false; + command.AddOption(countOption); + var orderbyOption = new Option("--orderby", description: "Order items by property values") { + Arity = ArgumentArity.ZeroOrMore + }; + orderbyOption.IsRequired = false; + command.AddOption(orderbyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + q.Top = top; + q.Skip = skip; + if (!String.IsNullOrEmpty(search)) q.Search = search; + if (!String.IsNullOrEmpty(filter)) q.Filter = filter; + q.Count = count; + q.Orderby = orderby; + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, outputOption); + return command; + } + /// + /// Create new navigation property ref to transitiveMemberOf for users + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Create new navigation property ref to transitiveMemberOf for users"; + // Create options for all the parameters + var userIdOption = new Option("--user-id", description: "key: id of user") { + }; + userIdOption.IsRequired = true; + command.AddOption(userIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/users/{user_id}/transitiveMemberOf/$ref{?top,skip,search,filter,count,orderby}"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Get ref of transitiveMemberOf from users + /// Request headers + /// Request options + /// Request query parameters + /// + public RequestInformation CreateGetRequestInformation(Action q = default, Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + if (q != null) { + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + qParams.AddQueryParameters(requestInfo.QueryParameters); + } + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Create new navigation property ref to transitiveMemberOf for users + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(ApiSdk.Users.Item.TransitiveMemberOf.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Get ref of transitiveMemberOf from users + public class GetQueryParameters : QueryParametersBase { + /// Include count of items + public bool? Count { get; set; } + /// Filter items by property values + public string Filter { get; set; } + /// Order items by property values + public string[] Orderby { get; set; } + /// Search items by search phrases + public string Search { get; set; } + /// Skip the first n items + public int? Skip { get; set; } + /// Show only the first n items + public int? Top { get; set; } + } + } +} diff --git a/src/generated/Users/Item/TransitiveMemberOf/Ref/RefResponse.cs b/src/generated/Users/Item/TransitiveMemberOf/Ref/RefResponse.cs new file mode 100644 index 00000000000..50467360aba --- /dev/null +++ b/src/generated/Users/Item/TransitiveMemberOf/Ref/RefResponse.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Users.Item.TransitiveMemberOf.Ref { + public class RefResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string NextLink { get; set; } + public List Value { get; set; } + /// + /// Instantiates a new refResponse and sets the default values. + /// + public RefResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"@odata.nextLink", (o,n) => { (o as RefResponse).NextLink = n.GetStringValue(); } }, + {"value", (o,n) => { (o as RefResponse).Value = n.GetCollectionOfPrimitiveValues().ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("@odata.nextLink", NextLink); + writer.WriteCollectionOfPrimitiveValues("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Users/Item/TransitiveMemberOf/TransitiveMemberOfRequestBuilder.cs b/src/generated/Users/Item/TransitiveMemberOf/TransitiveMemberOfRequestBuilder.cs index cfff216e475..baabe100411 100644 --- a/src/generated/Users/Item/TransitiveMemberOf/TransitiveMemberOfRequestBuilder.cs +++ b/src/generated/Users/Item/TransitiveMemberOf/TransitiveMemberOfRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Users.Item.TransitiveMemberOf.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -65,7 +65,11 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -76,20 +80,15 @@ public Command BuildGetCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Users.Item.TransitiveMemberOf.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Users.Item.TransitiveMemberOf.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPostCommand()); return command; @@ -128,18 +127,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get transitiveMemberOf from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get transitiveMemberOf from users public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/Item/TranslateExchangeIds/TranslateExchangeIds.cs b/src/generated/Users/Item/TranslateExchangeIds/TranslateExchangeIds.cs deleted file mode 100644 index 9555df641ec..00000000000 --- a/src/generated/Users/Item/TranslateExchangeIds/TranslateExchangeIds.cs +++ /dev/null @@ -1,45 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Users.Item.TranslateExchangeIds { - public class TranslateExchangeIds : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// An error object indicating the reason for the conversion failure. This value is not present if the conversion succeeded. - public GenericError ErrorDetails { get; set; } - /// The identifier that was converted. This value is the original, un-converted identifier. - public string SourceId { get; set; } - /// The converted identifier. This value is not present if the conversion failed. - public string TargetId { get; set; } - /// - /// Instantiates a new translateExchangeIds and sets the default values. - /// - public TranslateExchangeIds() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"errorDetails", (o,n) => { (o as TranslateExchangeIds).ErrorDetails = n.GetObjectValue(); } }, - {"sourceId", (o,n) => { (o as TranslateExchangeIds).SourceId = n.GetStringValue(); } }, - {"targetId", (o,n) => { (o as TranslateExchangeIds).TargetId = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("errorDetails", ErrorDetails); - writer.WriteStringValue("sourceId", SourceId); - writer.WriteStringValue("targetId", TargetId); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Users/Item/TranslateExchangeIds/TranslateExchangeIdsRequestBuilder.cs b/src/generated/Users/Item/TranslateExchangeIds/TranslateExchangeIdsRequestBuilder.cs index 60409c65bcb..6bea4474b6e 100644 --- a/src/generated/Users/Item/TranslateExchangeIds/TranslateExchangeIdsRequestBuilder.cs +++ b/src/generated/Users/Item/TranslateExchangeIds/TranslateExchangeIdsRequestBuilder.cs @@ -1,9 +1,10 @@ +using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +81,5 @@ public RequestInformation CreatePostRequestInformation(TranslateExchangeIdsReque requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action translateExchangeIds - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(TranslateExchangeIdsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/Item/UserRequestBuilder.cs b/src/generated/Users/Item/UserRequestBuilder.cs index ac81811d3cb..6e74ffa3071 100644 --- a/src/generated/Users/Item/UserRequestBuilder.cs +++ b/src/generated/Users/Item/UserRequestBuilder.cs @@ -66,10 +66,10 @@ using ApiSdk.Users.Item.WipeManagedAppRegistrationsByDeviceTag; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -87,6 +87,9 @@ public class UserRequestBuilder { public Command BuildActivitiesCommand() { var command = new Command("activities"); var builder = new ApiSdk.Users.Item.Activities.ActivitiesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -101,6 +104,9 @@ public Command BuildAgreementAcceptancesCommand() { public Command BuildAppRoleAssignmentsCommand() { var command = new Command("app-role-assignments"); var builder = new ApiSdk.Users.Item.AppRoleAssignments.AppRoleAssignmentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -140,6 +146,9 @@ public Command BuildCalendarCommand() { public Command BuildCalendarGroupsCommand() { var command = new Command("calendar-groups"); var builder = new ApiSdk.Users.Item.CalendarGroups.CalendarGroupsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -147,6 +156,9 @@ public Command BuildCalendarGroupsCommand() { public Command BuildCalendarsCommand() { var command = new Command("calendars"); var builder = new ApiSdk.Users.Item.Calendars.CalendarsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -154,6 +166,9 @@ public Command BuildCalendarsCommand() { public Command BuildCalendarViewCommand() { var command = new Command("calendar-view"); var builder = new ApiSdk.Users.Item.CalendarView.CalendarViewRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -167,6 +182,9 @@ public Command BuildChangePasswordCommand() { public Command BuildChatsCommand() { var command = new Command("chats"); var builder = new ApiSdk.Users.Item.Chats.ChatsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -186,6 +204,9 @@ public Command BuildCheckMemberObjectsCommand() { public Command BuildContactFoldersCommand() { var command = new Command("contact-folders"); var builder = new ApiSdk.Users.Item.ContactFolders.ContactFoldersRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -193,6 +214,9 @@ public Command BuildContactFoldersCommand() { public Command BuildContactsCommand() { var command = new Command("contacts"); var builder = new ApiSdk.Users.Item.Contacts.ContactsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -215,11 +239,10 @@ public Command BuildDeleteCommand() { }; userIdOption.IsRequired = true; command.AddOption(userIdOption); - command.SetHandler(async (string userId) => { + command.SetHandler(async (string userId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption); return command; @@ -227,6 +250,9 @@ public Command BuildDeleteCommand() { public Command BuildDeviceManagementTroubleshootingEventsCommand() { var command = new Command("device-management-troubleshooting-events"); var builder = new ApiSdk.Users.Item.DeviceManagementTroubleshootingEvents.DeviceManagementTroubleshootingEventsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -249,6 +275,9 @@ public Command BuildDriveCommand() { public Command BuildDrivesCommand() { var command = new Command("drives"); var builder = new ApiSdk.Users.Item.Drives.DrivesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -256,6 +285,9 @@ public Command BuildDrivesCommand() { public Command BuildEventsCommand() { var command = new Command("events"); var builder = new ApiSdk.Users.Item.Events.EventsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -269,6 +301,9 @@ public Command BuildExportPersonalDataCommand() { public Command BuildExtensionsCommand() { var command = new Command("extensions"); var builder = new ApiSdk.Users.Item.Extensions.ExtensionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -307,20 +342,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string userId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string userId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, userIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, userIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildGetMailTipsCommand() { @@ -364,6 +398,9 @@ public Command BuildInsightsCommand() { public Command BuildJoinedTeamsCommand() { var command = new Command("joined-teams"); var builder = new ApiSdk.Users.Item.JoinedTeams.JoinedTeamsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -371,6 +408,9 @@ public Command BuildJoinedTeamsCommand() { public Command BuildLicenseDetailsCommand() { var command = new Command("license-details"); var builder = new ApiSdk.Users.Item.LicenseDetails.LicenseDetailsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -378,6 +418,9 @@ public Command BuildLicenseDetailsCommand() { public Command BuildMailFoldersCommand() { var command = new Command("mail-folders"); var builder = new ApiSdk.Users.Item.MailFolders.MailFoldersRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -392,6 +435,9 @@ public Command BuildManagedAppRegistrationsCommand() { public Command BuildManagedDevicesCommand() { var command = new Command("managed-devices"); var builder = new ApiSdk.Users.Item.ManagedDevices.ManagedDevicesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -413,6 +459,9 @@ public Command BuildMemberOfCommand() { public Command BuildMessagesCommand() { var command = new Command("messages"); var builder = new ApiSdk.Users.Item.Messages.MessagesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -441,6 +490,9 @@ public Command BuildOnenoteCommand() { public Command BuildOnlineMeetingsCommand() { var command = new Command("online-meetings"); var builder = new ApiSdk.Users.Item.OnlineMeetings.OnlineMeetingsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildCreateOrGetCommand()); command.AddCommand(builder.BuildListCommand()); @@ -484,14 +536,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + command.SetHandler(async (string userId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, bodyOption); return command; @@ -499,6 +550,9 @@ public Command BuildPatchCommand() { public Command BuildPeopleCommand() { var command = new Command("people"); var builder = new ApiSdk.Users.Item.People.PeopleRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -515,6 +569,9 @@ public Command BuildPhotoCommand() { public Command BuildPhotosCommand() { var command = new Command("photos"); var builder = new ApiSdk.Users.Item.Photos.PhotosRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -573,6 +630,9 @@ public Command BuildRevokeSignInSessionsCommand() { public Command BuildScopedRoleMemberOfCommand() { var command = new Command("scoped-role-member-of"); var builder = new ApiSdk.Users.Item.ScopedRoleMemberOf.ScopedRoleMemberOfRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -698,29 +758,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. return requestInfo; } /// - /// Delete entity from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get entity from users by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \users\{user-id}\microsoft.graph.getManagedAppDiagnosticStatuses() /// public GetManagedAppDiagnosticStatusesRequestBuilder GetManagedAppDiagnosticStatuses() { @@ -733,19 +770,6 @@ public GetManagedAppPoliciesRequestBuilder GetManagedAppPolicies() { return new GetManagedAppPoliciesRequestBuilder(PathParameters, RequestAdapter); } /// - /// Update entity in users - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.User model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \users\{user-id}\microsoft.graph.reminderView(StartDateTime='{StartDateTime}',EndDateTime='{EndDateTime}') /// Usage: EndDateTime={EndDateTime} /// Usage: StartDateTime={StartDateTime} diff --git a/src/generated/Users/Item/WipeManagedAppRegistrationsByDeviceTag/WipeManagedAppRegistrationsByDeviceTagRequestBuilder.cs b/src/generated/Users/Item/WipeManagedAppRegistrationsByDeviceTag/WipeManagedAppRegistrationsByDeviceTagRequestBuilder.cs index b4890800c9e..9d30c219459 100644 --- a/src/generated/Users/Item/WipeManagedAppRegistrationsByDeviceTag/WipeManagedAppRegistrationsByDeviceTagRequestBuilder.cs +++ b/src/generated/Users/Item/WipeManagedAppRegistrationsByDeviceTag/WipeManagedAppRegistrationsByDeviceTagRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string userId, string body) => { + command.SetHandler(async (string userId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, userIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(WipeManagedAppRegistratio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Issues a wipe operation on an app registration with specified device tag. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WipeManagedAppRegistrationsByDeviceTagRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Users/UsersRequestBuilder.cs b/src/generated/Users/UsersRequestBuilder.cs index 9faeb8164e3..100a9104e17 100644 --- a/src/generated/Users/UsersRequestBuilder.cs +++ b/src/generated/Users/UsersRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Users.ValidateProperties; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,73 +26,72 @@ public class UsersRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new UserRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildActivitiesCommand(), - builder.BuildAgreementAcceptancesCommand(), - builder.BuildAppRoleAssignmentsCommand(), - builder.BuildAssignLicenseCommand(), - builder.BuildAuthenticationCommand(), - builder.BuildCalendarCommand(), - builder.BuildCalendarGroupsCommand(), - builder.BuildCalendarsCommand(), - builder.BuildCalendarViewCommand(), - builder.BuildChangePasswordCommand(), - builder.BuildChatsCommand(), - builder.BuildCheckMemberGroupsCommand(), - builder.BuildCheckMemberObjectsCommand(), - builder.BuildContactFoldersCommand(), - builder.BuildContactsCommand(), - builder.BuildCreatedObjectsCommand(), - builder.BuildDeleteCommand(), - builder.BuildDeviceManagementTroubleshootingEventsCommand(), - builder.BuildDirectReportsCommand(), - builder.BuildDriveCommand(), - builder.BuildDrivesCommand(), - builder.BuildEventsCommand(), - builder.BuildExportPersonalDataCommand(), - builder.BuildExtensionsCommand(), - builder.BuildFindMeetingTimesCommand(), - builder.BuildFollowedSitesCommand(), - builder.BuildGetCommand(), - builder.BuildGetMailTipsCommand(), - builder.BuildGetMemberGroupsCommand(), - builder.BuildGetMemberObjectsCommand(), - builder.BuildInferenceClassificationCommand(), - builder.BuildInsightsCommand(), - builder.BuildJoinedTeamsCommand(), - builder.BuildLicenseDetailsCommand(), - builder.BuildMailFoldersCommand(), - builder.BuildManagedAppRegistrationsCommand(), - builder.BuildManagedDevicesCommand(), - builder.BuildManagerCommand(), - builder.BuildMemberOfCommand(), - builder.BuildMessagesCommand(), - builder.BuildOauth2PermissionGrantsCommand(), - builder.BuildOnenoteCommand(), - builder.BuildOnlineMeetingsCommand(), - builder.BuildOutlookCommand(), - builder.BuildOwnedDevicesCommand(), - builder.BuildOwnedObjectsCommand(), - builder.BuildPatchCommand(), - builder.BuildPeopleCommand(), - builder.BuildPhotoCommand(), - builder.BuildPhotosCommand(), - builder.BuildPlannerCommand(), - builder.BuildPresenceCommand(), - builder.BuildRegisteredDevicesCommand(), - builder.BuildRemoveAllDevicesFromManagementCommand(), - builder.BuildReprocessLicenseAssignmentCommand(), - builder.BuildRestoreCommand(), - builder.BuildRevokeSignInSessionsCommand(), - builder.BuildScopedRoleMemberOfCommand(), - builder.BuildSendMailCommand(), - builder.BuildSettingsCommand(), - builder.BuildTeamworkCommand(), - builder.BuildTodoCommand(), - builder.BuildTransitiveMemberOfCommand(), - builder.BuildTranslateExchangeIdsCommand(), - builder.BuildWipeManagedAppRegistrationsByDeviceTagCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildActivitiesCommand()); + commands.Add(builder.BuildAgreementAcceptancesCommand()); + commands.Add(builder.BuildAppRoleAssignmentsCommand()); + commands.Add(builder.BuildAssignLicenseCommand()); + commands.Add(builder.BuildAuthenticationCommand()); + commands.Add(builder.BuildCalendarCommand()); + commands.Add(builder.BuildCalendarGroupsCommand()); + commands.Add(builder.BuildCalendarsCommand()); + commands.Add(builder.BuildCalendarViewCommand()); + commands.Add(builder.BuildChangePasswordCommand()); + commands.Add(builder.BuildChatsCommand()); + commands.Add(builder.BuildCheckMemberGroupsCommand()); + commands.Add(builder.BuildCheckMemberObjectsCommand()); + commands.Add(builder.BuildContactFoldersCommand()); + commands.Add(builder.BuildContactsCommand()); + commands.Add(builder.BuildCreatedObjectsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildDeviceManagementTroubleshootingEventsCommand()); + commands.Add(builder.BuildDirectReportsCommand()); + commands.Add(builder.BuildDriveCommand()); + commands.Add(builder.BuildDrivesCommand()); + commands.Add(builder.BuildEventsCommand()); + commands.Add(builder.BuildExportPersonalDataCommand()); + commands.Add(builder.BuildExtensionsCommand()); + commands.Add(builder.BuildFindMeetingTimesCommand()); + commands.Add(builder.BuildFollowedSitesCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildGetMailTipsCommand()); + commands.Add(builder.BuildGetMemberGroupsCommand()); + commands.Add(builder.BuildGetMemberObjectsCommand()); + commands.Add(builder.BuildInferenceClassificationCommand()); + commands.Add(builder.BuildInsightsCommand()); + commands.Add(builder.BuildJoinedTeamsCommand()); + commands.Add(builder.BuildLicenseDetailsCommand()); + commands.Add(builder.BuildMailFoldersCommand()); + commands.Add(builder.BuildManagedAppRegistrationsCommand()); + commands.Add(builder.BuildManagedDevicesCommand()); + commands.Add(builder.BuildManagerCommand()); + commands.Add(builder.BuildMemberOfCommand()); + commands.Add(builder.BuildMessagesCommand()); + commands.Add(builder.BuildOauth2PermissionGrantsCommand()); + commands.Add(builder.BuildOnenoteCommand()); + commands.Add(builder.BuildOnlineMeetingsCommand()); + commands.Add(builder.BuildOutlookCommand()); + commands.Add(builder.BuildOwnedDevicesCommand()); + commands.Add(builder.BuildOwnedObjectsCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPeopleCommand()); + commands.Add(builder.BuildPhotoCommand()); + commands.Add(builder.BuildPhotosCommand()); + commands.Add(builder.BuildPlannerCommand()); + commands.Add(builder.BuildPresenceCommand()); + commands.Add(builder.BuildRegisteredDevicesCommand()); + commands.Add(builder.BuildRemoveAllDevicesFromManagementCommand()); + commands.Add(builder.BuildReprocessLicenseAssignmentCommand()); + commands.Add(builder.BuildRestoreCommand()); + commands.Add(builder.BuildRevokeSignInSessionsCommand()); + commands.Add(builder.BuildScopedRoleMemberOfCommand()); + commands.Add(builder.BuildSendMailCommand()); + commands.Add(builder.BuildSettingsCommand()); + commands.Add(builder.BuildTeamworkCommand()); + commands.Add(builder.BuildTodoCommand()); + commands.Add(builder.BuildTransitiveMemberOfCommand()); + commands.Add(builder.BuildTranslateExchangeIdsCommand()); + commands.Add(builder.BuildWipeManagedAppRegistrationsByDeviceTagCommand()); return commands; } /// @@ -106,21 +105,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } public Command BuildGetAvailableExtensionPropertiesCommand() { @@ -177,7 +175,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -188,15 +190,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildValidatePropertiesCommand() { @@ -263,31 +260,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G public DeltaRequestBuilder Delta() { return new DeltaRequestBuilder(PathParameters, RequestAdapter); } - /// - /// Get entities from users - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to users - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.User model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from users public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Users/ValidateProperties/ValidatePropertiesRequestBuilder.cs b/src/generated/Users/ValidateProperties/ValidatePropertiesRequestBuilder.cs index 2a613f2f6a6..66c4898f48e 100644 --- a/src/generated/Users/ValidateProperties/ValidatePropertiesRequestBuilder.cs +++ b/src/generated/Users/ValidateProperties/ValidatePropertiesRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -29,14 +29,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, bodyOption); return command; @@ -72,18 +71,5 @@ public RequestInformation CreatePostRequestInformation(ValidatePropertiesRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action validateProperties - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ValidatePropertiesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Analytics/@Ref/@Ref.cs b/src/generated/Workbooks/Item/Analytics/@Ref/@Ref.cs deleted file mode 100644 index f5c20f89148..00000000000 --- a/src/generated/Workbooks/Item/Analytics/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Workbooks.Item.Analytics.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Workbooks/Item/Analytics/@Ref/RefRequestBuilder.cs b/src/generated/Workbooks/Item/Analytics/@Ref/RefRequestBuilder.cs deleted file mode 100644 index e5e3dcb63f4..00000000000 --- a/src/generated/Workbooks/Item/Analytics/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Analytics.@Ref { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\analytics\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Analytics about the view activities that took place on this item. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Analytics about the view activities that took place on this item."; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, driveItemIdOption); - return command; - } - /// - /// Analytics about the view activities that took place on this item. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Analytics about the view activities that took place on this item."; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption); - return command; - } - /// - /// Analytics about the view activities that took place on this item. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Analytics about the view activities that took place on this item."; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, driveItemIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/analytics/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Analytics about the view activities that took place on this item. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Analytics about the view activities that took place on this item. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Analytics about the view activities that took place on this item. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Workbooks.Item.Analytics.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Workbooks.Item.Analytics.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Workbooks/Item/Analytics/AnalyticsRequestBuilder.cs b/src/generated/Workbooks/Item/Analytics/AnalyticsRequestBuilder.cs index 14c413e8b17..f3db846f351 100644 --- a/src/generated/Workbooks/Item/Analytics/AnalyticsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Analytics/AnalyticsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Analytics.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Analytics about the view activities that took place on this item."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Workbooks.Item.Analytics.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Analytics.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Analytics about the view activities that took place on this item. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Analytics/Ref/Ref.cs b/src/generated/Workbooks/Item/Analytics/Ref/Ref.cs new file mode 100644 index 00000000000..ca97ec82834 --- /dev/null +++ b/src/generated/Workbooks/Item/Analytics/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Workbooks.Item.Analytics.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Workbooks/Item/Analytics/Ref/RefRequestBuilder.cs b/src/generated/Workbooks/Item/Analytics/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..00643b81e20 --- /dev/null +++ b/src/generated/Workbooks/Item/Analytics/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Analytics.Ref { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\analytics\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Analytics about the view activities that took place on this item. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Analytics about the view activities that took place on this item."; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + command.SetHandler(async (string driveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, driveItemIdOption); + return command; + } + /// + /// Analytics about the view activities that took place on this item. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Analytics about the view activities that took place on this item."; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, outputOption); + return command; + } + /// + /// Analytics about the view activities that took place on this item. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Analytics about the view activities that took place on this item."; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string driveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, driveItemIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/analytics/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Analytics about the view activities that took place on this item. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Analytics about the view activities that took place on this item. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Analytics about the view activities that took place on this item. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Workbooks.Item.Analytics.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Workbooks/Item/Checkin/CheckinRequestBuilder.cs b/src/generated/Workbooks/Item/Checkin/CheckinRequestBuilder.cs index 64706d0bfdf..2c19ea96107 100644 --- a/src/generated/Workbooks/Item/Checkin/CheckinRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Checkin/CheckinRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action checkin"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + command.SetHandler(async (string driveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(CheckinRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action checkin - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CheckinRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Checkout/CheckoutRequestBuilder.cs b/src/generated/Workbooks/Item/Checkout/CheckoutRequestBuilder.cs index e13de6a1fcb..cb351dd1ed6 100644 --- a/src/generated/Workbooks/Item/Checkout/CheckoutRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Checkout/CheckoutRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action checkout"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { + command.SetHandler(async (string driveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action checkout - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Children/ChildrenRequestBuilder.cs b/src/generated/Workbooks/Item/Children/ChildrenRequestBuilder.cs index 34fb91a30b0..bbec105f8cd 100644 --- a/src/generated/Workbooks/Item/Children/ChildrenRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Children/ChildrenRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Children.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class ChildrenRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DriveItemRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -37,7 +36,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Collection containing Item objects for the immediate children of Item. Only items representing folders have children. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -69,7 +67,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Collection containing Item objects for the immediate children of Item. Only items representing folders have children. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection containing Item objects for the immediate children of Item. Only items representing folders have children. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection containing Item objects for the immediate children of Item. Only items representing folders have children. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection containing Item objects for the immediate children of Item. Only items representing folders have children. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Children/Item/Content/ContentRequestBuilder.cs b/src/generated/Workbooks/Item/Children/Item/Content/ContentRequestBuilder.cs index 973c0cf5f59..e6dcc6d6ed1 100644 --- a/src/generated/Workbooks/Item/Children/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Children/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,32 +25,34 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The content stream, if the item represents a file."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var driveItemId1Option = new Option("--driveitem-id1", description: "key: id of driveItem") { + var driveItemId1Option = new Option("--drive-item-id1", description: "key: id of driveItem") { }; driveItemId1Option.IsRequired = true; command.AddOption(driveItemId1Option); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string driveItemId, string driveItemId1, FileInfo output) => { + command.SetHandler(async (string driveItemId, string driveItemId1, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, driveItemIdOption, driveItemId1Option, outputOption); + }, driveItemIdOption, driveItemId1Option, fileOption, outputOption); return command; } /// @@ -60,11 +62,11 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "The content stream, if the item represents a file."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var driveItemId1Option = new Option("--driveitem-id1", description: "key: id of driveItem") { + var driveItemId1Option = new Option("--drive-item-id1", description: "key: id of driveItem") { }; driveItemId1Option.IsRequired = true; command.AddOption(driveItemId1Option); @@ -72,12 +74,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string driveItemId1, FileInfo file) => { + command.SetHandler(async (string driveItemId, string driveItemId1, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, driveItemId1Option, bodyOption); return command; @@ -128,29 +129,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// The content stream, if the item represents a file. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The content stream, if the item represents a file. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Children/Item/DriveItemRequestBuilder.cs b/src/generated/Workbooks/Item/Children/Item/DriveItemRequestBuilder.cs index 88a98509c51..207ae550205 100644 --- a/src/generated/Workbooks/Item/Children/Item/DriveItemRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Children/Item/DriveItemRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Children.Item.Content; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,19 +34,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Collection containing Item objects for the immediate children of Item. Only items representing folders have children. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var driveItemId1Option = new Option("--driveitem-id1", description: "key: id of driveItem") { + var driveItemId1Option = new Option("--drive-item-id1", description: "key: id of driveItem") { }; driveItemId1Option.IsRequired = true; command.AddOption(driveItemId1Option); - command.SetHandler(async (string driveItemId, string driveItemId1) => { + command.SetHandler(async (string driveItemId, string driveItemId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, driveItemId1Option); return command; @@ -58,11 +57,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Collection containing Item objects for the immediate children of Item. Only items representing folders have children. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var driveItemId1Option = new Option("--driveitem-id1", description: "key: id of driveItem") { + var driveItemId1Option = new Option("--drive-item-id1", description: "key: id of driveItem") { }; driveItemId1Option.IsRequired = true; command.AddOption(driveItemId1Option); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string driveItemId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string driveItemId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, driveItemId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, driveItemId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -99,11 +97,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Collection containing Item objects for the immediate children of Item. Only items representing folders have children. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var driveItemId1Option = new Option("--driveitem-id1", description: "key: id of driveItem") { + var driveItemId1Option = new Option("--drive-item-id1", description: "key: id of driveItem") { }; driveItemId1Option.IsRequired = true; command.AddOption(driveItemId1Option); @@ -111,14 +109,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string driveItemId1, string body) => { + command.SetHandler(async (string driveItemId, string driveItemId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, driveItemId1Option, bodyOption); return command; @@ -190,42 +187,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection containing Item objects for the immediate children of Item. Only items representing folders have children. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection containing Item objects for the immediate children of Item. Only items representing folders have children. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection containing Item objects for the immediate children of Item. Only items representing folders have children. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection containing Item objects for the immediate children of Item. Only items representing folders have children. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Content/ContentRequestBuilder.cs b/src/generated/Workbooks/Item/Content/ContentRequestBuilder.cs index 181596e842a..9b775a168c4 100644 --- a/src/generated/Workbooks/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,28 +25,30 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The content stream, if the item represents a file."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string driveItemId, FileInfo output) => { + command.SetHandler(async (string driveItemId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, driveItemIdOption, outputOption); + }, driveItemIdOption, fileOption, outputOption); return command; } /// @@ -56,7 +58,7 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "The content stream, if the item represents a file."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -64,12 +66,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, FileInfo file) => { + command.SetHandler(async (string driveItemId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, bodyOption); return command; @@ -120,29 +121,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// The content stream, if the item represents a file. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The content stream, if the item represents a file. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Copy/CopyRequestBuilder.cs b/src/generated/Workbooks/Item/Copy/CopyRequestBuilder.cs index 86e1f2fce65..952c5340f5f 100644 --- a/src/generated/Workbooks/Item/Copy/CopyRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Copy/CopyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action copy"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CopyRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action copy - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CopyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes driveItem public class CopyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/CreateLink/CreateLinkRequestBody.cs b/src/generated/Workbooks/Item/CreateLink/CreateLinkRequestBody.cs index 42260a5cea8..bf6fceec302 100644 --- a/src/generated/Workbooks/Item/CreateLink/CreateLinkRequestBody.cs +++ b/src/generated/Workbooks/Item/CreateLink/CreateLinkRequestBody.cs @@ -10,6 +10,7 @@ public class CreateLinkRequestBody : IParsable { public DateTimeOffset? ExpirationDateTime { get; set; } public string Message { get; set; } public string Password { get; set; } + public bool? RetainInheritedPermissions { get; set; } public string Scope { get; set; } public string Type { get; set; } /// @@ -26,6 +27,7 @@ public IDictionary> GetFieldDeserializers() { {"expirationDateTime", (o,n) => { (o as CreateLinkRequestBody).ExpirationDateTime = n.GetDateTimeOffsetValue(); } }, {"message", (o,n) => { (o as CreateLinkRequestBody).Message = n.GetStringValue(); } }, {"password", (o,n) => { (o as CreateLinkRequestBody).Password = n.GetStringValue(); } }, + {"retainInheritedPermissions", (o,n) => { (o as CreateLinkRequestBody).RetainInheritedPermissions = n.GetBoolValue(); } }, {"scope", (o,n) => { (o as CreateLinkRequestBody).Scope = n.GetStringValue(); } }, {"type", (o,n) => { (o as CreateLinkRequestBody).Type = n.GetStringValue(); } }, }; @@ -39,6 +41,7 @@ public void Serialize(ISerializationWriter writer) { writer.WriteDateTimeOffsetValue("expirationDateTime", ExpirationDateTime); writer.WriteStringValue("message", Message); writer.WriteStringValue("password", Password); + writer.WriteBoolValue("retainInheritedPermissions", RetainInheritedPermissions); writer.WriteStringValue("scope", Scope); writer.WriteStringValue("type", Type); writer.WriteAdditionalData(AdditionalData); diff --git a/src/generated/Workbooks/Item/CreateLink/CreateLinkRequestBuilder.cs b/src/generated/Workbooks/Item/CreateLink/CreateLinkRequestBuilder.cs index 61173265762..43720621934 100644 --- a/src/generated/Workbooks/Item/CreateLink/CreateLinkRequestBuilder.cs +++ b/src/generated/Workbooks/Item/CreateLink/CreateLinkRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action createLink"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CreateLinkRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createLink - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateLinkRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes permission public class CreateLinkResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/CreateUploadSession/CreateUploadSessionRequestBuilder.cs b/src/generated/Workbooks/Item/CreateUploadSession/CreateUploadSessionRequestBuilder.cs index 56c280ca644..fdb20cb61d4 100644 --- a/src/generated/Workbooks/Item/CreateUploadSession/CreateUploadSessionRequestBuilder.cs +++ b/src/generated/Workbooks/Item/CreateUploadSession/CreateUploadSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action createUploadSession"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CreateUploadSessionReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createUploadSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateUploadSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes uploadSession public class CreateUploadSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Delta/DeltaRequestBuilder.cs b/src/generated/Workbooks/Item/Delta/DeltaRequestBuilder.cs index efa93270d71..83b5516d131 100644 --- a/src/generated/Workbooks/Item/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Delta/DeltaRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,22 +25,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/DeltaWithToken/DeltaWithTokenRequestBuilder.cs b/src/generated/Workbooks/Item/DeltaWithToken/DeltaWithTokenRequestBuilder.cs index 6200aebdae5..212b0f02d5d 100644 --- a/src/generated/Workbooks/Item/DeltaWithToken/DeltaWithTokenRequestBuilder.cs +++ b/src/generated/Workbooks/Item/DeltaWithToken/DeltaWithTokenRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function delta"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -33,18 +33,17 @@ public Command BuildGetCommand() { }; tokenOption.IsRequired = true; command.AddOption(tokenOption); - command.SetHandler(async (string driveItemId, string token) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string token, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, tokenOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, tokenOption, outputOption); return command; } /// @@ -77,16 +76,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/DriveItemRequestBuilder.cs b/src/generated/Workbooks/Item/DriveItemRequestBuilder.cs index 0ed19862764..5c75b038975 100644 --- a/src/generated/Workbooks/Item/DriveItemRequestBuilder.cs +++ b/src/generated/Workbooks/Item/DriveItemRequestBuilder.cs @@ -26,10 +26,10 @@ using ApiSdk.Workbooks.Item.Workbook; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -66,6 +66,9 @@ public Command BuildCheckoutCommand() { public Command BuildChildrenCommand() { var command = new Command("children"); var builder = new ApiSdk.Workbooks.Item.Children.ChildrenRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -102,15 +105,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete entity from workbooks"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { + command.SetHandler(async (string driveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption); return command; @@ -128,7 +130,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get entity from workbooks by key"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -142,20 +144,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildInviteCommand() { @@ -183,7 +184,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update entity in workbooks"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -191,14 +192,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + command.SetHandler(async (string driveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, bodyOption); return command; @@ -206,6 +206,9 @@ public Command BuildPatchCommand() { public Command BuildPermissionsCommand() { var command = new Command("permissions"); var builder = new ApiSdk.Workbooks.Item.Permissions.PermissionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -225,6 +228,9 @@ public Command BuildRestoreCommand() { public Command BuildSubscriptionsCommand() { var command = new Command("subscriptions"); var builder = new ApiSdk.Workbooks.Item.Subscriptions.SubscriptionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -232,6 +238,9 @@ public Command BuildSubscriptionsCommand() { public Command BuildThumbnailsCommand() { var command = new Command("thumbnails"); var builder = new ApiSdk.Workbooks.Item.Thumbnails.ThumbnailsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -251,6 +260,9 @@ public Command BuildValidatePermissionCommand() { public Command BuildVersionsCommand() { var command = new Command("versions"); var builder = new ApiSdk.Workbooks.Item.Versions.VersionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -341,17 +353,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. return requestInfo; } /// - /// Delete entity from workbooks - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\microsoft.graph.delta() /// public DeltaRequestBuilder Delta() { @@ -384,31 +385,6 @@ public GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalReques return new GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder(PathParameters, RequestAdapter, startDateTime, endDateTime, interval); } /// - /// Get entity from workbooks by key - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update entity in workbooks - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\microsoft.graph.search(q='{q}') /// Usage: q={q} /// diff --git a/src/generated/Workbooks/Item/Follow/FollowRequestBuilder.cs b/src/generated/Workbooks/Item/Follow/FollowRequestBuilder.cs index 4fd31ee6a30..e89638fee68 100644 --- a/src/generated/Workbooks/Item/Follow/FollowRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Follow/FollowRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action follow"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action follow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes driveItem public class FollowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs b/src/generated/Workbooks/Item/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs index 5a0471b837a..0279c25a5af 100644 --- a/src/generated/Workbooks/Item/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs +++ b/src/generated/Workbooks/Item/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,22 +25,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function getActivitiesByInterval"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getActivitiesByInterval - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs b/src/generated/Workbooks/Item/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs index f7a5bfc5471..d67c3bc3860 100644 --- a/src/generated/Workbooks/Item/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs +++ b/src/generated/Workbooks/Item/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function getActivitiesByInterval"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var startDateTimeOption = new Option("--startdatetime", description: "Usage: startDateTime={startDateTime}") { + var startDateTimeOption = new Option("--start-date-time", description: "Usage: startDateTime={startDateTime}") { }; startDateTimeOption.IsRequired = true; command.AddOption(startDateTimeOption); - var endDateTimeOption = new Option("--enddatetime", description: "Usage: endDateTime={endDateTime}") { + var endDateTimeOption = new Option("--end-date-time", description: "Usage: endDateTime={endDateTime}") { }; endDateTimeOption.IsRequired = true; command.AddOption(endDateTimeOption); @@ -41,18 +41,17 @@ public Command BuildGetCommand() { }; intervalOption.IsRequired = true; command.AddOption(intervalOption); - command.SetHandler(async (string driveItemId, string startDateTime, string endDateTime, string interval) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string startDateTime, string endDateTime, string interval, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, startDateTimeOption, endDateTimeOption, intervalOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, startDateTimeOption, endDateTimeOption, intervalOption, outputOption); return command; } /// @@ -89,16 +88,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getActivitiesByInterval - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Invite/InviteRequestBody.cs b/src/generated/Workbooks/Item/Invite/InviteRequestBody.cs index 9361caa71d1..c9ca4c9f572 100644 --- a/src/generated/Workbooks/Item/Invite/InviteRequestBody.cs +++ b/src/generated/Workbooks/Item/Invite/InviteRequestBody.cs @@ -13,6 +13,7 @@ public class InviteRequestBody : IParsable { public string Password { get; set; } public List Recipients { get; set; } public bool? RequireSignIn { get; set; } + public bool? RetainInheritedPermissions { get; set; } public List Roles { get; set; } public bool? SendInvitation { get; set; } /// @@ -31,6 +32,7 @@ public IDictionary> GetFieldDeserializers() { {"password", (o,n) => { (o as InviteRequestBody).Password = n.GetStringValue(); } }, {"recipients", (o,n) => { (o as InviteRequestBody).Recipients = n.GetCollectionOfObjectValues().ToList(); } }, {"requireSignIn", (o,n) => { (o as InviteRequestBody).RequireSignIn = n.GetBoolValue(); } }, + {"retainInheritedPermissions", (o,n) => { (o as InviteRequestBody).RetainInheritedPermissions = n.GetBoolValue(); } }, {"roles", (o,n) => { (o as InviteRequestBody).Roles = n.GetCollectionOfPrimitiveValues().ToList(); } }, {"sendInvitation", (o,n) => { (o as InviteRequestBody).SendInvitation = n.GetBoolValue(); } }, }; @@ -46,6 +48,7 @@ public void Serialize(ISerializationWriter writer) { writer.WriteStringValue("password", Password); writer.WriteCollectionOfObjectValues("recipients", Recipients); writer.WriteBoolValue("requireSignIn", RequireSignIn); + writer.WriteBoolValue("retainInheritedPermissions", RetainInheritedPermissions); writer.WriteCollectionOfPrimitiveValues("roles", Roles); writer.WriteBoolValue("sendInvitation", SendInvitation); writer.WriteAdditionalData(AdditionalData); diff --git a/src/generated/Workbooks/Item/Invite/InviteRequestBuilder.cs b/src/generated/Workbooks/Item/Invite/InviteRequestBuilder.cs index b5eb78fe38f..93d2fc3aeb1 100644 --- a/src/generated/Workbooks/Item/Invite/InviteRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Invite/InviteRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action invite"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -33,21 +33,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -81,18 +80,5 @@ public RequestInformation CreatePostRequestInformation(InviteRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action invite - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(InviteRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/ListItem/Analytics/@Ref/@Ref.cs b/src/generated/Workbooks/Item/ListItem/Analytics/@Ref/@Ref.cs deleted file mode 100644 index 13e8d22e3f0..00000000000 --- a/src/generated/Workbooks/Item/ListItem/Analytics/@Ref/@Ref.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Workbooks.Item.ListItem.Analytics.@Ref { - public class @Ref : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// - /// Instantiates a new @Ref and sets the default values. - /// - public @Ref() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Workbooks/Item/ListItem/Analytics/@Ref/RefRequestBuilder.cs b/src/generated/Workbooks/Item/ListItem/Analytics/@Ref/RefRequestBuilder.cs deleted file mode 100644 index d3420a785f2..00000000000 --- a/src/generated/Workbooks/Item/ListItem/Analytics/@Ref/RefRequestBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.ListItem.Analytics.@Ref { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\listItem\analytics\$ref - public class RefRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Analytics about the view activities that took place on this item. - /// - public Command BuildDeleteCommand() { - var command = new Command("delete"); - command.Description = "Analytics about the view activities that took place on this item."; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { - var requestInfo = CreateDeleteRequestInformation(q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, driveItemIdOption); - return command; - } - /// - /// Analytics about the view activities that took place on this item. - /// - public Command BuildGetCommand() { - var command = new Command("get"); - command.Description = "Analytics about the view activities that took place on this item."; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { - var requestInfo = CreateGetRequestInformation(q => { - }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption); - return command; - } - /// - /// Analytics about the view activities that took place on this item. - /// - public Command BuildPutCommand() { - var command = new Command("put"); - command.Description = "Analytics about the view activities that took place on this item."; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePutRequestInformation(model, q => { - }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? - Console.WriteLine("Success"); - }, driveItemIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new RefRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/listItem/analytics/$ref"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Analytics about the view activities that took place on this item. - /// Request headers - /// Request options - /// - public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.DELETE, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Analytics about the view activities that took place on this item. - /// Request headers - /// Request options - /// - public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.GET, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Analytics about the view activities that took place on this item. - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePutRequestInformation(ApiSdk.Workbooks.Item.ListItem.Analytics.@Ref.@Ref body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.PUT, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PutAsync(ApiSdk.Workbooks.Item.ListItem.Analytics.@Ref.@Ref model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePutRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - } -} diff --git a/src/generated/Workbooks/Item/ListItem/Analytics/AnalyticsRequestBuilder.cs b/src/generated/Workbooks/Item/ListItem/Analytics/AnalyticsRequestBuilder.cs index 748618e3965..e42a15f2785 100644 --- a/src/generated/Workbooks/Item/ListItem/Analytics/AnalyticsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/ListItem/Analytics/AnalyticsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.ListItem.Analytics.Ref; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Analytics about the view activities that took place on this item."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -41,25 +41,24 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefCommand() { var command = new Command("ref"); - var builder = new ApiSdk.Workbooks.Item.ListItem.Analytics.@Ref.RefRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.ListItem.Analytics.Ref.RefRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildDeleteCommand()); command.AddCommand(builder.BuildGetCommand()); command.AddCommand(builder.BuildPutCommand()); @@ -99,18 +98,6 @@ public RequestInformation CreateGetRequestInformation(Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Analytics about the view activities that took place on this item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Analytics about the view activities that took place on this item. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/ListItem/Analytics/Ref/Ref.cs b/src/generated/Workbooks/Item/ListItem/Analytics/Ref/Ref.cs new file mode 100644 index 00000000000..5faa1bacdc0 --- /dev/null +++ b/src/generated/Workbooks/Item/ListItem/Analytics/Ref/Ref.cs @@ -0,0 +1,32 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Workbooks.Item.ListItem.Analytics.Ref { + public class Ref : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// + /// Instantiates a new ref and sets the default values. + /// + public Ref() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Workbooks/Item/ListItem/Analytics/Ref/RefRequestBuilder.cs b/src/generated/Workbooks/Item/ListItem/Analytics/Ref/RefRequestBuilder.cs new file mode 100644 index 00000000000..506bfa1f672 --- /dev/null +++ b/src/generated/Workbooks/Item/ListItem/Analytics/Ref/RefRequestBuilder.cs @@ -0,0 +1,152 @@ +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.ListItem.Analytics.Ref { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\listItem\analytics\$ref + public class RefRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Analytics about the view activities that took place on this item. + /// + public Command BuildDeleteCommand() { + var command = new Command("delete"); + command.Description = "Analytics about the view activities that took place on this item."; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + command.SetHandler(async (string driveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateDeleteRequestInformation(q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, driveItemIdOption); + return command; + } + /// + /// Analytics about the view activities that took place on this item. + /// + public Command BuildGetCommand() { + var command = new Command("get"); + command.Description = "Analytics about the view activities that took place on this item."; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreateGetRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, outputOption); + return command; + } + /// + /// Analytics about the view activities that took place on this item. + /// + public Command BuildPutCommand() { + var command = new Command("put"); + command.Description = "Analytics about the view activities that took place on this item."; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + command.SetHandler(async (string driveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePutRequestInformation(model, q => { + }); + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + Console.WriteLine("Success"); + }, driveItemIdOption, bodyOption); + return command; + } + /// + /// Instantiates a new RefRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public RefRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/listItem/analytics/$ref"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Analytics about the view activities that took place on this item. + /// Request headers + /// Request options + /// + public RequestInformation CreateDeleteRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.DELETE, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Analytics about the view activities that took place on this item. + /// Request headers + /// Request options + /// + public RequestInformation CreateGetRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.GET, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// + /// Analytics about the view activities that took place on this item. + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePutRequestInformation(ApiSdk.Workbooks.Item.ListItem.Analytics.Ref.Ref body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.PUT, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + } +} diff --git a/src/generated/Workbooks/Item/ListItem/DriveItem/Content/ContentRequestBuilder.cs b/src/generated/Workbooks/Item/ListItem/DriveItem/Content/ContentRequestBuilder.cs index 1c0f83b4e9c..585d49b211e 100644 --- a/src/generated/Workbooks/Item/ListItem/DriveItem/Content/ContentRequestBuilder.cs +++ b/src/generated/Workbooks/Item/ListItem/DriveItem/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,28 +25,30 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The content stream, if the item represents a file."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string driveItemId, FileInfo output) => { + command.SetHandler(async (string driveItemId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, driveItemIdOption, outputOption); + }, driveItemIdOption, fileOption, outputOption); return command; } /// @@ -56,7 +58,7 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "The content stream, if the item represents a file."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -64,12 +66,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, FileInfo file) => { + command.SetHandler(async (string driveItemId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, bodyOption); return command; @@ -120,29 +121,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// The content stream, if the item represents a file. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The content stream, if the item represents a file. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/ListItem/DriveItem/DriveItemRequestBuilder.cs b/src/generated/Workbooks/Item/ListItem/DriveItem/DriveItemRequestBuilder.cs index 22ce5387826..3f5e60dac11 100644 --- a/src/generated/Workbooks/Item/ListItem/DriveItem/DriveItemRequestBuilder.cs +++ b/src/generated/Workbooks/Item/ListItem/DriveItem/DriveItemRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.ListItem.DriveItem.Content; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,15 +34,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "For document libraries, the driveItem relationship exposes the listItem as a [driveItem][]"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { + command.SetHandler(async (string driveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption); return command; @@ -54,7 +53,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "For document libraries, the driveItem relationship exposes the listItem as a [driveItem][]"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,7 +89,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "For document libraries, the driveItem relationship exposes the listItem as a [driveItem][]"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -99,14 +97,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + command.SetHandler(async (string driveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, bodyOption); return command; @@ -178,42 +175,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// For document libraries, the driveItem relationship exposes the listItem as a [driveItem][] - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// For document libraries, the driveItem relationship exposes the listItem as a [driveItem][] - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// For document libraries, the driveItem relationship exposes the listItem as a [driveItem][] - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// For document libraries, the driveItem relationship exposes the listItem as a [driveItem][] public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/ListItem/Fields/FieldsRequestBuilder.cs b/src/generated/Workbooks/Item/ListItem/Fields/FieldsRequestBuilder.cs index 9fe6e29fff3..faf970ec6de 100644 --- a/src/generated/Workbooks/Item/ListItem/Fields/FieldsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/ListItem/Fields/FieldsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The values of the columns set on this list item."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { + command.SetHandler(async (string driveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption); return command; @@ -46,7 +45,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The values of the columns set on this list item."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -60,20 +59,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The values of the columns set on this list item."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -91,14 +89,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + command.SetHandler(async (string driveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, bodyOption); return command; @@ -170,42 +167,6 @@ public RequestInformation CreatePatchRequestInformation(FieldValueSet body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The values of the columns set on this list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The values of the columns set on this list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The values of the columns set on this list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(FieldValueSet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The values of the columns set on this list item. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/ListItem/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs b/src/generated/Workbooks/Item/ListItem/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs index 530d132468f..af7c8e07109 100644 --- a/src/generated/Workbooks/Item/ListItem/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs +++ b/src/generated/Workbooks/Item/ListItem/GetActivitiesByInterval/GetActivitiesByIntervalRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,22 +25,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function getActivitiesByInterval"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getActivitiesByInterval - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/ListItem/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs b/src/generated/Workbooks/Item/ListItem/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs index 657a1b566b8..7ce10a59f03 100644 --- a/src/generated/Workbooks/Item/ListItem/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs +++ b/src/generated/Workbooks/Item/ListItem/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithInterval/GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function getActivitiesByInterval"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var startDateTimeOption = new Option("--startdatetime", description: "Usage: startDateTime={startDateTime}") { + var startDateTimeOption = new Option("--start-date-time", description: "Usage: startDateTime={startDateTime}") { }; startDateTimeOption.IsRequired = true; command.AddOption(startDateTimeOption); - var endDateTimeOption = new Option("--enddatetime", description: "Usage: endDateTime={endDateTime}") { + var endDateTimeOption = new Option("--end-date-time", description: "Usage: endDateTime={endDateTime}") { }; endDateTimeOption.IsRequired = true; command.AddOption(endDateTimeOption); @@ -41,18 +41,17 @@ public Command BuildGetCommand() { }; intervalOption.IsRequired = true; command.AddOption(intervalOption); - command.SetHandler(async (string driveItemId, string startDateTime, string endDateTime, string interval) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string startDateTime, string endDateTime, string interval, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, startDateTimeOption, endDateTimeOption, intervalOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, startDateTimeOption, endDateTimeOption, intervalOption, outputOption); return command; } /// @@ -89,16 +88,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function getActivitiesByInterval - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/ListItem/ListItemRequestBuilder.cs b/src/generated/Workbooks/Item/ListItem/ListItemRequestBuilder.cs index 662bfa8f84c..cbf40db6d2a 100644 --- a/src/generated/Workbooks/Item/ListItem/ListItemRequestBuilder.cs +++ b/src/generated/Workbooks/Item/ListItem/ListItemRequestBuilder.cs @@ -7,10 +7,10 @@ using ApiSdk.Workbooks.Item.ListItem.Versions; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -39,15 +39,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "For drives in SharePoint, the associated document library list item. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { + command.SetHandler(async (string driveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption); return command; @@ -76,7 +75,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "For drives in SharePoint, the associated document library list item. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -113,7 +111,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "For drives in SharePoint, the associated document library list item. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -121,14 +119,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + command.SetHandler(async (string driveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, bodyOption); return command; @@ -136,6 +133,9 @@ public Command BuildPatchCommand() { public Command BuildVersionsCommand() { var command = new Command("versions"); var builder = new ApiSdk.Workbooks.Item.ListItem.Versions.VersionsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -208,17 +208,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. return requestInfo; } /// - /// For drives in SharePoint, the associated document library list item. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\listItem\microsoft.graph.getActivitiesByInterval() /// public GetActivitiesByIntervalRequestBuilder GetActivitiesByInterval() { @@ -236,31 +225,6 @@ public GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalReques if(string.IsNullOrEmpty(startDateTime)) throw new ArgumentNullException(nameof(startDateTime)); return new GetActivitiesByIntervalWithStartDateTimeWithEndDateTimeWithIntervalRequestBuilder(PathParameters, RequestAdapter, startDateTime, endDateTime, interval); } - /// - /// For drives in SharePoint, the associated document library list item. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// For drives in SharePoint, the associated document library list item. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.ListItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// For drives in SharePoint, the associated document library list item. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/ListItem/Versions/Item/Fields/FieldsRequestBuilder.cs b/src/generated/Workbooks/Item/ListItem/Versions/Item/Fields/FieldsRequestBuilder.cs index 2d0ba80b4dc..d054351ebf2 100644 --- a/src/generated/Workbooks/Item/ListItem/Versions/Item/Fields/FieldsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/ListItem/Versions/Item/Fields/FieldsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "A collection of the fields and values for this version of the list item."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); - command.SetHandler(async (string driveItemId, string listItemVersionId) => { + command.SetHandler(async (string driveItemId, string listItemVersionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, listItemVersionIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "A collection of the fields and values for this version of the list item."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string listItemVersionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string listItemVersionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, listItemVersionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, listItemVersionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "A collection of the fields and values for this version of the list item."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string listItemVersionId, string body) => { + command.SetHandler(async (string driveItemId, string listItemVersionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, listItemVersionIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(FieldValueSet body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// A collection of the fields and values for this version of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of the fields and values for this version of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// A collection of the fields and values for this version of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(FieldValueSet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// A collection of the fields and values for this version of the list item. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/ListItem/Versions/Item/ListItemVersionRequestBuilder.cs b/src/generated/Workbooks/Item/ListItem/Versions/Item/ListItemVersionRequestBuilder.cs index 784999cb230..5e6514b2049 100644 --- a/src/generated/Workbooks/Item/ListItem/Versions/Item/ListItemVersionRequestBuilder.cs +++ b/src/generated/Workbooks/Item/ListItem/Versions/Item/ListItemVersionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.ListItem.Versions.Item.RestoreVersion; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,19 +28,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of previous versions of the list item."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); - command.SetHandler(async (string driveItemId, string listItemVersionId) => { + command.SetHandler(async (string driveItemId, string listItemVersionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, listItemVersionIdOption); return command; @@ -60,11 +59,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of previous versions of the list item."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); @@ -78,20 +77,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string listItemVersionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string listItemVersionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, listItemVersionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, listItemVersionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -101,11 +99,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of previous versions of the list item."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); @@ -113,14 +111,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string listItemVersionId, string body) => { + command.SetHandler(async (string driveItemId, string listItemVersionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, listItemVersionIdOption, bodyOption); return command; @@ -198,42 +195,6 @@ public RequestInformation CreatePatchRequestInformation(ListItemVersion body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ListItemVersion model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of previous versions of the list item. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/ListItem/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs b/src/generated/Workbooks/Item/ListItem/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs index 538717a4bbc..f339af75dd8 100644 --- a/src/generated/Workbooks/Item/ListItem/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs +++ b/src/generated/Workbooks/Item/ListItem/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,18 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action restoreVersion"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var listItemVersionIdOption = new Option("--listitemversion-id", description: "key: id of listItemVersion") { + var listItemVersionIdOption = new Option("--list-item-version-id", description: "key: id of listItemVersion") { }; listItemVersionIdOption.IsRequired = true; command.AddOption(listItemVersionIdOption); - command.SetHandler(async (string driveItemId, string listItemVersionId) => { + command.SetHandler(async (string driveItemId, string listItemVersionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, listItemVersionIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action restoreVersion - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/ListItem/Versions/VersionsRequestBuilder.cs b/src/generated/Workbooks/Item/ListItem/Versions/VersionsRequestBuilder.cs index 56119c4cdd9..3540174322a 100644 --- a/src/generated/Workbooks/Item/ListItem/Versions/VersionsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/ListItem/Versions/VersionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.ListItem.Versions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class VersionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ListItemVersionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildFieldsCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildRestoreVersionCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFieldsCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRestoreVersionCommand()); return commands; } /// @@ -38,7 +37,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The list of previous versions of the list item."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -46,21 +45,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -70,7 +68,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The list of previous versions of the list item."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -109,7 +107,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -120,15 +122,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -183,31 +180,6 @@ public RequestInformation CreatePostRequestInformation(ListItemVersion body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of previous versions of the list item. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ListItemVersion model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of previous versions of the list item. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Permissions/Item/Grant/GrantRequestBuilder.cs b/src/generated/Workbooks/Item/Permissions/Item/Grant/GrantRequestBuilder.cs index 51a611f6c92..c3cd26457a0 100644 --- a/src/generated/Workbooks/Item/Permissions/Item/Grant/GrantRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Permissions/Item/Grant/GrantRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action grant"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -37,21 +37,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string permissionId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string permissionId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, permissionIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, permissionIdOption, bodyOption, outputOption); return command; } /// @@ -85,18 +84,5 @@ public RequestInformation CreatePostRequestInformation(GrantRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action grant - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> PostAsync(GrantRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Permissions/Item/PermissionRequestBuilder.cs b/src/generated/Workbooks/Item/Permissions/Item/PermissionRequestBuilder.cs index 0b78d1d084e..1cebdf6c449 100644 --- a/src/generated/Workbooks/Item/Permissions/Item/PermissionRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Permissions/Item/PermissionRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Permissions.Item.Grant; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,7 +27,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The set of permissions for the item. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -35,11 +35,10 @@ public Command BuildDeleteCommand() { }; permissionIdOption.IsRequired = true; command.AddOption(permissionIdOption); - command.SetHandler(async (string driveItemId, string permissionId) => { + command.SetHandler(async (string driveItemId, string permissionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, permissionIdOption); return command; @@ -51,7 +50,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The set of permissions for the item. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string permissionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string permissionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, permissionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, permissionIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildGrantCommand() { @@ -98,7 +96,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The set of permissions for the item. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -110,14 +108,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string permissionId, string body) => { + command.SetHandler(async (string driveItemId, string permissionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, permissionIdOption, bodyOption); return command; @@ -189,42 +186,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The set of permissions for the item. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The set of permissions for the item. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The set of permissions for the item. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Permission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The set of permissions for the item. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Permissions/PermissionsRequestBuilder.cs b/src/generated/Workbooks/Item/Permissions/PermissionsRequestBuilder.cs index 7b5abd27aa1..821983d4e5c 100644 --- a/src/generated/Workbooks/Item/Permissions/PermissionsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Permissions/PermissionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Permissions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class PermissionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new PermissionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildGrantCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildGrantCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -37,7 +36,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The set of permissions for the item. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -69,7 +67,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The set of permissions for the item. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The set of permissions for the item. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The set of permissions for the item. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.Permission model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The set of permissions for the item. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Preview/PreviewRequestBuilder.cs b/src/generated/Workbooks/Item/Preview/PreviewRequestBuilder.cs index 1f1c6b087f1..1ca699a010b 100644 --- a/src/generated/Workbooks/Item/Preview/PreviewRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Preview/PreviewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action preview"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(PreviewRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action preview - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PreviewRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes itemPreviewInfo public class PreviewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Restore/RestoreRequestBuilder.cs b/src/generated/Workbooks/Item/Restore/RestoreRequestBuilder.cs index 465e756f6d0..2ef911194f7 100644 --- a/src/generated/Workbooks/Item/Restore/RestoreRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Restore/RestoreRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action restore"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(RestoreRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action restore - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RestoreRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes driveItem public class RestoreResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/SearchWithQ/SearchWithQRequestBuilder.cs b/src/generated/Workbooks/Item/SearchWithQ/SearchWithQRequestBuilder.cs index 4a3e69a39df..096e9265cd6 100644 --- a/src/generated/Workbooks/Item/SearchWithQ/SearchWithQRequestBuilder.cs +++ b/src/generated/Workbooks/Item/SearchWithQ/SearchWithQRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function search"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -33,18 +33,17 @@ public Command BuildGetCommand() { }; qOption.IsRequired = true; command.AddOption(qOption); - command.SetHandler(async (string driveItemId, string q) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string q, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendCollectionAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteCollectionOfObjectValues(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, qOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, qOption, outputOption); return command; } /// @@ -77,16 +76,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function search - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task> GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendCollectionAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Subscriptions/Item/SubscriptionRequestBuilder.cs b/src/generated/Workbooks/Item/Subscriptions/Item/SubscriptionRequestBuilder.cs index 0b0618f94d4..9553ffe66c6 100644 --- a/src/generated/Workbooks/Item/Subscriptions/Item/SubscriptionRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Subscriptions/Item/SubscriptionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The set of subscriptions on the item. Only supported on the root of a drive."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,11 +34,10 @@ public Command BuildDeleteCommand() { }; subscriptionIdOption.IsRequired = true; command.AddOption(subscriptionIdOption); - command.SetHandler(async (string driveItemId, string subscriptionId) => { + command.SetHandler(async (string driveItemId, string subscriptionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, subscriptionIdOption); return command; @@ -50,7 +49,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The set of subscriptions on the item. Only supported on the root of a drive."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string subscriptionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string subscriptionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, subscriptionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, subscriptionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,7 +89,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The set of subscriptions on the item. Only supported on the root of a drive."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string subscriptionId, string body) => { + command.SetHandler(async (string driveItemId, string subscriptionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, subscriptionIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(Subscription body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The set of subscriptions on the item. Only supported on the root of a drive. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The set of subscriptions on the item. Only supported on the root of a drive. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The set of subscriptions on the item. Only supported on the root of a drive. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(Subscription model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The set of subscriptions on the item. Only supported on the root of a drive. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Subscriptions/SubscriptionsRequestBuilder.cs b/src/generated/Workbooks/Item/Subscriptions/SubscriptionsRequestBuilder.cs index 48170151e60..7cd0f6b2db6 100644 --- a/src/generated/Workbooks/Item/Subscriptions/SubscriptionsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Subscriptions/SubscriptionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Subscriptions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class SubscriptionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new SubscriptionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The set of subscriptions on the item. Only supported on the root of a drive."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The set of subscriptions on the item. Only supported on the root of a drive."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(Subscription body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The set of subscriptions on the item. Only supported on the root of a drive. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The set of subscriptions on the item. Only supported on the root of a drive. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Subscription model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The set of subscriptions on the item. Only supported on the root of a drive. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Thumbnails/Item/ThumbnailSetRequestBuilder.cs b/src/generated/Workbooks/Item/Thumbnails/Item/ThumbnailSetRequestBuilder.cs index 22cc22a5440..9cf8c10acd0 100644 --- a/src/generated/Workbooks/Item/Thumbnails/Item/ThumbnailSetRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Thumbnails/Item/ThumbnailSetRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Collection containing [ThumbnailSet][] objects associated with the item. For more info, see [getting thumbnails][]. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var thumbnailSetIdOption = new Option("--thumbnailset-id", description: "key: id of thumbnailSet") { + var thumbnailSetIdOption = new Option("--thumbnail-set-id", description: "key: id of thumbnailSet") { }; thumbnailSetIdOption.IsRequired = true; command.AddOption(thumbnailSetIdOption); - command.SetHandler(async (string driveItemId, string thumbnailSetId) => { + command.SetHandler(async (string driveItemId, string thumbnailSetId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, thumbnailSetIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Collection containing [ThumbnailSet][] objects associated with the item. For more info, see [getting thumbnails][]. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var thumbnailSetIdOption = new Option("--thumbnailset-id", description: "key: id of thumbnailSet") { + var thumbnailSetIdOption = new Option("--thumbnail-set-id", description: "key: id of thumbnailSet") { }; thumbnailSetIdOption.IsRequired = true; command.AddOption(thumbnailSetIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string thumbnailSetId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string thumbnailSetId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, thumbnailSetIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, thumbnailSetIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Collection containing [ThumbnailSet][] objects associated with the item. For more info, see [getting thumbnails][]. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var thumbnailSetIdOption = new Option("--thumbnailset-id", description: "key: id of thumbnailSet") { + var thumbnailSetIdOption = new Option("--thumbnail-set-id", description: "key: id of thumbnailSet") { }; thumbnailSetIdOption.IsRequired = true; command.AddOption(thumbnailSetIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string thumbnailSetId, string body) => { + command.SetHandler(async (string driveItemId, string thumbnailSetId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, thumbnailSetIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(ThumbnailSet body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection containing [ThumbnailSet][] objects associated with the item. For more info, see [getting thumbnails][]. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection containing [ThumbnailSet][] objects associated with the item. For more info, see [getting thumbnails][]. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection containing [ThumbnailSet][] objects associated with the item. For more info, see [getting thumbnails][]. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ThumbnailSet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection containing [ThumbnailSet][] objects associated with the item. For more info, see [getting thumbnails][]. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Thumbnails/ThumbnailsRequestBuilder.cs b/src/generated/Workbooks/Item/Thumbnails/ThumbnailsRequestBuilder.cs index 964452f4955..89b598a271a 100644 --- a/src/generated/Workbooks/Item/Thumbnails/ThumbnailsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Thumbnails/ThumbnailsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Thumbnails.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class ThumbnailsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new ThumbnailSetRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Collection containing [ThumbnailSet][] objects associated with the item. For more info, see [getting thumbnails][]. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Collection containing [ThumbnailSet][] objects associated with the item. For more info, see [getting thumbnails][]. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -107,7 +105,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -118,15 +120,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -181,31 +178,6 @@ public RequestInformation CreatePostRequestInformation(ThumbnailSet body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection containing [ThumbnailSet][] objects associated with the item. For more info, see [getting thumbnails][]. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection containing [ThumbnailSet][] objects associated with the item. For more info, see [getting thumbnails][]. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ThumbnailSet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection containing [ThumbnailSet][] objects associated with the item. For more info, see [getting thumbnails][]. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Unfollow/UnfollowRequestBuilder.cs b/src/generated/Workbooks/Item/Unfollow/UnfollowRequestBuilder.cs index 079c84bd9d4..e84b9e6d019 100644 --- a/src/generated/Workbooks/Item/Unfollow/UnfollowRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Unfollow/UnfollowRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action unfollow"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { + command.SetHandler(async (string driveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action unfollow - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/ValidatePermission/ValidatePermissionRequestBuilder.cs b/src/generated/Workbooks/Item/ValidatePermission/ValidatePermissionRequestBuilder.cs index 9edbaa0fb51..53b1ca27584 100644 --- a/src/generated/Workbooks/Item/ValidatePermission/ValidatePermissionRequestBuilder.cs +++ b/src/generated/Workbooks/Item/ValidatePermission/ValidatePermissionRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action validatePermission"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + command.SetHandler(async (string driveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(ValidatePermissionRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action validatePermission - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ValidatePermissionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Versions/Item/Content/ContentRequestBuilder.cs b/src/generated/Workbooks/Item/Versions/Item/Content/ContentRequestBuilder.cs index dfe66071243..1cd78edb181 100644 --- a/src/generated/Workbooks/Item/Versions/Item/Content/ContentRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Versions/Item/Content/ContentRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,32 +25,34 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The content stream, if the item represents a file."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var driveItemVersionIdOption = new Option("--driveitemversion-id", description: "key: id of driveItemVersion") { + var driveItemVersionIdOption = new Option("--drive-item-version-id", description: "key: id of driveItemVersion") { }; driveItemVersionIdOption.IsRequired = true; command.AddOption(driveItemVersionIdOption); - var outputOption = new Option("--output"); + var fileOption = new Option("--file"); + command.AddOption(fileOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; command.AddOption(outputOption); - command.SetHandler(async (string driveItemId, string driveItemVersionId, FileInfo output) => { + command.SetHandler(async (string driveItemId, string driveItemVersionId, FileInfo file, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - if (output == null) { - using var reader = new StreamReader(result); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + if (file == null) { + formatter.WriteOutput(response); } else { - using var writeStream = output.OpenWrite(); - await result.CopyToAsync(writeStream); - Console.WriteLine($"Content written to {output.FullName}."); + using var writeStream = file.OpenWrite(); + await response.CopyToAsync(writeStream); + Console.WriteLine($"Content written to {file.FullName}."); } - }, driveItemIdOption, driveItemVersionIdOption, outputOption); + }, driveItemIdOption, driveItemVersionIdOption, fileOption, outputOption); return command; } /// @@ -60,11 +62,11 @@ public Command BuildPutCommand() { var command = new Command("put"); command.Description = "The content stream, if the item represents a file."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var driveItemVersionIdOption = new Option("--driveitemversion-id", description: "key: id of driveItemVersion") { + var driveItemVersionIdOption = new Option("--drive-item-version-id", description: "key: id of driveItemVersion") { }; driveItemVersionIdOption.IsRequired = true; command.AddOption(driveItemVersionIdOption); @@ -72,12 +74,11 @@ public Command BuildPutCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string driveItemVersionId, FileInfo file) => { + command.SetHandler(async (string driveItemId, string driveItemVersionId, FileInfo file, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = file.OpenRead(); var requestInfo = CreatePutRequestInformation(stream, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, driveItemVersionIdOption, bodyOption); return command; @@ -128,29 +129,5 @@ public RequestInformation CreatePutRequestInformation(Stream body, Action - /// The content stream, if the item represents a file. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The content stream, if the item represents a file. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// Binary request body - /// - public async Task PutAsync(Stream stream, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = stream ?? throw new ArgumentNullException(nameof(stream)); - var requestInfo = CreatePutRequestInformation(stream, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Versions/Item/DriveItemVersionRequestBuilder.cs b/src/generated/Workbooks/Item/Versions/Item/DriveItemVersionRequestBuilder.cs index 6641043eec9..4fb2ef7c5a8 100644 --- a/src/generated/Workbooks/Item/Versions/Item/DriveItemVersionRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Versions/Item/DriveItemVersionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Versions.Item.RestoreVersion; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -35,19 +35,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The list of previous versions of the item. For more info, see [getting previous versions][]. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var driveItemVersionIdOption = new Option("--driveitemversion-id", description: "key: id of driveItemVersion") { + var driveItemVersionIdOption = new Option("--drive-item-version-id", description: "key: id of driveItemVersion") { }; driveItemVersionIdOption.IsRequired = true; command.AddOption(driveItemVersionIdOption); - command.SetHandler(async (string driveItemId, string driveItemVersionId) => { + command.SetHandler(async (string driveItemId, string driveItemVersionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, driveItemVersionIdOption); return command; @@ -59,11 +58,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The list of previous versions of the item. For more info, see [getting previous versions][]. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var driveItemVersionIdOption = new Option("--driveitemversion-id", description: "key: id of driveItemVersion") { + var driveItemVersionIdOption = new Option("--drive-item-version-id", description: "key: id of driveItemVersion") { }; driveItemVersionIdOption.IsRequired = true; command.AddOption(driveItemVersionIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string driveItemVersionId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string driveItemVersionId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, driveItemVersionIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, driveItemVersionIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -100,11 +98,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The list of previous versions of the item. For more info, see [getting previous versions][]. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var driveItemVersionIdOption = new Option("--driveitemversion-id", description: "key: id of driveItemVersion") { + var driveItemVersionIdOption = new Option("--drive-item-version-id", description: "key: id of driveItemVersion") { }; driveItemVersionIdOption.IsRequired = true; command.AddOption(driveItemVersionIdOption); @@ -112,14 +110,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string driveItemVersionId, string body) => { + command.SetHandler(async (string driveItemId, string driveItemVersionId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, driveItemVersionIdOption, bodyOption); return command; @@ -197,42 +194,6 @@ public RequestInformation CreatePatchRequestInformation(DriveItemVersion body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of previous versions of the item. For more info, see [getting previous versions][]. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of previous versions of the item. For more info, see [getting previous versions][]. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of previous versions of the item. For more info, see [getting previous versions][]. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(DriveItemVersion model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of previous versions of the item. For more info, see [getting previous versions][]. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs b/src/generated/Workbooks/Item/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs index 8f62149df0b..4811dfad3ad 100644 --- a/src/generated/Workbooks/Item/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Versions/Item/RestoreVersion/RestoreVersionRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,18 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action restoreVersion"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var driveItemVersionIdOption = new Option("--driveitemversion-id", description: "key: id of driveItemVersion") { + var driveItemVersionIdOption = new Option("--drive-item-version-id", description: "key: id of driveItemVersion") { }; driveItemVersionIdOption.IsRequired = true; command.AddOption(driveItemVersionIdOption); - command.SetHandler(async (string driveItemId, string driveItemVersionId) => { + command.SetHandler(async (string driveItemId, string driveItemVersionId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, driveItemVersionIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action restoreVersion - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Versions/VersionsRequestBuilder.cs b/src/generated/Workbooks/Item/Versions/VersionsRequestBuilder.cs index 01d64ed62ae..a5994280eab 100644 --- a/src/generated/Workbooks/Item/Versions/VersionsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Versions/VersionsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Versions.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,13 +22,12 @@ public class VersionsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DriveItemVersionRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildContentCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildRestoreVersionCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRestoreVersionCommand()); return commands; } /// @@ -38,7 +37,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The list of previous versions of the item. For more info, see [getting previous versions][]. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -46,21 +45,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -70,7 +68,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The list of previous versions of the item. For more info, see [getting previous versions][]. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -109,7 +107,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -120,15 +122,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -183,31 +180,6 @@ public RequestInformation CreatePostRequestInformation(DriveItemVersion body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The list of previous versions of the item. For more info, see [getting previous versions][]. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The list of previous versions of the item. For more info, see [getting previous versions][]. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DriveItemVersion model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The list of previous versions of the item. For more info, see [getting previous versions][]. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Application/ApplicationRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Application/ApplicationRequestBuilder.cs index 986ad2b1c6d..064f440db5f 100644 --- a/src/generated/Workbooks/Item/Workbook/Application/ApplicationRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Application/ApplicationRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Application.Calculate; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,15 +33,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property application for workbooks"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { + command.SetHandler(async (string driveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption); return command; @@ -53,7 +52,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get application from workbooks"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -67,20 +66,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -90,7 +88,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property application in workbooks"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -98,14 +96,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + command.SetHandler(async (string driveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, bodyOption); return command; @@ -177,42 +174,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookApplication body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property application for workbooks - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get application from workbooks - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property application in workbooks - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookApplication model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get application from workbooks public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Application/Calculate/CalculateRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Application/Calculate/CalculateRequestBuilder.cs index 7bebc72d820..3fae34111ae 100644 --- a/src/generated/Workbooks/Item/Workbook/Application/Calculate/CalculateRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Application/Calculate/CalculateRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,7 +25,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action calculate"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -33,14 +33,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + command.SetHandler(async (string driveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, bodyOption); return command; @@ -76,18 +75,5 @@ public RequestInformation CreatePostRequestInformation(CalculateRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action calculate - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CalculateRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/CloseSession/CloseSessionRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/CloseSession/CloseSessionRequestBuilder.cs index 5d936f3ff24..8ba1c972ebe 100644 --- a/src/generated/Workbooks/Item/Workbook/CloseSession/CloseSessionRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/CloseSession/CloseSessionRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action closeSession"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { + command.SetHandler(async (string driveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action closeSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Comments/CommentsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Comments/CommentsRequestBuilder.cs index 986c1e6b638..1c7295b1ccc 100644 --- a/src/generated/Workbooks/Item/Workbook/Comments/CommentsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Comments/CommentsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Comments.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,12 +22,11 @@ public class CommentsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new WorkbookCommentRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildRepliesCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRepliesCommand()); return commands; } /// @@ -37,7 +36,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Create new navigation property to comments for workbooks"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -45,21 +44,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -69,7 +67,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Get comments from workbooks"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -108,7 +106,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -119,15 +121,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -182,31 +179,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookComment body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get comments from workbooks - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Create new navigation property to comments for workbooks - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookComment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get comments from workbooks public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Comments/Item/Replies/Item/WorkbookCommentReplyRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Comments/Item/Replies/Item/WorkbookCommentReplyRequestBuilder.cs index d27f187b3d9..3684c15668d 100644 --- a/src/generated/Workbooks/Item/Workbook/Comments/Item/Replies/Item/WorkbookCommentReplyRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Comments/Item/Replies/Item/WorkbookCommentReplyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookCommentIdOption = new Option("--workbookcomment-id", description: "key: id of workbookComment") { + var workbookCommentIdOption = new Option("--workbook-comment-id", description: "key: id of workbookComment") { }; workbookCommentIdOption.IsRequired = true; command.AddOption(workbookCommentIdOption); - var workbookCommentReplyIdOption = new Option("--workbookcommentreply-id", description: "key: id of workbookCommentReply") { + var workbookCommentReplyIdOption = new Option("--workbook-comment-reply-id", description: "key: id of workbookCommentReply") { }; workbookCommentReplyIdOption.IsRequired = true; command.AddOption(workbookCommentReplyIdOption); - command.SetHandler(async (string driveItemId, string workbookCommentId, string workbookCommentReplyId) => { + command.SetHandler(async (string driveItemId, string workbookCommentId, string workbookCommentReplyId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookCommentIdOption, workbookCommentReplyIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookCommentIdOption = new Option("--workbookcomment-id", description: "key: id of workbookComment") { + var workbookCommentIdOption = new Option("--workbook-comment-id", description: "key: id of workbookComment") { }; workbookCommentIdOption.IsRequired = true; command.AddOption(workbookCommentIdOption); - var workbookCommentReplyIdOption = new Option("--workbookcommentreply-id", description: "key: id of workbookCommentReply") { + var workbookCommentReplyIdOption = new Option("--workbook-comment-reply-id", description: "key: id of workbookCommentReply") { }; workbookCommentReplyIdOption.IsRequired = true; command.AddOption(workbookCommentReplyIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookCommentId, string workbookCommentReplyId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookCommentId, string workbookCommentReplyId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookCommentIdOption, workbookCommentReplyIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookCommentIdOption, workbookCommentReplyIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookCommentIdOption = new Option("--workbookcomment-id", description: "key: id of workbookComment") { + var workbookCommentIdOption = new Option("--workbook-comment-id", description: "key: id of workbookComment") { }; workbookCommentIdOption.IsRequired = true; command.AddOption(workbookCommentIdOption); - var workbookCommentReplyIdOption = new Option("--workbookcommentreply-id", description: "key: id of workbookCommentReply") { + var workbookCommentReplyIdOption = new Option("--workbook-comment-reply-id", description: "key: id of workbookCommentReply") { }; workbookCommentReplyIdOption.IsRequired = true; command.AddOption(workbookCommentReplyIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookCommentId, string workbookCommentReplyId, string body) => { + command.SetHandler(async (string driveItemId, string workbookCommentId, string workbookCommentReplyId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookCommentIdOption, workbookCommentReplyIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookCommentReply bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookCommentReply model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Comments/Item/Replies/RepliesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Comments/Item/Replies/RepliesRequestBuilder.cs index bdcc943db2e..57e228249db 100644 --- a/src/generated/Workbooks/Item/Workbook/Comments/Item/Replies/RepliesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Comments/Item/Replies/RepliesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Comments.Item.Replies.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class RepliesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new WorkbookCommentReplyRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,11 +35,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookCommentIdOption = new Option("--workbookcomment-id", description: "key: id of workbookComment") { + var workbookCommentIdOption = new Option("--workbook-comment-id", description: "key: id of workbookComment") { }; workbookCommentIdOption.IsRequired = true; command.AddOption(workbookCommentIdOption); @@ -48,21 +47,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookCommentId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookCommentId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookCommentIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookCommentIdOption, bodyOption, outputOption); return command; } /// @@ -72,11 +70,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookCommentIdOption = new Option("--workbookcomment-id", description: "key: id of workbookComment") { + var workbookCommentIdOption = new Option("--workbook-comment-id", description: "key: id of workbookComment") { }; workbookCommentIdOption.IsRequired = true; command.AddOption(workbookCommentIdOption); @@ -115,7 +113,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookCommentId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookCommentId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -126,15 +128,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookCommentIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookCommentIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -189,31 +186,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookCommentReply body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookCommentReply model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Comments/Item/WorkbookCommentRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Comments/Item/WorkbookCommentRequestBuilder.cs index ca76cbee0a6..59f61556140 100644 --- a/src/generated/Workbooks/Item/Workbook/Comments/Item/WorkbookCommentRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Comments/Item/WorkbookCommentRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Comments.Item.Replies; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,19 +27,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property comments for workbooks"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookCommentIdOption = new Option("--workbookcomment-id", description: "key: id of workbookComment") { + var workbookCommentIdOption = new Option("--workbook-comment-id", description: "key: id of workbookComment") { }; workbookCommentIdOption.IsRequired = true; command.AddOption(workbookCommentIdOption); - command.SetHandler(async (string driveItemId, string workbookCommentId) => { + command.SetHandler(async (string driveItemId, string workbookCommentId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookCommentIdOption); return command; @@ -51,11 +50,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get comments from workbooks"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookCommentIdOption = new Option("--workbookcomment-id", description: "key: id of workbookComment") { + var workbookCommentIdOption = new Option("--workbook-comment-id", description: "key: id of workbookComment") { }; workbookCommentIdOption.IsRequired = true; command.AddOption(workbookCommentIdOption); @@ -69,20 +68,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookCommentId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookCommentId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookCommentIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookCommentIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -92,11 +90,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property comments in workbooks"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookCommentIdOption = new Option("--workbookcomment-id", description: "key: id of workbookComment") { + var workbookCommentIdOption = new Option("--workbook-comment-id", description: "key: id of workbookComment") { }; workbookCommentIdOption.IsRequired = true; command.AddOption(workbookCommentIdOption); @@ -104,14 +102,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookCommentId, string body) => { + command.SetHandler(async (string driveItemId, string workbookCommentId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookCommentIdOption, bodyOption); return command; @@ -119,6 +116,9 @@ public Command BuildPatchCommand() { public Command BuildRepliesCommand() { var command = new Command("replies"); var builder = new ApiSdk.Workbooks.Item.Workbook.Comments.Item.Replies.RepliesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -190,42 +190,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookComment body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property comments for workbooks - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get comments from workbooks - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property comments in workbooks - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookComment model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get comments from workbooks public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/CreateSession/CreateSessionRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/CreateSession/CreateSessionRequestBuilder.cs index 66f255758a0..6780805bc78 100644 --- a/src/generated/Workbooks/Item/Workbook/CreateSession/CreateSessionRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/CreateSession/CreateSessionRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action createSession"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CreateSessionRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action createSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CreateSessionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookSessionInfo public class CreateSessionResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/@And/AndRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/@And/AndRequestBuilder.cs deleted file mode 100644 index ed8e0c2bc78..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Functions/@And/AndRequestBuilder.cs +++ /dev/null @@ -1,129 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Functions.@And { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\functions\microsoft.graph.and - public class AndRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action and - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action and"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AndRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AndRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/functions/microsoft.graph.and"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action and - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AndRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action and - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AndRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookFunctionResult - public class AndResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookFunctionResult - public WorkbookFunctionResult WorkbookFunctionResult { get; set; } - /// - /// Instantiates a new andResponse and sets the default values. - /// - public AndResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookFunctionResult", (o,n) => { (o as AndResponse).WorkbookFunctionResult = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookFunctionResult", WorkbookFunctionResult); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Functions/@Base/BaseRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/@Base/BaseRequestBuilder.cs deleted file mode 100644 index 2d639304b5a..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Functions/@Base/BaseRequestBuilder.cs +++ /dev/null @@ -1,129 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Functions.@Base { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\functions\microsoft.graph.base - public class BaseRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action base - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action base"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new BaseRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public BaseRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/functions/microsoft.graph.base"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action base - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(BaseRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action base - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(BaseRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookFunctionResult - public class BaseResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookFunctionResult - public WorkbookFunctionResult WorkbookFunctionResult { get; set; } - /// - /// Instantiates a new baseResponse and sets the default values. - /// - public BaseResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookFunctionResult", (o,n) => { (o as BaseResponse).WorkbookFunctionResult = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookFunctionResult", WorkbookFunctionResult); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Functions/@Char/CharRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/@Char/CharRequestBuilder.cs deleted file mode 100644 index 075424d57ff..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Functions/@Char/CharRequestBuilder.cs +++ /dev/null @@ -1,129 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Functions.@Char { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\functions\microsoft.graph.char - public class CharRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action char - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action char"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new CharRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public CharRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/functions/microsoft.graph.char"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action char - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(CharRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action char - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CharRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookFunctionResult - public class CharResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookFunctionResult - public WorkbookFunctionResult WorkbookFunctionResult { get; set; } - /// - /// Instantiates a new charResponse and sets the default values. - /// - public CharResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookFunctionResult", (o,n) => { (o as CharResponse).WorkbookFunctionResult = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookFunctionResult", WorkbookFunctionResult); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Functions/@Decimal/DecimalRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/@Decimal/DecimalRequestBuilder.cs deleted file mode 100644 index 91c5b2c4af0..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Functions/@Decimal/DecimalRequestBuilder.cs +++ /dev/null @@ -1,129 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Functions.@Decimal { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\functions\microsoft.graph.decimal - public class DecimalRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action decimal - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action decimal"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new DecimalRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public DecimalRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/functions/microsoft.graph.decimal"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action decimal - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(DecimalRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action decimal - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DecimalRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookFunctionResult - public class DecimalResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookFunctionResult - public WorkbookFunctionResult WorkbookFunctionResult { get; set; } - /// - /// Instantiates a new decimalResponse and sets the default values. - /// - public DecimalResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookFunctionResult", (o,n) => { (o as DecimalResponse).WorkbookFunctionResult = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookFunctionResult", WorkbookFunctionResult); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Functions/@False/FalseRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/@False/FalseRequestBuilder.cs deleted file mode 100644 index 2eaa8752fa4..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Functions/@False/FalseRequestBuilder.cs +++ /dev/null @@ -1,117 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Functions.@False { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\functions\microsoft.graph.false - public class FalseRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action false - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action false"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { - var requestInfo = CreatePostRequestInformation(q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption); - return command; - } - /// - /// Instantiates a new FalseRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public FalseRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/functions/microsoft.graph.false"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action false - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action false - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookFunctionResult - public class FalseResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookFunctionResult - public WorkbookFunctionResult WorkbookFunctionResult { get; set; } - /// - /// Instantiates a new falseResponse and sets the default values. - /// - public FalseResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookFunctionResult", (o,n) => { (o as FalseResponse).WorkbookFunctionResult = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookFunctionResult", WorkbookFunctionResult); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Functions/@Fixed/FixedRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/@Fixed/FixedRequestBuilder.cs deleted file mode 100644 index efca14be100..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Functions/@Fixed/FixedRequestBuilder.cs +++ /dev/null @@ -1,129 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Functions.@Fixed { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\functions\microsoft.graph.fixed - public class FixedRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action fixed - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action fixed"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new FixedRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public FixedRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/functions/microsoft.graph.fixed"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action fixed - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(FixedRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action fixed - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(FixedRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookFunctionResult - public class FixedResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookFunctionResult - public WorkbookFunctionResult WorkbookFunctionResult { get; set; } - /// - /// Instantiates a new fixedResponse and sets the default values. - /// - public FixedResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookFunctionResult", (o,n) => { (o as FixedResponse).WorkbookFunctionResult = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookFunctionResult", WorkbookFunctionResult); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Functions/@If/IfRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/@If/IfRequestBuilder.cs deleted file mode 100644 index 41ef848eaae..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Functions/@If/IfRequestBuilder.cs +++ /dev/null @@ -1,129 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Functions.@If { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\functions\microsoft.graph.if - public class IfRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action if - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action if"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new IfRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public IfRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/functions/microsoft.graph.if"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action if - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(IfRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action if - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(IfRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookFunctionResult - public class IfResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookFunctionResult - public WorkbookFunctionResult WorkbookFunctionResult { get; set; } - /// - /// Instantiates a new ifResponse and sets the default values. - /// - public IfResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookFunctionResult", (o,n) => { (o as IfResponse).WorkbookFunctionResult = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookFunctionResult", WorkbookFunctionResult); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Functions/@Int/IntRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/@Int/IntRequestBuilder.cs deleted file mode 100644 index 772f0b73b43..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Functions/@Int/IntRequestBuilder.cs +++ /dev/null @@ -1,129 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Functions.@Int { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\functions\microsoft.graph.int - public class IntRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action int - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action int"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new IntRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public IntRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/functions/microsoft.graph.int"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action int - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(IntRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action int - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(IntRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookFunctionResult - public class IntResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookFunctionResult - public WorkbookFunctionResult WorkbookFunctionResult { get; set; } - /// - /// Instantiates a new intResponse and sets the default values. - /// - public IntResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookFunctionResult", (o,n) => { (o as IntResponse).WorkbookFunctionResult = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookFunctionResult", WorkbookFunctionResult); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Functions/@Not/NotRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/@Not/NotRequestBuilder.cs deleted file mode 100644 index 6613cac2dd6..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Functions/@Not/NotRequestBuilder.cs +++ /dev/null @@ -1,129 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Functions.@Not { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\functions\microsoft.graph.not - public class NotRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action not - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action not"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new NotRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public NotRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/functions/microsoft.graph.not"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action not - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(NotRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action not - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(NotRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookFunctionResult - public class NotResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookFunctionResult - public WorkbookFunctionResult WorkbookFunctionResult { get; set; } - /// - /// Instantiates a new notResponse and sets the default values. - /// - public NotResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookFunctionResult", (o,n) => { (o as NotResponse).WorkbookFunctionResult = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookFunctionResult", WorkbookFunctionResult); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Functions/@Or/OrRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/@Or/OrRequestBuilder.cs deleted file mode 100644 index 619be26499b..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Functions/@Or/OrRequestBuilder.cs +++ /dev/null @@ -1,129 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Functions.@Or { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\functions\microsoft.graph.or - public class OrRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action or - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action or"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new OrRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public OrRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/functions/microsoft.graph.or"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action or - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(OrRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action or - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OrRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookFunctionResult - public class OrResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookFunctionResult - public WorkbookFunctionResult WorkbookFunctionResult { get; set; } - /// - /// Instantiates a new orResponse and sets the default values. - /// - public OrResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookFunctionResult", (o,n) => { (o as OrResponse).WorkbookFunctionResult = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookFunctionResult", WorkbookFunctionResult); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Functions/@True/TrueRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/@True/TrueRequestBuilder.cs deleted file mode 100644 index 6ecc5b5dd5f..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Functions/@True/TrueRequestBuilder.cs +++ /dev/null @@ -1,117 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Functions.@True { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\functions\microsoft.graph.true - public class TrueRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action true - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action true"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { - var requestInfo = CreatePostRequestInformation(q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption); - return command; - } - /// - /// Instantiates a new TrueRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public TrueRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/functions/microsoft.graph.true"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action true - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action true - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookFunctionResult - public class TrueResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookFunctionResult - public WorkbookFunctionResult WorkbookFunctionResult { get; set; } - /// - /// Instantiates a new trueResponse and sets the default values. - /// - public TrueResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookFunctionResult", (o,n) => { (o as TrueResponse).WorkbookFunctionResult = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookFunctionResult", WorkbookFunctionResult); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Functions/@Yield/YieldRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/@Yield/YieldRequestBuilder.cs deleted file mode 100644 index 2997fa15d6a..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Functions/@Yield/YieldRequestBuilder.cs +++ /dev/null @@ -1,129 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Functions.@Yield { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\functions\microsoft.graph.yield - public class YieldRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action yield - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action yield"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new YieldRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public YieldRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/functions/microsoft.graph.yield"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action yield - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(YieldRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action yield - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(YieldRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookFunctionResult - public class YieldResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookFunctionResult - public WorkbookFunctionResult WorkbookFunctionResult { get; set; } - /// - /// Instantiates a new yieldResponse and sets the default values. - /// - public YieldResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookFunctionResult", (o,n) => { (o as YieldResponse).WorkbookFunctionResult = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookFunctionResult", WorkbookFunctionResult); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Abs/AbsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Abs/AbsRequestBuilder.cs index 7e9599e028c..53ba1990682 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Abs/AbsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Abs/AbsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action abs"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(AbsRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action abs - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AbsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class AbsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/AccrInt/AccrIntRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/AccrInt/AccrIntRequestBuilder.cs index d160f02d989..a99e4daaf54 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/AccrInt/AccrIntRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/AccrInt/AccrIntRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action accrInt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(AccrIntRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accrInt - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AccrIntRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class AccrIntResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/AccrIntM/AccrIntMRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/AccrIntM/AccrIntMRequestBuilder.cs index 80259f94859..2c0b0d21b35 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/AccrIntM/AccrIntMRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/AccrIntM/AccrIntMRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action accrIntM"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(AccrIntMRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action accrIntM - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AccrIntMRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class AccrIntMResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Acos/AcosRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Acos/AcosRequestBuilder.cs index d6c4928b504..bfd849665a7 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Acos/AcosRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Acos/AcosRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action acos"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(AcosRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action acos - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcosRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class AcosResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Acosh/AcoshRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Acosh/AcoshRequestBuilder.cs index 1e002bb8d8c..8230ab5082c 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Acosh/AcoshRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Acosh/AcoshRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action acosh"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(AcoshRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action acosh - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcoshRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class AcoshResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Acot/AcotRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Acot/AcotRequestBuilder.cs index 769e9c24cdf..c201d2e70f5 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Acot/AcotRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Acot/AcotRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action acot"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(AcotRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action acot - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcotRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class AcotResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Acoth/AcothRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Acoth/AcothRequestBuilder.cs index 62c60ce6f37..e09054c983b 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Acoth/AcothRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Acoth/AcothRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action acoth"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(AcothRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action acoth - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AcothRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class AcothResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/AmorDegrc/AmorDegrcRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/AmorDegrc/AmorDegrcRequestBuilder.cs index 642e5e21800..464abfe0fb7 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/AmorDegrc/AmorDegrcRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/AmorDegrc/AmorDegrcRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action amorDegrc"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(AmorDegrcRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action amorDegrc - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AmorDegrcRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class AmorDegrcResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/AmorLinc/AmorLincRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/AmorLinc/AmorLincRequestBuilder.cs index 82e51aa4aeb..fe0b7216f5c 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/AmorLinc/AmorLincRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/AmorLinc/AmorLincRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action amorLinc"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(AmorLincRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action amorLinc - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AmorLincRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class AmorLincResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/@And/AndRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Functions/And/AndRequestBody.cs similarity index 96% rename from src/generated/Workbooks/Item/Workbook/Functions/@And/AndRequestBody.cs rename to src/generated/Workbooks/Item/Workbook/Functions/And/AndRequestBody.cs index 33992de96d6..10b52843d1a 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/@And/AndRequestBody.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/And/AndRequestBody.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Functions.@And { +namespace ApiSdk.Workbooks.Item.Workbook.Functions.And { public class AndRequestBody : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } diff --git a/src/generated/Workbooks/Item/Workbook/Functions/And/AndRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/And/AndRequestBuilder.cs new file mode 100644 index 00000000000..e3dcfff92fe --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Functions/And/AndRequestBuilder.cs @@ -0,0 +1,115 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Functions.And { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\functions\microsoft.graph.and + public class AndRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action and + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action and"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new AndRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AndRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/functions/microsoft.graph.and"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action and + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AndRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookFunctionResult + public class AndResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookFunctionResult + public WorkbookFunctionResult WorkbookFunctionResult { get; set; } + /// + /// Instantiates a new andResponse and sets the default values. + /// + public AndResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookFunctionResult", (o,n) => { (o as AndResponse).WorkbookFunctionResult = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookFunctionResult", WorkbookFunctionResult); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Arabic/ArabicRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Arabic/ArabicRequestBuilder.cs index e0d3e250c63..c6cbe93445b 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Arabic/ArabicRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Arabic/ArabicRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action arabic"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ArabicRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action arabic - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ArabicRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ArabicResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Areas/AreasRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Areas/AreasRequestBuilder.cs index 75e3c422b9f..132c596524e 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Areas/AreasRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Areas/AreasRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action areas"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(AreasRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action areas - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AreasRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class AreasResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Asc/AscRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Asc/AscRequestBuilder.cs index 547479bc8b7..debd55d2d53 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Asc/AscRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Asc/AscRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action asc"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(AscRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action asc - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AscRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class AscResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Asin/AsinRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Asin/AsinRequestBuilder.cs index e0ecba6e22d..0676b57aab1 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Asin/AsinRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Asin/AsinRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action asin"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(AsinRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action asin - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AsinRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class AsinResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Asinh/AsinhRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Asinh/AsinhRequestBuilder.cs index c70cfc95966..2305a428faf 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Asinh/AsinhRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Asinh/AsinhRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action asinh"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(AsinhRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action asinh - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AsinhRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class AsinhResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Atan/AtanRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Atan/AtanRequestBuilder.cs index 1d460163a9f..a258e6ef6f7 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Atan/AtanRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Atan/AtanRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action atan"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(AtanRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action atan - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AtanRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class AtanResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Atan2/Atan2RequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Atan2/Atan2RequestBuilder.cs index 3a138dd7635..607efce90d8 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Atan2/Atan2RequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Atan2/Atan2RequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action atan2"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Atan2RequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action atan2 - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Atan2RequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Atan2Response : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Atanh/AtanhRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Atanh/AtanhRequestBuilder.cs index 538a9203a66..829199e8b6e 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Atanh/AtanhRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Atanh/AtanhRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action atanh"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(AtanhRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action atanh - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AtanhRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class AtanhResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/AveDev/AveDevRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/AveDev/AveDevRequestBuilder.cs index dd539ab1f9a..f459d7451db 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/AveDev/AveDevRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/AveDev/AveDevRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action aveDev"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(AveDevRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action aveDev - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AveDevRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class AveDevResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Average/AverageRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Average/AverageRequestBuilder.cs index d03bf7f270c..71e561ba4fc 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Average/AverageRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Average/AverageRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action average"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(AverageRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action average - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AverageRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class AverageResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/AverageA/AverageARequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/AverageA/AverageARequestBuilder.cs index ba4087e4a79..01e7f868544 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/AverageA/AverageARequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/AverageA/AverageARequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action averageA"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(AverageARequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action averageA - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AverageARequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class AverageAResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/AverageIf/AverageIfRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/AverageIf/AverageIfRequestBuilder.cs index 87d202a8198..90d47a00c60 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/AverageIf/AverageIfRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/AverageIf/AverageIfRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action averageIf"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(AverageIfRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action averageIf - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AverageIfRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class AverageIfResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/AverageIfs/AverageIfsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/AverageIfs/AverageIfsRequestBuilder.cs index d71d8909cb8..aa07107377f 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/AverageIfs/AverageIfsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/AverageIfs/AverageIfsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action averageIfs"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(AverageIfsRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action averageIfs - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AverageIfsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class AverageIfsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/BahtText/BahtTextRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/BahtText/BahtTextRequestBuilder.cs index 7462efc4092..adfc129f3a1 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/BahtText/BahtTextRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/BahtText/BahtTextRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action bahtText"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(BahtTextRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action bahtText - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(BahtTextRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class BahtTextResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/@Base/BaseRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Functions/Base/BaseRequestBody.cs similarity index 97% rename from src/generated/Workbooks/Item/Workbook/Functions/@Base/BaseRequestBody.cs rename to src/generated/Workbooks/Item/Workbook/Functions/Base/BaseRequestBody.cs index 648fa45cd63..3f4e4b78069 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/@Base/BaseRequestBody.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Base/BaseRequestBody.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Functions.@Base { +namespace ApiSdk.Workbooks.Item.Workbook.Functions.Base { public class BaseRequestBody : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Base/BaseRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Base/BaseRequestBuilder.cs new file mode 100644 index 00000000000..b22894692fd --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Functions/Base/BaseRequestBuilder.cs @@ -0,0 +1,115 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Functions.Base { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\functions\microsoft.graph.base + public class BaseRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action base + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action base"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new BaseRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public BaseRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/functions/microsoft.graph.base"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action base + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(BaseRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookFunctionResult + public class BaseResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookFunctionResult + public WorkbookFunctionResult WorkbookFunctionResult { get; set; } + /// + /// Instantiates a new baseResponse and sets the default values. + /// + public BaseResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookFunctionResult", (o,n) => { (o as BaseResponse).WorkbookFunctionResult = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookFunctionResult", WorkbookFunctionResult); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Functions/BesselI/BesselIRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/BesselI/BesselIRequestBuilder.cs index b4104ca1e3f..e089ed43dd2 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/BesselI/BesselIRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/BesselI/BesselIRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action besselI"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(BesselIRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action besselI - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(BesselIRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class BesselIResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/BesselJ/BesselJRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/BesselJ/BesselJRequestBuilder.cs index 9f7d9d2fa45..3c228429cf7 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/BesselJ/BesselJRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/BesselJ/BesselJRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action besselJ"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(BesselJRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action besselJ - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(BesselJRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class BesselJResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/BesselK/BesselKRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/BesselK/BesselKRequestBuilder.cs index a0862a505ef..5a838efc6e0 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/BesselK/BesselKRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/BesselK/BesselKRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action besselK"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(BesselKRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action besselK - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(BesselKRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class BesselKResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/BesselY/BesselYRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/BesselY/BesselYRequestBuilder.cs index c2154d84c27..9a3596fe6f9 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/BesselY/BesselYRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/BesselY/BesselYRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action besselY"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(BesselYRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action besselY - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(BesselYRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class BesselYResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Beta_Dist/Beta_DistRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Beta_Dist/Beta_DistRequestBuilder.cs index 7eb6b6e502b..e8e0e636d1e 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Beta_Dist/Beta_DistRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Beta_Dist/Beta_DistRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action beta_Dist"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Beta_DistRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action beta_Dist - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Beta_DistRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Beta_DistResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Beta_Inv/Beta_InvRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Beta_Inv/Beta_InvRequestBuilder.cs index 6f27fcafab5..b7d1b28a4f6 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Beta_Inv/Beta_InvRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Beta_Inv/Beta_InvRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action beta_Inv"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Beta_InvRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action beta_Inv - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Beta_InvRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Beta_InvResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Bin2Dec/Bin2DecRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Bin2Dec/Bin2DecRequestBuilder.cs index f50772dc21d..23718f21832 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Bin2Dec/Bin2DecRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Bin2Dec/Bin2DecRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action bin2Dec"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Bin2DecRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action bin2Dec - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Bin2DecRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Bin2DecResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Bin2Hex/Bin2HexRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Bin2Hex/Bin2HexRequestBuilder.cs index 46d1843a53c..68895641723 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Bin2Hex/Bin2HexRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Bin2Hex/Bin2HexRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action bin2Hex"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Bin2HexRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action bin2Hex - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Bin2HexRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Bin2HexResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Bin2Oct/Bin2OctRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Bin2Oct/Bin2OctRequestBuilder.cs index db1a4f27376..c2acf78ed5a 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Bin2Oct/Bin2OctRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Bin2Oct/Bin2OctRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action bin2Oct"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Bin2OctRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action bin2Oct - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Bin2OctRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Bin2OctResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Binom_Dist/Binom_DistRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Binom_Dist/Binom_DistRequestBuilder.cs index dde2113039f..79cdac832d6 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Binom_Dist/Binom_DistRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Binom_Dist/Binom_DistRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action binom_Dist"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Binom_DistRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action binom_Dist - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Binom_DistRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Binom_DistResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Binom_Dist_Range/Binom_Dist_RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Binom_Dist_Range/Binom_Dist_RangeRequestBuilder.cs index d12ad409d75..b7a34fa2c77 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Binom_Dist_Range/Binom_Dist_RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Binom_Dist_Range/Binom_Dist_RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action binom_Dist_Range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Binom_Dist_RangeRequestBo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action binom_Dist_Range - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Binom_Dist_RangeRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Binom_Dist_RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Binom_Inv/Binom_InvRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Binom_Inv/Binom_InvRequestBuilder.cs index 0b330e3f479..ed16a72b63d 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Binom_Inv/Binom_InvRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Binom_Inv/Binom_InvRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action binom_Inv"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Binom_InvRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action binom_Inv - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Binom_InvRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Binom_InvResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Bitand/BitandRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Bitand/BitandRequestBuilder.cs index 73f0c4e2b2f..2b7f4b25cf6 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Bitand/BitandRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Bitand/BitandRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action bitand"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(BitandRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action bitand - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(BitandRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class BitandResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Bitlshift/BitlshiftRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Bitlshift/BitlshiftRequestBuilder.cs index ff840d22b69..f73060aac35 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Bitlshift/BitlshiftRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Bitlshift/BitlshiftRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action bitlshift"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(BitlshiftRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action bitlshift - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(BitlshiftRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class BitlshiftResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Bitor/BitorRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Bitor/BitorRequestBuilder.cs index 7ab79959f30..6257571c64e 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Bitor/BitorRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Bitor/BitorRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action bitor"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(BitorRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action bitor - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(BitorRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class BitorResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Bitrshift/BitrshiftRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Bitrshift/BitrshiftRequestBuilder.cs index 788f94b0aa7..ae9cceabb4d 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Bitrshift/BitrshiftRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Bitrshift/BitrshiftRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action bitrshift"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(BitrshiftRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action bitrshift - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(BitrshiftRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class BitrshiftResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Bitxor/BitxorRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Bitxor/BitxorRequestBuilder.cs index 03bc2e77d4d..137f6d06d7d 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Bitxor/BitxorRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Bitxor/BitxorRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action bitxor"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(BitxorRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action bitxor - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(BitxorRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class BitxorResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Ceiling_Math/Ceiling_MathRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Ceiling_Math/Ceiling_MathRequestBuilder.cs index 4d9ef933e54..82c6897d0ee 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Ceiling_Math/Ceiling_MathRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Ceiling_Math/Ceiling_MathRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action ceiling_Math"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Ceiling_MathRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action ceiling_Math - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Ceiling_MathRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Ceiling_MathResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Ceiling_Precise/Ceiling_PreciseRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Ceiling_Precise/Ceiling_PreciseRequestBuilder.cs index ceafa3778a3..a1b587665a0 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Ceiling_Precise/Ceiling_PreciseRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Ceiling_Precise/Ceiling_PreciseRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action ceiling_Precise"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Ceiling_PreciseRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action ceiling_Precise - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Ceiling_PreciseRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Ceiling_PreciseResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/@Char/CharRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Functions/Char/CharRequestBody.cs similarity index 96% rename from src/generated/Workbooks/Item/Workbook/Functions/@Char/CharRequestBody.cs rename to src/generated/Workbooks/Item/Workbook/Functions/Char/CharRequestBody.cs index 8734d6b6db5..45814f4e3e7 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/@Char/CharRequestBody.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Char/CharRequestBody.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Functions.@Char { +namespace ApiSdk.Workbooks.Item.Workbook.Functions.Char { public class CharRequestBody : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Char/CharRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Char/CharRequestBuilder.cs new file mode 100644 index 00000000000..2320c4d590d --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Functions/Char/CharRequestBuilder.cs @@ -0,0 +1,115 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Functions.Char { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\functions\microsoft.graph.char + public class CharRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action char + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action char"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new CharRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public CharRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/functions/microsoft.graph.char"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action char + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(CharRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookFunctionResult + public class CharResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookFunctionResult + public WorkbookFunctionResult WorkbookFunctionResult { get; set; } + /// + /// Instantiates a new charResponse and sets the default values. + /// + public CharResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookFunctionResult", (o,n) => { (o as CharResponse).WorkbookFunctionResult = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookFunctionResult", WorkbookFunctionResult); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ChiSq_Dist/ChiSq_DistRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ChiSq_Dist/ChiSq_DistRequestBuilder.cs index b0ccb6ca279..29c3a02b727 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ChiSq_Dist/ChiSq_DistRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ChiSq_Dist/ChiSq_DistRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action chiSq_Dist"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ChiSq_DistRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action chiSq_Dist - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ChiSq_DistRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ChiSq_DistResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ChiSq_Dist_RT/ChiSq_Dist_RTRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ChiSq_Dist_RT/ChiSq_Dist_RTRequestBuilder.cs index 96b141476d0..fdec509eabb 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ChiSq_Dist_RT/ChiSq_Dist_RTRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ChiSq_Dist_RT/ChiSq_Dist_RTRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action chiSq_Dist_RT"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ChiSq_Dist_RTRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action chiSq_Dist_RT - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ChiSq_Dist_RTRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ChiSq_Dist_RTResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ChiSq_Inv/ChiSq_InvRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ChiSq_Inv/ChiSq_InvRequestBuilder.cs index d70e5455a07..170c48830ee 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ChiSq_Inv/ChiSq_InvRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ChiSq_Inv/ChiSq_InvRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action chiSq_Inv"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ChiSq_InvRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action chiSq_Inv - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ChiSq_InvRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ChiSq_InvResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ChiSq_Inv_RT/ChiSq_Inv_RTRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ChiSq_Inv_RT/ChiSq_Inv_RTRequestBuilder.cs index 0f219d1d038..de1a653a451 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ChiSq_Inv_RT/ChiSq_Inv_RTRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ChiSq_Inv_RT/ChiSq_Inv_RTRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action chiSq_Inv_RT"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ChiSq_Inv_RTRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action chiSq_Inv_RT - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ChiSq_Inv_RTRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ChiSq_Inv_RTResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Choose/ChooseRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Choose/ChooseRequestBuilder.cs index e5c3924514a..f3593cb7266 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Choose/ChooseRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Choose/ChooseRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action choose"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ChooseRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action choose - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ChooseRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ChooseResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Clean/CleanRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Clean/CleanRequestBuilder.cs index 37697f9f4ff..3c6dda9be35 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Clean/CleanRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Clean/CleanRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clean"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CleanRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action clean - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CleanRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class CleanResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Code/CodeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Code/CodeRequestBuilder.cs index e63a841a29e..0a10fff8a02 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Code/CodeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Code/CodeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action code"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CodeRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action code - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CodeRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class CodeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Columns/ColumnsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Columns/ColumnsRequestBuilder.cs index debebccc61d..917866177c7 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Columns/ColumnsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Columns/ColumnsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action columns"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ColumnsRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action columns - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ColumnsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ColumnsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Combin/CombinRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Combin/CombinRequestBuilder.cs index d0f523363a0..def6f75ad0b 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Combin/CombinRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Combin/CombinRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action combin"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CombinRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action combin - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CombinRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class CombinResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Combina/CombinaRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Combina/CombinaRequestBuilder.cs index 140e274816b..80cbcecf37a 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Combina/CombinaRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Combina/CombinaRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action combina"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CombinaRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action combina - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CombinaRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class CombinaResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Complex/ComplexRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Complex/ComplexRequestBuilder.cs index f32a2f2a1c8..358031b996a 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Complex/ComplexRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Complex/ComplexRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action complex"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ComplexRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action complex - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ComplexRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ComplexResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Concatenate/ConcatenateRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Concatenate/ConcatenateRequestBuilder.cs index 93fe4bc9af5..cffe4e204d9 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Concatenate/ConcatenateRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Concatenate/ConcatenateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action concatenate"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ConcatenateRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action concatenate - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ConcatenateRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ConcatenateResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Confidence_Norm/Confidence_NormRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Confidence_Norm/Confidence_NormRequestBuilder.cs index f72ef6a4a03..888906df41a 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Confidence_Norm/Confidence_NormRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Confidence_Norm/Confidence_NormRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action confidence_Norm"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Confidence_NormRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action confidence_Norm - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Confidence_NormRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Confidence_NormResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Confidence_T/Confidence_TRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Confidence_T/Confidence_TRequestBuilder.cs index 79a37502a50..66f952175d0 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Confidence_T/Confidence_TRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Confidence_T/Confidence_TRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action confidence_T"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Confidence_TRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action confidence_T - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Confidence_TRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Confidence_TResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Convert/ConvertRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Convert/ConvertRequestBuilder.cs index 96681d49b72..bccb4a88bf2 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Convert/ConvertRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Convert/ConvertRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action convert"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ConvertRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action convert - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ConvertRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ConvertResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Cos/CosRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Cos/CosRequestBuilder.cs index 9c8e95e239e..d649baab25a 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Cos/CosRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Cos/CosRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action cos"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CosRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cos - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CosRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class CosResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Cosh/CoshRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Cosh/CoshRequestBuilder.cs index 7d04aaefd81..13e4c445ca2 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Cosh/CoshRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Cosh/CoshRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action cosh"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CoshRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cosh - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CoshRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class CoshResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Cot/CotRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Cot/CotRequestBuilder.cs index e20a42b6b67..508b80e5054 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Cot/CotRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Cot/CotRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action cot"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CotRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cot - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CotRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class CotResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Coth/CothRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Coth/CothRequestBuilder.cs index 91549404493..7a4a10aa090 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Coth/CothRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Coth/CothRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action coth"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CothRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action coth - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CothRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class CothResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Count/CountRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Count/CountRequestBuilder.cs index c2613000256..f9021543b8d 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Count/CountRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Count/CountRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action count"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CountRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action count - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CountRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class CountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/CountA/CountARequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/CountA/CountARequestBuilder.cs index 036a418622b..fe305915dd0 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/CountA/CountARequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/CountA/CountARequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action countA"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CountARequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action countA - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CountARequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class CountAResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/CountBlank/CountBlankRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/CountBlank/CountBlankRequestBuilder.cs index e99752875fa..2b3c4efb9b4 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/CountBlank/CountBlankRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/CountBlank/CountBlankRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action countBlank"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CountBlankRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action countBlank - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CountBlankRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class CountBlankResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/CountIf/CountIfRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/CountIf/CountIfRequestBuilder.cs index bfe4ffc69aa..578589fbbc0 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/CountIf/CountIfRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/CountIf/CountIfRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action countIf"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CountIfRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action countIf - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CountIfRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class CountIfResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/CountIfs/CountIfsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/CountIfs/CountIfsRequestBuilder.cs index 93f771aa290..ede77e59ede 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/CountIfs/CountIfsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/CountIfs/CountIfsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action countIfs"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CountIfsRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action countIfs - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CountIfsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class CountIfsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/CoupDayBs/CoupDayBsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/CoupDayBs/CoupDayBsRequestBuilder.cs index 946d9a5cb44..d7332df8527 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/CoupDayBs/CoupDayBsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/CoupDayBs/CoupDayBsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action coupDayBs"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CoupDayBsRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action coupDayBs - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CoupDayBsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class CoupDayBsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/CoupDays/CoupDaysRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/CoupDays/CoupDaysRequestBuilder.cs index 56cefcb90a7..230d390c38c 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/CoupDays/CoupDaysRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/CoupDays/CoupDaysRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action coupDays"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CoupDaysRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action coupDays - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CoupDaysRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class CoupDaysResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/CoupDaysNc/CoupDaysNcRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/CoupDaysNc/CoupDaysNcRequestBuilder.cs index 3e61607c94d..dfb4509889f 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/CoupDaysNc/CoupDaysNcRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/CoupDaysNc/CoupDaysNcRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action coupDaysNc"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CoupDaysNcRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action coupDaysNc - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CoupDaysNcRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class CoupDaysNcResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/CoupNcd/CoupNcdRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/CoupNcd/CoupNcdRequestBuilder.cs index d33ce72350d..5b7e0599825 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/CoupNcd/CoupNcdRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/CoupNcd/CoupNcdRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action coupNcd"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CoupNcdRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action coupNcd - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CoupNcdRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class CoupNcdResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/CoupNum/CoupNumRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/CoupNum/CoupNumRequestBuilder.cs index b791717e882..a951009538b 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/CoupNum/CoupNumRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/CoupNum/CoupNumRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action coupNum"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CoupNumRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action coupNum - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CoupNumRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class CoupNumResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/CoupPcd/CoupPcdRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/CoupPcd/CoupPcdRequestBuilder.cs index cf0ecb7a010..5cd62f37242 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/CoupPcd/CoupPcdRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/CoupPcd/CoupPcdRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action coupPcd"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CoupPcdRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action coupPcd - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CoupPcdRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class CoupPcdResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Csc/CscRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Csc/CscRequestBuilder.cs index f5803957cdb..995f2f5b7a6 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Csc/CscRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Csc/CscRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action csc"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CscRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action csc - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CscRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class CscResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Csch/CschRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Csch/CschRequestBuilder.cs index 963c906f9a8..0c65887813a 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Csch/CschRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Csch/CschRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action csch"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CschRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action csch - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CschRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class CschResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/CumIPmt/CumIPmtRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/CumIPmt/CumIPmtRequestBuilder.cs index e3e42f2ddee..1291c842b03 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/CumIPmt/CumIPmtRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/CumIPmt/CumIPmtRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action cumIPmt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CumIPmtRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cumIPmt - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CumIPmtRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class CumIPmtResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/CumPrinc/CumPrincRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/CumPrinc/CumPrincRequestBuilder.cs index fe112179799..ac05fa8ed97 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/CumPrinc/CumPrincRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/CumPrinc/CumPrincRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action cumPrinc"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(CumPrincRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action cumPrinc - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(CumPrincRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class CumPrincResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Date/DateRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Date/DateRequestBuilder.cs index 2109e147ef2..6eff565e74f 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Date/DateRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Date/DateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action date"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(DateRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action date - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DateRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class DateResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Datevalue/DatevalueRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Datevalue/DatevalueRequestBuilder.cs index 6f1c855925e..65c46420f6e 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Datevalue/DatevalueRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Datevalue/DatevalueRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action datevalue"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(DatevalueRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action datevalue - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DatevalueRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class DatevalueResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Daverage/DaverageRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Daverage/DaverageRequestBuilder.cs index 49a9752601e..0aa6b13495f 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Daverage/DaverageRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Daverage/DaverageRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action daverage"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(DaverageRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action daverage - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DaverageRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class DaverageResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Day/DayRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Day/DayRequestBuilder.cs index b14ea6f3a93..3f10e47c516 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Day/DayRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Day/DayRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action day"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(DayRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action day - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DayRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class DayResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Days/DaysRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Days/DaysRequestBuilder.cs index 2d64a1edaef..28da0f74050 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Days/DaysRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Days/DaysRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action days"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(DaysRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action days - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DaysRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class DaysResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Days360/Days360RequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Days360/Days360RequestBuilder.cs index a9209e99d49..9e88fd4bac2 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Days360/Days360RequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Days360/Days360RequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action days360"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Days360RequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action days360 - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Days360RequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Days360Response : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Db/DbRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Db/DbRequestBuilder.cs index 2aa79003c3d..5e2410ea21e 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Db/DbRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Db/DbRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action db"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(DbRequestBody body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action db - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DbRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class DbResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Dbcs/DbcsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Dbcs/DbcsRequestBuilder.cs index f9c7c029c41..b438c03bd80 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Dbcs/DbcsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Dbcs/DbcsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action dbcs"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(DbcsRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action dbcs - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DbcsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class DbcsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Dcount/DcountRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Dcount/DcountRequestBuilder.cs index c49bb78770c..f41fa49d514 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Dcount/DcountRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Dcount/DcountRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action dcount"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(DcountRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action dcount - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DcountRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class DcountResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/DcountA/DcountARequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/DcountA/DcountARequestBuilder.cs index 5d22f722190..7ebb4875787 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/DcountA/DcountARequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/DcountA/DcountARequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action dcountA"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(DcountARequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action dcountA - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DcountARequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class DcountAResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Ddb/DdbRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Ddb/DdbRequestBuilder.cs index 194640d0247..b5bdb257f85 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Ddb/DdbRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Ddb/DdbRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action ddb"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(DdbRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action ddb - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DdbRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class DdbResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Dec2Bin/Dec2BinRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Dec2Bin/Dec2BinRequestBuilder.cs index c22cef533ac..17adf05b412 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Dec2Bin/Dec2BinRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Dec2Bin/Dec2BinRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action dec2Bin"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Dec2BinRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action dec2Bin - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Dec2BinRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Dec2BinResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Dec2Hex/Dec2HexRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Dec2Hex/Dec2HexRequestBuilder.cs index 34d34423649..d39ba3599f4 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Dec2Hex/Dec2HexRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Dec2Hex/Dec2HexRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action dec2Hex"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Dec2HexRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action dec2Hex - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Dec2HexRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Dec2HexResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Dec2Oct/Dec2OctRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Dec2Oct/Dec2OctRequestBuilder.cs index 87661e369fc..821519e9b68 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Dec2Oct/Dec2OctRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Dec2Oct/Dec2OctRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action dec2Oct"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Dec2OctRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action dec2Oct - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Dec2OctRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Dec2OctResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/@Decimal/DecimalRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Functions/Decimal/DecimalRequestBody.cs similarity index 96% rename from src/generated/Workbooks/Item/Workbook/Functions/@Decimal/DecimalRequestBody.cs rename to src/generated/Workbooks/Item/Workbook/Functions/Decimal/DecimalRequestBody.cs index d9b9a52f1d0..f6c78852eb2 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/@Decimal/DecimalRequestBody.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Decimal/DecimalRequestBody.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Functions.@Decimal { +namespace ApiSdk.Workbooks.Item.Workbook.Functions.Decimal { public class DecimalRequestBody : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Decimal/DecimalRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Decimal/DecimalRequestBuilder.cs new file mode 100644 index 00000000000..640332f5c73 --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Functions/Decimal/DecimalRequestBuilder.cs @@ -0,0 +1,115 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Functions.Decimal { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\functions\microsoft.graph.decimal + public class DecimalRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action decimal + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action decimal"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new DecimalRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public DecimalRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/functions/microsoft.graph.decimal"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action decimal + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(DecimalRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookFunctionResult + public class DecimalResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookFunctionResult + public WorkbookFunctionResult WorkbookFunctionResult { get; set; } + /// + /// Instantiates a new decimalResponse and sets the default values. + /// + public DecimalResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookFunctionResult", (o,n) => { (o as DecimalResponse).WorkbookFunctionResult = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookFunctionResult", WorkbookFunctionResult); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Degrees/DegreesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Degrees/DegreesRequestBuilder.cs index 7ec72aaed22..c91df0c5dd2 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Degrees/DegreesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Degrees/DegreesRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action degrees"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(DegreesRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action degrees - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DegreesRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class DegreesResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Delta/DeltaRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Delta/DeltaRequestBuilder.cs index 14287397d45..2faad494902 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Delta/DeltaRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Delta/DeltaRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action delta"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(DeltaRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action delta - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DeltaRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class DeltaResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/DevSq/DevSqRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/DevSq/DevSqRequestBuilder.cs index fb8d3962bd2..05fef427c1d 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/DevSq/DevSqRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/DevSq/DevSqRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action devSq"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(DevSqRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action devSq - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DevSqRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class DevSqResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Dget/DgetRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Dget/DgetRequestBuilder.cs index 081245bca32..ee9963cebc4 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Dget/DgetRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Dget/DgetRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action dget"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(DgetRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action dget - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DgetRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class DgetResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Disc/DiscRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Disc/DiscRequestBuilder.cs index b04b134f99b..a890c435575 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Disc/DiscRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Disc/DiscRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action disc"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(DiscRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action disc - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DiscRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class DiscResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Dmax/DmaxRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Dmax/DmaxRequestBuilder.cs index df206d2211f..a7380bbb692 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Dmax/DmaxRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Dmax/DmaxRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action dmax"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(DmaxRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action dmax - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DmaxRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class DmaxResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Dmin/DminRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Dmin/DminRequestBuilder.cs index b5b9e00f149..f6379d2ef86 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Dmin/DminRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Dmin/DminRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action dmin"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(DminRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action dmin - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DminRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class DminResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Dollar/DollarRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Dollar/DollarRequestBuilder.cs index b33ea437dd1..60f65c35c9c 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Dollar/DollarRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Dollar/DollarRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action dollar"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(DollarRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action dollar - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DollarRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class DollarResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/DollarDe/DollarDeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/DollarDe/DollarDeRequestBuilder.cs index 4caf6f8a609..d0de029ba05 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/DollarDe/DollarDeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/DollarDe/DollarDeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action dollarDe"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(DollarDeRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action dollarDe - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DollarDeRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class DollarDeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/DollarFr/DollarFrRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/DollarFr/DollarFrRequestBuilder.cs index 4cc8f9bd328..53668abb1e5 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/DollarFr/DollarFrRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/DollarFr/DollarFrRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action dollarFr"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(DollarFrRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action dollarFr - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DollarFrRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class DollarFrResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Dproduct/DproductRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Dproduct/DproductRequestBuilder.cs index ea76bf46dac..2dc6d3912e8 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Dproduct/DproductRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Dproduct/DproductRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action dproduct"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(DproductRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action dproduct - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DproductRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class DproductResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/DstDev/DstDevRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/DstDev/DstDevRequestBuilder.cs index 3a2a4acbe14..ff03a61eb54 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/DstDev/DstDevRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/DstDev/DstDevRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action dstDev"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(DstDevRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action dstDev - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DstDevRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class DstDevResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/DstDevP/DstDevPRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/DstDevP/DstDevPRequestBuilder.cs index cf5894f4f81..ee700a3adb0 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/DstDevP/DstDevPRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/DstDevP/DstDevPRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action dstDevP"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(DstDevPRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action dstDevP - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DstDevPRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class DstDevPResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Dsum/DsumRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Dsum/DsumRequestBuilder.cs index 63f09a19342..6c5c5b01bdf 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Dsum/DsumRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Dsum/DsumRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action dsum"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(DsumRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action dsum - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DsumRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class DsumResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Duration/DurationRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Duration/DurationRequestBuilder.cs index 8e1de1fcb92..3e214c4bc44 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Duration/DurationRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Duration/DurationRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action duration"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(DurationRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action duration - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DurationRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class DurationResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Dvar/DvarRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Dvar/DvarRequestBuilder.cs index b3e1c546915..a257a066b44 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Dvar/DvarRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Dvar/DvarRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action dvar"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(DvarRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action dvar - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DvarRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class DvarResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/DvarP/DvarPRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/DvarP/DvarPRequestBuilder.cs index 8f4cc98b9be..d83279aa2ff 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/DvarP/DvarPRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/DvarP/DvarPRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action dvarP"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(DvarPRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action dvarP - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(DvarPRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class DvarPResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Ecma_Ceiling/Ecma_CeilingRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Ecma_Ceiling/Ecma_CeilingRequestBuilder.cs index 7c4c45b5f7f..2ba04134d2d 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Ecma_Ceiling/Ecma_CeilingRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Ecma_Ceiling/Ecma_CeilingRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action ecma_Ceiling"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Ecma_CeilingRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action ecma_Ceiling - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Ecma_CeilingRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Ecma_CeilingResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Edate/EdateRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Edate/EdateRequestBuilder.cs index 8ea86f65a45..5b5248c4ecd 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Edate/EdateRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Edate/EdateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action edate"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(EdateRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action edate - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EdateRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class EdateResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Effect/EffectRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Effect/EffectRequestBuilder.cs index 3c4879503a0..2bfdcd89604 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Effect/EffectRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Effect/EffectRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action effect"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(EffectRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action effect - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EffectRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class EffectResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/EoMonth/EoMonthRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/EoMonth/EoMonthRequestBuilder.cs index d988892cfd8..81707c95543 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/EoMonth/EoMonthRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/EoMonth/EoMonthRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action eoMonth"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(EoMonthRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action eoMonth - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EoMonthRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class EoMonthResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Erf/ErfRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Erf/ErfRequestBuilder.cs index 928790c013b..796e86909ee 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Erf/ErfRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Erf/ErfRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action erf"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ErfRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action erf - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ErfRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ErfResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ErfC/ErfCRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ErfC/ErfCRequestBuilder.cs index 4e0b9e9eaf8..2d253ba58f5 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ErfC/ErfCRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ErfC/ErfCRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action erfC"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ErfCRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action erfC - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ErfCRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ErfCResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ErfC_Precise/ErfC_PreciseRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ErfC_Precise/ErfC_PreciseRequestBuilder.cs index aae5b2611c6..0079e027177 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ErfC_Precise/ErfC_PreciseRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ErfC_Precise/ErfC_PreciseRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action erfC_Precise"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ErfC_PreciseRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action erfC_Precise - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ErfC_PreciseRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ErfC_PreciseResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Erf_Precise/Erf_PreciseRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Erf_Precise/Erf_PreciseRequestBuilder.cs index e302f322de2..c11ca38ef2e 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Erf_Precise/Erf_PreciseRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Erf_Precise/Erf_PreciseRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action erf_Precise"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Erf_PreciseRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action erf_Precise - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Erf_PreciseRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Erf_PreciseResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Error_Type/Error_TypeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Error_Type/Error_TypeRequestBuilder.cs index 8dd55255182..6409e14d690 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Error_Type/Error_TypeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Error_Type/Error_TypeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action error_Type"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Error_TypeRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action error_Type - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Error_TypeRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Error_TypeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Even/EvenRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Even/EvenRequestBuilder.cs index 83a1c4caf61..448ae21d22c 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Even/EvenRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Even/EvenRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action even"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(EvenRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action even - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(EvenRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class EvenResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Exact/ExactRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Exact/ExactRequestBuilder.cs index efb6a01eac1..65ba6a0d8c6 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Exact/ExactRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Exact/ExactRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action exact"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ExactRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action exact - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ExactRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ExactResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Exp/ExpRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Exp/ExpRequestBuilder.cs index 841736a39c1..6b633a50a53 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Exp/ExpRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Exp/ExpRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action exp"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ExpRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action exp - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ExpRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ExpResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Expon_Dist/Expon_DistRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Expon_Dist/Expon_DistRequestBuilder.cs index a3ad4c9077d..e184a78058e 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Expon_Dist/Expon_DistRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Expon_Dist/Expon_DistRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action expon_Dist"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Expon_DistRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action expon_Dist - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Expon_DistRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Expon_DistResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/F_Dist/F_DistRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/F_Dist/F_DistRequestBuilder.cs index e92633b8285..5e550773b4d 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/F_Dist/F_DistRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/F_Dist/F_DistRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action f_Dist"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(F_DistRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action f_Dist - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(F_DistRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class F_DistResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/F_Dist_RT/F_Dist_RTRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/F_Dist_RT/F_Dist_RTRequestBuilder.cs index 4b887cf5d24..10cdcecb6ca 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/F_Dist_RT/F_Dist_RTRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/F_Dist_RT/F_Dist_RTRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action f_Dist_RT"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(F_Dist_RTRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action f_Dist_RT - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(F_Dist_RTRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class F_Dist_RTResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/F_Inv/F_InvRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/F_Inv/F_InvRequestBuilder.cs index b71d1a0c5c7..763bd8c6eda 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/F_Inv/F_InvRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/F_Inv/F_InvRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action f_Inv"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(F_InvRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action f_Inv - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(F_InvRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class F_InvResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/F_Inv_RT/F_Inv_RTRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/F_Inv_RT/F_Inv_RTRequestBuilder.cs index 0c56dbed1fc..3b5fb8ef380 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/F_Inv_RT/F_Inv_RTRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/F_Inv_RT/F_Inv_RTRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action f_Inv_RT"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(F_Inv_RTRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action f_Inv_RT - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(F_Inv_RTRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class F_Inv_RTResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Fact/FactRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Fact/FactRequestBuilder.cs index 0e07646c026..0fa0bbdce7c 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Fact/FactRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Fact/FactRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action fact"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(FactRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action fact - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(FactRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class FactResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/FactDouble/FactDoubleRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/FactDouble/FactDoubleRequestBuilder.cs index 87d8a5a7513..eca8eeb7517 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/FactDouble/FactDoubleRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/FactDouble/FactDoubleRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action factDouble"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(FactDoubleRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action factDouble - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(FactDoubleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class FactDoubleResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/False/FalseRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/False/FalseRequestBuilder.cs new file mode 100644 index 00000000000..e5b2484928a --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Functions/False/FalseRequestBuilder.cs @@ -0,0 +1,105 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Functions.False { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\functions\microsoft.graph.false + public class FalseRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action false + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action false"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreatePostRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, outputOption); + return command; + } + /// + /// Instantiates a new FalseRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public FalseRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/functions/microsoft.graph.false"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action false + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookFunctionResult + public class FalseResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookFunctionResult + public WorkbookFunctionResult WorkbookFunctionResult { get; set; } + /// + /// Instantiates a new falseResponse and sets the default values. + /// + public FalseResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookFunctionResult", (o,n) => { (o as FalseResponse).WorkbookFunctionResult = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookFunctionResult", WorkbookFunctionResult); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Find/FindRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Find/FindRequestBuilder.cs index d8f8eda727f..15d097defeb 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Find/FindRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Find/FindRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action find"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(FindRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action find - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(FindRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class FindResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/FindB/FindBRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/FindB/FindBRequestBuilder.cs index 2fe8b84412b..d705c645cb9 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/FindB/FindBRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/FindB/FindBRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action findB"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(FindBRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action findB - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(FindBRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class FindBResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Fisher/FisherRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Fisher/FisherRequestBuilder.cs index 86b08f218e4..4f3f7ca243b 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Fisher/FisherRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Fisher/FisherRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action fisher"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(FisherRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action fisher - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(FisherRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class FisherResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/FisherInv/FisherInvRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/FisherInv/FisherInvRequestBuilder.cs index 85b30d02d88..0565dce91ee 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/FisherInv/FisherInvRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/FisherInv/FisherInvRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action fisherInv"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(FisherInvRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action fisherInv - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(FisherInvRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class FisherInvResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/@Fixed/FixedRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Functions/Fixed/FixedRequestBody.cs similarity index 97% rename from src/generated/Workbooks/Item/Workbook/Functions/@Fixed/FixedRequestBody.cs rename to src/generated/Workbooks/Item/Workbook/Functions/Fixed/FixedRequestBody.cs index 961c3e2f770..56566d0d4c4 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/@Fixed/FixedRequestBody.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Fixed/FixedRequestBody.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Functions.@Fixed { +namespace ApiSdk.Workbooks.Item.Workbook.Functions.Fixed { public class FixedRequestBody : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Fixed/FixedRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Fixed/FixedRequestBuilder.cs new file mode 100644 index 00000000000..207dd19d34a --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Functions/Fixed/FixedRequestBuilder.cs @@ -0,0 +1,115 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Functions.Fixed { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\functions\microsoft.graph.fixed + public class FixedRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action fixed + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action fixed"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new FixedRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public FixedRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/functions/microsoft.graph.fixed"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action fixed + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(FixedRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookFunctionResult + public class FixedResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookFunctionResult + public WorkbookFunctionResult WorkbookFunctionResult { get; set; } + /// + /// Instantiates a new fixedResponse and sets the default values. + /// + public FixedResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookFunctionResult", (o,n) => { (o as FixedResponse).WorkbookFunctionResult = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookFunctionResult", WorkbookFunctionResult); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Floor_Math/Floor_MathRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Floor_Math/Floor_MathRequestBuilder.cs index ce776005a5a..2b219e732b7 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Floor_Math/Floor_MathRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Floor_Math/Floor_MathRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action floor_Math"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Floor_MathRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action floor_Math - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Floor_MathRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Floor_MathResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Floor_Precise/Floor_PreciseRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Floor_Precise/Floor_PreciseRequestBuilder.cs index 3214a4e7bb8..8a7455b4647 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Floor_Precise/Floor_PreciseRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Floor_Precise/Floor_PreciseRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action floor_Precise"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Floor_PreciseRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action floor_Precise - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Floor_PreciseRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Floor_PreciseResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/FunctionsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/FunctionsRequestBuilder.cs index bd1927f178f..f82e3aa6591 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/FunctionsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/FunctionsRequestBuilder.cs @@ -367,10 +367,10 @@ using ApiSdk.Workbooks.Item.Workbook.Functions.Z_Test; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -441,7 +441,7 @@ public Command BuildAmorLincCommand() { } public Command BuildAndCommand() { var command = new Command("and"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Functions.@And.AndRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Functions.And.AndRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } @@ -531,7 +531,7 @@ public Command BuildBahtTextCommand() { } public Command BuildBaseCommand() { var command = new Command("base"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Functions.@Base.BaseRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Functions.Base.BaseRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } @@ -651,7 +651,7 @@ public Command BuildCeiling_PreciseCommand() { } public Command BuildCharCommand() { var command = new Command("char"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Functions.@Char.CharRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Functions.Char.CharRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } @@ -945,7 +945,7 @@ public Command BuildDec2OctCommand() { } public Command BuildDecimalCommand() { var command = new Command("decimal"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Functions.@Decimal.DecimalRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Functions.Decimal.DecimalRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } @@ -962,15 +962,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Delete navigation property functions for workbooks"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { + command.SetHandler(async (string driveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption); return command; @@ -1187,7 +1186,7 @@ public Command BuildFactDoubleCommand() { } public Command BuildFalseCommand() { var command = new Command("false"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Functions.@False.FalseRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Functions.False.FalseRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } @@ -1217,7 +1216,7 @@ public Command BuildFisherInvCommand() { } public Command BuildFixedCommand() { var command = new Command("fixed"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Functions.@Fixed.FixedRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Functions.Fixed.FixedRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } @@ -1306,7 +1305,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Get functions from workbooks"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -1320,20 +1319,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildHarMeanCommand() { @@ -1386,7 +1384,7 @@ public Command BuildHypGeom_DistCommand() { } public Command BuildIfCommand() { var command = new Command("if"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Functions.@If.IfRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Functions.If.IfRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } @@ -1542,7 +1540,7 @@ public Command BuildImTanCommand() { } public Command BuildIntCommand() { var command = new Command("int"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Functions.@Int.IntRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Functions.Int.IntRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } @@ -1884,7 +1882,7 @@ public Command BuildNorm_S_InvCommand() { } public Command BuildNotCommand() { var command = new Command("not"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Functions.@Not.NotRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Functions.Not.NotRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } @@ -1962,7 +1960,7 @@ public Command BuildOddLYieldCommand() { } public Command BuildOrCommand() { var command = new Command("or"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Functions.@Or.OrRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Functions.Or.OrRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } @@ -1973,7 +1971,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Update the navigation property functions in workbooks"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -1981,14 +1979,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + command.SetHandler(async (string driveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, bodyOption); return command; @@ -2499,7 +2496,7 @@ public Command BuildTrimMeanCommand() { } public Command BuildTrueCommand() { var command = new Command("true"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Functions.@True.TrueRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Functions.True.TrueRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } @@ -2643,7 +2640,7 @@ public Command BuildYearFracCommand() { } public Command BuildYieldCommand() { var command = new Command("yield"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Functions.@Yield.YieldRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Functions.Yield.YieldRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } @@ -2732,42 +2729,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookFunctions body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Delete navigation property functions for workbooks - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Get functions from workbooks - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Update the navigation property functions in workbooks - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookFunctions model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Get functions from workbooks public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Fv/FvRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Fv/FvRequestBuilder.cs index 17395f61b4b..ea6ab39d8b4 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Fv/FvRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Fv/FvRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action fv"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(FvRequestBody body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action fv - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(FvRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class FvResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Fvschedule/FvscheduleRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Fvschedule/FvscheduleRequestBuilder.cs index 78223a32476..0e452c99a72 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Fvschedule/FvscheduleRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Fvschedule/FvscheduleRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action fvschedule"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(FvscheduleRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action fvschedule - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(FvscheduleRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class FvscheduleResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Gamma/GammaRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Gamma/GammaRequestBuilder.cs index 30df1606b2d..a36dde544d5 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Gamma/GammaRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Gamma/GammaRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action gamma"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(GammaRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action gamma - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GammaRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class GammaResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/GammaLn/GammaLnRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/GammaLn/GammaLnRequestBuilder.cs index c821364d226..5fdf9176b59 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/GammaLn/GammaLnRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/GammaLn/GammaLnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action gammaLn"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(GammaLnRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action gammaLn - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GammaLnRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class GammaLnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/GammaLn_Precise/GammaLn_PreciseRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/GammaLn_Precise/GammaLn_PreciseRequestBuilder.cs index da6f2f310b5..7389afcc88c 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/GammaLn_Precise/GammaLn_PreciseRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/GammaLn_Precise/GammaLn_PreciseRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action gammaLn_Precise"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(GammaLn_PreciseRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action gammaLn_Precise - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GammaLn_PreciseRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class GammaLn_PreciseResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Gamma_Dist/Gamma_DistRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Gamma_Dist/Gamma_DistRequestBuilder.cs index 73bd8504b58..c16f03db225 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Gamma_Dist/Gamma_DistRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Gamma_Dist/Gamma_DistRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action gamma_Dist"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Gamma_DistRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action gamma_Dist - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Gamma_DistRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Gamma_DistResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Gamma_Inv/Gamma_InvRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Gamma_Inv/Gamma_InvRequestBuilder.cs index 76e0f43ca46..87e699d08b2 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Gamma_Inv/Gamma_InvRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Gamma_Inv/Gamma_InvRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action gamma_Inv"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Gamma_InvRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action gamma_Inv - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Gamma_InvRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Gamma_InvResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Gauss/GaussRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Gauss/GaussRequestBuilder.cs index 0840060f443..b7cb6c9d812 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Gauss/GaussRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Gauss/GaussRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action gauss"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(GaussRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action gauss - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GaussRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class GaussResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Gcd/GcdRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Gcd/GcdRequestBuilder.cs index c156beda0d9..ed22c7e82fc 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Gcd/GcdRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Gcd/GcdRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action gcd"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(GcdRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action gcd - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GcdRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class GcdResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/GeStep/GeStepRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/GeStep/GeStepRequestBuilder.cs index d9bf773d3df..804c5c1d74e 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/GeStep/GeStepRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/GeStep/GeStepRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action geStep"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(GeStepRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action geStep - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GeStepRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class GeStepResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/GeoMean/GeoMeanRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/GeoMean/GeoMeanRequestBuilder.cs index 324683f67de..42ea9268249 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/GeoMean/GeoMeanRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/GeoMean/GeoMeanRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action geoMean"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(GeoMeanRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action geoMean - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(GeoMeanRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class GeoMeanResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/HarMean/HarMeanRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/HarMean/HarMeanRequestBuilder.cs index 5e6a90926bb..c8226eb0df1 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/HarMean/HarMeanRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/HarMean/HarMeanRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action harMean"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(HarMeanRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action harMean - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(HarMeanRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class HarMeanResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Hex2Bin/Hex2BinRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Hex2Bin/Hex2BinRequestBuilder.cs index a9a547789b9..53007911a47 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Hex2Bin/Hex2BinRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Hex2Bin/Hex2BinRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action hex2Bin"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Hex2BinRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action hex2Bin - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Hex2BinRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Hex2BinResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Hex2Dec/Hex2DecRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Hex2Dec/Hex2DecRequestBuilder.cs index 1f9770b92dd..679bf88f0c7 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Hex2Dec/Hex2DecRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Hex2Dec/Hex2DecRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action hex2Dec"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Hex2DecRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action hex2Dec - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Hex2DecRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Hex2DecResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Hex2Oct/Hex2OctRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Hex2Oct/Hex2OctRequestBuilder.cs index c713e1aae35..a9a784f4abc 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Hex2Oct/Hex2OctRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Hex2Oct/Hex2OctRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action hex2Oct"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Hex2OctRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action hex2Oct - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Hex2OctRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Hex2OctResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Hlookup/HlookupRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Hlookup/HlookupRequestBuilder.cs index 904592d5666..7226965ac84 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Hlookup/HlookupRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Hlookup/HlookupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action hlookup"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(HlookupRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action hlookup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(HlookupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class HlookupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Hour/HourRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Hour/HourRequestBuilder.cs index e323d117a89..b36f6fa1b50 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Hour/HourRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Hour/HourRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action hour"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(HourRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action hour - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(HourRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class HourResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/HypGeom_Dist/HypGeom_DistRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/HypGeom_Dist/HypGeom_DistRequestBuilder.cs index e99ad2c7dd6..b3e8cb816b7 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/HypGeom_Dist/HypGeom_DistRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/HypGeom_Dist/HypGeom_DistRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action hypGeom_Dist"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(HypGeom_DistRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action hypGeom_Dist - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(HypGeom_DistRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class HypGeom_DistResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Hyperlink/HyperlinkRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Hyperlink/HyperlinkRequestBuilder.cs index 19986d04a6c..635fd820324 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Hyperlink/HyperlinkRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Hyperlink/HyperlinkRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action hyperlink"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(HyperlinkRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action hyperlink - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(HyperlinkRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class HyperlinkResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/@If/IfRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Functions/If/IfRequestBody.cs similarity index 97% rename from src/generated/Workbooks/Item/Workbook/Functions/@If/IfRequestBody.cs rename to src/generated/Workbooks/Item/Workbook/Functions/If/IfRequestBody.cs index 7e196a85c04..76453f89c79 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/@If/IfRequestBody.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/If/IfRequestBody.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Functions.@If { +namespace ApiSdk.Workbooks.Item.Workbook.Functions.If { public class IfRequestBody : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } diff --git a/src/generated/Workbooks/Item/Workbook/Functions/If/IfRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/If/IfRequestBuilder.cs new file mode 100644 index 00000000000..a771c59871c --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Functions/If/IfRequestBuilder.cs @@ -0,0 +1,115 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Functions.If { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\functions\microsoft.graph.if + public class IfRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action if + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action if"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new IfRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public IfRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/functions/microsoft.graph.if"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action if + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(IfRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookFunctionResult + public class IfResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookFunctionResult + public WorkbookFunctionResult WorkbookFunctionResult { get; set; } + /// + /// Instantiates a new ifResponse and sets the default values. + /// + public IfResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookFunctionResult", (o,n) => { (o as IfResponse).WorkbookFunctionResult = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookFunctionResult", WorkbookFunctionResult); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ImAbs/ImAbsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ImAbs/ImAbsRequestBuilder.cs index cf96bc9ca34..707228078f9 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ImAbs/ImAbsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ImAbs/ImAbsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action imAbs"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ImAbsRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action imAbs - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ImAbsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ImAbsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ImArgument/ImArgumentRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ImArgument/ImArgumentRequestBuilder.cs index a5c88b8c655..101c9f2c3f2 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ImArgument/ImArgumentRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ImArgument/ImArgumentRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action imArgument"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ImArgumentRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action imArgument - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ImArgumentRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ImArgumentResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ImConjugate/ImConjugateRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ImConjugate/ImConjugateRequestBuilder.cs index 2a79602e765..13226654cc7 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ImConjugate/ImConjugateRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ImConjugate/ImConjugateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action imConjugate"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ImConjugateRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action imConjugate - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ImConjugateRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ImConjugateResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ImCos/ImCosRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ImCos/ImCosRequestBuilder.cs index 14daba9fc71..e22e88d42a6 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ImCos/ImCosRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ImCos/ImCosRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action imCos"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ImCosRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action imCos - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ImCosRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ImCosResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ImCosh/ImCoshRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ImCosh/ImCoshRequestBuilder.cs index 281efe6059d..900e7d74bf1 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ImCosh/ImCoshRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ImCosh/ImCoshRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action imCosh"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ImCoshRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action imCosh - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ImCoshRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ImCoshResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ImCot/ImCotRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ImCot/ImCotRequestBuilder.cs index 6a582055146..1cb4ad151ab 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ImCot/ImCotRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ImCot/ImCotRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action imCot"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ImCotRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action imCot - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ImCotRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ImCotResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ImCsc/ImCscRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ImCsc/ImCscRequestBuilder.cs index 037fcfee6d7..1736093e84a 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ImCsc/ImCscRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ImCsc/ImCscRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action imCsc"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ImCscRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action imCsc - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ImCscRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ImCscResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ImCsch/ImCschRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ImCsch/ImCschRequestBuilder.cs index b89193b8232..56b0b9fd332 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ImCsch/ImCschRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ImCsch/ImCschRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action imCsch"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ImCschRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action imCsch - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ImCschRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ImCschResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ImDiv/ImDivRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ImDiv/ImDivRequestBuilder.cs index 85019545cc0..f775068afe9 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ImDiv/ImDivRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ImDiv/ImDivRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action imDiv"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ImDivRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action imDiv - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ImDivRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ImDivResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ImExp/ImExpRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ImExp/ImExpRequestBuilder.cs index 9d1d5231d44..438a686182b 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ImExp/ImExpRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ImExp/ImExpRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action imExp"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ImExpRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action imExp - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ImExpRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ImExpResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ImLn/ImLnRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ImLn/ImLnRequestBuilder.cs index 5dcd16a5d15..da6924b87b4 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ImLn/ImLnRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ImLn/ImLnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action imLn"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ImLnRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action imLn - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ImLnRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ImLnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ImLog10/ImLog10RequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ImLog10/ImLog10RequestBuilder.cs index f15c7f9e46a..13c1f42df0b 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ImLog10/ImLog10RequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ImLog10/ImLog10RequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action imLog10"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ImLog10RequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action imLog10 - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ImLog10RequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ImLog10Response : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ImLog2/ImLog2RequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ImLog2/ImLog2RequestBuilder.cs index 0bede81d125..c8c1ff62925 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ImLog2/ImLog2RequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ImLog2/ImLog2RequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action imLog2"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ImLog2RequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action imLog2 - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ImLog2RequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ImLog2Response : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ImPower/ImPowerRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ImPower/ImPowerRequestBuilder.cs index 7548db81042..a1752564719 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ImPower/ImPowerRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ImPower/ImPowerRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action imPower"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ImPowerRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action imPower - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ImPowerRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ImPowerResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ImProduct/ImProductRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ImProduct/ImProductRequestBuilder.cs index 890c9cc21f6..cb140d9ce47 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ImProduct/ImProductRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ImProduct/ImProductRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action imProduct"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ImProductRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action imProduct - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ImProductRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ImProductResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ImReal/ImRealRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ImReal/ImRealRequestBuilder.cs index 89947491b9f..3df9121848b 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ImReal/ImRealRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ImReal/ImRealRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action imReal"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ImRealRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action imReal - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ImRealRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ImRealResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ImSec/ImSecRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ImSec/ImSecRequestBuilder.cs index 86ad92e757e..c3ed6126994 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ImSec/ImSecRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ImSec/ImSecRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action imSec"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ImSecRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action imSec - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ImSecRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ImSecResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ImSech/ImSechRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ImSech/ImSechRequestBuilder.cs index ae0d147473d..3ae4f0722ee 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ImSech/ImSechRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ImSech/ImSechRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action imSech"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ImSechRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action imSech - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ImSechRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ImSechResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ImSin/ImSinRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ImSin/ImSinRequestBuilder.cs index a87273ca7a4..48b6897ffc4 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ImSin/ImSinRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ImSin/ImSinRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action imSin"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ImSinRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action imSin - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ImSinRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ImSinResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ImSinh/ImSinhRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ImSinh/ImSinhRequestBuilder.cs index 978142a8221..9723f406dc6 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ImSinh/ImSinhRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ImSinh/ImSinhRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action imSinh"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ImSinhRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action imSinh - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ImSinhRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ImSinhResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ImSqrt/ImSqrtRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ImSqrt/ImSqrtRequestBuilder.cs index d076ab8479f..c01d781a812 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ImSqrt/ImSqrtRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ImSqrt/ImSqrtRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action imSqrt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ImSqrtRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action imSqrt - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ImSqrtRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ImSqrtResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ImSub/ImSubRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ImSub/ImSubRequestBuilder.cs index 8b65852e726..ba53919936f 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ImSub/ImSubRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ImSub/ImSubRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action imSub"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ImSubRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action imSub - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ImSubRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ImSubResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ImSum/ImSumRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ImSum/ImSumRequestBuilder.cs index 7ea4ac9fc8f..82a54e43453 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ImSum/ImSumRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ImSum/ImSumRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action imSum"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ImSumRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action imSum - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ImSumRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ImSumResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ImTan/ImTanRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ImTan/ImTanRequestBuilder.cs index 9315f1402b2..890e4275701 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ImTan/ImTanRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ImTan/ImTanRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action imTan"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ImTanRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action imTan - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ImTanRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ImTanResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Imaginary/ImaginaryRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Imaginary/ImaginaryRequestBuilder.cs index 8ba386f7dd8..65afe7c000a 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Imaginary/ImaginaryRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Imaginary/ImaginaryRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action imaginary"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ImaginaryRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action imaginary - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ImaginaryRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ImaginaryResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/@Int/IntRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Functions/Int/IntRequestBody.cs similarity index 96% rename from src/generated/Workbooks/Item/Workbook/Functions/@Int/IntRequestBody.cs rename to src/generated/Workbooks/Item/Workbook/Functions/Int/IntRequestBody.cs index a37305e42c7..b2888d1d067 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/@Int/IntRequestBody.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Int/IntRequestBody.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Functions.@Int { +namespace ApiSdk.Workbooks.Item.Workbook.Functions.Int { public class IntRequestBody : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Int/IntRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Int/IntRequestBuilder.cs new file mode 100644 index 00000000000..43a5ef52f9a --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Functions/Int/IntRequestBuilder.cs @@ -0,0 +1,115 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Functions.Int { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\functions\microsoft.graph.int + public class IntRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action int + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action int"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new IntRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public IntRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/functions/microsoft.graph.int"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action int + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(IntRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookFunctionResult + public class IntResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookFunctionResult + public WorkbookFunctionResult WorkbookFunctionResult { get; set; } + /// + /// Instantiates a new intResponse and sets the default values. + /// + public IntResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookFunctionResult", (o,n) => { (o as IntResponse).WorkbookFunctionResult = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookFunctionResult", WorkbookFunctionResult); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Functions/IntRate/IntRateRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/IntRate/IntRateRequestBuilder.cs index c7a93742127..cee9453703f 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/IntRate/IntRateRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/IntRate/IntRateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action intRate"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(IntRateRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action intRate - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(IntRateRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class IntRateResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Ipmt/IpmtRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Ipmt/IpmtRequestBuilder.cs index 671edb30ccc..f04e0f4ac94 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Ipmt/IpmtRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Ipmt/IpmtRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action ipmt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(IpmtRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action ipmt - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(IpmtRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class IpmtResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Irr/IrrRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Irr/IrrRequestBuilder.cs index 87493eb4a6e..307f9af63bc 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Irr/IrrRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Irr/IrrRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action irr"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(IrrRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action irr - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(IrrRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class IrrResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/IsErr/IsErrRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/IsErr/IsErrRequestBuilder.cs index 6852c066f46..2c1444e1035 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/IsErr/IsErrRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/IsErr/IsErrRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action isErr"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(IsErrRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action isErr - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(IsErrRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class IsErrResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/IsError/IsErrorRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/IsError/IsErrorRequestBuilder.cs index 19b23977ce9..bf86761b7f2 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/IsError/IsErrorRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/IsError/IsErrorRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action isError"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(IsErrorRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action isError - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(IsErrorRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class IsErrorResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/IsEven/IsEvenRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/IsEven/IsEvenRequestBuilder.cs index adee0ef7cf3..7b5b581b215 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/IsEven/IsEvenRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/IsEven/IsEvenRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action isEven"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(IsEvenRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action isEven - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(IsEvenRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class IsEvenResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/IsFormula/IsFormulaRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/IsFormula/IsFormulaRequestBuilder.cs index 320cc68ed9e..5b662d51dba 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/IsFormula/IsFormulaRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/IsFormula/IsFormulaRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action isFormula"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(IsFormulaRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action isFormula - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(IsFormulaRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class IsFormulaResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/IsLogical/IsLogicalRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/IsLogical/IsLogicalRequestBuilder.cs index c1ea8d873a3..730adc6b88b 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/IsLogical/IsLogicalRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/IsLogical/IsLogicalRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action isLogical"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(IsLogicalRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action isLogical - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(IsLogicalRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class IsLogicalResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/IsNA/IsNARequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/IsNA/IsNARequestBuilder.cs index eb7dd899182..c9dd98c7441 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/IsNA/IsNARequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/IsNA/IsNARequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action isNA"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(IsNARequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action isNA - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(IsNARequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class IsNAResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/IsNonText/IsNonTextRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/IsNonText/IsNonTextRequestBuilder.cs index 442fa4087f2..f0adaccc934 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/IsNonText/IsNonTextRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/IsNonText/IsNonTextRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action isNonText"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(IsNonTextRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action isNonText - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(IsNonTextRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class IsNonTextResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/IsNumber/IsNumberRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/IsNumber/IsNumberRequestBuilder.cs index d34ac001217..2396ce70651 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/IsNumber/IsNumberRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/IsNumber/IsNumberRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action isNumber"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(IsNumberRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action isNumber - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(IsNumberRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class IsNumberResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/IsOdd/IsOddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/IsOdd/IsOddRequestBuilder.cs index ef2bff2fdf1..cc0550e647b 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/IsOdd/IsOddRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/IsOdd/IsOddRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action isOdd"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(IsOddRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action isOdd - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(IsOddRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class IsOddResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/IsText/IsTextRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/IsText/IsTextRequestBuilder.cs index 2ab38608783..6581a40bcbc 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/IsText/IsTextRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/IsText/IsTextRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action isText"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(IsTextRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action isText - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(IsTextRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class IsTextResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/IsoWeekNum/IsoWeekNumRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/IsoWeekNum/IsoWeekNumRequestBuilder.cs index 46e03a79377..50978be42d2 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/IsoWeekNum/IsoWeekNumRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/IsoWeekNum/IsoWeekNumRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action isoWeekNum"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(IsoWeekNumRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action isoWeekNum - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(IsoWeekNumRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class IsoWeekNumResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Iso_Ceiling/Iso_CeilingRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Iso_Ceiling/Iso_CeilingRequestBuilder.cs index d5f15ae5a21..7a72baf165a 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Iso_Ceiling/Iso_CeilingRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Iso_Ceiling/Iso_CeilingRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action iso_Ceiling"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Iso_CeilingRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action iso_Ceiling - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Iso_CeilingRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Iso_CeilingResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Ispmt/IspmtRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Ispmt/IspmtRequestBuilder.cs index 6c5ba682402..e8ad0db7ae4 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Ispmt/IspmtRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Ispmt/IspmtRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action ispmt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(IspmtRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action ispmt - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(IspmtRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class IspmtResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Isref/IsrefRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Isref/IsrefRequestBuilder.cs index c89cea85b67..d0d1c31d24b 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Isref/IsrefRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Isref/IsrefRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action isref"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(IsrefRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action isref - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(IsrefRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class IsrefResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Kurt/KurtRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Kurt/KurtRequestBuilder.cs index 15d25697bfd..8f2628f6324 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Kurt/KurtRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Kurt/KurtRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action kurt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(KurtRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action kurt - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(KurtRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class KurtResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Large/LargeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Large/LargeRequestBuilder.cs index 44ceece8cd2..3eeb20cbf38 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Large/LargeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Large/LargeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action large"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(LargeRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action large - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(LargeRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class LargeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Lcm/LcmRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Lcm/LcmRequestBuilder.cs index 9adc1c10308..967bd6a4245 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Lcm/LcmRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Lcm/LcmRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action lcm"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(LcmRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action lcm - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(LcmRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class LcmResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Left/LeftRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Left/LeftRequestBuilder.cs index 17d6b7c6868..5295c0eff24 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Left/LeftRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Left/LeftRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action left"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(LeftRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action left - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(LeftRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class LeftResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Leftb/LeftbRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Leftb/LeftbRequestBuilder.cs index 6cdbaf8b071..c5b97e2d83b 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Leftb/LeftbRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Leftb/LeftbRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action leftb"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(LeftbRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action leftb - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(LeftbRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class LeftbResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Len/LenRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Len/LenRequestBuilder.cs index 08da47ee678..55db17e9690 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Len/LenRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Len/LenRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action len"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(LenRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action len - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(LenRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class LenResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Lenb/LenbRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Lenb/LenbRequestBuilder.cs index de3ae617c5a..16a26306047 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Lenb/LenbRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Lenb/LenbRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action lenb"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(LenbRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action lenb - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(LenbRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class LenbResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Ln/LnRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Ln/LnRequestBuilder.cs index cd6f7a26090..b9527cffb16 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Ln/LnRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Ln/LnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action ln"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(LnRequestBody body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action ln - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(LnRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class LnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Log/LogRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Functions/Log/LogRequestBody.cs index 6508200b22f..82ac385168d 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Log/LogRequestBody.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Log/LogRequestBody.cs @@ -6,9 +6,9 @@ using System.Linq; namespace ApiSdk.Workbooks.Item.Workbook.Functions.Log { public class LogRequestBody : IParsable { - public Json @Base { get; set; } /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } + public Json Base { get; set; } public Json Number { get; set; } /// /// Instantiates a new logRequestBody and sets the default values. @@ -21,7 +21,7 @@ public LogRequestBody() { /// public IDictionary> GetFieldDeserializers() { return new Dictionary> { - {"base", (o,n) => { (o as LogRequestBody).@Base = n.GetObjectValue(); } }, + {"base", (o,n) => { (o as LogRequestBody).Base = n.GetObjectValue(); } }, {"number", (o,n) => { (o as LogRequestBody).Number = n.GetObjectValue(); } }, }; } @@ -31,7 +31,7 @@ public IDictionary> GetFieldDeserializers() { /// public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("base", @Base); + writer.WriteObjectValue("base", Base); writer.WriteObjectValue("number", Number); writer.WriteAdditionalData(AdditionalData); } diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Log/LogRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Log/LogRequestBuilder.cs index 97241daefba..d9a4724cbf5 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Log/LogRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Log/LogRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action log"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(LogRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action log - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(LogRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class LogResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Log10/Log10RequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Log10/Log10RequestBuilder.cs index 413056d828f..74e8cd5e8c9 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Log10/Log10RequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Log10/Log10RequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action log10"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Log10RequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action log10 - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Log10RequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Log10Response : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/LogNorm_Dist/LogNorm_DistRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/LogNorm_Dist/LogNorm_DistRequestBuilder.cs index 16cc8524a7f..49d51729555 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/LogNorm_Dist/LogNorm_DistRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/LogNorm_Dist/LogNorm_DistRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action logNorm_Dist"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(LogNorm_DistRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action logNorm_Dist - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(LogNorm_DistRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class LogNorm_DistResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/LogNorm_Inv/LogNorm_InvRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/LogNorm_Inv/LogNorm_InvRequestBuilder.cs index e755d3fdc48..b97eb4115f3 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/LogNorm_Inv/LogNorm_InvRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/LogNorm_Inv/LogNorm_InvRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action logNorm_Inv"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(LogNorm_InvRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action logNorm_Inv - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(LogNorm_InvRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class LogNorm_InvResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Lookup/LookupRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Lookup/LookupRequestBuilder.cs index 08e16aa1935..ef864cef5dc 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Lookup/LookupRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Lookup/LookupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action lookup"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(LookupRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action lookup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(LookupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class LookupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Lower/LowerRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Lower/LowerRequestBuilder.cs index 561515a6a3d..1b301d565c7 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Lower/LowerRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Lower/LowerRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action lower"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(LowerRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action lower - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(LowerRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class LowerResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Match/MatchRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Match/MatchRequestBuilder.cs index 6b8a076b16b..68e7c98a066 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Match/MatchRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Match/MatchRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action match"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(MatchRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action match - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MatchRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class MatchResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Max/MaxRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Max/MaxRequestBuilder.cs index 7b6288a2a50..65757b79b6b 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Max/MaxRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Max/MaxRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action max"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(MaxRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action max - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MaxRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class MaxResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/MaxA/MaxARequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/MaxA/MaxARequestBuilder.cs index 0d0ee7850e5..d22ca5131d4 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/MaxA/MaxARequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/MaxA/MaxARequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action maxA"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(MaxARequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action maxA - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MaxARequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class MaxAResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Mduration/MdurationRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Mduration/MdurationRequestBuilder.cs index fd9fae47bd7..04cb91fb8c4 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Mduration/MdurationRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Mduration/MdurationRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action mduration"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(MdurationRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action mduration - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MdurationRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class MdurationResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Median/MedianRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Median/MedianRequestBuilder.cs index e555f93c5b4..65c1a95f8bf 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Median/MedianRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Median/MedianRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action median"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(MedianRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action median - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MedianRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class MedianResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Mid/MidRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Mid/MidRequestBuilder.cs index 9eb96b54645..4cec2a7221d 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Mid/MidRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Mid/MidRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action mid"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(MidRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action mid - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MidRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class MidResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Midb/MidbRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Midb/MidbRequestBuilder.cs index 3235a86f38b..8a0f164c01d 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Midb/MidbRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Midb/MidbRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action midb"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(MidbRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action midb - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MidbRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class MidbResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Min/MinRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Min/MinRequestBuilder.cs index b8d5155d96f..d57e744eeb9 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Min/MinRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Min/MinRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action min"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(MinRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action min - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MinRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class MinResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/MinA/MinARequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/MinA/MinARequestBuilder.cs index 1fb7763ef10..6be7ae7e4e0 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/MinA/MinARequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/MinA/MinARequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action minA"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(MinARequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action minA - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MinARequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class MinAResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Minute/MinuteRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Minute/MinuteRequestBuilder.cs index a7303124554..64a5ce6f952 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Minute/MinuteRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Minute/MinuteRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action minute"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(MinuteRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action minute - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MinuteRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class MinuteResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Mirr/MirrRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Mirr/MirrRequestBuilder.cs index 9581ebdb048..aeed4cc9bc6 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Mirr/MirrRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Mirr/MirrRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action mirr"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(MirrRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action mirr - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MirrRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class MirrResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Mod/ModRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Mod/ModRequestBuilder.cs index 67801d75d6e..dba406d2c3c 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Mod/ModRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Mod/ModRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action mod"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ModRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action mod - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ModRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ModResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Month/MonthRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Month/MonthRequestBuilder.cs index 99ddf07d141..5139ed1ef6f 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Month/MonthRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Month/MonthRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action month"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(MonthRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action month - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MonthRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class MonthResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Mround/MroundRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Mround/MroundRequestBuilder.cs index 2cf0b089f11..7b80deed873 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Mround/MroundRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Mround/MroundRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action mround"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(MroundRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action mround - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MroundRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class MroundResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/MultiNomial/MultiNomialRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/MultiNomial/MultiNomialRequestBuilder.cs index a0fd7b38ab1..d10b537198b 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/MultiNomial/MultiNomialRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/MultiNomial/MultiNomialRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action multiNomial"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(MultiNomialRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action multiNomial - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(MultiNomialRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class MultiNomialResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/N/NRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/N/NRequestBuilder.cs index ab349c59885..d9337d0ffc7 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/N/NRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/N/NRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action n"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(NRequestBody body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action n - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(NRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class NResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Na/NaRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Na/NaRequestBuilder.cs index b34aa0e119f..f3b404261a9 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Na/NaRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Na/NaRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action na"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action na - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class NaResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/NegBinom_Dist/NegBinom_DistRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/NegBinom_Dist/NegBinom_DistRequestBuilder.cs index 185d2107346..07a45e920e4 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/NegBinom_Dist/NegBinom_DistRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/NegBinom_Dist/NegBinom_DistRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action negBinom_Dist"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(NegBinom_DistRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action negBinom_Dist - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(NegBinom_DistRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class NegBinom_DistResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/NetworkDays/NetworkDaysRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/NetworkDays/NetworkDaysRequestBuilder.cs index 48c11294165..f2bcded20d8 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/NetworkDays/NetworkDaysRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/NetworkDays/NetworkDaysRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action networkDays"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(NetworkDaysRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action networkDays - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(NetworkDaysRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class NetworkDaysResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/NetworkDays_Intl/NetworkDays_IntlRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/NetworkDays_Intl/NetworkDays_IntlRequestBuilder.cs index 81b4a6f3cd8..93c1bb0fd32 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/NetworkDays_Intl/NetworkDays_IntlRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/NetworkDays_Intl/NetworkDays_IntlRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action networkDays_Intl"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(NetworkDays_IntlRequestBo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action networkDays_Intl - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(NetworkDays_IntlRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class NetworkDays_IntlResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Nominal/NominalRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Nominal/NominalRequestBuilder.cs index 8a5101949e1..21339cc842e 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Nominal/NominalRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Nominal/NominalRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action nominal"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(NominalRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action nominal - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(NominalRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class NominalResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Norm_Dist/Norm_DistRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Norm_Dist/Norm_DistRequestBuilder.cs index 65b7a86e2a5..777f7c6af49 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Norm_Dist/Norm_DistRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Norm_Dist/Norm_DistRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action norm_Dist"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Norm_DistRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action norm_Dist - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Norm_DistRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Norm_DistResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Norm_Inv/Norm_InvRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Norm_Inv/Norm_InvRequestBuilder.cs index dfa9cf37c94..3f5c8989c49 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Norm_Inv/Norm_InvRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Norm_Inv/Norm_InvRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action norm_Inv"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Norm_InvRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action norm_Inv - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Norm_InvRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Norm_InvResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Norm_S_Dist/Norm_S_DistRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Norm_S_Dist/Norm_S_DistRequestBuilder.cs index 607a28d727b..b62353f33fd 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Norm_S_Dist/Norm_S_DistRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Norm_S_Dist/Norm_S_DistRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action norm_S_Dist"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Norm_S_DistRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action norm_S_Dist - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Norm_S_DistRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Norm_S_DistResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Norm_S_Inv/Norm_S_InvRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Norm_S_Inv/Norm_S_InvRequestBuilder.cs index 23dfb72b300..2e954959670 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Norm_S_Inv/Norm_S_InvRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Norm_S_Inv/Norm_S_InvRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action norm_S_Inv"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Norm_S_InvRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action norm_S_Inv - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Norm_S_InvRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Norm_S_InvResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/@Not/NotRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Functions/Not/NotRequestBody.cs similarity index 96% rename from src/generated/Workbooks/Item/Workbook/Functions/@Not/NotRequestBody.cs rename to src/generated/Workbooks/Item/Workbook/Functions/Not/NotRequestBody.cs index 1f2637247e3..0dfcca44e2d 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/@Not/NotRequestBody.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Not/NotRequestBody.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Functions.@Not { +namespace ApiSdk.Workbooks.Item.Workbook.Functions.Not { public class NotRequestBody : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Not/NotRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Not/NotRequestBuilder.cs new file mode 100644 index 00000000000..0e1aa663b73 --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Functions/Not/NotRequestBuilder.cs @@ -0,0 +1,115 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Functions.Not { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\functions\microsoft.graph.not + public class NotRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action not + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action not"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new NotRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public NotRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/functions/microsoft.graph.not"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action not + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(NotRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookFunctionResult + public class NotResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookFunctionResult + public WorkbookFunctionResult WorkbookFunctionResult { get; set; } + /// + /// Instantiates a new notResponse and sets the default values. + /// + public NotResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookFunctionResult", (o,n) => { (o as NotResponse).WorkbookFunctionResult = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookFunctionResult", WorkbookFunctionResult); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Now/NowRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Now/NowRequestBuilder.cs index 968bcb215a7..2312098396c 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Now/NowRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Now/NowRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action now"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action now - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class NowResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Nper/NperRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Nper/NperRequestBuilder.cs index 17992a46da7..4ed4ad02696 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Nper/NperRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Nper/NperRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action nper"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(NperRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action nper - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(NperRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class NperResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Npv/NpvRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Npv/NpvRequestBuilder.cs index 0c64408d585..e37935e3d89 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Npv/NpvRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Npv/NpvRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action npv"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(NpvRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action npv - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(NpvRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class NpvResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/NumberValue/NumberValueRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/NumberValue/NumberValueRequestBuilder.cs index cb648540a69..4b454749b33 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/NumberValue/NumberValueRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/NumberValue/NumberValueRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action numberValue"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(NumberValueRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action numberValue - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(NumberValueRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class NumberValueResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Oct2Bin/Oct2BinRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Oct2Bin/Oct2BinRequestBuilder.cs index 3558df20d42..329f9b4c524 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Oct2Bin/Oct2BinRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Oct2Bin/Oct2BinRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action oct2Bin"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Oct2BinRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action oct2Bin - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Oct2BinRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Oct2BinResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Oct2Dec/Oct2DecRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Oct2Dec/Oct2DecRequestBuilder.cs index f497c374dc8..b6c685487de 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Oct2Dec/Oct2DecRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Oct2Dec/Oct2DecRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action oct2Dec"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Oct2DecRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action oct2Dec - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Oct2DecRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Oct2DecResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Oct2Hex/Oct2HexRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Oct2Hex/Oct2HexRequestBuilder.cs index 9223a5d55e8..c5a6deb1005 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Oct2Hex/Oct2HexRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Oct2Hex/Oct2HexRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action oct2Hex"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Oct2HexRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action oct2Hex - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Oct2HexRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Oct2HexResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Odd/OddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Odd/OddRequestBuilder.cs index d6f29b41247..fe24f0417a8 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Odd/OddRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Odd/OddRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action odd"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(OddRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action odd - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OddRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class OddResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/OddFPrice/OddFPriceRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/OddFPrice/OddFPriceRequestBuilder.cs index a7bcbd9d94a..92c1fe52c07 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/OddFPrice/OddFPriceRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/OddFPrice/OddFPriceRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action oddFPrice"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(OddFPriceRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action oddFPrice - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OddFPriceRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class OddFPriceResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/OddFYield/OddFYieldRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/OddFYield/OddFYieldRequestBuilder.cs index b7cda531b1d..4b727fca4a5 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/OddFYield/OddFYieldRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/OddFYield/OddFYieldRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action oddFYield"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(OddFYieldRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action oddFYield - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OddFYieldRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class OddFYieldResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/OddLPrice/OddLPriceRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/OddLPrice/OddLPriceRequestBuilder.cs index 035f7fab0a3..74c1af809ea 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/OddLPrice/OddLPriceRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/OddLPrice/OddLPriceRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action oddLPrice"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(OddLPriceRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action oddLPrice - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OddLPriceRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class OddLPriceResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/OddLYield/OddLYieldRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/OddLYield/OddLYieldRequestBuilder.cs index b1d522671db..6719b27fa64 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/OddLYield/OddLYieldRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/OddLYield/OddLYieldRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action oddLYield"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(OddLYieldRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action oddLYield - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(OddLYieldRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class OddLYieldResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/@Or/OrRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Functions/Or/OrRequestBody.cs similarity index 96% rename from src/generated/Workbooks/Item/Workbook/Functions/@Or/OrRequestBody.cs rename to src/generated/Workbooks/Item/Workbook/Functions/Or/OrRequestBody.cs index 45ffac7ada4..f89fbafce19 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/@Or/OrRequestBody.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Or/OrRequestBody.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Functions.@Or { +namespace ApiSdk.Workbooks.Item.Workbook.Functions.Or { public class OrRequestBody : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Or/OrRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Or/OrRequestBuilder.cs new file mode 100644 index 00000000000..2f44956b1e1 --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Functions/Or/OrRequestBuilder.cs @@ -0,0 +1,115 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Functions.Or { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\functions\microsoft.graph.or + public class OrRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action or + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action or"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new OrRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public OrRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/functions/microsoft.graph.or"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action or + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(OrRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookFunctionResult + public class OrResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookFunctionResult + public WorkbookFunctionResult WorkbookFunctionResult { get; set; } + /// + /// Instantiates a new orResponse and sets the default values. + /// + public OrResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookFunctionResult", (o,n) => { (o as OrResponse).WorkbookFunctionResult = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookFunctionResult", WorkbookFunctionResult); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Pduration/PdurationRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Pduration/PdurationRequestBuilder.cs index 5c64df82115..67d35ee4043 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Pduration/PdurationRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Pduration/PdurationRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action pduration"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(PdurationRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action pduration - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PdurationRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class PdurationResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/PercentRank_Exc/PercentRank_ExcRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/PercentRank_Exc/PercentRank_ExcRequestBuilder.cs index 7331d848231..7a28e30cabe 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/PercentRank_Exc/PercentRank_ExcRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/PercentRank_Exc/PercentRank_ExcRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action percentRank_Exc"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(PercentRank_ExcRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action percentRank_Exc - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PercentRank_ExcRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class PercentRank_ExcResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/PercentRank_Inc/PercentRank_IncRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/PercentRank_Inc/PercentRank_IncRequestBuilder.cs index 03f8a337aa6..683b37447f7 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/PercentRank_Inc/PercentRank_IncRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/PercentRank_Inc/PercentRank_IncRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action percentRank_Inc"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(PercentRank_IncRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action percentRank_Inc - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PercentRank_IncRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class PercentRank_IncResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Percentile_Exc/Percentile_ExcRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Percentile_Exc/Percentile_ExcRequestBuilder.cs index 49ae47c54ae..44be904cefa 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Percentile_Exc/Percentile_ExcRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Percentile_Exc/Percentile_ExcRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action percentile_Exc"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Percentile_ExcRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action percentile_Exc - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Percentile_ExcRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Percentile_ExcResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Percentile_Inc/Percentile_IncRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Percentile_Inc/Percentile_IncRequestBuilder.cs index a40bcda195f..053e8665aee 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Percentile_Inc/Percentile_IncRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Percentile_Inc/Percentile_IncRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action percentile_Inc"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Percentile_IncRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action percentile_Inc - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Percentile_IncRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Percentile_IncResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Permut/PermutRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Permut/PermutRequestBuilder.cs index 734565bede7..7d4082f79d3 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Permut/PermutRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Permut/PermutRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action permut"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(PermutRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action permut - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PermutRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class PermutResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Permutationa/PermutationaRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Permutationa/PermutationaRequestBuilder.cs index 5aeabb06363..1ab65f3fa0e 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Permutationa/PermutationaRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Permutationa/PermutationaRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action permutationa"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(PermutationaRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action permutationa - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PermutationaRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class PermutationaResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Phi/PhiRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Phi/PhiRequestBuilder.cs index 7d71556acf9..f159677ae61 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Phi/PhiRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Phi/PhiRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action phi"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(PhiRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action phi - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PhiRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class PhiResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Pi/PiRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Pi/PiRequestBuilder.cs index 21ffc5aba7e..389be20833f 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Pi/PiRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Pi/PiRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action pi"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action pi - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class PiResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Pmt/PmtRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Pmt/PmtRequestBuilder.cs index 6edda643b1e..9fa3ae6e165 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Pmt/PmtRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Pmt/PmtRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action pmt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(PmtRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action pmt - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PmtRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class PmtResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Poisson_Dist/Poisson_DistRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Poisson_Dist/Poisson_DistRequestBuilder.cs index 85e46a94679..5570bf32f6d 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Poisson_Dist/Poisson_DistRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Poisson_Dist/Poisson_DistRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action poisson_Dist"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Poisson_DistRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action poisson_Dist - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Poisson_DistRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Poisson_DistResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Power/PowerRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Power/PowerRequestBuilder.cs index 0c4580c7e25..f645ce449df 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Power/PowerRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Power/PowerRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action power"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(PowerRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action power - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PowerRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class PowerResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Ppmt/PpmtRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Ppmt/PpmtRequestBuilder.cs index 6826a7b8b0c..369a787a144 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Ppmt/PpmtRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Ppmt/PpmtRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action ppmt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(PpmtRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action ppmt - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PpmtRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class PpmtResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Price/PriceRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Price/PriceRequestBuilder.cs index bc82a81962e..eeb86fb6ff2 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Price/PriceRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Price/PriceRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action price"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(PriceRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action price - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PriceRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class PriceResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/PriceDisc/PriceDiscRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/PriceDisc/PriceDiscRequestBuilder.cs index bbb0f92620a..483a1de45ae 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/PriceDisc/PriceDiscRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/PriceDisc/PriceDiscRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action priceDisc"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(PriceDiscRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action priceDisc - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PriceDiscRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class PriceDiscResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/PriceMat/PriceMatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/PriceMat/PriceMatRequestBuilder.cs index 7c00e0072a5..ea2d8b9853a 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/PriceMat/PriceMatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/PriceMat/PriceMatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action priceMat"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(PriceMatRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action priceMat - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PriceMatRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class PriceMatResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Product/ProductRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Product/ProductRequestBuilder.cs index 1ddfda4a9bd..8c51513e777 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Product/ProductRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Product/ProductRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action product"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ProductRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action product - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ProductRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ProductResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Proper/ProperRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Proper/ProperRequestBuilder.cs index 02e2f19ed20..7ae1cd60a9a 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Proper/ProperRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Proper/ProperRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action proper"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ProperRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action proper - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ProperRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ProperResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Pv/PvRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Pv/PvRequestBuilder.cs index 88d1a4281dc..460e0dd4a16 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Pv/PvRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Pv/PvRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action pv"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(PvRequestBody body, Actio requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action pv - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(PvRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class PvResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Quartile_Exc/Quartile_ExcRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Quartile_Exc/Quartile_ExcRequestBuilder.cs index 6a2cd1465a0..6ef906f587e 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Quartile_Exc/Quartile_ExcRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Quartile_Exc/Quartile_ExcRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action quartile_Exc"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Quartile_ExcRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action quartile_Exc - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Quartile_ExcRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Quartile_ExcResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Quartile_Inc/Quartile_IncRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Quartile_Inc/Quartile_IncRequestBuilder.cs index cb613218d82..6132f65a98c 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Quartile_Inc/Quartile_IncRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Quartile_Inc/Quartile_IncRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action quartile_Inc"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Quartile_IncRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action quartile_Inc - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Quartile_IncRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Quartile_IncResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Quotient/QuotientRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Quotient/QuotientRequestBuilder.cs index 0ec7b922ad3..a9f901f327f 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Quotient/QuotientRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Quotient/QuotientRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action quotient"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(QuotientRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action quotient - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(QuotientRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class QuotientResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Radians/RadiansRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Radians/RadiansRequestBuilder.cs index 73ab941460a..e1ae53a2590 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Radians/RadiansRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Radians/RadiansRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action radians"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(RadiansRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action radians - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RadiansRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class RadiansResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Rand/RandRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Rand/RandRequestBuilder.cs index 1a4c168a8b7..8e83a435310 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Rand/RandRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Rand/RandRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action rand"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action rand - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class RandResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/RandBetween/RandBetweenRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/RandBetween/RandBetweenRequestBuilder.cs index 3f979ddee29..292c5031617 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/RandBetween/RandBetweenRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/RandBetween/RandBetweenRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action randBetween"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(RandBetweenRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action randBetween - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RandBetweenRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class RandBetweenResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Rank_Avg/Rank_AvgRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Functions/Rank_Avg/Rank_AvgRequestBody.cs index 704cd5b44e2..29f5aefae01 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Rank_Avg/Rank_AvgRequestBody.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Rank_Avg/Rank_AvgRequestBody.cs @@ -6,11 +6,11 @@ using System.Linq; namespace ApiSdk.Workbooks.Item.Workbook.Functions.Rank_Avg { public class Rank_AvgRequestBody : IParsable { - public Json @Ref { get; set; } /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public Json Number { get; set; } public Json Order { get; set; } + public Json Ref { get; set; } /// /// Instantiates a new rank_AvgRequestBody and sets the default values. /// @@ -22,9 +22,9 @@ public Rank_AvgRequestBody() { /// public IDictionary> GetFieldDeserializers() { return new Dictionary> { - {"ref", (o,n) => { (o as Rank_AvgRequestBody).@Ref = n.GetObjectValue(); } }, {"number", (o,n) => { (o as Rank_AvgRequestBody).Number = n.GetObjectValue(); } }, {"order", (o,n) => { (o as Rank_AvgRequestBody).Order = n.GetObjectValue(); } }, + {"ref", (o,n) => { (o as Rank_AvgRequestBody).Ref = n.GetObjectValue(); } }, }; } /// @@ -33,9 +33,9 @@ public IDictionary> GetFieldDeserializers() { /// public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("ref", @Ref); writer.WriteObjectValue("number", Number); writer.WriteObjectValue("order", Order); + writer.WriteObjectValue("ref", Ref); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Rank_Avg/Rank_AvgRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Rank_Avg/Rank_AvgRequestBuilder.cs index 123034b47ba..1a174981a3b 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Rank_Avg/Rank_AvgRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Rank_Avg/Rank_AvgRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action rank_Avg"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Rank_AvgRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action rank_Avg - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Rank_AvgRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Rank_AvgResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Rank_Eq/Rank_EqRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Functions/Rank_Eq/Rank_EqRequestBody.cs index d8b5627f6d0..71796fe1511 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Rank_Eq/Rank_EqRequestBody.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Rank_Eq/Rank_EqRequestBody.cs @@ -6,11 +6,11 @@ using System.Linq; namespace ApiSdk.Workbooks.Item.Workbook.Functions.Rank_Eq { public class Rank_EqRequestBody : IParsable { - public Json @Ref { get; set; } /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } public Json Number { get; set; } public Json Order { get; set; } + public Json Ref { get; set; } /// /// Instantiates a new rank_EqRequestBody and sets the default values. /// @@ -22,9 +22,9 @@ public Rank_EqRequestBody() { /// public IDictionary> GetFieldDeserializers() { return new Dictionary> { - {"ref", (o,n) => { (o as Rank_EqRequestBody).@Ref = n.GetObjectValue(); } }, {"number", (o,n) => { (o as Rank_EqRequestBody).Number = n.GetObjectValue(); } }, {"order", (o,n) => { (o as Rank_EqRequestBody).Order = n.GetObjectValue(); } }, + {"ref", (o,n) => { (o as Rank_EqRequestBody).Ref = n.GetObjectValue(); } }, }; } /// @@ -33,9 +33,9 @@ public IDictionary> GetFieldDeserializers() { /// public void Serialize(ISerializationWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("ref", @Ref); writer.WriteObjectValue("number", Number); writer.WriteObjectValue("order", Order); + writer.WriteObjectValue("ref", Ref); writer.WriteAdditionalData(AdditionalData); } } diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Rank_Eq/Rank_EqRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Rank_Eq/Rank_EqRequestBuilder.cs index d5b91967619..dfd61144726 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Rank_Eq/Rank_EqRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Rank_Eq/Rank_EqRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action rank_Eq"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Rank_EqRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action rank_Eq - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Rank_EqRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Rank_EqResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Rate/RateRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Rate/RateRequestBuilder.cs index 60d8762a411..91bed457c0c 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Rate/RateRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Rate/RateRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action rate"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(RateRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action rate - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RateRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class RateResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Received/ReceivedRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Received/ReceivedRequestBuilder.cs index f27f8e83b84..435d5ad2266 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Received/ReceivedRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Received/ReceivedRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action received"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ReceivedRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action received - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ReceivedRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ReceivedResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Replace/ReplaceRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Replace/ReplaceRequestBuilder.cs index d26794317ae..7ac6ab1cf20 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Replace/ReplaceRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Replace/ReplaceRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action replace"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ReplaceRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action replace - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ReplaceRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ReplaceResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/ReplaceB/ReplaceBRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/ReplaceB/ReplaceBRequestBuilder.cs index c5fb73720de..51b2386639a 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/ReplaceB/ReplaceBRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/ReplaceB/ReplaceBRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action replaceB"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ReplaceBRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action replaceB - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ReplaceBRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ReplaceBResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Rept/ReptRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Rept/ReptRequestBuilder.cs index d96ec878a4b..eeb1aca6479 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Rept/ReptRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Rept/ReptRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action rept"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ReptRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action rept - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ReptRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ReptResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Right/RightRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Right/RightRequestBuilder.cs index 2c2b5e6e6a0..a2668748736 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Right/RightRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Right/RightRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action right"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(RightRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action right - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RightRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class RightResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Rightb/RightbRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Rightb/RightbRequestBuilder.cs index 1797014a459..1f127a0e8e6 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Rightb/RightbRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Rightb/RightbRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action rightb"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(RightbRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action rightb - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RightbRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class RightbResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Roman/RomanRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Roman/RomanRequestBuilder.cs index 2855beb62ce..91febc1de4e 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Roman/RomanRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Roman/RomanRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action roman"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(RomanRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action roman - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RomanRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class RomanResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Round/RoundRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Round/RoundRequestBuilder.cs index dd509be65ce..f3e8d5177db 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Round/RoundRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Round/RoundRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action round"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(RoundRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action round - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RoundRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class RoundResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/RoundDown/RoundDownRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/RoundDown/RoundDownRequestBuilder.cs index adc84d8aabe..49d5d15c1a7 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/RoundDown/RoundDownRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/RoundDown/RoundDownRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action roundDown"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(RoundDownRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action roundDown - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RoundDownRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class RoundDownResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/RoundUp/RoundUpRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/RoundUp/RoundUpRequestBuilder.cs index d5ab64e0565..315675815a6 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/RoundUp/RoundUpRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/RoundUp/RoundUpRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action roundUp"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(RoundUpRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action roundUp - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RoundUpRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class RoundUpResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Rows/RowsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Rows/RowsRequestBuilder.cs index b457a1f6077..df10cbc40f2 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Rows/RowsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Rows/RowsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action rows"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(RowsRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action rows - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RowsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class RowsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Rri/RriRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Rri/RriRequestBuilder.cs index 85d8c824eae..24a9a3760a4 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Rri/RriRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Rri/RriRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action rri"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(RriRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action rri - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(RriRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class RriResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Sec/SecRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Sec/SecRequestBuilder.cs index cc0c6c12716..dd0a78f5b74 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Sec/SecRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Sec/SecRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action sec"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(SecRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action sec - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SecRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class SecResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Sech/SechRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Sech/SechRequestBuilder.cs index 652c39392d1..4d0b6d9bd30 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Sech/SechRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Sech/SechRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action sech"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(SechRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action sech - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SechRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class SechResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Second/SecondRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Second/SecondRequestBuilder.cs index 965ca8184bd..bb8ea94e0ae 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Second/SecondRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Second/SecondRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action second"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(SecondRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action second - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SecondRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class SecondResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/SeriesSum/SeriesSumRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/SeriesSum/SeriesSumRequestBuilder.cs index 384cff3c263..cd47e5bf378 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/SeriesSum/SeriesSumRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/SeriesSum/SeriesSumRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action seriesSum"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(SeriesSumRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action seriesSum - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SeriesSumRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class SeriesSumResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Sheet/SheetRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Sheet/SheetRequestBuilder.cs index b501e525317..2a33e0e4bb8 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Sheet/SheetRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Sheet/SheetRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action sheet"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(SheetRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action sheet - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SheetRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class SheetResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Sheets/SheetsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Sheets/SheetsRequestBuilder.cs index 681bc1adb2f..34e819307b8 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Sheets/SheetsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Sheets/SheetsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action sheets"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(SheetsRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action sheets - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SheetsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class SheetsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Sign/SignRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Sign/SignRequestBuilder.cs index e37f0de3c31..9f9720f5d94 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Sign/SignRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Sign/SignRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action sign"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(SignRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action sign - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SignRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class SignResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Sin/SinRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Sin/SinRequestBuilder.cs index 7f7e02f8e95..67c15de2701 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Sin/SinRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Sin/SinRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action sin"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(SinRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action sin - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SinRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class SinResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Sinh/SinhRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Sinh/SinhRequestBuilder.cs index 961f74e5f39..26f4d4ba3de 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Sinh/SinhRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Sinh/SinhRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action sinh"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(SinhRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action sinh - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SinhRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class SinhResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Skew/SkewRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Skew/SkewRequestBuilder.cs index 6e4a7efacdd..ad5fa418b73 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Skew/SkewRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Skew/SkewRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action skew"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(SkewRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action skew - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SkewRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class SkewResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Skew_p/Skew_pRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Skew_p/Skew_pRequestBuilder.cs index 1f00557fc43..8d53cfd6502 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Skew_p/Skew_pRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Skew_p/Skew_pRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action skew_p"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Skew_pRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action skew_p - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Skew_pRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Skew_pResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Sln/SlnRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Sln/SlnRequestBuilder.cs index eac7a56b726..204375a218c 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Sln/SlnRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Sln/SlnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action sln"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(SlnRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action sln - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SlnRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class SlnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Small/SmallRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Small/SmallRequestBuilder.cs index ee944d8af94..fef364fe687 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Small/SmallRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Small/SmallRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action small"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(SmallRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action small - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SmallRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class SmallResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Sqrt/SqrtRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Sqrt/SqrtRequestBuilder.cs index 3674dd95958..9d6b58c9a82 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Sqrt/SqrtRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Sqrt/SqrtRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action sqrt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(SqrtRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action sqrt - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SqrtRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class SqrtResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/SqrtPi/SqrtPiRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/SqrtPi/SqrtPiRequestBuilder.cs index d4a98aae57c..6e5ee487b2b 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/SqrtPi/SqrtPiRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/SqrtPi/SqrtPiRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action sqrtPi"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(SqrtPiRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action sqrtPi - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SqrtPiRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class SqrtPiResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/StDevA/StDevARequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/StDevA/StDevARequestBuilder.cs index 444be6a507f..add5960ccee 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/StDevA/StDevARequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/StDevA/StDevARequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action stDevA"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(StDevARequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action stDevA - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(StDevARequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class StDevAResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/StDevPA/StDevPARequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/StDevPA/StDevPARequestBuilder.cs index 9221ddfb2e1..a4b5f5a579f 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/StDevPA/StDevPARequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/StDevPA/StDevPARequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action stDevPA"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(StDevPARequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action stDevPA - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(StDevPARequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class StDevPAResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/StDev_P/StDev_PRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/StDev_P/StDev_PRequestBuilder.cs index 85e61c65052..55a78be8775 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/StDev_P/StDev_PRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/StDev_P/StDev_PRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action stDev_P"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(StDev_PRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action stDev_P - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(StDev_PRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class StDev_PResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/StDev_S/StDev_SRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/StDev_S/StDev_SRequestBuilder.cs index 7f752a2555d..185116c72f2 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/StDev_S/StDev_SRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/StDev_S/StDev_SRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action stDev_S"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(StDev_SRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action stDev_S - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(StDev_SRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class StDev_SResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Standardize/StandardizeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Standardize/StandardizeRequestBuilder.cs index 60de8fc5017..2c8f93aabf7 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Standardize/StandardizeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Standardize/StandardizeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action standardize"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(StandardizeRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action standardize - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(StandardizeRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class StandardizeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Substitute/SubstituteRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Substitute/SubstituteRequestBuilder.cs index 6f109a86911..446214d92fc 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Substitute/SubstituteRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Substitute/SubstituteRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action substitute"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(SubstituteRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action substitute - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SubstituteRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class SubstituteResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Subtotal/SubtotalRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Subtotal/SubtotalRequestBuilder.cs index edfd28d82c6..02682002b1e 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Subtotal/SubtotalRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Subtotal/SubtotalRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action subtotal"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(SubtotalRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action subtotal - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SubtotalRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class SubtotalResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Sum/SumRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Sum/SumRequestBuilder.cs index 45045376f4f..515ba3fc845 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Sum/SumRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Sum/SumRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action sum"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(SumRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action sum - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SumRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class SumResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/SumIf/SumIfRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/SumIf/SumIfRequestBuilder.cs index 5d021035998..98a6f5f0d3c 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/SumIf/SumIfRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/SumIf/SumIfRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action sumIf"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(SumIfRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action sumIf - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SumIfRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class SumIfResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/SumIfs/SumIfsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/SumIfs/SumIfsRequestBuilder.cs index 43dbb28c4a4..6c0fd864509 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/SumIfs/SumIfsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/SumIfs/SumIfsRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action sumIfs"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(SumIfsRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action sumIfs - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SumIfsRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class SumIfsResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/SumSq/SumSqRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/SumSq/SumSqRequestBuilder.cs index 4f5a4e06532..859a45e3cb0 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/SumSq/SumSqRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/SumSq/SumSqRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action sumSq"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(SumSqRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action sumSq - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SumSqRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class SumSqResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Syd/SydRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Syd/SydRequestBuilder.cs index b44a8f78b06..41a38f7e949 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Syd/SydRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Syd/SydRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action syd"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(SydRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action syd - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SydRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class SydResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/T/TRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/T/TRequestBuilder.cs index c576a491c31..1c1c2fb01ab 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/T/TRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/T/TRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action t"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(TRequestBody body, Action requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action t - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class TResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/T_Dist/T_DistRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/T_Dist/T_DistRequestBuilder.cs index 1af7de2bd1c..9f210a1da71 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/T_Dist/T_DistRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/T_Dist/T_DistRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action t_Dist"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(T_DistRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action t_Dist - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(T_DistRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class T_DistResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/T_Dist_2T/T_Dist_2TRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/T_Dist_2T/T_Dist_2TRequestBuilder.cs index e9de4d95d4d..4029a1abfcd 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/T_Dist_2T/T_Dist_2TRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/T_Dist_2T/T_Dist_2TRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action t_Dist_2T"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(T_Dist_2TRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action t_Dist_2T - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(T_Dist_2TRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class T_Dist_2TResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/T_Dist_RT/T_Dist_RTRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/T_Dist_RT/T_Dist_RTRequestBuilder.cs index 3eb73f2ab7f..47c8f9bdd30 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/T_Dist_RT/T_Dist_RTRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/T_Dist_RT/T_Dist_RTRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action t_Dist_RT"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(T_Dist_RTRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action t_Dist_RT - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(T_Dist_RTRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class T_Dist_RTResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/T_Inv/T_InvRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/T_Inv/T_InvRequestBuilder.cs index d56e009a3d4..5549b14d913 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/T_Inv/T_InvRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/T_Inv/T_InvRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action t_Inv"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(T_InvRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action t_Inv - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(T_InvRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class T_InvResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/T_Inv_2T/T_Inv_2TRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/T_Inv_2T/T_Inv_2TRequestBuilder.cs index e97d0112c71..19295336ebd 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/T_Inv_2T/T_Inv_2TRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/T_Inv_2T/T_Inv_2TRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action t_Inv_2T"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(T_Inv_2TRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action t_Inv_2T - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(T_Inv_2TRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class T_Inv_2TResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Tan/TanRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Tan/TanRequestBuilder.cs index 73df3e0d365..f2acec5783f 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Tan/TanRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Tan/TanRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action tan"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(TanRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tan - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TanRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class TanResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Tanh/TanhRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Tanh/TanhRequestBuilder.cs index bee4967e829..d368c45cf0a 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Tanh/TanhRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Tanh/TanhRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action tanh"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(TanhRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tanh - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TanhRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class TanhResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/TbillEq/TbillEqRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/TbillEq/TbillEqRequestBuilder.cs index 84fed36f131..bb466aeb536 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/TbillEq/TbillEqRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/TbillEq/TbillEqRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action tbillEq"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(TbillEqRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tbillEq - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TbillEqRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class TbillEqResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/TbillPrice/TbillPriceRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/TbillPrice/TbillPriceRequestBuilder.cs index 468d122d3f9..136e103387a 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/TbillPrice/TbillPriceRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/TbillPrice/TbillPriceRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action tbillPrice"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(TbillPriceRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tbillPrice - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TbillPriceRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class TbillPriceResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/TbillYield/TbillYieldRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/TbillYield/TbillYieldRequestBuilder.cs index 37f3aa65981..79b8b22a26c 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/TbillYield/TbillYieldRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/TbillYield/TbillYieldRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action tbillYield"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(TbillYieldRequestBody bod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action tbillYield - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TbillYieldRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class TbillYieldResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Text/TextRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Text/TextRequestBuilder.cs index 1cf6c6be4e3..eea645d802c 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Text/TextRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Text/TextRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action text"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(TextRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action text - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TextRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class TextResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Time/TimeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Time/TimeRequestBuilder.cs index 312d28c6fb4..10a8f42a4ee 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Time/TimeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Time/TimeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action time"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(TimeRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action time - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TimeRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class TimeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Timevalue/TimevalueRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Timevalue/TimevalueRequestBuilder.cs index b59c185d43e..4e398511989 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Timevalue/TimevalueRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Timevalue/TimevalueRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action timevalue"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(TimevalueRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action timevalue - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TimevalueRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class TimevalueResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Today/TodayRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Today/TodayRequestBuilder.cs index f6b54811e63..36abaa479a2 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Today/TodayRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Today/TodayRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,22 +26,21 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action today"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, outputOption); return command; } /// @@ -72,17 +71,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action today - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class TodayResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Trim/TrimRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Trim/TrimRequestBuilder.cs index 3810979a0a8..2e6c7637842 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Trim/TrimRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Trim/TrimRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action trim"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(TrimRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action trim - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TrimRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class TrimResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/TrimMean/TrimMeanRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/TrimMean/TrimMeanRequestBuilder.cs index 46fbf9da8e9..fb1ccaae5b6 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/TrimMean/TrimMeanRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/TrimMean/TrimMeanRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action trimMean"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(TrimMeanRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action trimMean - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TrimMeanRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class TrimMeanResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/True/TrueRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/True/TrueRequestBuilder.cs new file mode 100644 index 00000000000..95b7bb2a1be --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Functions/True/TrueRequestBuilder.cs @@ -0,0 +1,105 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Functions.True { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\functions\microsoft.graph.true + public class TrueRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action true + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action true"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + var requestInfo = CreatePostRequestInformation(q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, outputOption); + return command; + } + /// + /// Instantiates a new TrueRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public TrueRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/functions/microsoft.graph.true"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action true + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(Action> h = default, IEnumerable o = default) { + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookFunctionResult + public class TrueResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookFunctionResult + public WorkbookFunctionResult WorkbookFunctionResult { get; set; } + /// + /// Instantiates a new trueResponse and sets the default values. + /// + public TrueResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookFunctionResult", (o,n) => { (o as TrueResponse).WorkbookFunctionResult = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookFunctionResult", WorkbookFunctionResult); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Trunc/TruncRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Trunc/TruncRequestBuilder.cs index 01326701e7a..3326e8867a5 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Trunc/TruncRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Trunc/TruncRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action trunc"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(TruncRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action trunc - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TruncRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class TruncResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Type/TypeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Type/TypeRequestBuilder.cs index 39f776aaf90..9340c63f2e4 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Type/TypeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Type/TypeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action type"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(TypeRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action type - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(TypeRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class TypeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Unichar/UnicharRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Unichar/UnicharRequestBuilder.cs index b6c4769eda4..a8f77df57bd 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Unichar/UnicharRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Unichar/UnicharRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action unichar"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(UnicharRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action unichar - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UnicharRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class UnicharResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Unicode/UnicodeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Unicode/UnicodeRequestBuilder.cs index 2ca05d017c2..2e3bf932fad 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Unicode/UnicodeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Unicode/UnicodeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action unicode"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(UnicodeRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action unicode - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UnicodeRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class UnicodeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Upper/UpperRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Upper/UpperRequestBuilder.cs index 939fc02a3f8..c79eea697c0 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Upper/UpperRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Upper/UpperRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action upper"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(UpperRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action upper - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UpperRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class UpperResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Usdollar/UsdollarRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Usdollar/UsdollarRequestBuilder.cs index 12618b66a17..fc5ead22911 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Usdollar/UsdollarRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Usdollar/UsdollarRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action usdollar"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(UsdollarRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action usdollar - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(UsdollarRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class UsdollarResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Value/ValueRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Value/ValueRequestBuilder.cs index efec95ebe52..368b2c319e8 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Value/ValueRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Value/ValueRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action value"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(ValueRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action value - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ValueRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class ValueResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/VarA/VarARequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/VarA/VarARequestBuilder.cs index 49875cc6733..cb36e8e06a7 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/VarA/VarARequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/VarA/VarARequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action varA"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(VarARequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action varA - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(VarARequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class VarAResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/VarPA/VarPARequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/VarPA/VarPARequestBuilder.cs index 756c787d5bd..233d37c04a4 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/VarPA/VarPARequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/VarPA/VarPARequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action varPA"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(VarPARequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action varPA - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(VarPARequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class VarPAResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Var_P/Var_PRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Var_P/Var_PRequestBuilder.cs index 22acf9fdf9c..62c1eda19da 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Var_P/Var_PRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Var_P/Var_PRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action var_P"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Var_PRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action var_P - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Var_PRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Var_PResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Var_S/Var_SRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Var_S/Var_SRequestBuilder.cs index 6b0615f4148..a2d2b58394b 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Var_S/Var_SRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Var_S/Var_SRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action var_S"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Var_SRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action var_S - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Var_SRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Var_SResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Vdb/VdbRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Vdb/VdbRequestBuilder.cs index 5bff4354749..41891929596 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Vdb/VdbRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Vdb/VdbRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action vdb"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(VdbRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action vdb - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(VdbRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class VdbResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Vlookup/VlookupRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Vlookup/VlookupRequestBuilder.cs index b896e75b61b..7b7e71a1ee8 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Vlookup/VlookupRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Vlookup/VlookupRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action vlookup"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(VlookupRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action vlookup - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(VlookupRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class VlookupResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/WeekNum/WeekNumRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/WeekNum/WeekNumRequestBuilder.cs index d61295dce88..481d4de31ce 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/WeekNum/WeekNumRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/WeekNum/WeekNumRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action weekNum"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(WeekNumRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action weekNum - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WeekNumRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class WeekNumResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Weekday/WeekdayRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Weekday/WeekdayRequestBuilder.cs index 657dd95ab38..fdc0bc66405 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Weekday/WeekdayRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Weekday/WeekdayRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action weekday"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(WeekdayRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action weekday - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WeekdayRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class WeekdayResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Weibull_Dist/Weibull_DistRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Weibull_Dist/Weibull_DistRequestBuilder.cs index 070277a91e2..8291e38e1bb 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Weibull_Dist/Weibull_DistRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Weibull_Dist/Weibull_DistRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action weibull_Dist"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Weibull_DistRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action weibull_Dist - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Weibull_DistRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Weibull_DistResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/WorkDay/WorkDayRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/WorkDay/WorkDayRequestBuilder.cs index 67da2902c87..cb21d25cd3d 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/WorkDay/WorkDayRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/WorkDay/WorkDayRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action workDay"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(WorkDayRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action workDay - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkDayRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class WorkDayResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/WorkDay_Intl/WorkDay_IntlRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/WorkDay_Intl/WorkDay_IntlRequestBuilder.cs index d1bbb5b27fb..7acc03cfc7d 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/WorkDay_Intl/WorkDay_IntlRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/WorkDay_Intl/WorkDay_IntlRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action workDay_Intl"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(WorkDay_IntlRequestBody b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action workDay_Intl - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkDay_IntlRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class WorkDay_IntlResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Xirr/XirrRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Xirr/XirrRequestBuilder.cs index 49ba9c2ef64..1ce3cd52cd8 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Xirr/XirrRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Xirr/XirrRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action xirr"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(XirrRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action xirr - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(XirrRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class XirrResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Xnpv/XnpvRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Xnpv/XnpvRequestBuilder.cs index 55d3d88873f..6473c00b766 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Xnpv/XnpvRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Xnpv/XnpvRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action xnpv"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(XnpvRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action xnpv - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(XnpvRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class XnpvResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Xor/XorRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Xor/XorRequestBuilder.cs index 33c7d9ce3e9..f666294e147 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Xor/XorRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Xor/XorRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action xor"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(XorRequestBody body, Acti requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action xor - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(XorRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class XorResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Year/YearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Year/YearRequestBuilder.cs index e13dc6c1c8d..a4a7592a69d 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Year/YearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Year/YearRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action year"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(YearRequestBody body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action year - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(YearRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class YearResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/YearFrac/YearFracRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/YearFrac/YearFracRequestBuilder.cs index 46d1c521cfc..2bfb511b2bc 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/YearFrac/YearFracRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/YearFrac/YearFracRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action yearFrac"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(YearFracRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action yearFrac - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(YearFracRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class YearFracResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/@Yield/YieldRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Functions/Yield/YieldRequestBody.cs similarity index 97% rename from src/generated/Workbooks/Item/Workbook/Functions/@Yield/YieldRequestBody.cs rename to src/generated/Workbooks/Item/Workbook/Functions/Yield/YieldRequestBody.cs index 6cfef51e496..ae24fbee557 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/@Yield/YieldRequestBody.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Yield/YieldRequestBody.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Functions.@Yield { +namespace ApiSdk.Workbooks.Item.Workbook.Functions.Yield { public class YieldRequestBody : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. public IDictionary AdditionalData { get; set; } diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Yield/YieldRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Yield/YieldRequestBuilder.cs new file mode 100644 index 00000000000..c2e8294e77f --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Functions/Yield/YieldRequestBuilder.cs @@ -0,0 +1,115 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Functions.Yield { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\functions\microsoft.graph.yield + public class YieldRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action yield + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action yield"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new YieldRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public YieldRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/functions/microsoft.graph.yield"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action yield + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(YieldRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookFunctionResult + public class YieldResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookFunctionResult + public WorkbookFunctionResult WorkbookFunctionResult { get; set; } + /// + /// Instantiates a new yieldResponse and sets the default values. + /// + public YieldResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookFunctionResult", (o,n) => { (o as YieldResponse).WorkbookFunctionResult = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookFunctionResult", WorkbookFunctionResult); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Functions/YieldDisc/YieldDiscRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/YieldDisc/YieldDiscRequestBuilder.cs index d5532b7a3f9..724529ad529 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/YieldDisc/YieldDiscRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/YieldDisc/YieldDiscRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action yieldDisc"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(YieldDiscRequestBody body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action yieldDisc - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(YieldDiscRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class YieldDiscResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/YieldMat/YieldMatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/YieldMat/YieldMatRequestBuilder.cs index bdd6997d470..7cdfd1dc978 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/YieldMat/YieldMatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/YieldMat/YieldMatRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action yieldMat"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(YieldMatRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action yieldMat - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(YieldMatRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class YieldMatResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Functions/Z_Test/Z_TestRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Functions/Z_Test/Z_TestRequestBuilder.cs index 6ceb1e0bbee..5e767c33114 100644 --- a/src/generated/Workbooks/Item/Workbook/Functions/Z_Test/Z_TestRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Functions/Z_Test/Z_TestRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action z_Test"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(Z_TestRequestBody body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action z_Test - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Z_TestRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookFunctionResult public class Z_TestResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/@Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Names/@Add/AddRequestBody.cs deleted file mode 100644 index ea5b22197e6..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Names/@Add/AddRequestBody.cs +++ /dev/null @@ -1,42 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Names.@Add { - public class AddRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string Comment { get; set; } - public string Name { get; set; } - public Json Reference { get; set; } - /// - /// Instantiates a new addRequestBody and sets the default values. - /// - public AddRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"comment", (o,n) => { (o as AddRequestBody).Comment = n.GetStringValue(); } }, - {"name", (o,n) => { (o as AddRequestBody).Name = n.GetStringValue(); } }, - {"reference", (o,n) => { (o as AddRequestBody).Reference = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("comment", Comment); - writer.WriteStringValue("name", Name); - writer.WriteObjectValue("reference", Reference); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Names/@Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/@Add/AddRequestBuilder.cs deleted file mode 100644 index 83aa80a9355..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Names/@Add/AddRequestBuilder.cs +++ /dev/null @@ -1,129 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Names.@Add { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\microsoft.graph.add - public class AddRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action add - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action add"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AddRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/names/microsoft.graph.add"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action add - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action add - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookNamedItem - public class AddResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookNamedItem - public WorkbookNamedItem WorkbookNamedItem { get; set; } - /// - /// Instantiates a new addResponse and sets the default values. - /// - public AddResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookNamedItem", (o,n) => { (o as AddResponse).WorkbookNamedItem = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookNamedItem", WorkbookNamedItem); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Names/Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Names/Add/AddRequestBody.cs new file mode 100644 index 00000000000..067a56aac39 --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Names/Add/AddRequestBody.cs @@ -0,0 +1,42 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Workbooks.Item.Workbook.Names.Add { + public class AddRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string Comment { get; set; } + public string Name { get; set; } + public Json Reference { get; set; } + /// + /// Instantiates a new addRequestBody and sets the default values. + /// + public AddRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"comment", (o,n) => { (o as AddRequestBody).Comment = n.GetStringValue(); } }, + {"name", (o,n) => { (o as AddRequestBody).Name = n.GetStringValue(); } }, + {"reference", (o,n) => { (o as AddRequestBody).Reference = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("comment", Comment); + writer.WriteStringValue("name", Name); + writer.WriteObjectValue("reference", Reference); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Names/Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Add/AddRequestBuilder.cs new file mode 100644 index 00000000000..ebf92ad8493 --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Names/Add/AddRequestBuilder.cs @@ -0,0 +1,115 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Names.Add { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\microsoft.graph.add + public class AddRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action add + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action add"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new AddRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/names/microsoft.graph.add"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action add + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookNamedItem + public class AddResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookNamedItem + public WorkbookNamedItem WorkbookNamedItem { get; set; } + /// + /// Instantiates a new addResponse and sets the default values. + /// + public AddResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookNamedItem", (o,n) => { (o as AddResponse).WorkbookNamedItem = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookNamedItem", WorkbookNamedItem); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Names/AddFormulaLocal/AddFormulaLocalRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/AddFormulaLocal/AddFormulaLocalRequestBuilder.cs index 5d4534b57c4..6b5823a00b2 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/AddFormulaLocal/AddFormulaLocalRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/AddFormulaLocal/AddFormulaLocalRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action addFormulaLocal"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,21 +34,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -82,19 +81,6 @@ public RequestInformation CreatePostRequestInformation(AddFormulaLocalRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action addFormulaLocal - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddFormulaLocalRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookNamedItem public class AddFormulaLocalResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Range/RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Range/RangeRequestBuilder.cs index 4f8d25bb77d..e646c4e08e1 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Range/RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/WorkbookNamedItemRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/WorkbookNamedItemRequestBuilder.cs index e79d9c40733..70ea9f2465c 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/WorkbookNamedItemRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/WorkbookNamedItemRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,19 +28,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents a collection of workbooks scoped named items (named ranges and constants). Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption); return command; @@ -52,11 +51,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents a collection of workbooks scoped named items (named ranges and constants). Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -70,20 +69,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -93,11 +91,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents a collection of workbooks scoped named items (named ranges and constants). Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -105,14 +103,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, bodyOption); return command; @@ -198,42 +195,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookNamedItem body, return requestInfo; } /// - /// Represents a collection of workbooks scoped named items (named ranges and constants). Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a collection of workbooks scoped named items (named ranges and constants). Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a collection of workbooks scoped named items (named ranges and constants). Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookNamedItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\microsoft.graph.range() /// public RangeRequestBuilder Range() { diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs index 1c876e7b2f1..9a040c2c58b 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function cell"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -42,18 +42,17 @@ public Command BuildGetCommand() { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, int? row, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, int? row, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, rowOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, rowOption, columnOption, outputOption); return command; } /// @@ -88,17 +87,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function cell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class CellWithRowWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/@Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/@Add/AddRequestBody.cs deleted file mode 100644 index 6bfc6fd7d74..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/@Add/AddRequestBody.cs +++ /dev/null @@ -1,42 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.@Add { - public class AddRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string SeriesBy { get; set; } - public Json SourceData { get; set; } - public string Type { get; set; } - /// - /// Instantiates a new addRequestBody and sets the default values. - /// - public AddRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"seriesBy", (o,n) => { (o as AddRequestBody).SeriesBy = n.GetStringValue(); } }, - {"sourceData", (o,n) => { (o as AddRequestBody).SourceData = n.GetObjectValue(); } }, - {"type", (o,n) => { (o as AddRequestBody).Type = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("seriesBy", SeriesBy); - writer.WriteObjectValue("sourceData", SourceData); - writer.WriteStringValue("type", Type); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/@Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/@Add/AddRequestBuilder.cs deleted file mode 100644 index f369942e9af..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/@Add/AddRequestBuilder.cs +++ /dev/null @@ -1,133 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.@Add { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\worksheet\charts\microsoft.graph.add - public class AddRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action add - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action add"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { - }; - workbookNamedItemIdOption.IsRequired = true; - command.AddOption(workbookNamedItemIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AddRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/names/{workbookNamedItem_id}/worksheet/charts/microsoft.graph.add"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action add - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action add - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookChart - public class AddResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookChart - public WorkbookChart WorkbookChart { get; set; } - /// - /// Instantiates a new addResponse and sets the default values. - /// - public AddResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookChart", (o,n) => { (o as AddResponse).WorkbookChart = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookChart", WorkbookChart); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Add/AddRequestBody.cs new file mode 100644 index 00000000000..d52c126142b --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Add/AddRequestBody.cs @@ -0,0 +1,42 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Add { + public class AddRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string SeriesBy { get; set; } + public Json SourceData { get; set; } + public string Type { get; set; } + /// + /// Instantiates a new addRequestBody and sets the default values. + /// + public AddRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"seriesBy", (o,n) => { (o as AddRequestBody).SeriesBy = n.GetStringValue(); } }, + {"sourceData", (o,n) => { (o as AddRequestBody).SourceData = n.GetObjectValue(); } }, + {"type", (o,n) => { (o as AddRequestBody).Type = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("seriesBy", SeriesBy); + writer.WriteObjectValue("sourceData", SourceData); + writer.WriteStringValue("type", Type); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Add/AddRequestBuilder.cs new file mode 100644 index 00000000000..543d5f328f0 --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Add/AddRequestBuilder.cs @@ -0,0 +1,119 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Add { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\worksheet\charts\microsoft.graph.add + public class AddRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action add + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action add"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { + }; + workbookNamedItemIdOption.IsRequired = true; + command.AddOption(workbookNamedItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new AddRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/names/{workbookNamedItem_id}/worksheet/charts/microsoft.graph.add"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action add + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookChart + public class AddResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookChart + public WorkbookChart WorkbookChart { get; set; } + /// + /// Instantiates a new addResponse and sets the default values. + /// + public AddResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookChart", (o,n) => { (o as AddResponse).WorkbookChart = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookChart", WorkbookChart); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/ChartsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/ChartsRequestBuilder.cs index aafbe134962..519b716001a 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/ChartsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/ChartsRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.ItemWithName; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public class ChartsRequestBuilder { private string UrlTemplate { get; set; } public Command BuildAddCommand() { var command = new Command("add"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.@Add.AddRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Add.AddRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } public List BuildCommand() { var builder = new WorkbookChartRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAxesCommand(), - builder.BuildDataLabelsCommand(), - builder.BuildDeleteCommand(), - builder.BuildFormatCommand(), - builder.BuildGetCommand(), - builder.BuildLegendCommand(), - builder.BuildPatchCommand(), - builder.BuildSeriesCommand(), - builder.BuildSetDataCommand(), - builder.BuildSetPositionCommand(), - builder.BuildTitleCommand(), - builder.BuildWorksheetCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAxesCommand()); + commands.Add(builder.BuildDataLabelsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFormatCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildLegendCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSeriesCommand()); + commands.Add(builder.BuildSetDataCommand()); + commands.Add(builder.BuildSetPositionCommand()); + commands.Add(builder.BuildTitleCommand()); + commands.Add(builder.BuildWorksheetCommand()); return commands; } /// @@ -55,11 +54,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Returns collection of charts that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -67,21 +66,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, bodyOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Returns collection of charts that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -134,7 +132,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -145,15 +147,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -215,18 +212,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookChart body, Actio return requestInfo; } /// - /// Returns collection of charts that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\worksheet\charts\microsoft.graph.itemAt(index={index}) /// Usage: index={index} /// @@ -242,19 +227,6 @@ public ItemWithNameRequestBuilder ItemWithName(string name) { if(string.IsNullOrEmpty(name)) throw new ArgumentNullException(nameof(name)); return new ItemWithNameRequestBuilder(PathParameters, RequestAdapter, name); } - /// - /// Returns collection of charts that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookChart model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns collection of charts that are part of the worksheet. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Count/CountRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Count/CountRequestBuilder.cs index b445ff722e9..b4459ed8aee 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Count/CountRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Count/CountRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,26 +25,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function count"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteIntValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, outputOption); return command; } /// @@ -75,16 +74,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function count - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/AxesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/AxesRequestBuilder.cs index 99ba32b1b0c..c9cec8721c5 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/AxesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/AxesRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.ValueAxis; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,23 +41,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart axes. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -69,15 +68,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart axes. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -91,20 +90,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -114,15 +112,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart axes. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -130,14 +128,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -233,42 +230,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxes body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart axes. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart axes. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart axes. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxes model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart axes. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/CategoryAxisRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/CategoryAxisRequestBuilder.cs index 94068415415..026c25d8900 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/CategoryAxisRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/CategoryAxisRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.CategoryAxis.Title; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the category axis in a chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -68,15 +67,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the category axis in a chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildMajorGridlinesCommand() { @@ -131,15 +129,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the category axis in a chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -147,14 +145,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -235,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxis body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the category axis in a chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the category axis in a chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the category axis in a chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxis model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the category axis in a chart. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/Font/FontRequestBuilder.cs index 9482364012a..e62649970cb 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/FormatRequestBuilder.cs index 063b4a67f42..bdabcbab0ee 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/FormatRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.CategoryAxis.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,23 +28,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of a chart object, which includes line and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of a chart object, which includes line and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -118,15 +116,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of a chart object, which includes line and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxisFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxisFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/Line/Clear/ClearRequestBuilder.cs index fc49a8811d7..3ea63ed575a 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/Line/LineRequestBuilder.cs index 54746917366..ca2ec922ee0 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.CategoryAxis.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/FormatRequestBuilder.cs index ae87d99d3d6..07a7cb1880f 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.CategoryAxis.MajorGridlines.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -55,15 +54,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlinesFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlinesFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of chart gridlines. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs index ad07981128d..61456133377 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs index 48513ab5463..2fd4a0dafd2 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.CategoryAxis.MajorGridlines.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs index c6a13f6c390..efda9ddfda1 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.CategoryAxis.MajorGridlines.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns a gridlines object that represents the major gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns a gridlines object that represents the major gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns a gridlines object that represents the major gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlines b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlines model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/FormatRequestBuilder.cs index 29ef7b161de..77024256075 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.CategoryAxis.MinorGridlines.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -55,15 +54,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlinesFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlinesFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of chart gridlines. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs index 0fdb7e01bcc..1307a59c62e 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs index cddfdbca7e6..71912f7e19b 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.CategoryAxis.MinorGridlines.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs index f5f12d312cc..6a435044a99 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.CategoryAxis.MinorGridlines.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlines b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlines model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Title/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Title/Format/Font/FontRequestBuilder.cs index 604fd3a3c57..564e8017893 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Title/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Title/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Title/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Title/Format/FormatRequestBuilder.cs index badac4d464e..801e8a94608 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Title/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Title/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.CategoryAxis.Title.Format.Font; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of chart axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -63,15 +62,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of chart axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -85,20 +84,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -108,15 +106,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of chart axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -124,14 +122,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -203,42 +200,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxisTitleFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of chart axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxisTitleFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of chart axis title. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Title/TitleRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Title/TitleRequestBuilder.cs index 6b158a19467..55804067a0a 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Title/TitleRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Title/TitleRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.CategoryAxis.Title.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxisTitle b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxisTitle model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the axis title. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/Font/FontRequestBuilder.cs index d4e65f37c9c..5d6f55df29b 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/FormatRequestBuilder.cs index abeacffb01f..e8e786c1727 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/FormatRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.SeriesAxis.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,23 +28,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of a chart object, which includes line and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of a chart object, which includes line and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -118,15 +116,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of a chart object, which includes line and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxisFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxisFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/Line/Clear/ClearRequestBuilder.cs index 23bec65145b..3391cbdb337 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/Line/LineRequestBuilder.cs index 2bad7b7b7c4..ff44877f559 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.SeriesAxis.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/FormatRequestBuilder.cs index 24ed2a1a780..684b9b030d1 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.SeriesAxis.MajorGridlines.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -55,15 +54,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlinesFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlinesFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of chart gridlines. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs index 9c9d2167dce..93dc67fa3dd 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs index 3005aabe4f5..a2dd9cac39b 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.SeriesAxis.MajorGridlines.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs index 1f30af6079c..a94fd75a4d6 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.SeriesAxis.MajorGridlines.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns a gridlines object that represents the major gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns a gridlines object that represents the major gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns a gridlines object that represents the major gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlines b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlines model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/FormatRequestBuilder.cs index 42be92f25f0..7de0b535ba7 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.SeriesAxis.MinorGridlines.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -55,15 +54,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlinesFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlinesFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of chart gridlines. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs index 519c471dab7..aa40959823d 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs index 4ac1f28bd3b..d9310663cf1 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.SeriesAxis.MinorGridlines.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs index 445ee43fc2b..3b2a6b2f668 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.SeriesAxis.MinorGridlines.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlines b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlines model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/SeriesAxisRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/SeriesAxisRequestBuilder.cs index ecd43164c30..6a1d161cf7c 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/SeriesAxisRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/SeriesAxisRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.SeriesAxis.Title; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the series axis of a 3-dimensional chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -68,15 +67,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the series axis of a 3-dimensional chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildMajorGridlinesCommand() { @@ -131,15 +129,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the series axis of a 3-dimensional chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -147,14 +145,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -235,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxis body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the series axis of a 3-dimensional chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the series axis of a 3-dimensional chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the series axis of a 3-dimensional chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxis model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the series axis of a 3-dimensional chart. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Title/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Title/Format/Font/FontRequestBuilder.cs index ed09a61389d..930a2f9b74a 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Title/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Title/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Title/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Title/Format/FormatRequestBuilder.cs index ff591b40a3e..ce7d8a5e132 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Title/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Title/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.SeriesAxis.Title.Format.Font; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of chart axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -63,15 +62,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of chart axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -85,20 +84,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -108,15 +106,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of chart axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -124,14 +122,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -203,42 +200,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxisTitleFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of chart axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxisTitleFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of chart axis title. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Title/TitleRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Title/TitleRequestBuilder.cs index 09606929bd7..78b9ad41ca6 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Title/TitleRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Title/TitleRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.SeriesAxis.Title.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxisTitle b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxisTitle model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the axis title. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/Font/FontRequestBuilder.cs index 2a58d669d26..0336c975e64 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/FormatRequestBuilder.cs index f5b4f5cc4ce..d61ba07d714 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/FormatRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.ValueAxis.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,23 +28,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of a chart object, which includes line and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of a chart object, which includes line and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -118,15 +116,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of a chart object, which includes line and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxisFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxisFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/Line/Clear/ClearRequestBuilder.cs index b3b5d711f40..08efccbc897 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/Line/LineRequestBuilder.cs index ed77c79f78d..e9722376779 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.ValueAxis.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/FormatRequestBuilder.cs index 0816c068c07..e95d7ddec02 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.ValueAxis.MajorGridlines.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -55,15 +54,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlinesFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlinesFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of chart gridlines. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs index 7359a28cc60..ce1258d0c36 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs index ccbb398401a..6e09d67f1d8 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.ValueAxis.MajorGridlines.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs index 6c38e58de43..92f35dff983 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.ValueAxis.MajorGridlines.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns a gridlines object that represents the major gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns a gridlines object that represents the major gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns a gridlines object that represents the major gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlines b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlines model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/FormatRequestBuilder.cs index f065cbfddc5..d4cdb907ff0 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.ValueAxis.MinorGridlines.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -55,15 +54,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlinesFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlinesFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of chart gridlines. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs index 99c13a6742f..d014370d0fa 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs index b4bc23adbd8..380bb39d027 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.ValueAxis.MinorGridlines.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs index 26aa2e89689..c0b5165af14 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.ValueAxis.MinorGridlines.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlines b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlines model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Title/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Title/Format/Font/FontRequestBuilder.cs index ca1c5294023..01553d758d2 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Title/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Title/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Title/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Title/Format/FormatRequestBuilder.cs index 755b185849c..f3ff4ae148c 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Title/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Title/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.ValueAxis.Title.Format.Font; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of chart axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -63,15 +62,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of chart axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -85,20 +84,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -108,15 +106,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of chart axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -124,14 +122,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -203,42 +200,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxisTitleFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of chart axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxisTitleFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of chart axis title. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Title/TitleRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Title/TitleRequestBuilder.cs index f07fdd46de8..31ed4028243 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Title/TitleRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/Title/TitleRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.ValueAxis.Title.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxisTitle b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxisTitle model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the axis title. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/ValueAxisRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/ValueAxisRequestBuilder.cs index 64d70133fda..ff760f2a835 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/ValueAxisRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Axes/ValueAxis/ValueAxisRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Axes.ValueAxis.Title; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the value axis in an axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -68,15 +67,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the value axis in an axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildMajorGridlinesCommand() { @@ -131,15 +129,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the value axis in an axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -147,14 +145,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -235,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxis body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the value axis in an axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the value axis in an axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the value axis in an axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxis model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the value axis in an axis. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/DataLabels/DataLabelsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/DataLabels/DataLabelsRequestBuilder.cs index e613844db43..a746518ae37 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/DataLabels/DataLabelsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/DataLabels/DataLabelsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.DataLabels.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the datalabels on the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -65,15 +64,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the datalabels on the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -87,20 +86,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,15 +108,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the datalabels on the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -126,14 +124,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -205,42 +202,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartDataLabels requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the datalabels on the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the datalabels on the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the datalabels on the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartDataLabels model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the datalabels on the chart. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/DataLabels/Format/Fill/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/DataLabels/Format/Fill/Clear/ClearRequestBuilder.cs index ef8c25f8c06..fe267954c98 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/DataLabels/Format/Fill/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/DataLabels/Format/Fill/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/DataLabels/Format/Fill/FillRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/DataLabels/Format/Fill/FillRequestBuilder.cs index a62c2ac3226..4ece701a674 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/DataLabels/Format/Fill/FillRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/DataLabels/Format/Fill/FillRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.DataLabels.Format.Fill.SetSolidColor; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,23 +34,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the fill format of the current chart data label. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the fill format of the current chart data label. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,15 +105,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the fill format of the current chart data label. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -123,14 +121,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFill body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the fill format of the current chart data label. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of the current chart data label. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of the current chart data label. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFill model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the fill format of the current chart data label. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/DataLabels/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/DataLabels/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs index 17627299043..8e47f660559 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/DataLabels/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/DataLabels/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setSolidColor"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SetSolidColorRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setSolidColor - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetSolidColorRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/DataLabels/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/DataLabels/Format/Font/FontRequestBuilder.cs index cf5b8a1fa01..0f230141f32 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/DataLabels/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/DataLabels/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart data label. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart data label. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart data label. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart data label. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart data label. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart data label. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes (font name, font size, color, etc.) for a chart data label. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/DataLabels/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/DataLabels/Format/FormatRequestBuilder.cs index 93f02a7ac47..10ea0435244 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/DataLabels/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/DataLabels/Format/FormatRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.DataLabels.Format.Font; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,23 +28,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the format of chart data labels, which includes fill and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -74,15 +73,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the format of chart data labels, which includes fill and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -96,20 +95,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,15 +117,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the format of chart data labels, which includes fill and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -135,14 +133,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -214,42 +211,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartDataLabelFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the format of chart data labels, which includes fill and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the format of chart data labels, which includes fill and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the format of chart data labels, which includes fill and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartDataLabelFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the format of chart data labels, which includes fill and font formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Format/Fill/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Format/Fill/Clear/ClearRequestBuilder.cs index 701884eaf53..2980912404b 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Format/Fill/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Format/Fill/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Format/Fill/FillRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Format/Fill/FillRequestBuilder.cs index 31ce8b11256..81cc24ab4e8 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Format/Fill/FillRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Format/Fill/FillRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Format.Fill.SetSolidColor; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,23 +34,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the fill format of an object, which includes background formatting information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the fill format of an object, which includes background formatting information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,15 +105,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the fill format of an object, which includes background formatting information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -123,14 +121,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFill body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the fill format of an object, which includes background formatting information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of an object, which includes background formatting information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of an object, which includes background formatting information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFill model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the fill format of an object, which includes background formatting information. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs index dcc6dc8e33d..73bfcca41f6 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setSolidColor"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SetSolidColorRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setSolidColor - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetSolidColorRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Format/Font/FontRequestBuilder.cs index ea09c3ad703..2093e5ce15d 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Format/FormatRequestBuilder.cs index 925b1006c23..6dd9e824b0e 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Format/FormatRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Format.Font; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,23 +28,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Encapsulates the format properties for the chart area. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -74,15 +73,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Encapsulates the format properties for the chart area. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -96,20 +95,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,15 +117,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Encapsulates the format properties for the chart area. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -135,14 +133,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -214,42 +211,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAreaFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Encapsulates the format properties for the chart area. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Encapsulates the format properties for the chart area. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Encapsulates the format properties for the chart area. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAreaFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Encapsulates the format properties for the chart area. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Image/ImageRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Image/ImageRequestBuilder.cs index e5fa4ce9928..244135eaa18 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Image/ImageRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Image/ImageRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,30 +25,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function image"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, outputOption); return command; } /// @@ -79,16 +78,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function image - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/ImageWithWidth/ImageWithWidthRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/ImageWithWidth/ImageWithWidthRequestBuilder.cs index f607e1fe624..1b61f99088f 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/ImageWithWidth/ImageWithWidthRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/ImageWithWidth/ImageWithWidthRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function image"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -41,18 +41,17 @@ public Command BuildGetCommand() { }; widthOption.IsRequired = true; command.AddOption(widthOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, int? width) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, int? width, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, widthOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, widthOption, outputOption); return command; } /// @@ -85,16 +84,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function image - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/ImageWithWidthWithHeight/ImageWithWidthWithHeightRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/ImageWithWidthWithHeight/ImageWithWidthWithHeightRequestBuilder.cs index 5dc40b58270..f38639ae689 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/ImageWithWidthWithHeight/ImageWithWidthWithHeightRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/ImageWithWidthWithHeight/ImageWithWidthWithHeightRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function image"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -45,18 +45,17 @@ public Command BuildGetCommand() { }; heightOption.IsRequired = true; command.AddOption(heightOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, int? width, int? height) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, int? width, int? height, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, widthOption, heightOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, widthOption, heightOption, outputOption); return command; } /// @@ -91,16 +90,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function image - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/ImageWithWidthWithHeightWithFittingMode/ImageWithWidthWithHeightWithFittingModeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/ImageWithWidthWithHeightWithFittingMode/ImageWithWidthWithHeightWithFittingModeRequestBuilder.cs index 8c2ac8625e8..4c5f469de6e 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/ImageWithWidthWithHeightWithFittingMode/ImageWithWidthWithHeightWithFittingModeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/ImageWithWidthWithHeightWithFittingMode/ImageWithWidthWithHeightWithFittingModeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function image"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -45,22 +45,21 @@ public Command BuildGetCommand() { }; heightOption.IsRequired = true; command.AddOption(heightOption); - var fittingModeOption = new Option("--fittingmode", description: "Usage: fittingMode={fittingMode}") { + var fittingModeOption = new Option("--fitting-mode", description: "Usage: fittingMode={fittingMode}") { }; fittingModeOption.IsRequired = true; command.AddOption(fittingModeOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, int? width, int? height, string fittingMode) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, int? width, int? height, string fittingMode, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, widthOption, heightOption, fittingModeOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, widthOption, heightOption, fittingModeOption, outputOption); return command; } /// @@ -97,16 +96,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function image - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Legend/Format/Fill/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Legend/Format/Fill/Clear/ClearRequestBuilder.cs index e774523113a..3fa0338a898 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Legend/Format/Fill/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Legend/Format/Fill/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Legend/Format/Fill/FillRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Legend/Format/Fill/FillRequestBuilder.cs index 09ef0ac1a30..f70325c4e89 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Legend/Format/Fill/FillRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Legend/Format/Fill/FillRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Legend.Format.Fill.SetSolidColor; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,23 +34,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the fill format of an object, which includes background formating information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the fill format of an object, which includes background formating information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,15 +105,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the fill format of an object, which includes background formating information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -123,14 +121,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFill body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the fill format of an object, which includes background formating information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of an object, which includes background formating information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of an object, which includes background formating information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFill model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the fill format of an object, which includes background formating information. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Legend/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Legend/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs index f2b196ed0bb..76ad05b94f1 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Legend/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Legend/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setSolidColor"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SetSolidColorRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setSolidColor - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetSolidColorRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Legend/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Legend/Format/Font/FontRequestBuilder.cs index 4b0596fdab6..4cba874f52a 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Legend/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Legend/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes such as font name, font size, color, etc. of a chart legend. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes such as font name, font size, color, etc. of a chart legend. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes such as font name, font size, color, etc. of a chart legend. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes such as font name, font size, color, etc. of a chart legend. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes such as font name, font size, color, etc. of a chart legend. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes such as font name, font size, color, etc. of a chart legend. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes such as font name, font size, color, etc. of a chart legend. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Legend/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Legend/Format/FormatRequestBuilder.cs index a9789856f21..df9af6b7e72 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Legend/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Legend/Format/FormatRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Legend.Format.Font; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,23 +28,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of a chart legend, which includes fill and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -74,15 +73,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of a chart legend, which includes fill and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -96,20 +95,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,15 +117,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of a chart legend, which includes fill and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -135,14 +133,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -214,42 +211,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLegendForma requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of a chart legend, which includes fill and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart legend, which includes fill and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart legend, which includes fill and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLegendFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of a chart legend, which includes fill and font formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Legend/LegendRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Legend/LegendRequestBuilder.cs index 39046d0a9c3..2fd4a51c472 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Legend/LegendRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Legend/LegendRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Legend.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the legend for the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -65,15 +64,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the legend for the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -87,20 +86,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,15 +108,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the legend for the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -126,14 +124,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -205,42 +202,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLegend body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the legend for the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the legend for the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the legend for the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLegend model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the legend for the chart. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Count/CountRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Count/CountRequestBuilder.cs index 25cdab09e26..1cf25d61c5d 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Count/CountRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Count/CountRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,30 +25,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function count"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteIntValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, outputOption); return command; } /// @@ -79,16 +78,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function count - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Format/Fill/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Format/Fill/Clear/ClearRequestBuilder.cs index 1bb43611fec..423b8a98240 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Format/Fill/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Format/Fill/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,27 +25,26 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption); return command; @@ -78,16 +77,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Format/Fill/FillRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Format/Fill/FillRequestBuilder.cs index 236d40fa68e..c5b9d506276 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Format/Fill/FillRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Format/Fill/FillRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Series.Item.Format.Fill.SetSolidColor; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,27 +34,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the fill format of a chart series, which includes background formating information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption); return command; @@ -66,19 +65,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the fill format of a chart series, which includes background formating information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -92,20 +91,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,19 +113,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the fill format of a chart series, which includes background formating information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -135,14 +133,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFill body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the fill format of a chart series, which includes background formating information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of a chart series, which includes background formating information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of a chart series, which includes background formating information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFill model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the fill format of a chart series, which includes background formating information. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs index e58edd1f723..3650b98493f 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setSolidColor"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(SetSolidColorRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setSolidColor - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetSolidColorRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Format/FormatRequestBuilder.cs index 29e92cf9fa9..f3a43bd3a19 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Format/FormatRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Series.Item.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,27 +28,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of a chart series, which includes fill and line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption); return command; @@ -70,19 +69,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of a chart series, which includes fill and line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -96,20 +95,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -128,19 +126,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of a chart series, which includes fill and line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -148,14 +146,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, bodyOption); return command; @@ -227,42 +224,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartSeriesForma requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of a chart series, which includes fill and line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart series, which includes fill and line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart series, which includes fill and line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartSeriesFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of a chart series, which includes fill and line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Format/Line/Clear/ClearRequestBuilder.cs index c0cfdc3aac6..0b1223de677 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,27 +25,26 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption); return command; @@ -78,16 +77,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Format/Line/LineRequestBuilder.cs index f2ed0e7ca80..70dd7617c33 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Series.Item.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,27 +33,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption); return command; @@ -65,19 +64,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -91,20 +90,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -114,19 +112,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/Count/CountRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/Count/CountRequestBuilder.cs index af16d745023..9c98473e05e 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/Count/CountRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/Count/CountRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,34 +25,33 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function count"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteIntValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, outputOption); return command; } /// @@ -83,16 +82,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function count - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/Fill/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/Fill/Clear/ClearRequestBuilder.cs index 415b04dc71a..892d89c44ac 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/Fill/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/Fill/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,31 +25,30 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption); return command; @@ -82,16 +81,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/Fill/FillRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/Fill/FillRequestBuilder.cs index f9447d4ae90..e25c25b3b03 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/Fill/FillRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/Fill/FillRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Series.Item.Points.Item.Format.Fill.SetSolidColor; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,31 +34,30 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the fill format of a chart, which includes background formating information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption); return command; @@ -70,23 +69,23 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the fill format of a chart, which includes background formating information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); @@ -100,20 +99,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -123,23 +121,23 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the fill format of a chart, which includes background formating information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); @@ -147,14 +145,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, bodyOption); return command; @@ -232,42 +229,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFill body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the fill format of a chart, which includes background formating information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of a chart, which includes background formating information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of a chart, which includes background formating information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFill model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the fill format of a chart, which includes background formating information. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs index 331199cd5a8..695eb01885c 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,23 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setSolidColor"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); @@ -49,14 +49,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, bodyOption); return command; @@ -92,18 +91,5 @@ public RequestInformation CreatePostRequestInformation(SetSolidColorRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setSolidColor - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetSolidColorRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/FormatRequestBuilder.cs index 57e6a7f6316..6ef635ecf5a 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Series.Item.Points.Item.Format.Fill; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,31 +27,30 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Encapsulates the format properties chart point. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption); return command; @@ -73,23 +72,23 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Encapsulates the format properties chart point. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); @@ -103,20 +102,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -126,23 +124,23 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Encapsulates the format properties chart point. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); @@ -150,14 +148,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, bodyOption); return command; @@ -229,42 +226,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartPointFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Encapsulates the format properties chart point. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Encapsulates the format properties chart point. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Encapsulates the format properties chart point. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartPointFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Encapsulates the format properties chart point. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/Item/WorkbookChartPointRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/Item/WorkbookChartPointRequestBuilder.cs index 4bce560ede5..ccbf367ef02 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/Item/WorkbookChartPointRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/Item/WorkbookChartPointRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Series.Item.Points.Item.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,31 +27,30 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents a collection of all points in the series. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption); return command; @@ -72,23 +71,23 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents a collection of all points in the series. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); @@ -102,20 +101,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -125,23 +123,23 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents a collection of all points in the series. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); @@ -149,14 +147,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, bodyOption); return command; @@ -228,42 +225,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartPoint body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents a collection of all points in the series. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a collection of all points in the series. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a collection of all points in the series. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartPoint model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents a collection of all points in the series. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs index 3ce59170c4c..056b7d421fe 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function itemAt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -46,18 +46,17 @@ public Command BuildGetCommand() { }; indexOption.IsRequired = true; command.AddOption(indexOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, int? index) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, int? index, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, indexOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, indexOption, outputOption); return command; } /// @@ -90,17 +89,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function itemAt - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookChartPoint public class ItemAtWithIndexResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/PointsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/PointsRequestBuilder.cs index ff98b7f87cf..cb49b9aa97c 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/PointsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/Points/PointsRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Series.Item.Points.ItemAtWithIndex; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -24,12 +24,11 @@ public class PointsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new WorkbookChartPointRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildFormatCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFormatCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -39,19 +38,19 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Represents a collection of all points in the series. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -59,21 +58,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, bodyOption, outputOption); return command; } /// @@ -83,19 +81,19 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Represents a collection of all points in the series. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -134,7 +132,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -145,15 +147,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -215,18 +212,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookChartPoint body, return requestInfo; } /// - /// Represents a collection of all points in the series. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\worksheet\charts\{workbookChart-id}\series\{workbookChartSeries-id}\points\microsoft.graph.itemAt(index={index}) /// Usage: index={index} /// @@ -234,19 +219,6 @@ public ItemAtWithIndexRequestBuilder ItemAtWithIndex(int? index) { _ = index ?? throw new ArgumentNullException(nameof(index)); return new ItemAtWithIndexRequestBuilder(PathParameters, RequestAdapter, index); } - /// - /// Represents a collection of all points in the series. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookChartPoint model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents a collection of all points in the series. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/WorkbookChartSeriesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/WorkbookChartSeriesRequestBuilder.cs index 175f53a35c0..15c75a57b29 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/WorkbookChartSeriesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/Item/WorkbookChartSeriesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Series.Item.Points; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,27 +28,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents either a single series or collection of series in the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption); return command; @@ -70,19 +69,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents either a single series or collection of series in the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -96,20 +95,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,19 +117,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents either a single series or collection of series in the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -139,14 +137,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string workbookChartSeriesId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, workbookChartSeriesIdOption, bodyOption); return command; @@ -154,6 +151,9 @@ public Command BuildPatchCommand() { public Command BuildPointsCommand() { var command = new Command("points"); var builder = new ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Series.Item.Points.PointsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -225,42 +225,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartSeries body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents either a single series or collection of series in the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents either a single series or collection of series in the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents either a single series or collection of series in the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartSeries model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents either a single series or collection of series in the chart. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs index 0644e90dd29..8ca25c761a1 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function itemAt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -42,18 +42,17 @@ public Command BuildGetCommand() { }; indexOption.IsRequired = true; command.AddOption(indexOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, int? index) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, int? index, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, indexOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, indexOption, outputOption); return command; } /// @@ -86,17 +85,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function itemAt - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookChartSeries public class ItemAtWithIndexResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/SeriesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/SeriesRequestBuilder.cs index 96362ca9347..713c9f2170c 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/SeriesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Series/SeriesRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Series.ItemAtWithIndex; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -24,13 +24,12 @@ public class SeriesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new WorkbookChartSeriesRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildFormatCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildPointsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFormatCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPointsCommand()); return commands; } /// @@ -40,15 +39,15 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Represents either a single series or collection of series in the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption, outputOption); return command; } /// @@ -80,15 +78,15 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Represents either a single series or collection of series in the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -127,7 +125,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -138,15 +140,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -208,18 +205,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookChartSeries body, return requestInfo; } /// - /// Represents either a single series or collection of series in the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\worksheet\charts\{workbookChart-id}\series\microsoft.graph.itemAt(index={index}) /// Usage: index={index} /// @@ -227,19 +212,6 @@ public ItemAtWithIndexRequestBuilder ItemAtWithIndex(int? index) { _ = index ?? throw new ArgumentNullException(nameof(index)); return new ItemAtWithIndexRequestBuilder(PathParameters, RequestAdapter, index); } - /// - /// Represents either a single series or collection of series in the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookChartSeries model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents either a single series or collection of series in the chart. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/SetData/SetDataRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/SetData/SetDataRequestBuilder.cs index a6f4625a211..61c50d6371d 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/SetData/SetDataRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/SetData/SetDataRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setData"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SetDataRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setData - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetDataRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/SetPosition/SetPositionRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/SetPosition/SetPositionRequestBuilder.cs index fa5a800dd14..ab1bdb24b95 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/SetPosition/SetPositionRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/SetPosition/SetPositionRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setPosition"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SetPositionRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setPosition - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetPositionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Title/Format/Fill/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Title/Format/Fill/Clear/ClearRequestBuilder.cs index 4966175dd30..91201d7ff7d 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Title/Format/Fill/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Title/Format/Fill/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Title/Format/Fill/FillRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Title/Format/Fill/FillRequestBuilder.cs index 3fc810fe4ad..786eb448f46 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Title/Format/Fill/FillRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Title/Format/Fill/FillRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Title.Format.Fill.SetSolidColor; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,23 +34,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the fill format of an object, which includes background formatting information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the fill format of an object, which includes background formatting information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,15 +105,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the fill format of an object, which includes background formatting information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -123,14 +121,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFill body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the fill format of an object, which includes background formatting information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of an object, which includes background formatting information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of an object, which includes background formatting information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFill model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the fill format of an object, which includes background formatting information. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Title/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Title/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs index 6d68d527695..25fc19ee822 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Title/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Title/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setSolidColor"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SetSolidColorRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setSolidColor - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetSolidColorRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Title/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Title/Format/Font/FontRequestBuilder.cs index 74cecd4cdb2..3a459972874 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Title/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Title/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Title/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Title/Format/FormatRequestBuilder.cs index 444da23b275..ce14d4aab6b 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Title/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Title/Format/FormatRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Title.Format.Font; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,23 +28,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of a chart title, which includes fill and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -74,15 +73,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of a chart title, which includes fill and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -96,20 +95,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,15 +117,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of a chart title, which includes fill and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -135,14 +133,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -214,42 +211,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartTitleFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of a chart title, which includes fill and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart title, which includes fill and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart title, which includes fill and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartTitleFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of a chart title, which includes fill and font formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Title/TitleRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Title/TitleRequestBuilder.cs index 89ed0f493b6..deac5a0470f 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Title/TitleRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Title/TitleRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Title.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the title of the specified chart, including the text, visibility, position and formating of the title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -65,15 +64,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the title of the specified chart, including the text, visibility, position and formating of the title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -87,20 +86,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,15 +108,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the title of the specified chart, including the text, visibility, position and formating of the title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -126,14 +124,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -205,42 +202,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartTitle body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the title of the specified chart, including the text, visibility, position and formating of the title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the title of the specified chart, including the text, visibility, position and formating of the title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the title of the specified chart, including the text, visibility, position and formating of the title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartTitle model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the title of the specified chart, including the text, visibility, position and formating of the title. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/WorkbookChartRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/WorkbookChartRequestBuilder.cs index f8bdabe4ba2..dbf3faefeb0 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/WorkbookChartRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/WorkbookChartRequestBuilder.cs @@ -14,10 +14,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Worksheet; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -59,23 +59,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns collection of charts that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -97,15 +96,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns collection of charts that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -119,20 +118,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLegendCommand() { @@ -151,15 +149,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns collection of charts that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -167,14 +165,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -182,6 +179,9 @@ public Command BuildPatchCommand() { public Command BuildSeriesCommand() { var command = new Command("series"); var builder = new ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Series.SeriesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -283,29 +283,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChart body, Acti return requestInfo; } /// - /// Returns collection of charts that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns collection of charts that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\worksheet\charts\{workbookChart-id}\microsoft.graph.image() /// public ImageRequestBuilder Image() { @@ -341,19 +318,6 @@ public ImageWithWidthWithHeightWithFittingModeRequestBuilder ImageWithWidthWithH _ = width ?? throw new ArgumentNullException(nameof(width)); return new ImageWithWidthWithHeightWithFittingModeRequestBuilder(PathParameters, RequestAdapter, width, height, fittingMode); } - /// - /// Returns collection of charts that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChart model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns collection of charts that are part of the worksheet. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs index 8e7ca70a2f0..a647ee141ad 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function cell"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -46,18 +46,17 @@ public Command BuildGetCommand() { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, int? row, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, int? row, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, rowOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, rowOption, columnOption, outputOption); return command; } /// @@ -92,17 +91,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function cell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class CellWithRowWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Worksheet/Range/RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Worksheet/Range/RangeRequestBuilder.cs index d3f2f87b9f9..8331f303ce9 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Worksheet/Range/RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Worksheet/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs index 15efb4150d0..b7db4b6a7d3 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -42,18 +42,17 @@ public Command BuildGetCommand() { }; addressOption.IsRequired = true; command.AddOption(addressOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string address) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string address, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, addressOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, addressOption, outputOption); return command; } /// @@ -86,17 +85,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeWithAddressResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs index ebae6d8c29e..ca922a67e7b 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs index 2d4f28ca5a8..5a2f2ece16d 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,34 +26,33 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var valuesOnlyOption = new Option("--valuesonly", description: "Usage: valuesOnly={valuesOnly}") { + var valuesOnlyOption = new Option("--values-only", description: "Usage: valuesOnly={valuesOnly}") { }; valuesOnlyOption.IsRequired = true; command.AddOption(valuesOnlyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, bool? valuesOnly) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, bool? valuesOnly, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, valuesOnlyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, valuesOnlyOption, outputOption); return command; } /// @@ -86,17 +85,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeWithValuesOnlyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Worksheet/WorksheetRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Worksheet/WorksheetRequestBuilder.cs index 7d8e8706bf2..04bbbe3c45d 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Worksheet/WorksheetRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/Item/Worksheet/WorksheetRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.Item.Worksheet.UsedRangeWithValuesOnly; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,23 +31,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The worksheet containing the current chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption); return command; @@ -59,15 +58,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The worksheet containing the current chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -81,20 +80,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,15 +102,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The worksheet containing the current chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -120,14 +118,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookChartIdOption, bodyOption); return command; @@ -210,42 +207,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookWorksheet body, return requestInfo; } /// - /// The worksheet containing the current chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The worksheet containing the current chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The worksheet containing the current chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookWorksheet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\worksheet\charts\{workbookChart-id}\worksheet\microsoft.graph.range() /// public RangeRequestBuilder Range() { diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs index ff374aeaf35..66fe1437b05 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function itemAt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; indexOption.IsRequired = true; command.AddOption(indexOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, int? index) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, int? index, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, indexOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, indexOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function itemAt - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookChart public class ItemAtWithIndexResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/ItemWithName/ItemWithNameRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/ItemWithName/ItemWithNameRequestBuilder.cs index 4ab7543a135..5f069bbe89e 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/ItemWithName/ItemWithNameRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Charts/ItemWithName/ItemWithNameRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function item"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; nameOption.IsRequired = true; command.AddOption(nameOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string name) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string name, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, nameOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, nameOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function item - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookChart public class ItemWithNameResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/@Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/@Add/AddRequestBody.cs deleted file mode 100644 index 512d86ce129..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/@Add/AddRequestBody.cs +++ /dev/null @@ -1,42 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Names.@Add { - public class AddRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string Comment { get; set; } - public string Name { get; set; } - public Json Reference { get; set; } - /// - /// Instantiates a new addRequestBody and sets the default values. - /// - public AddRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"comment", (o,n) => { (o as AddRequestBody).Comment = n.GetStringValue(); } }, - {"name", (o,n) => { (o as AddRequestBody).Name = n.GetStringValue(); } }, - {"reference", (o,n) => { (o as AddRequestBody).Reference = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("comment", Comment); - writer.WriteStringValue("name", Name); - writer.WriteObjectValue("reference", Reference); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/@Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/@Add/AddRequestBuilder.cs deleted file mode 100644 index ddff39b7de6..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/@Add/AddRequestBuilder.cs +++ /dev/null @@ -1,133 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Names.@Add { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\worksheet\names\microsoft.graph.add - public class AddRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action add - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action add"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { - }; - workbookNamedItemIdOption.IsRequired = true; - command.AddOption(workbookNamedItemIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AddRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/names/{workbookNamedItem_id}/worksheet/names/microsoft.graph.add"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action add - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action add - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookNamedItem - public class AddResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookNamedItem - public WorkbookNamedItem WorkbookNamedItem { get; set; } - /// - /// Instantiates a new addResponse and sets the default values. - /// - public AddResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookNamedItem", (o,n) => { (o as AddResponse).WorkbookNamedItem = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookNamedItem", WorkbookNamedItem); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/Add/AddRequestBody.cs new file mode 100644 index 00000000000..c5fd07c0aa2 --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/Add/AddRequestBody.cs @@ -0,0 +1,42 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Names.Add { + public class AddRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string Comment { get; set; } + public string Name { get; set; } + public Json Reference { get; set; } + /// + /// Instantiates a new addRequestBody and sets the default values. + /// + public AddRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"comment", (o,n) => { (o as AddRequestBody).Comment = n.GetStringValue(); } }, + {"name", (o,n) => { (o as AddRequestBody).Name = n.GetStringValue(); } }, + {"reference", (o,n) => { (o as AddRequestBody).Reference = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("comment", Comment); + writer.WriteStringValue("name", Name); + writer.WriteObjectValue("reference", Reference); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/Add/AddRequestBuilder.cs new file mode 100644 index 00000000000..ac145a972d3 --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/Add/AddRequestBuilder.cs @@ -0,0 +1,119 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Names.Add { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\worksheet\names\microsoft.graph.add + public class AddRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action add + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action add"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { + }; + workbookNamedItemIdOption.IsRequired = true; + command.AddOption(workbookNamedItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new AddRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/names/{workbookNamedItem_id}/worksheet/names/microsoft.graph.add"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action add + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookNamedItem + public class AddResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookNamedItem + public WorkbookNamedItem WorkbookNamedItem { get; set; } + /// + /// Instantiates a new addResponse and sets the default values. + /// + public AddResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookNamedItem", (o,n) => { (o as AddResponse).WorkbookNamedItem = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookNamedItem", WorkbookNamedItem); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/AddFormulaLocal/AddFormulaLocalRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/AddFormulaLocal/AddFormulaLocalRequestBuilder.cs index 00977b4103f..80201031e69 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/AddFormulaLocal/AddFormulaLocalRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/AddFormulaLocal/AddFormulaLocalRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action addFormulaLocal"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(AddFormulaLocalRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action addFormulaLocal - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddFormulaLocalRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookNamedItem public class AddFormulaLocalResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/Item/Range/RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/Item/Range/RangeRequestBuilder.cs index bfaaa80e066..93a4335aab1 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/Item/Range/RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/Item/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookNamedItemId1Option = new Option("--workbooknameditem-id1", description: "key: id of workbookNamedItem") { + var workbookNamedItemId1Option = new Option("--workbook-named-item-id1", description: "key: id of workbookNamedItem") { }; workbookNamedItemId1Option.IsRequired = true; command.AddOption(workbookNamedItemId1Option); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookNamedItemId1) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookNamedItemId1, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookNamedItemId1Option); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookNamedItemId1Option, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/Item/WorkbookNamedItemRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/Item/WorkbookNamedItemRequestBuilder.cs index 0a00e42d41c..3314bf106fc 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/Item/WorkbookNamedItemRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/Item/WorkbookNamedItemRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Names.Item.Range; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns collection of names that are associated with the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookNamedItemId1Option = new Option("--workbooknameditem-id1", description: "key: id of workbookNamedItem") { + var workbookNamedItemId1Option = new Option("--workbook-named-item-id1", description: "key: id of workbookNamedItem") { }; workbookNamedItemId1Option.IsRequired = true; command.AddOption(workbookNamedItemId1Option); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookNamedItemId1) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookNamedItemId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookNamedItemId1Option); return command; @@ -55,15 +54,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns collection of names that are associated with the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookNamedItemId1Option = new Option("--workbooknameditem-id1", description: "key: id of workbookNamedItem") { + var workbookNamedItemId1Option = new Option("--workbook-named-item-id1", description: "key: id of workbookNamedItem") { }; workbookNamedItemId1Option.IsRequired = true; command.AddOption(workbookNamedItemId1Option); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookNamedItemId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookNamedItemId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookNamedItemId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookNamedItemId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -100,15 +98,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns collection of names that are associated with the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookNamedItemId1Option = new Option("--workbooknameditem-id1", description: "key: id of workbookNamedItem") { + var workbookNamedItemId1Option = new Option("--workbook-named-item-id1", description: "key: id of workbookNamedItem") { }; workbookNamedItemId1Option.IsRequired = true; command.AddOption(workbookNamedItemId1Option); @@ -116,14 +114,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookNamedItemId1, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookNamedItemId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookNamedItemId1Option, bodyOption); return command; @@ -196,42 +193,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookNamedItem body, return requestInfo; } /// - /// Returns collection of names that are associated with the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns collection of names that are associated with the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns collection of names that are associated with the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookNamedItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\worksheet\names\{workbookNamedItem-id1}\microsoft.graph.range() /// public RangeRequestBuilder Range() { diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/NamesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/NamesRequestBuilder.cs index 6c8010a22b0..0fd8cf2f401 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/NamesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Names/NamesRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Names.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -24,7 +24,7 @@ public class NamesRequestBuilder { private string UrlTemplate { get; set; } public Command BuildAddCommand() { var command = new Command("add"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Names.@Add.AddRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Names.Add.AddRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } @@ -36,11 +36,10 @@ public Command BuildAddFormulaLocalCommand() { } public List BuildCommand() { var builder = new WorkbookNamedItemRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -50,11 +49,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Returns collection of names that are associated with the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -62,21 +61,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, bodyOption, outputOption); return command; } /// @@ -86,11 +84,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Returns collection of names that are associated with the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -129,7 +127,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -140,15 +142,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -203,31 +200,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookNamedItem body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Returns collection of names that are associated with the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns collection of names that are associated with the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookNamedItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns collection of names that are associated with the worksheet. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Refresh/RefreshRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Refresh/RefreshRequestBuilder.cs index d726549bc37..2e4a3f4120e 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Refresh/RefreshRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Refresh/RefreshRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action refresh"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookPivotTableId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookPivotTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookPivotTableIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action refresh - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/WorkbookPivotTableRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/WorkbookPivotTableRequestBuilder.cs index d1280f8a547..8e9c37e8026 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/WorkbookPivotTableRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/WorkbookPivotTableRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.PivotTables.Item.Worksheet; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,23 +28,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Collection of PivotTables that are part of the worksheet."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookPivotTableId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookPivotTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookPivotTableIdOption); return command; @@ -56,15 +55,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Collection of PivotTables that are part of the worksheet."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); @@ -78,20 +77,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookPivotTableId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookPivotTableId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookPivotTableIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookPivotTableIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -101,15 +99,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Collection of PivotTables that are part of the worksheet."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); @@ -117,14 +115,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookPivotTableId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookPivotTableId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookPivotTableIdOption, bodyOption); return command; @@ -210,42 +207,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookPivotTable body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of PivotTables that are part of the worksheet. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of PivotTables that are part of the worksheet. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of PivotTables that are part of the worksheet. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookPivotTable model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of PivotTables that are part of the worksheet. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs index 3b3f55cf316..37e44326f97 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function cell"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); @@ -46,18 +46,17 @@ public Command BuildGetCommand() { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookPivotTableId, int? row, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookPivotTableId, int? row, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookPivotTableIdOption, rowOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookPivotTableIdOption, rowOption, columnOption, outputOption); return command; } /// @@ -92,17 +91,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function cell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class CellWithRowWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Worksheet/Range/RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Worksheet/Range/RangeRequestBuilder.cs index bf059ac8aba..0108c2ff021 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Worksheet/Range/RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Worksheet/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookPivotTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookPivotTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookPivotTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookPivotTableIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs index 14a343811e5..fdf30a94c90 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); @@ -42,18 +42,17 @@ public Command BuildGetCommand() { }; addressOption.IsRequired = true; command.AddOption(addressOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookPivotTableId, string address) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookPivotTableId, string address, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookPivotTableIdOption, addressOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookPivotTableIdOption, addressOption, outputOption); return command; } /// @@ -86,17 +85,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeWithAddressResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs index 05588957dd5..daae372c59c 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookPivotTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookPivotTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookPivotTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookPivotTableIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs index 2c3ea9a7122..d112a51e4a9 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,34 +26,33 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); - var valuesOnlyOption = new Option("--valuesonly", description: "Usage: valuesOnly={valuesOnly}") { + var valuesOnlyOption = new Option("--values-only", description: "Usage: valuesOnly={valuesOnly}") { }; valuesOnlyOption.IsRequired = true; command.AddOption(valuesOnlyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookPivotTableId, bool? valuesOnly) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookPivotTableId, bool? valuesOnly, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookPivotTableIdOption, valuesOnlyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookPivotTableIdOption, valuesOnlyOption, outputOption); return command; } /// @@ -86,17 +85,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeWithValuesOnlyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Worksheet/WorksheetRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Worksheet/WorksheetRequestBuilder.cs index af34355a515..6483aae6cd8 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Worksheet/WorksheetRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/Item/Worksheet/WorksheetRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.PivotTables.Item.Worksheet.UsedRangeWithValuesOnly; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,23 +31,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The worksheet containing the current PivotTable. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookPivotTableId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookPivotTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookPivotTableIdOption); return command; @@ -59,15 +58,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The worksheet containing the current PivotTable. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); @@ -81,20 +80,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookPivotTableId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookPivotTableId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookPivotTableIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookPivotTableIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,15 +102,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The worksheet containing the current PivotTable. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); @@ -120,14 +118,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookPivotTableId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookPivotTableId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookPivotTableIdOption, bodyOption); return command; @@ -210,42 +207,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookWorksheet body, return requestInfo; } /// - /// The worksheet containing the current PivotTable. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The worksheet containing the current PivotTable. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The worksheet containing the current PivotTable. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookWorksheet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\worksheet\pivotTables\{workbookPivotTable-id}\worksheet\microsoft.graph.range() /// public RangeRequestBuilder Range() { diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/PivotTablesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/PivotTablesRequestBuilder.cs index 2545f6d889a..b29782f2c85 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/PivotTablesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/PivotTablesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.PivotTables.RefreshAll; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,13 +23,12 @@ public class PivotTablesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new WorkbookPivotTableRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildRefreshCommand(), - builder.BuildWorksheetCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRefreshCommand()); + commands.Add(builder.BuildWorksheetCommand()); return commands; } /// @@ -39,11 +38,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Collection of PivotTables that are part of the worksheet."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -51,21 +50,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, bodyOption, outputOption); return command; } /// @@ -75,11 +73,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Collection of PivotTables that are part of the worksheet."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -129,15 +131,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefreshAllCommand() { @@ -198,31 +195,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookPivotTable body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of PivotTables that are part of the worksheet. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of PivotTables that are part of the worksheet. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookPivotTable model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of PivotTables that are part of the worksheet. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/RefreshAll/RefreshAllRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/RefreshAll/RefreshAllRequestBuilder.cs index bc760877d3c..a6727679a3d 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/RefreshAll/RefreshAllRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/PivotTables/RefreshAll/RefreshAllRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,18 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action refreshAll"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action refreshAll - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Protection/Protect/ProtectRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Protection/Protect/ProtectRequestBuilder.cs index 13a97ef5dc8..78865719cd6 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Protection/Protect/ProtectRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Protection/Protect/ProtectRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,11 +25,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action protect"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ProtectRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action protect - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ProtectRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Protection/ProtectionRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Protection/ProtectionRequestBuilder.cs index be2384105fc..874e83db151 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Protection/ProtectionRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Protection/ProtectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Protection.Unprotect; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,19 +28,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns sheet protection object for a worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption); return command; @@ -52,11 +51,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns sheet protection object for a worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -70,20 +69,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -93,11 +91,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns sheet protection object for a worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -105,14 +103,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, bodyOption); return command; @@ -196,42 +193,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookWorksheetProtect requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Returns sheet protection object for a worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns sheet protection object for a worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns sheet protection object for a worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookWorksheetProtection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns sheet protection object for a worksheet. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Protection/Unprotect/UnprotectRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Protection/Unprotect/UnprotectRequestBuilder.cs index 61fb25f8222..a5dd33ce712 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Protection/Unprotect/UnprotectRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Protection/Unprotect/UnprotectRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,18 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action unprotect"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action unprotect - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Range/RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Range/RangeRequestBuilder.cs index bdadc20a848..9e79688b440 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Range/RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs index 2d6979d7718..bc59afc07dc 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; addressOption.IsRequired = true; command.AddOption(addressOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string address) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string address, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, addressOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, addressOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeWithAddressResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/@Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/@Add/AddRequestBody.cs deleted file mode 100644 index cc717d04f33..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/@Add/AddRequestBody.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.@Add { - public class AddRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string Address { get; set; } - public bool? HasHeaders { get; set; } - /// - /// Instantiates a new addRequestBody and sets the default values. - /// - public AddRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"address", (o,n) => { (o as AddRequestBody).Address = n.GetStringValue(); } }, - {"hasHeaders", (o,n) => { (o as AddRequestBody).HasHeaders = n.GetBoolValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("address", Address); - writer.WriteBoolValue("hasHeaders", HasHeaders); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/@Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/@Add/AddRequestBuilder.cs deleted file mode 100644 index 81f5a530192..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/@Add/AddRequestBuilder.cs +++ /dev/null @@ -1,133 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.@Add { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\worksheet\tables\microsoft.graph.add - public class AddRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action add - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action add"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { - }; - workbookNamedItemIdOption.IsRequired = true; - command.AddOption(workbookNamedItemIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AddRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/names/{workbookNamedItem_id}/worksheet/tables/microsoft.graph.add"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action add - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action add - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookTable - public class AddResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookTable - public WorkbookTable WorkbookTable { get; set; } - /// - /// Instantiates a new addResponse and sets the default values. - /// - public AddResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookTable", (o,n) => { (o as AddResponse).WorkbookTable = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookTable", WorkbookTable); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Add/AddRequestBody.cs new file mode 100644 index 00000000000..4e339ae956c --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Add/AddRequestBody.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.Add { + public class AddRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string Address { get; set; } + public bool? HasHeaders { get; set; } + /// + /// Instantiates a new addRequestBody and sets the default values. + /// + public AddRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"address", (o,n) => { (o as AddRequestBody).Address = n.GetStringValue(); } }, + {"hasHeaders", (o,n) => { (o as AddRequestBody).HasHeaders = n.GetBoolValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("address", Address); + writer.WriteBoolValue("hasHeaders", HasHeaders); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Add/AddRequestBuilder.cs new file mode 100644 index 00000000000..43d15806cbf --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Add/AddRequestBuilder.cs @@ -0,0 +1,119 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.Add { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\worksheet\tables\microsoft.graph.add + public class AddRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action add + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action add"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { + }; + workbookNamedItemIdOption.IsRequired = true; + command.AddOption(workbookNamedItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new AddRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/names/{workbookNamedItem_id}/worksheet/tables/microsoft.graph.add"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action add + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookTable + public class AddResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookTable + public WorkbookTable WorkbookTable { get; set; } + /// + /// Instantiates a new addResponse and sets the default values. + /// + public AddResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookTable", (o,n) => { (o as AddResponse).WorkbookTable = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookTable", WorkbookTable); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Count/CountRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Count/CountRequestBuilder.cs index 9cbbf93f2eb..01311ab2ec8 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Count/CountRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Count/CountRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,26 +25,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function count"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteIntValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, outputOption); return command; } /// @@ -75,16 +74,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function count - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/ClearFilters/ClearFiltersRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/ClearFilters/ClearFiltersRequestBuilder.cs index a71f8cfec7e..cdeb0cb31b8 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/ClearFilters/ClearFiltersRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/ClearFilters/ClearFiltersRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clearFilters"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clearFilters - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/@Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/@Add/AddRequestBody.cs deleted file mode 100644 index 3686da2a474..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/@Add/AddRequestBody.cs +++ /dev/null @@ -1,42 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.Item.Columns.@Add { - public class AddRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public int? Index { get; set; } - public string Name { get; set; } - public Json Values { get; set; } - /// - /// Instantiates a new addRequestBody and sets the default values. - /// - public AddRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"index", (o,n) => { (o as AddRequestBody).Index = n.GetIntValue(); } }, - {"name", (o,n) => { (o as AddRequestBody).Name = n.GetStringValue(); } }, - {"values", (o,n) => { (o as AddRequestBody).Values = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteIntValue("index", Index); - writer.WriteStringValue("name", Name); - writer.WriteObjectValue("values", Values); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/@Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/@Add/AddRequestBuilder.cs deleted file mode 100644 index fd2dedc09e6..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/@Add/AddRequestBuilder.cs +++ /dev/null @@ -1,137 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.Item.Columns.@Add { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\worksheet\tables\{workbookTable-id}\columns\microsoft.graph.add - public class AddRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action add - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action add"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { - }; - workbookNamedItemIdOption.IsRequired = true; - command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { - }; - workbookTableIdOption.IsRequired = true; - command.AddOption(workbookTableIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AddRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/names/{workbookNamedItem_id}/worksheet/tables/{workbookTable_id}/columns/microsoft.graph.add"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action add - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action add - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookTableColumn - public class AddResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookTableColumn - public WorkbookTableColumn WorkbookTableColumn { get; set; } - /// - /// Instantiates a new addResponse and sets the default values. - /// - public AddResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookTableColumn", (o,n) => { (o as AddResponse).WorkbookTableColumn = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookTableColumn", WorkbookTableColumn); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Add/AddRequestBody.cs new file mode 100644 index 00000000000..0547593237e --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Add/AddRequestBody.cs @@ -0,0 +1,42 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.Item.Columns.Add { + public class AddRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public int? Index { get; set; } + public string Name { get; set; } + public Json Values { get; set; } + /// + /// Instantiates a new addRequestBody and sets the default values. + /// + public AddRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"index", (o,n) => { (o as AddRequestBody).Index = n.GetIntValue(); } }, + {"name", (o,n) => { (o as AddRequestBody).Name = n.GetStringValue(); } }, + {"values", (o,n) => { (o as AddRequestBody).Values = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteIntValue("index", Index); + writer.WriteStringValue("name", Name); + writer.WriteObjectValue("values", Values); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Add/AddRequestBuilder.cs new file mode 100644 index 00000000000..5ac98f08cdd --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Add/AddRequestBuilder.cs @@ -0,0 +1,123 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.Item.Columns.Add { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\worksheet\tables\{workbookTable-id}\columns\microsoft.graph.add + public class AddRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action add + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action add"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { + }; + workbookNamedItemIdOption.IsRequired = true; + command.AddOption(workbookNamedItemIdOption); + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { + }; + workbookTableIdOption.IsRequired = true; + command.AddOption(workbookTableIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new AddRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/names/{workbookNamedItem_id}/worksheet/tables/{workbookTable_id}/columns/microsoft.graph.add"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action add + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookTableColumn + public class AddResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookTableColumn + public WorkbookTableColumn WorkbookTableColumn { get; set; } + /// + /// Instantiates a new addResponse and sets the default values. + /// + public AddResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookTableColumn", (o,n) => { (o as AddResponse).WorkbookTableColumn = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookTableColumn", WorkbookTableColumn); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/ColumnsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/ColumnsRequestBuilder.cs index a8adda3bd2a..3b4cab2a485 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/ColumnsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/ColumnsRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.Item.Columns.ItemAtWithIndex; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public class ColumnsRequestBuilder { private string UrlTemplate { get; set; } public Command BuildAddCommand() { var command = new Command("add"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.Item.Columns.@Add.AddRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.Item.Columns.Add.AddRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } public List BuildCommand() { var builder = new WorkbookTableColumnRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildFilterCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFilterCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -46,15 +45,15 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Represents a collection of all the columns in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -62,21 +61,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, bodyOption, outputOption); return command; } /// @@ -86,15 +84,15 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Represents a collection of all the columns in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -133,7 +131,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -144,15 +146,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -214,18 +211,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookTableColumn body, return requestInfo; } /// - /// Represents a collection of all the columns in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\worksheet\tables\{workbookTable-id}\columns\microsoft.graph.itemAt(index={index}) /// Usage: index={index} /// @@ -233,19 +218,6 @@ public ItemAtWithIndexRequestBuilder ItemAtWithIndex(int? index) { _ = index ?? throw new ArgumentNullException(nameof(index)); return new ItemAtWithIndexRequestBuilder(PathParameters, RequestAdapter, index); } - /// - /// Represents a collection of all the columns in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookTableColumn model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents a collection of all the columns in the table. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Count/CountRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Count/CountRequestBuilder.cs index 3f0c2a54180..89b4720e36f 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Count/CountRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Count/CountRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,30 +25,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function count"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteIntValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -79,16 +78,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function count - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs index 65a2b5742c6..d1038ca2bee 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,34 +26,33 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function dataBodyRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function dataBodyRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class DataBodyRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/Apply/ApplyRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/Apply/ApplyRequestBuilder.cs index ee370561409..c55acb45408 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/Apply/ApplyRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/Apply/ApplyRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action apply"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ApplyRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action apply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyBottomItemsFilter/ApplyBottomItemsFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyBottomItemsFilter/ApplyBottomItemsFilterRequestBuilder.cs index 7a53706053e..74d922d9c0f 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyBottomItemsFilter/ApplyBottomItemsFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyBottomItemsFilter/ApplyBottomItemsFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyBottomItemsFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ApplyBottomItemsFilterReq requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyBottomItemsFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyBottomItemsFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyBottomPercentFilter/ApplyBottomPercentFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyBottomPercentFilter/ApplyBottomPercentFilterRequestBuilder.cs index 2d02d159c0b..fac9491a519 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyBottomPercentFilter/ApplyBottomPercentFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyBottomPercentFilter/ApplyBottomPercentFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyBottomPercentFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ApplyBottomPercentFilterR requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyBottomPercentFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyBottomPercentFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyCellColorFilter/ApplyCellColorFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyCellColorFilter/ApplyCellColorFilterRequestBuilder.cs index b52ccf94c3d..619af6c2c09 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyCellColorFilter/ApplyCellColorFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyCellColorFilter/ApplyCellColorFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyCellColorFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ApplyCellColorFilterReque requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyCellColorFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyCellColorFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyCustomFilter/ApplyCustomFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyCustomFilter/ApplyCustomFilterRequestBuilder.cs index 56ab330cafc..b8fb1ef518e 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyCustomFilter/ApplyCustomFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyCustomFilter/ApplyCustomFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyCustomFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ApplyCustomFilterRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyCustomFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyCustomFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyDynamicFilter/ApplyDynamicFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyDynamicFilter/ApplyDynamicFilterRequestBuilder.cs index 79ee95eea0d..84113f1547b 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyDynamicFilter/ApplyDynamicFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyDynamicFilter/ApplyDynamicFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyDynamicFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ApplyDynamicFilterRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyDynamicFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyDynamicFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyFontColorFilter/ApplyFontColorFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyFontColorFilter/ApplyFontColorFilterRequestBuilder.cs index 91ca86838da..e081ba9c002 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyFontColorFilter/ApplyFontColorFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyFontColorFilter/ApplyFontColorFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyFontColorFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ApplyFontColorFilterReque requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyFontColorFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyFontColorFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyIconFilter/ApplyIconFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyIconFilter/ApplyIconFilterRequestBuilder.cs index e3632c67369..797ddedca96 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyIconFilter/ApplyIconFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyIconFilter/ApplyIconFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyIconFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ApplyIconFilterRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyIconFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyIconFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyTopItemsFilter/ApplyTopItemsFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyTopItemsFilter/ApplyTopItemsFilterRequestBuilder.cs index 4640764dbcc..6f928689905 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyTopItemsFilter/ApplyTopItemsFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyTopItemsFilter/ApplyTopItemsFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyTopItemsFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ApplyTopItemsFilterReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyTopItemsFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyTopItemsFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyTopPercentFilter/ApplyTopPercentFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyTopPercentFilter/ApplyTopPercentFilterRequestBuilder.cs index 3f8ae413e35..c0cc13a7cbd 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyTopPercentFilter/ApplyTopPercentFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyTopPercentFilter/ApplyTopPercentFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyTopPercentFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ApplyTopPercentFilterRequ requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyTopPercentFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyTopPercentFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyValuesFilter/ApplyValuesFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyValuesFilter/ApplyValuesFilterRequestBuilder.cs index fb80b4dfe61..a4b1ce2fa83 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyValuesFilter/ApplyValuesFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/ApplyValuesFilter/ApplyValuesFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyValuesFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ApplyValuesFilterRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyValuesFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyValuesFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/Clear/ClearRequestBuilder.cs index 74ac3c45231..3de449edaae 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,27 +25,26 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption); return command; @@ -78,16 +77,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/FilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/FilterRequestBuilder.cs index 5dc161dcc2a..ebfc89d7def 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/FilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Filter/FilterRequestBuilder.cs @@ -13,10 +13,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.Item.Columns.Item.Filter.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -110,27 +110,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Retrieve the filter applied to the column. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption); return command; @@ -142,19 +141,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Retrieve the filter applied to the column. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -168,20 +167,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,19 +189,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Retrieve the filter applied to the column. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -211,14 +209,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -290,42 +287,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookFilter body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Retrieve the filter applied to the column. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Retrieve the filter applied to the column. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Retrieve the filter applied to the column. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookFilter model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Retrieve the filter applied to the column. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs index 3460f9e65e8..864d5e492dd 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,34 +26,33 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function headerRowRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function headerRowRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class HeaderRowRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Range/RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Range/RangeRequestBuilder.cs index 4abcc2c60bf..219745abe05 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Range/RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,34 +26,33 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs index 5fc361bcf43..5b38fe97608 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,34 +26,33 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function totalRowRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function totalRowRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class TotalRowRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/WorkbookTableColumnRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/WorkbookTableColumnRequestBuilder.cs index a6d58d3d0c3..4fbfa68d2cc 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/WorkbookTableColumnRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/Item/WorkbookTableColumnRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.Item.Columns.Item.TotalRowRange; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,27 +31,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents a collection of all the columns in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption); return command; @@ -83,19 +82,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents a collection of all the columns in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -109,20 +108,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -132,19 +130,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents a collection of all the columns in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -152,14 +150,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -238,48 +235,12 @@ public DataBodyRangeRequestBuilder DataBodyRange() { return new DataBodyRangeRequestBuilder(PathParameters, RequestAdapter); } /// - /// Represents a collection of all the columns in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a collection of all the columns in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\worksheet\tables\{workbookTable-id}\columns\{workbookTableColumn-id}\microsoft.graph.headerRowRange() /// public HeaderRowRangeRequestBuilder HeaderRowRange() { return new HeaderRowRangeRequestBuilder(PathParameters, RequestAdapter); } /// - /// Represents a collection of all the columns in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookTableColumn model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\worksheet\tables\{workbookTable-id}\columns\{workbookTableColumn-id}\microsoft.graph.range() /// public RangeRequestBuilder Range() { diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs index c36cc54a8b0..01ab296c7ed 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Columns/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function itemAt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -42,18 +42,17 @@ public Command BuildGetCommand() { }; indexOption.IsRequired = true; command.AddOption(indexOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, int? index) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, int? index, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, indexOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, indexOption, outputOption); return command; } /// @@ -86,17 +85,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function itemAt - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookTableColumn public class ItemAtWithIndexResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/ConvertToRange/ConvertToRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/ConvertToRange/ConvertToRangeRequestBuilder.cs index 68c5bcc8565..1da6fbee2cb 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/ConvertToRange/ConvertToRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/ConvertToRange/ConvertToRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action convertToRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action convertToRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ConvertToRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs index ee4dc03e51c..93a51562041 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function dataBodyRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function dataBodyRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class DataBodyRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs index 92756e0e14c..5aab26785fb 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function headerRowRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function headerRowRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class HeaderRowRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Range/RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Range/RangeRequestBuilder.cs index d3d1a1dca6b..62d9085999f 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Range/RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/ReapplyFilters/ReapplyFiltersRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/ReapplyFilters/ReapplyFiltersRequestBuilder.cs index 918eaa5e249..19e27962536 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/ReapplyFilters/ReapplyFiltersRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/ReapplyFilters/ReapplyFiltersRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action reapplyFilters"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action reapplyFilters - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/@Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/@Add/AddRequestBody.cs deleted file mode 100644 index 872f5819ae5..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/@Add/AddRequestBody.cs +++ /dev/null @@ -1,39 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.Item.Rows.@Add { - public class AddRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public int? Index { get; set; } - public Json Values { get; set; } - /// - /// Instantiates a new addRequestBody and sets the default values. - /// - public AddRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"index", (o,n) => { (o as AddRequestBody).Index = n.GetIntValue(); } }, - {"values", (o,n) => { (o as AddRequestBody).Values = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteIntValue("index", Index); - writer.WriteObjectValue("values", Values); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/@Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/@Add/AddRequestBuilder.cs deleted file mode 100644 index c2f055b0d02..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/@Add/AddRequestBuilder.cs +++ /dev/null @@ -1,137 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.Item.Rows.@Add { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\worksheet\tables\{workbookTable-id}\rows\microsoft.graph.add - public class AddRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action add - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action add"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { - }; - workbookNamedItemIdOption.IsRequired = true; - command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { - }; - workbookTableIdOption.IsRequired = true; - command.AddOption(workbookTableIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AddRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/names/{workbookNamedItem_id}/worksheet/tables/{workbookTable_id}/rows/microsoft.graph.add"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action add - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action add - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookTableRow - public class AddResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookTableRow - public WorkbookTableRow WorkbookTableRow { get; set; } - /// - /// Instantiates a new addResponse and sets the default values. - /// - public AddResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookTableRow", (o,n) => { (o as AddResponse).WorkbookTableRow = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookTableRow", WorkbookTableRow); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/Add/AddRequestBody.cs new file mode 100644 index 00000000000..0bae4adff29 --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/Add/AddRequestBody.cs @@ -0,0 +1,39 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.Item.Rows.Add { + public class AddRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public int? Index { get; set; } + public Json Values { get; set; } + /// + /// Instantiates a new addRequestBody and sets the default values. + /// + public AddRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"index", (o,n) => { (o as AddRequestBody).Index = n.GetIntValue(); } }, + {"values", (o,n) => { (o as AddRequestBody).Values = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteIntValue("index", Index); + writer.WriteObjectValue("values", Values); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/Add/AddRequestBuilder.cs new file mode 100644 index 00000000000..ad74801c19c --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/Add/AddRequestBuilder.cs @@ -0,0 +1,123 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.Item.Rows.Add { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\worksheet\tables\{workbookTable-id}\rows\microsoft.graph.add + public class AddRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action add + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action add"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { + }; + workbookNamedItemIdOption.IsRequired = true; + command.AddOption(workbookNamedItemIdOption); + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { + }; + workbookTableIdOption.IsRequired = true; + command.AddOption(workbookTableIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new AddRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/names/{workbookNamedItem_id}/worksheet/tables/{workbookTable_id}/rows/microsoft.graph.add"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action add + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookTableRow + public class AddResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookTableRow + public WorkbookTableRow WorkbookTableRow { get; set; } + /// + /// Instantiates a new addResponse and sets the default values. + /// + public AddResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookTableRow", (o,n) => { (o as AddResponse).WorkbookTableRow = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookTableRow", WorkbookTableRow); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/Count/CountRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/Count/CountRequestBuilder.cs index 97a7e0b7c14..757038f8ae3 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/Count/CountRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/Count/CountRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,30 +25,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function count"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteIntValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -79,16 +78,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function count - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/Item/Range/RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/Item/Range/RangeRequestBuilder.cs index f4055768d0c..95eedc42a26 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/Item/Range/RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/Item/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,34 +26,33 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableRowIdOption = new Option("--workbooktablerow-id", description: "key: id of workbookTableRow") { + var workbookTableRowIdOption = new Option("--workbook-table-row-id", description: "key: id of workbookTableRow") { }; workbookTableRowIdOption.IsRequired = true; command.AddOption(workbookTableRowIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableRowId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableRowId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableRowIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableRowIdOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/Item/WorkbookTableRowRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/Item/WorkbookTableRowRequestBuilder.cs index bba2e21df1c..af774204503 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/Item/WorkbookTableRowRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/Item/WorkbookTableRowRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.Item.Rows.Item.Range; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,27 +27,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents a collection of all the rows in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableRowIdOption = new Option("--workbooktablerow-id", description: "key: id of workbookTableRow") { + var workbookTableRowIdOption = new Option("--workbook-table-row-id", description: "key: id of workbookTableRow") { }; workbookTableRowIdOption.IsRequired = true; command.AddOption(workbookTableRowIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableRowId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableRowId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableRowIdOption); return command; @@ -59,19 +58,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents a collection of all the rows in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableRowIdOption = new Option("--workbooktablerow-id", description: "key: id of workbookTableRow") { + var workbookTableRowIdOption = new Option("--workbook-table-row-id", description: "key: id of workbookTableRow") { }; workbookTableRowIdOption.IsRequired = true; command.AddOption(workbookTableRowIdOption); @@ -85,20 +84,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableRowId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableRowId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableRowIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableRowIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -108,19 +106,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents a collection of all the rows in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableRowIdOption = new Option("--workbooktablerow-id", description: "key: id of workbookTableRow") { + var workbookTableRowIdOption = new Option("--workbook-table-row-id", description: "key: id of workbookTableRow") { }; workbookTableRowIdOption.IsRequired = true; command.AddOption(workbookTableRowIdOption); @@ -128,14 +126,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableRowId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string workbookTableRowId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, workbookTableRowIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookTableRow body, A return requestInfo; } /// - /// Represents a collection of all the rows in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a collection of all the rows in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a collection of all the rows in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookTableRow model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\worksheet\tables\{workbookTable-id}\rows\{workbookTableRow-id}\microsoft.graph.range() /// public RangeRequestBuilder Range() { diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs index dd2d7977970..341cbe6618e 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function itemAt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -42,18 +42,17 @@ public Command BuildGetCommand() { }; indexOption.IsRequired = true; command.AddOption(indexOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, int? index) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, int? index, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, indexOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, indexOption, outputOption); return command; } /// @@ -86,17 +85,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function itemAt - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookTableRow public class ItemAtWithIndexResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/RowsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/RowsRequestBuilder.cs index 60fb372d3bf..becb51bdaed 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/RowsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Rows/RowsRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.Item.Rows.ItemAtWithIndex; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,17 +25,16 @@ public class RowsRequestBuilder { private string UrlTemplate { get; set; } public Command BuildAddCommand() { var command = new Command("add"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.Item.Rows.@Add.AddRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.Item.Rows.Add.AddRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } public List BuildCommand() { var builder = new WorkbookTableRowRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,15 +44,15 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Represents a collection of all the rows in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -61,21 +60,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, bodyOption, outputOption); return command; } /// @@ -85,15 +83,15 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Represents a collection of all the rows in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -132,7 +130,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -143,15 +145,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -213,18 +210,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookTableRow body, Ac return requestInfo; } /// - /// Represents a collection of all the rows in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\worksheet\tables\{workbookTable-id}\rows\microsoft.graph.itemAt(index={index}) /// Usage: index={index} /// @@ -232,19 +217,6 @@ public ItemAtWithIndexRequestBuilder ItemAtWithIndex(int? index) { _ = index ?? throw new ArgumentNullException(nameof(index)); return new ItemAtWithIndexRequestBuilder(PathParameters, RequestAdapter, index); } - /// - /// Represents a collection of all the rows in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookTableRow model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents a collection of all the rows in the table. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Sort/Apply/ApplyRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Sort/Apply/ApplyRequestBuilder.cs index 78c4f127f57..53120fd2478 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Sort/Apply/ApplyRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Sort/Apply/ApplyRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action apply"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ApplyRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action apply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Sort/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Sort/Clear/ClearRequestBuilder.cs index 80a17c1db6a..088da64f07a 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Sort/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Sort/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Sort/Reapply/ReapplyRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Sort/Reapply/ReapplyRequestBuilder.cs index 7dde18ea6f3..06da4b8f632 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Sort/Reapply/ReapplyRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Sort/Reapply/ReapplyRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action reapply"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action reapply - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Sort/SortRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Sort/SortRequestBuilder.cs index 0e66369ce1e..d08268634b9 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Sort/SortRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Sort/SortRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.Item.Sort.Reapply; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,23 +41,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the sorting for the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption); return command; @@ -69,15 +68,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the sorting for the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -91,20 +90,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -114,15 +112,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the sorting for the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -130,14 +128,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, bodyOption); return command; @@ -215,42 +212,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookTableSort body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the sorting for the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the sorting for the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the sorting for the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookTableSort model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the sorting for the table. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs index e92ea24437b..da14aa14031 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function totalRowRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function totalRowRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class TotalRowRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/WorkbookTableRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/WorkbookTableRequestBuilder.cs index 50f5e590ec5..85da2d07cc6 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/WorkbookTableRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/WorkbookTableRequestBuilder.cs @@ -12,10 +12,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.Item.Worksheet; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -40,6 +40,9 @@ public Command BuildColumnsCommand() { var command = new Command("columns"); var builder = new ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.Item.Columns.ColumnsRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -57,23 +60,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Collection of tables that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption); return command; @@ -85,15 +87,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Collection of tables that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -107,20 +109,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -130,15 +131,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Collection of tables that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -146,14 +147,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, bodyOption); return command; @@ -168,6 +168,9 @@ public Command BuildRowsCommand() { var command = new Command("rows"); var builder = new ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.Item.Rows.RowsRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -265,48 +268,12 @@ public DataBodyRangeRequestBuilder DataBodyRange() { return new DataBodyRangeRequestBuilder(PathParameters, RequestAdapter); } /// - /// Collection of tables that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of tables that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\worksheet\tables\{workbookTable-id}\microsoft.graph.headerRowRange() /// public HeaderRowRangeRequestBuilder HeaderRowRange() { return new HeaderRowRangeRequestBuilder(PathParameters, RequestAdapter); } /// - /// Collection of tables that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookTable model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\worksheet\tables\{workbookTable-id}\microsoft.graph.range() /// public RangeRequestBuilder Range() { diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs index 35a5df98bd4..b516e199130 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function cell"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -46,18 +46,17 @@ public Command BuildGetCommand() { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, int? row, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, int? row, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, rowOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, rowOption, columnOption, outputOption); return command; } /// @@ -92,17 +91,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function cell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class CellWithRowWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Worksheet/Range/RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Worksheet/Range/RangeRequestBuilder.cs index 4ada20091b5..6053ebee8af 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Worksheet/Range/RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Worksheet/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs index d663d2e981e..aea1d578263 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -42,18 +42,17 @@ public Command BuildGetCommand() { }; addressOption.IsRequired = true; command.AddOption(addressOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string address) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string address, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, addressOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, addressOption, outputOption); return command; } /// @@ -86,17 +85,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeWithAddressResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs index 8f8453f6d67..1bd4aeda4e0 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs index 54127a5146a..f7119b1cde4 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,34 +26,33 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var valuesOnlyOption = new Option("--valuesonly", description: "Usage: valuesOnly={valuesOnly}") { + var valuesOnlyOption = new Option("--values-only", description: "Usage: valuesOnly={valuesOnly}") { }; valuesOnlyOption.IsRequired = true; command.AddOption(valuesOnlyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, bool? valuesOnly) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, bool? valuesOnly, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, valuesOnlyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, valuesOnlyOption, outputOption); return command; } /// @@ -86,17 +85,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeWithValuesOnlyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Worksheet/WorksheetRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Worksheet/WorksheetRequestBuilder.cs index 72c7ba24a3a..468df31f5a3 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Worksheet/WorksheetRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/Item/Worksheet/WorksheetRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.Item.Worksheet.UsedRangeWithValuesOnly; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,23 +31,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The worksheet containing the current table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption); return command; @@ -59,15 +58,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The worksheet containing the current table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -81,20 +80,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,15 +102,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The worksheet containing the current table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -120,14 +118,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string workbookTableId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, workbookTableIdOption, bodyOption); return command; @@ -210,42 +207,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookWorksheet body, return requestInfo; } /// - /// The worksheet containing the current table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The worksheet containing the current table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The worksheet containing the current table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookWorksheet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\worksheet\tables\{workbookTable-id}\worksheet\microsoft.graph.range() /// public RangeRequestBuilder Range() { diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs index e4aebdc9a61..6b68b522ac8 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function itemAt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; indexOption.IsRequired = true; command.AddOption(indexOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, int? index) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, int? index, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, indexOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, indexOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function itemAt - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookTable public class ItemAtWithIndexResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/TablesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/TablesRequestBuilder.cs index 1f4a4926502..147f9104c00 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/TablesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/Tables/TablesRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.ItemAtWithIndex; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,24 +25,23 @@ public class TablesRequestBuilder { private string UrlTemplate { get; set; } public Command BuildAddCommand() { var command = new Command("add"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.@Add.AddRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.Add.AddRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } public List BuildCommand() { var builder = new WorkbookTableRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildClearFiltersCommand(), - builder.BuildColumnsCommand(), - builder.BuildConvertToRangeCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildReapplyFiltersCommand(), - builder.BuildRowsCommand(), - builder.BuildSortCommand(), - builder.BuildWorksheetCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildClearFiltersCommand()); + commands.Add(builder.BuildColumnsCommand()); + commands.Add(builder.BuildConvertToRangeCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildReapplyFiltersCommand()); + commands.Add(builder.BuildRowsCommand()); + commands.Add(builder.BuildSortCommand()); + commands.Add(builder.BuildWorksheetCommand()); return commands; } /// @@ -52,11 +51,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Collection of tables that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -64,21 +63,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, bodyOption, outputOption); return command; } /// @@ -88,11 +86,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Collection of tables that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -131,7 +129,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -142,15 +144,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -212,18 +209,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookTable body, Actio return requestInfo; } /// - /// Collection of tables that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\worksheet\tables\microsoft.graph.itemAt(index={index}) /// Usage: index={index} /// @@ -231,19 +216,6 @@ public ItemAtWithIndexRequestBuilder ItemAtWithIndex(int? index) { _ = index ?? throw new ArgumentNullException(nameof(index)); return new ItemAtWithIndexRequestBuilder(PathParameters, RequestAdapter, index); } - /// - /// Collection of tables that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookTable model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of tables that are part of the worksheet. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs index 49f35286d3e..9a40737606f 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs index 751dcff99e2..8ca1b217a0d 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var valuesOnlyOption = new Option("--valuesonly", description: "Usage: valuesOnly={valuesOnly}") { + var valuesOnlyOption = new Option("--values-only", description: "Usage: valuesOnly={valuesOnly}") { }; valuesOnlyOption.IsRequired = true; command.AddOption(valuesOnlyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, bool? valuesOnly) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, bool? valuesOnly, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, valuesOnlyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, valuesOnlyOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeWithValuesOnlyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/WorksheetRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/WorksheetRequestBuilder.cs index 191c061323c..a3fe1e6844b 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/WorksheetRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/Item/Worksheet/WorksheetRequestBuilder.cs @@ -11,10 +11,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.UsedRangeWithValuesOnly; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,6 +33,9 @@ public Command BuildChartsCommand() { var command = new Command("charts"); var builder = new ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Charts.ChartsRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -44,19 +47,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns the worksheet on which the named item is scoped to. Available only if the item is scoped to the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption); return command; @@ -68,11 +70,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns the worksheet on which the named item is scoped to. Available only if the item is scoped to the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -86,20 +88,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookNamedItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookNamedItemIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildNamesCommand() { @@ -107,6 +108,9 @@ public Command BuildNamesCommand() { var builder = new ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Names.NamesRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCommand()); command.AddCommand(builder.BuildAddFormulaLocalCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -118,11 +122,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns the worksheet on which the named item is scoped to. Available only if the item is scoped to the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -130,14 +134,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookNamedItemId, string body) => { + command.SetHandler(async (string driveItemId, string workbookNamedItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookNamedItemIdOption, bodyOption); return command; @@ -145,6 +148,9 @@ public Command BuildPatchCommand() { public Command BuildPivotTablesCommand() { var command = new Command("pivot-tables"); var builder = new ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.PivotTables.PivotTablesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); command.AddCommand(builder.BuildRefreshAllCommand()); @@ -164,6 +170,9 @@ public Command BuildTablesCommand() { var command = new Command("tables"); var builder = new ApiSdk.Workbooks.Item.Workbook.Names.Item.Worksheet.Tables.TablesRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -246,42 +255,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookWorksheet body, return requestInfo; } /// - /// Returns the worksheet on which the named item is scoped to. Available only if the item is scoped to the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns the worksheet on which the named item is scoped to. Available only if the item is scoped to the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns the worksheet on which the named item is scoped to. Available only if the item is scoped to the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookWorksheet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\names\{workbookNamedItem-id}\worksheet\microsoft.graph.range() /// public RangeRequestBuilder Range() { diff --git a/src/generated/Workbooks/Item/Workbook/Names/NamesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Names/NamesRequestBuilder.cs index d08e748556b..36508da1386 100644 --- a/src/generated/Workbooks/Item/Workbook/Names/NamesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Names/NamesRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Workbooks.Item.Workbook.Names.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -24,7 +24,7 @@ public class NamesRequestBuilder { private string UrlTemplate { get; set; } public Command BuildAddCommand() { var command = new Command("add"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Names.@Add.AddRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Names.Add.AddRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } @@ -36,12 +36,11 @@ public Command BuildAddFormulaLocalCommand() { } public List BuildCommand() { var builder = new WorkbookNamedItemRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildWorksheetCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildWorksheetCommand()); return commands; } /// @@ -51,7 +50,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Represents a collection of workbooks scoped named items (named ranges and constants). Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -59,21 +58,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -83,7 +81,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Represents a collection of workbooks scoped named items (named ranges and constants). Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -122,7 +120,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -133,15 +135,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -196,31 +193,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookNamedItem body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents a collection of workbooks scoped named items (named ranges and constants). Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a collection of workbooks scoped named items (named ranges and constants). Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookNamedItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents a collection of workbooks scoped named items (named ranges and constants). Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Operations/Item/WorkbookOperationRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Operations/Item/WorkbookOperationRequestBuilder.cs index 1364e799f01..6641e45f0da 100644 --- a/src/generated/Workbooks/Item/Workbook/Operations/Item/WorkbookOperationRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Operations/Item/WorkbookOperationRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The status of Workbook operations. Getting an operation collection is not supported, but you can get the status of a long-running operation if the Location header is returned in the response. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookOperationIdOption = new Option("--workbookoperation-id", description: "key: id of workbookOperation") { + var workbookOperationIdOption = new Option("--workbook-operation-id", description: "key: id of workbookOperation") { }; workbookOperationIdOption.IsRequired = true; command.AddOption(workbookOperationIdOption); - command.SetHandler(async (string driveItemId, string workbookOperationId) => { + command.SetHandler(async (string driveItemId, string workbookOperationId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookOperationIdOption); return command; @@ -50,11 +49,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The status of Workbook operations. Getting an operation collection is not supported, but you can get the status of a long-running operation if the Location header is returned in the response. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookOperationIdOption = new Option("--workbookoperation-id", description: "key: id of workbookOperation") { + var workbookOperationIdOption = new Option("--workbook-operation-id", description: "key: id of workbookOperation") { }; workbookOperationIdOption.IsRequired = true; command.AddOption(workbookOperationIdOption); @@ -68,20 +67,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookOperationId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookOperationId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookOperationIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookOperationIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The status of Workbook operations. Getting an operation collection is not supported, but you can get the status of a long-running operation if the Location header is returned in the response. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookOperationIdOption = new Option("--workbookoperation-id", description: "key: id of workbookOperation") { + var workbookOperationIdOption = new Option("--workbook-operation-id", description: "key: id of workbookOperation") { }; workbookOperationIdOption.IsRequired = true; command.AddOption(workbookOperationIdOption); @@ -103,14 +101,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookOperationId, string body) => { + command.SetHandler(async (string driveItemId, string workbookOperationId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookOperationIdOption, bodyOption); return command; @@ -182,42 +179,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookOperation body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The status of Workbook operations. Getting an operation collection is not supported, but you can get the status of a long-running operation if the Location header is returned in the response. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The status of Workbook operations. Getting an operation collection is not supported, but you can get the status of a long-running operation if the Location header is returned in the response. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The status of Workbook operations. Getting an operation collection is not supported, but you can get the status of a long-running operation if the Location header is returned in the response. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookOperation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// The status of Workbook operations. Getting an operation collection is not supported, but you can get the status of a long-running operation if the Location header is returned in the response. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Operations/OperationsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Operations/OperationsRequestBuilder.cs index 65e03bed598..4de8e192245 100644 --- a/src/generated/Workbooks/Item/Workbook/Operations/OperationsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Operations/OperationsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Operations.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,11 +22,10 @@ public class OperationsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new WorkbookOperationRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -36,7 +35,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "The status of Workbook operations. Getting an operation collection is not supported, but you can get the status of a long-running operation if the Location header is returned in the response. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -44,21 +43,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -68,7 +66,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "The status of Workbook operations. Getting an operation collection is not supported, but you can get the status of a long-running operation if the Location header is returned in the response. Read-only. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -91,22 +89,21 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string search, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string search, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { if (!String.IsNullOrEmpty(search)) q.Search = search; q.Orderby = orderby; q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, searchOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, searchOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -161,31 +158,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookOperation body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// The status of Workbook operations. Getting an operation collection is not supported, but you can get the status of a long-running operation if the Location header is returned in the response. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The status of Workbook operations. Getting an operation collection is not supported, but you can get the status of a long-running operation if the Location header is returned in the response. Read-only. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookOperation model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// The status of Workbook operations. Getting an operation collection is not supported, but you can get the status of a long-running operation if the Location header is returned in the response. Read-only. Nullable. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/RefreshSession/RefreshSessionRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/RefreshSession/RefreshSessionRequestBuilder.cs index bfe09768efb..d746b3338a8 100644 --- a/src/generated/Workbooks/Item/Workbook/RefreshSession/RefreshSessionRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/RefreshSession/RefreshSessionRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,14 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action refreshSession"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { + command.SetHandler(async (string driveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption); return command; @@ -66,16 +65,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action refreshSession - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/SessionInfoResourceWithKey/SessionInfoResourceWithKeyRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/SessionInfoResourceWithKey/SessionInfoResourceWithKeyRequestBuilder.cs index 8c3b5342783..7fd3ac36460 100644 --- a/src/generated/Workbooks/Item/Workbook/SessionInfoResourceWithKey/SessionInfoResourceWithKeyRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/SessionInfoResourceWithKey/SessionInfoResourceWithKeyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function sessionInfoResource"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,18 +34,17 @@ public Command BuildGetCommand() { }; keyOption.IsRequired = true; command.AddOption(keyOption); - command.SetHandler(async (string driveItemId, string key) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string key, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, keyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, keyOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function sessionInfoResource - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookSessionInfo public class SessionInfoResourceWithKeyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/TableRowOperationResultWithKey/TableRowOperationResultWithKeyRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/TableRowOperationResultWithKey/TableRowOperationResultWithKeyRequestBuilder.cs index 4cca55655fa..176bc575118 100644 --- a/src/generated/Workbooks/Item/Workbook/TableRowOperationResultWithKey/TableRowOperationResultWithKeyRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/TableRowOperationResultWithKey/TableRowOperationResultWithKeyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function tableRowOperationResult"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,18 +34,17 @@ public Command BuildGetCommand() { }; keyOption.IsRequired = true; command.AddOption(keyOption); - command.SetHandler(async (string driveItemId, string key) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string key, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, keyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, keyOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function tableRowOperationResult - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookTableRow public class TableRowOperationResultWithKeyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/@Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Tables/@Add/AddRequestBody.cs deleted file mode 100644 index e0dc9c22b33..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Tables/@Add/AddRequestBody.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Tables.@Add { - public class AddRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string Address { get; set; } - public bool? HasHeaders { get; set; } - /// - /// Instantiates a new addRequestBody and sets the default values. - /// - public AddRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"address", (o,n) => { (o as AddRequestBody).Address = n.GetStringValue(); } }, - {"hasHeaders", (o,n) => { (o as AddRequestBody).HasHeaders = n.GetBoolValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("address", Address); - writer.WriteBoolValue("hasHeaders", HasHeaders); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Tables/@Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/@Add/AddRequestBuilder.cs deleted file mode 100644 index c1ce0d3b35a..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Tables/@Add/AddRequestBuilder.cs +++ /dev/null @@ -1,129 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Tables.@Add { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\microsoft.graph.add - public class AddRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action add - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action add"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AddRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/tables/microsoft.graph.add"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action add - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action add - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookTable - public class AddResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookTable - public WorkbookTable WorkbookTable { get; set; } - /// - /// Instantiates a new addResponse and sets the default values. - /// - public AddResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookTable", (o,n) => { (o as AddResponse).WorkbookTable = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookTable", WorkbookTable); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Tables/Add/AddRequestBody.cs new file mode 100644 index 00000000000..27717f5e93d --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Tables/Add/AddRequestBody.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Workbooks.Item.Workbook.Tables.Add { + public class AddRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string Address { get; set; } + public bool? HasHeaders { get; set; } + /// + /// Instantiates a new addRequestBody and sets the default values. + /// + public AddRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"address", (o,n) => { (o as AddRequestBody).Address = n.GetStringValue(); } }, + {"hasHeaders", (o,n) => { (o as AddRequestBody).HasHeaders = n.GetBoolValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("address", Address); + writer.WriteBoolValue("hasHeaders", HasHeaders); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Add/AddRequestBuilder.cs new file mode 100644 index 00000000000..392c3e8a4aa --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Tables/Add/AddRequestBuilder.cs @@ -0,0 +1,115 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Tables.Add { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\microsoft.graph.add + public class AddRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action add + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action add"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new AddRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/tables/microsoft.graph.add"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action add + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookTable + public class AddResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookTable + public WorkbookTable WorkbookTable { get; set; } + /// + /// Instantiates a new addResponse and sets the default values. + /// + public AddResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookTable", (o,n) => { (o as AddResponse).WorkbookTable = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookTable", WorkbookTable); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Count/CountRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Count/CountRequestBuilder.cs index f1c28be9e58..08f7ffd3bf5 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Count/CountRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Count/CountRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,22 +25,21 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function count"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteIntValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, outputOption); return command; } /// @@ -71,16 +70,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function count - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/ClearFilters/ClearFiltersRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/ClearFilters/ClearFiltersRequestBuilder.cs index 07ab6473dff..523177762fe 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/ClearFilters/ClearFiltersRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/ClearFilters/ClearFiltersRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,18 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clearFilters"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clearFilters - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/@Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/@Add/AddRequestBody.cs deleted file mode 100644 index a1df965cf90..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/@Add/AddRequestBody.cs +++ /dev/null @@ -1,42 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Tables.Item.Columns.@Add { - public class AddRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public int? Index { get; set; } - public string Name { get; set; } - public Json Values { get; set; } - /// - /// Instantiates a new addRequestBody and sets the default values. - /// - public AddRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"index", (o,n) => { (o as AddRequestBody).Index = n.GetIntValue(); } }, - {"name", (o,n) => { (o as AddRequestBody).Name = n.GetStringValue(); } }, - {"values", (o,n) => { (o as AddRequestBody).Values = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteIntValue("index", Index); - writer.WriteStringValue("name", Name); - writer.WriteObjectValue("values", Values); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/@Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/@Add/AddRequestBuilder.cs deleted file mode 100644 index f11c0b5c206..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/@Add/AddRequestBuilder.cs +++ /dev/null @@ -1,133 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Tables.Item.Columns.@Add { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\columns\microsoft.graph.add - public class AddRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action add - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action add"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { - }; - workbookTableIdOption.IsRequired = true; - command.AddOption(workbookTableIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AddRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/tables/{workbookTable_id}/columns/microsoft.graph.add"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action add - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action add - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookTableColumn - public class AddResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookTableColumn - public WorkbookTableColumn WorkbookTableColumn { get; set; } - /// - /// Instantiates a new addResponse and sets the default values. - /// - public AddResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookTableColumn", (o,n) => { (o as AddResponse).WorkbookTableColumn = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookTableColumn", WorkbookTableColumn); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Add/AddRequestBody.cs new file mode 100644 index 00000000000..9c5cd646795 --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Add/AddRequestBody.cs @@ -0,0 +1,42 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Workbooks.Item.Workbook.Tables.Item.Columns.Add { + public class AddRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public int? Index { get; set; } + public string Name { get; set; } + public Json Values { get; set; } + /// + /// Instantiates a new addRequestBody and sets the default values. + /// + public AddRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"index", (o,n) => { (o as AddRequestBody).Index = n.GetIntValue(); } }, + {"name", (o,n) => { (o as AddRequestBody).Name = n.GetStringValue(); } }, + {"values", (o,n) => { (o as AddRequestBody).Values = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteIntValue("index", Index); + writer.WriteStringValue("name", Name); + writer.WriteObjectValue("values", Values); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Add/AddRequestBuilder.cs new file mode 100644 index 00000000000..8677c7b59c3 --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Add/AddRequestBuilder.cs @@ -0,0 +1,119 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Tables.Item.Columns.Add { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\columns\microsoft.graph.add + public class AddRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action add + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action add"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { + }; + workbookTableIdOption.IsRequired = true; + command.AddOption(workbookTableIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new AddRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/tables/{workbookTable_id}/columns/microsoft.graph.add"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action add + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookTableColumn + public class AddResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookTableColumn + public WorkbookTableColumn WorkbookTableColumn { get; set; } + /// + /// Instantiates a new addResponse and sets the default values. + /// + public AddResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookTableColumn", (o,n) => { (o as AddResponse).WorkbookTableColumn = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookTableColumn", WorkbookTableColumn); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/ColumnsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/ColumnsRequestBuilder.cs index 38bb4347628..d5698e0b021 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/ColumnsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/ColumnsRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Columns.ItemAtWithIndex; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public class ColumnsRequestBuilder { private string UrlTemplate { get; set; } public Command BuildAddCommand() { var command = new Command("add"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Tables.Item.Columns.@Add.AddRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Tables.Item.Columns.Add.AddRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } public List BuildCommand() { var builder = new WorkbookTableColumnRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildFilterCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFilterCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -46,11 +45,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Represents a collection of all the columns in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -58,21 +57,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, bodyOption, outputOption); return command; } /// @@ -82,11 +80,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Represents a collection of all the columns in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -125,7 +123,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -136,15 +138,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -206,18 +203,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookTableColumn body, return requestInfo; } /// - /// Represents a collection of all the columns in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\columns\microsoft.graph.itemAt(index={index}) /// Usage: index={index} /// @@ -225,19 +210,6 @@ public ItemAtWithIndexRequestBuilder ItemAtWithIndex(int? index) { _ = index ?? throw new ArgumentNullException(nameof(index)); return new ItemAtWithIndexRequestBuilder(PathParameters, RequestAdapter, index); } - /// - /// Represents a collection of all the columns in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookTableColumn model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents a collection of all the columns in the table. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Count/CountRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Count/CountRequestBuilder.cs index dc66681e176..a6605797e36 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Count/CountRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Count/CountRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,26 +25,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function count"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteIntValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -75,16 +74,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function count - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs index 1fa0f49852d..22fae79e7ec 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function dataBodyRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function dataBodyRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class DataBodyRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/Apply/ApplyRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/Apply/ApplyRequestBuilder.cs index fed6cc9f3a9..f0b9db420f0 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/Apply/ApplyRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/Apply/ApplyRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action apply"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ApplyRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action apply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyBottomItemsFilter/ApplyBottomItemsFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyBottomItemsFilter/ApplyBottomItemsFilterRequestBuilder.cs index ee83d9092e0..17318c51824 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyBottomItemsFilter/ApplyBottomItemsFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyBottomItemsFilter/ApplyBottomItemsFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyBottomItemsFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ApplyBottomItemsFilterReq requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyBottomItemsFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyBottomItemsFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyBottomPercentFilter/ApplyBottomPercentFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyBottomPercentFilter/ApplyBottomPercentFilterRequestBuilder.cs index 0a8074f3444..a6335934a22 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyBottomPercentFilter/ApplyBottomPercentFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyBottomPercentFilter/ApplyBottomPercentFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyBottomPercentFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ApplyBottomPercentFilterR requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyBottomPercentFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyBottomPercentFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyCellColorFilter/ApplyCellColorFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyCellColorFilter/ApplyCellColorFilterRequestBuilder.cs index 05a807bebae..5e659a9a444 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyCellColorFilter/ApplyCellColorFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyCellColorFilter/ApplyCellColorFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyCellColorFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ApplyCellColorFilterReque requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyCellColorFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyCellColorFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyCustomFilter/ApplyCustomFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyCustomFilter/ApplyCustomFilterRequestBuilder.cs index 3fe1bdf1d09..b3bb1472adc 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyCustomFilter/ApplyCustomFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyCustomFilter/ApplyCustomFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyCustomFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ApplyCustomFilterRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyCustomFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyCustomFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyDynamicFilter/ApplyDynamicFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyDynamicFilter/ApplyDynamicFilterRequestBuilder.cs index 9737af8fb23..ebb82b11104 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyDynamicFilter/ApplyDynamicFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyDynamicFilter/ApplyDynamicFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyDynamicFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ApplyDynamicFilterRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyDynamicFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyDynamicFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyFontColorFilter/ApplyFontColorFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyFontColorFilter/ApplyFontColorFilterRequestBuilder.cs index 520aa6b7894..d7616c68386 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyFontColorFilter/ApplyFontColorFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyFontColorFilter/ApplyFontColorFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyFontColorFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ApplyFontColorFilterReque requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyFontColorFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyFontColorFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyIconFilter/ApplyIconFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyIconFilter/ApplyIconFilterRequestBuilder.cs index 1ea194a6ae9..b343a2798d7 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyIconFilter/ApplyIconFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyIconFilter/ApplyIconFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyIconFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ApplyIconFilterRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyIconFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyIconFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyTopItemsFilter/ApplyTopItemsFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyTopItemsFilter/ApplyTopItemsFilterRequestBuilder.cs index 36e9648f3e3..b816ed08f45 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyTopItemsFilter/ApplyTopItemsFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyTopItemsFilter/ApplyTopItemsFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyTopItemsFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ApplyTopItemsFilterReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyTopItemsFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyTopItemsFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyTopPercentFilter/ApplyTopPercentFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyTopPercentFilter/ApplyTopPercentFilterRequestBuilder.cs index 80d335847a7..39d3169fbe0 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyTopPercentFilter/ApplyTopPercentFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyTopPercentFilter/ApplyTopPercentFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyTopPercentFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ApplyTopPercentFilterRequ requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyTopPercentFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyTopPercentFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyValuesFilter/ApplyValuesFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyValuesFilter/ApplyValuesFilterRequestBuilder.cs index 05c46e02e8a..53a7ffbd23b 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyValuesFilter/ApplyValuesFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/ApplyValuesFilter/ApplyValuesFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyValuesFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ApplyValuesFilterRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyValuesFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyValuesFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/Clear/ClearRequestBuilder.cs index 0e047e9a4d3..5c5eb0a3736 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/FilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/FilterRequestBuilder.cs index 2410351a251..e25bb23db08 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/FilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Filter/FilterRequestBuilder.cs @@ -13,10 +13,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Columns.Item.Filter.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -110,23 +110,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Retrieve the filter applied to the column. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption); return command; @@ -138,15 +137,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Retrieve the filter applied to the column. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -160,20 +159,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -183,15 +181,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Retrieve the filter applied to the column. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -199,14 +197,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -278,42 +275,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookFilter body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Retrieve the filter applied to the column. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Retrieve the filter applied to the column. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Retrieve the filter applied to the column. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookFilter model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Retrieve the filter applied to the column. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs index 736e10a6938..913efc810f7 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function headerRowRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function headerRowRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class HeaderRowRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Range/RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Range/RangeRequestBuilder.cs index 972b9e3ad82..c6cec07b161 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Range/RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs index c4efa306304..6dbea2478b3 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function totalRowRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function totalRowRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class TotalRowRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/WorkbookTableColumnRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/WorkbookTableColumnRequestBuilder.cs index 6d8ac7a40ec..a3d2318dcf2 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/WorkbookTableColumnRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/Item/WorkbookTableColumnRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Columns.Item.TotalRowRange; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,23 +31,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents a collection of all the columns in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption); return command; @@ -79,15 +78,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents a collection of all the columns in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -101,20 +100,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -124,15 +122,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents a collection of all the columns in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -140,14 +138,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -226,48 +223,12 @@ public DataBodyRangeRequestBuilder DataBodyRange() { return new DataBodyRangeRequestBuilder(PathParameters, RequestAdapter); } /// - /// Represents a collection of all the columns in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a collection of all the columns in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\columns\{workbookTableColumn-id}\microsoft.graph.headerRowRange() /// public HeaderRowRangeRequestBuilder HeaderRowRange() { return new HeaderRowRangeRequestBuilder(PathParameters, RequestAdapter); } /// - /// Represents a collection of all the columns in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookTableColumn model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\columns\{workbookTableColumn-id}\microsoft.graph.range() /// public RangeRequestBuilder Range() { diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs index cc772cb0ab5..c8153c04b32 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Columns/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function itemAt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; indexOption.IsRequired = true; command.AddOption(indexOption); - command.SetHandler(async (string driveItemId, string workbookTableId, int? index) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, int? index, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, indexOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, indexOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function itemAt - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookTableColumn public class ItemAtWithIndexResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/ConvertToRange/ConvertToRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/ConvertToRange/ConvertToRangeRequestBuilder.cs index 2f72758579b..2a767ad6e9a 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/ConvertToRange/ConvertToRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/ConvertToRange/ConvertToRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action convertToRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action convertToRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ConvertToRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs index 7b0ab1483d4..2e3382befa8 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function dataBodyRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function dataBodyRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class DataBodyRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs index 0bfd4aafe82..ff22e8a98f6 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function headerRowRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function headerRowRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class HeaderRowRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Range/RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Range/RangeRequestBuilder.cs index 5c636a657bc..b9d1e164ca2 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Range/RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/ReapplyFilters/ReapplyFiltersRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/ReapplyFilters/ReapplyFiltersRequestBuilder.cs index 783b26b2c25..c140e7a9353 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/ReapplyFilters/ReapplyFiltersRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/ReapplyFilters/ReapplyFiltersRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,18 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action reapplyFilters"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action reapplyFilters - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/@Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/@Add/AddRequestBody.cs deleted file mode 100644 index 4013b595cbc..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/@Add/AddRequestBody.cs +++ /dev/null @@ -1,39 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Tables.Item.Rows.@Add { - public class AddRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public int? Index { get; set; } - public Json Values { get; set; } - /// - /// Instantiates a new addRequestBody and sets the default values. - /// - public AddRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"index", (o,n) => { (o as AddRequestBody).Index = n.GetIntValue(); } }, - {"values", (o,n) => { (o as AddRequestBody).Values = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteIntValue("index", Index); - writer.WriteObjectValue("values", Values); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/@Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/@Add/AddRequestBuilder.cs deleted file mode 100644 index 5abadf0bdc8..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/@Add/AddRequestBuilder.cs +++ /dev/null @@ -1,133 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Tables.Item.Rows.@Add { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\rows\microsoft.graph.add - public class AddRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action add - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action add"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { - }; - workbookTableIdOption.IsRequired = true; - command.AddOption(workbookTableIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AddRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/tables/{workbookTable_id}/rows/microsoft.graph.add"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action add - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action add - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookTableRow - public class AddResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookTableRow - public WorkbookTableRow WorkbookTableRow { get; set; } - /// - /// Instantiates a new addResponse and sets the default values. - /// - public AddResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookTableRow", (o,n) => { (o as AddResponse).WorkbookTableRow = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookTableRow", WorkbookTableRow); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/Add/AddRequestBody.cs new file mode 100644 index 00000000000..d979060234b --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/Add/AddRequestBody.cs @@ -0,0 +1,39 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Workbooks.Item.Workbook.Tables.Item.Rows.Add { + public class AddRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public int? Index { get; set; } + public Json Values { get; set; } + /// + /// Instantiates a new addRequestBody and sets the default values. + /// + public AddRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"index", (o,n) => { (o as AddRequestBody).Index = n.GetIntValue(); } }, + {"values", (o,n) => { (o as AddRequestBody).Values = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteIntValue("index", Index); + writer.WriteObjectValue("values", Values); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/Add/AddRequestBuilder.cs new file mode 100644 index 00000000000..0115adc1379 --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/Add/AddRequestBuilder.cs @@ -0,0 +1,119 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Tables.Item.Rows.Add { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\rows\microsoft.graph.add + public class AddRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action add + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action add"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { + }; + workbookTableIdOption.IsRequired = true; + command.AddOption(workbookTableIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new AddRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/tables/{workbookTable_id}/rows/microsoft.graph.add"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action add + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookTableRow + public class AddResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookTableRow + public WorkbookTableRow WorkbookTableRow { get; set; } + /// + /// Instantiates a new addResponse and sets the default values. + /// + public AddResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookTableRow", (o,n) => { (o as AddResponse).WorkbookTableRow = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookTableRow", WorkbookTableRow); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/Count/CountRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/Count/CountRequestBuilder.cs index d96accb8f4c..4917d80e1ca 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/Count/CountRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/Count/CountRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,26 +25,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function count"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteIntValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -75,16 +74,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function count - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/Item/Range/RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/Item/Range/RangeRequestBuilder.cs index 26e4730d0cb..6345c4253cd 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/Item/Range/RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/Item/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableRowIdOption = new Option("--workbooktablerow-id", description: "key: id of workbookTableRow") { + var workbookTableRowIdOption = new Option("--workbook-table-row-id", description: "key: id of workbookTableRow") { }; workbookTableRowIdOption.IsRequired = true; command.AddOption(workbookTableRowIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableRowId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableRowId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookTableRowIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookTableRowIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/Item/WorkbookTableRowRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/Item/WorkbookTableRowRequestBuilder.cs index fb77cdb54f7..837216a3cca 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/Item/WorkbookTableRowRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/Item/WorkbookTableRowRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Rows.Item.Range; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents a collection of all the rows in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableRowIdOption = new Option("--workbooktablerow-id", description: "key: id of workbookTableRow") { + var workbookTableRowIdOption = new Option("--workbook-table-row-id", description: "key: id of workbookTableRow") { }; workbookTableRowIdOption.IsRequired = true; command.AddOption(workbookTableRowIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableRowId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableRowId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookTableRowIdOption); return command; @@ -55,15 +54,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents a collection of all the rows in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableRowIdOption = new Option("--workbooktablerow-id", description: "key: id of workbookTableRow") { + var workbookTableRowIdOption = new Option("--workbook-table-row-id", description: "key: id of workbookTableRow") { }; workbookTableRowIdOption.IsRequired = true; command.AddOption(workbookTableRowIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableRowId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableRowId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookTableRowIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookTableRowIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -100,15 +98,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents a collection of all the rows in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableRowIdOption = new Option("--workbooktablerow-id", description: "key: id of workbookTableRow") { + var workbookTableRowIdOption = new Option("--workbook-table-row-id", description: "key: id of workbookTableRow") { }; workbookTableRowIdOption.IsRequired = true; command.AddOption(workbookTableRowIdOption); @@ -116,14 +114,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableRowId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableRowId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookTableRowIdOption, bodyOption); return command; @@ -196,42 +193,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookTableRow body, A return requestInfo; } /// - /// Represents a collection of all the rows in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a collection of all the rows in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a collection of all the rows in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookTableRow model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\rows\{workbookTableRow-id}\microsoft.graph.range() /// public RangeRequestBuilder Range() { diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs index edbd883c6c5..59a54468f1c 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function itemAt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; indexOption.IsRequired = true; command.AddOption(indexOption); - command.SetHandler(async (string driveItemId, string workbookTableId, int? index) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, int? index, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, indexOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, indexOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function itemAt - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookTableRow public class ItemAtWithIndexResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/RowsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/RowsRequestBuilder.cs index c8cafdf9e03..d788417e311 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/RowsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Rows/RowsRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Rows.ItemAtWithIndex; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,17 +25,16 @@ public class RowsRequestBuilder { private string UrlTemplate { get; set; } public Command BuildAddCommand() { var command = new Command("add"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Tables.Item.Rows.@Add.AddRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Tables.Item.Rows.Add.AddRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } public List BuildCommand() { var builder = new WorkbookTableRowRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,11 +44,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Represents a collection of all the rows in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -57,21 +56,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, bodyOption, outputOption); return command; } /// @@ -81,11 +79,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Represents a collection of all the rows in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -124,7 +122,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -135,15 +137,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -205,18 +202,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookTableRow body, Ac return requestInfo; } /// - /// Represents a collection of all the rows in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\rows\microsoft.graph.itemAt(index={index}) /// Usage: index={index} /// @@ -224,19 +209,6 @@ public ItemAtWithIndexRequestBuilder ItemAtWithIndex(int? index) { _ = index ?? throw new ArgumentNullException(nameof(index)); return new ItemAtWithIndexRequestBuilder(PathParameters, RequestAdapter, index); } - /// - /// Represents a collection of all the rows in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookTableRow model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents a collection of all the rows in the table. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Sort/Apply/ApplyRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Sort/Apply/ApplyRequestBuilder.cs index aedbaf9885e..8356b2514d6 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Sort/Apply/ApplyRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Sort/Apply/ApplyRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,11 +25,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action apply"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ApplyRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action apply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Sort/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Sort/Clear/ClearRequestBuilder.cs index 4f0ce3dfdb3..ffb5c0d0fc6 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Sort/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Sort/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,18 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Sort/Reapply/ReapplyRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Sort/Reapply/ReapplyRequestBuilder.cs index 41d6d6ef122..ace7400dea7 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Sort/Reapply/ReapplyRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Sort/Reapply/ReapplyRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,18 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action reapply"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action reapply - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Sort/SortRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Sort/SortRequestBuilder.cs index a1ab8cec5fe..0970e1dd43b 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Sort/SortRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Sort/SortRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Sort.Reapply; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,19 +41,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the sorting for the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption); return command; @@ -65,11 +64,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the sorting for the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,11 +104,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the sorting for the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -118,14 +116,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, bodyOption); return command; @@ -203,42 +200,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookTableSort body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the sorting for the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the sorting for the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the sorting for the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookTableSort model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the sorting for the table. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs index 318b2bb630c..cd4137e5db6 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function totalRowRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function totalRowRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class TotalRowRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/WorkbookTableRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/WorkbookTableRequestBuilder.cs index 62cdffb41f7..d96d48d661e 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/WorkbookTableRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/WorkbookTableRequestBuilder.cs @@ -12,10 +12,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -40,6 +40,9 @@ public Command BuildColumnsCommand() { var command = new Command("columns"); var builder = new ApiSdk.Workbooks.Item.Workbook.Tables.Item.Columns.ColumnsRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -57,19 +60,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents a collection of tables associated with the workbook. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption); return command; @@ -81,11 +83,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents a collection of tables associated with the workbook. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -99,20 +101,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -122,11 +123,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents a collection of tables associated with the workbook. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -134,14 +135,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, bodyOption); return command; @@ -156,6 +156,9 @@ public Command BuildRowsCommand() { var command = new Command("rows"); var builder = new ApiSdk.Workbooks.Item.Workbook.Tables.Item.Rows.RowsRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -258,48 +261,12 @@ public DataBodyRangeRequestBuilder DataBodyRange() { return new DataBodyRangeRequestBuilder(PathParameters, RequestAdapter); } /// - /// Represents a collection of tables associated with the workbook. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a collection of tables associated with the workbook. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\microsoft.graph.headerRowRange() /// public HeaderRowRangeRequestBuilder HeaderRowRange() { return new HeaderRowRangeRequestBuilder(PathParameters, RequestAdapter); } /// - /// Represents a collection of tables associated with the workbook. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookTable model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\microsoft.graph.range() /// public RangeRequestBuilder Range() { diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs index b833e4405e6..f1fbafbb811 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function cell"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -42,18 +42,17 @@ public Command BuildGetCommand() { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string driveItemId, string workbookTableId, int? row, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, int? row, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, rowOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, rowOption, columnOption, outputOption); return command; } /// @@ -88,17 +87,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function cell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class CellWithRowWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/@Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/@Add/AddRequestBody.cs deleted file mode 100644 index 53d84808670..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/@Add/AddRequestBody.cs +++ /dev/null @@ -1,42 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.@Add { - public class AddRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string SeriesBy { get; set; } - public Json SourceData { get; set; } - public string Type { get; set; } - /// - /// Instantiates a new addRequestBody and sets the default values. - /// - public AddRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"seriesBy", (o,n) => { (o as AddRequestBody).SeriesBy = n.GetStringValue(); } }, - {"sourceData", (o,n) => { (o as AddRequestBody).SourceData = n.GetObjectValue(); } }, - {"type", (o,n) => { (o as AddRequestBody).Type = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("seriesBy", SeriesBy); - writer.WriteObjectValue("sourceData", SourceData); - writer.WriteStringValue("type", Type); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/@Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/@Add/AddRequestBuilder.cs deleted file mode 100644 index f7ccf38184b..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/@Add/AddRequestBuilder.cs +++ /dev/null @@ -1,133 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.@Add { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\worksheet\charts\microsoft.graph.add - public class AddRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action add - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action add"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { - }; - workbookTableIdOption.IsRequired = true; - command.AddOption(workbookTableIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AddRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/tables/{workbookTable_id}/worksheet/charts/microsoft.graph.add"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action add - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action add - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookChart - public class AddResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookChart - public WorkbookChart WorkbookChart { get; set; } - /// - /// Instantiates a new addResponse and sets the default values. - /// - public AddResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookChart", (o,n) => { (o as AddResponse).WorkbookChart = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookChart", WorkbookChart); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Add/AddRequestBody.cs new file mode 100644 index 00000000000..e561b06b388 --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Add/AddRequestBody.cs @@ -0,0 +1,42 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Add { + public class AddRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string SeriesBy { get; set; } + public Json SourceData { get; set; } + public string Type { get; set; } + /// + /// Instantiates a new addRequestBody and sets the default values. + /// + public AddRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"seriesBy", (o,n) => { (o as AddRequestBody).SeriesBy = n.GetStringValue(); } }, + {"sourceData", (o,n) => { (o as AddRequestBody).SourceData = n.GetObjectValue(); } }, + {"type", (o,n) => { (o as AddRequestBody).Type = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("seriesBy", SeriesBy); + writer.WriteObjectValue("sourceData", SourceData); + writer.WriteStringValue("type", Type); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Add/AddRequestBuilder.cs new file mode 100644 index 00000000000..5a377b0775f --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Add/AddRequestBuilder.cs @@ -0,0 +1,119 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Add { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\worksheet\charts\microsoft.graph.add + public class AddRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action add + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action add"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { + }; + workbookTableIdOption.IsRequired = true; + command.AddOption(workbookTableIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new AddRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/tables/{workbookTable_id}/worksheet/charts/microsoft.graph.add"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action add + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookChart + public class AddResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookChart + public WorkbookChart WorkbookChart { get; set; } + /// + /// Instantiates a new addResponse and sets the default values. + /// + public AddResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookChart", (o,n) => { (o as AddResponse).WorkbookChart = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookChart", WorkbookChart); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/ChartsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/ChartsRequestBuilder.cs index dc704951a0d..9510febd71d 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/ChartsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/ChartsRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.ItemWithName; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public class ChartsRequestBuilder { private string UrlTemplate { get; set; } public Command BuildAddCommand() { var command = new Command("add"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.@Add.AddRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Add.AddRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } public List BuildCommand() { var builder = new WorkbookChartRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAxesCommand(), - builder.BuildDataLabelsCommand(), - builder.BuildDeleteCommand(), - builder.BuildFormatCommand(), - builder.BuildGetCommand(), - builder.BuildLegendCommand(), - builder.BuildPatchCommand(), - builder.BuildSeriesCommand(), - builder.BuildSetDataCommand(), - builder.BuildSetPositionCommand(), - builder.BuildTitleCommand(), - builder.BuildWorksheetCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAxesCommand()); + commands.Add(builder.BuildDataLabelsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFormatCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildLegendCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSeriesCommand()); + commands.Add(builder.BuildSetDataCommand()); + commands.Add(builder.BuildSetPositionCommand()); + commands.Add(builder.BuildTitleCommand()); + commands.Add(builder.BuildWorksheetCommand()); return commands; } /// @@ -55,11 +54,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Returns collection of charts that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -67,21 +66,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, bodyOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Returns collection of charts that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -134,7 +132,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -145,15 +147,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -215,18 +212,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookChart body, Actio return requestInfo; } /// - /// Returns collection of charts that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\worksheet\charts\microsoft.graph.itemAt(index={index}) /// Usage: index={index} /// @@ -242,19 +227,6 @@ public ItemWithNameRequestBuilder ItemWithName(string name) { if(string.IsNullOrEmpty(name)) throw new ArgumentNullException(nameof(name)); return new ItemWithNameRequestBuilder(PathParameters, RequestAdapter, name); } - /// - /// Returns collection of charts that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookChart model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns collection of charts that are part of the worksheet. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Count/CountRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Count/CountRequestBuilder.cs index 3f896becfc7..4f22e765a07 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Count/CountRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Count/CountRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,26 +25,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function count"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteIntValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -75,16 +74,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function count - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/AxesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/AxesRequestBuilder.cs index adfc86295b3..39016f43e46 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/AxesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/AxesRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.ValueAxis; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,23 +41,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart axes. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -69,15 +68,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart axes. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -91,20 +90,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -114,15 +112,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart axes. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -130,14 +128,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -233,42 +230,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxes body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart axes. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart axes. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart axes. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxes model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart axes. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/CategoryAxisRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/CategoryAxisRequestBuilder.cs index 5d3c841258e..335f0992b9e 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/CategoryAxisRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/CategoryAxisRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.CategoryAxis.Title; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the category axis in a chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -68,15 +67,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the category axis in a chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildMajorGridlinesCommand() { @@ -131,15 +129,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the category axis in a chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -147,14 +145,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -235,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxis body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the category axis in a chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the category axis in a chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the category axis in a chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxis model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the category axis in a chart. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/Font/FontRequestBuilder.cs index e7715c9d306..0829fbd3c28 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/FormatRequestBuilder.cs index 0e45bcf4bf5..11eae1f8f2f 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/FormatRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.CategoryAxis.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,23 +28,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of a chart object, which includes line and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of a chart object, which includes line and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -118,15 +116,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of a chart object, which includes line and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxisFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxisFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/Line/Clear/ClearRequestBuilder.cs index 6ed0f12f936..298f2f4da0d 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/Line/LineRequestBuilder.cs index 3434df47993..d2f708e1117 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.CategoryAxis.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/FormatRequestBuilder.cs index 2d007da858c..65fa966a599 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.CategoryAxis.MajorGridlines.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -55,15 +54,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlinesFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlinesFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of chart gridlines. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs index 1f5295b6c4b..064a20d9a9e 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs index f7b7354d388..93d910f7548 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.CategoryAxis.MajorGridlines.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs index 818bf208435..b936e1bcbf6 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.CategoryAxis.MajorGridlines.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns a gridlines object that represents the major gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns a gridlines object that represents the major gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns a gridlines object that represents the major gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlines b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlines model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/FormatRequestBuilder.cs index 7cd62ad00c0..fe415082459 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.CategoryAxis.MinorGridlines.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -55,15 +54,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlinesFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlinesFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of chart gridlines. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs index 59a10349be9..3a8cfad90d3 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs index f94adf9cb1d..3af10fb26dd 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.CategoryAxis.MinorGridlines.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs index fbeaa57f439..29a577c4d40 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.CategoryAxis.MinorGridlines.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlines b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlines model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Title/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Title/Format/Font/FontRequestBuilder.cs index b75fe64e104..77217ce5e2d 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Title/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Title/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Title/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Title/Format/FormatRequestBuilder.cs index 3c23396c16f..840040833a7 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Title/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Title/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.CategoryAxis.Title.Format.Font; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of chart axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -63,15 +62,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of chart axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -85,20 +84,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -108,15 +106,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of chart axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -124,14 +122,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -203,42 +200,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxisTitleFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of chart axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxisTitleFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of chart axis title. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Title/TitleRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Title/TitleRequestBuilder.cs index 8039dd6b899..a927629baa4 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Title/TitleRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/CategoryAxis/Title/TitleRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.CategoryAxis.Title.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxisTitle b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxisTitle model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the axis title. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/Font/FontRequestBuilder.cs index 206054601fb..75f97aacdd9 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/FormatRequestBuilder.cs index 2e6faccd8c3..4631a8bd526 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/FormatRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.SeriesAxis.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,23 +28,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of a chart object, which includes line and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of a chart object, which includes line and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -118,15 +116,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of a chart object, which includes line and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxisFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxisFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/Line/Clear/ClearRequestBuilder.cs index 05b5a3ee9e3..e29aad8fa4a 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/Line/LineRequestBuilder.cs index 9f5b785724a..ed2e6e53bb8 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.SeriesAxis.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/FormatRequestBuilder.cs index 66602071037..1a0a77d35c9 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.SeriesAxis.MajorGridlines.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -55,15 +54,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlinesFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlinesFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of chart gridlines. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs index eabbeba41b9..6032847739a 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs index 9366884d0b0..1b374972cad 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.SeriesAxis.MajorGridlines.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs index d167f71acc7..9f11efa517c 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.SeriesAxis.MajorGridlines.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns a gridlines object that represents the major gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns a gridlines object that represents the major gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns a gridlines object that represents the major gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlines b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlines model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/FormatRequestBuilder.cs index ead12ad8d50..ff3ddef98fe 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.SeriesAxis.MinorGridlines.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -55,15 +54,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlinesFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlinesFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of chart gridlines. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs index afe2baf3622..3d5718c0488 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs index 03a9ac27e5f..0caa1b7a9e9 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.SeriesAxis.MinorGridlines.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs index 64da2977f78..a12bddbbc5b 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.SeriesAxis.MinorGridlines.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlines b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlines model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/SeriesAxisRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/SeriesAxisRequestBuilder.cs index eb608c50fb1..3e9656aa519 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/SeriesAxisRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/SeriesAxisRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.SeriesAxis.Title; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the series axis of a 3-dimensional chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -68,15 +67,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the series axis of a 3-dimensional chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildMajorGridlinesCommand() { @@ -131,15 +129,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the series axis of a 3-dimensional chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -147,14 +145,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -235,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxis body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the series axis of a 3-dimensional chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the series axis of a 3-dimensional chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the series axis of a 3-dimensional chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxis model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the series axis of a 3-dimensional chart. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Title/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Title/Format/Font/FontRequestBuilder.cs index d02f8320fbe..ab80b84ef6e 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Title/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Title/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Title/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Title/Format/FormatRequestBuilder.cs index c74fe55b49f..1f53d398080 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Title/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Title/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.SeriesAxis.Title.Format.Font; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of chart axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -63,15 +62,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of chart axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -85,20 +84,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -108,15 +106,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of chart axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -124,14 +122,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -203,42 +200,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxisTitleFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of chart axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxisTitleFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of chart axis title. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Title/TitleRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Title/TitleRequestBuilder.cs index bff9ce1e5c6..9fb39f93b84 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Title/TitleRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/SeriesAxis/Title/TitleRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.SeriesAxis.Title.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxisTitle b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxisTitle model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the axis title. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/Font/FontRequestBuilder.cs index c1803d61551..1f06a973ba3 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/FormatRequestBuilder.cs index 13eec450a23..7a5ce30f1be 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/FormatRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.ValueAxis.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,23 +28,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of a chart object, which includes line and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of a chart object, which includes line and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -118,15 +116,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of a chart object, which includes line and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxisFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxisFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/Line/Clear/ClearRequestBuilder.cs index 38b1d2eeb06..4b59cdabf04 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/Line/LineRequestBuilder.cs index 1d6c5b86857..bbdc763d38f 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.ValueAxis.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/FormatRequestBuilder.cs index 6db914acc38..ff759491938 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.ValueAxis.MajorGridlines.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -55,15 +54,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlinesFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlinesFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of chart gridlines. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs index ed4d928bd2f..4790efc2dc8 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs index eced1c3e6a6..801ca214545 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.ValueAxis.MajorGridlines.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs index 788b782e7e7..ac4d4bceaee 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.ValueAxis.MajorGridlines.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns a gridlines object that represents the major gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns a gridlines object that represents the major gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns a gridlines object that represents the major gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlines b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlines model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/FormatRequestBuilder.cs index e6bec984f58..5e468f4e6fe 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.ValueAxis.MinorGridlines.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -55,15 +54,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlinesFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlinesFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of chart gridlines. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs index f4963336b51..2abb687090b 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs index 5c763402028..d17787390d0 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.ValueAxis.MinorGridlines.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs index 8f2171b38fe..e7e0965543f 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.ValueAxis.MinorGridlines.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlines b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlines model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Title/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Title/Format/Font/FontRequestBuilder.cs index bcc33420f28..184cc69e8b9 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Title/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Title/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Title/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Title/Format/FormatRequestBuilder.cs index c5a043dc2f6..eaee5cfcd10 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Title/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Title/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.ValueAxis.Title.Format.Font; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of chart axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -63,15 +62,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of chart axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -85,20 +84,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -108,15 +106,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of chart axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -124,14 +122,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -203,42 +200,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxisTitleFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of chart axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxisTitleFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of chart axis title. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Title/TitleRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Title/TitleRequestBuilder.cs index 979a1e132d9..0ec9a3f59a1 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Title/TitleRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/Title/TitleRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.ValueAxis.Title.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxisTitle b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxisTitle model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the axis title. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/ValueAxisRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/ValueAxisRequestBuilder.cs index 2e5d32e6f6c..057409d77e1 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/ValueAxisRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Axes/ValueAxis/ValueAxisRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Axes.ValueAxis.Title; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the value axis in an axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -68,15 +67,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the value axis in an axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildMajorGridlinesCommand() { @@ -131,15 +129,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the value axis in an axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -147,14 +145,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -235,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxis body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the value axis in an axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the value axis in an axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the value axis in an axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxis model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the value axis in an axis. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/DataLabels/DataLabelsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/DataLabels/DataLabelsRequestBuilder.cs index 00ff29066bd..b6260331ed4 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/DataLabels/DataLabelsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/DataLabels/DataLabelsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.DataLabels.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the datalabels on the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -65,15 +64,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the datalabels on the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -87,20 +86,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,15 +108,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the datalabels on the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -126,14 +124,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -205,42 +202,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartDataLabels requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the datalabels on the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the datalabels on the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the datalabels on the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartDataLabels model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the datalabels on the chart. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/DataLabels/Format/Fill/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/DataLabels/Format/Fill/Clear/ClearRequestBuilder.cs index 6587743c2ed..943e42ee6f3 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/DataLabels/Format/Fill/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/DataLabels/Format/Fill/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/DataLabels/Format/Fill/FillRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/DataLabels/Format/Fill/FillRequestBuilder.cs index 26c80603feb..75b0ee4fc9c 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/DataLabels/Format/Fill/FillRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/DataLabels/Format/Fill/FillRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.DataLabels.Format.Fill.SetSolidColor; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,23 +34,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the fill format of the current chart data label. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the fill format of the current chart data label. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,15 +105,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the fill format of the current chart data label. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -123,14 +121,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFill body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the fill format of the current chart data label. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of the current chart data label. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of the current chart data label. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFill model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the fill format of the current chart data label. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/DataLabels/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/DataLabels/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs index d59ea90ef6c..7cc9b5cb3d3 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/DataLabels/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/DataLabels/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setSolidColor"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SetSolidColorRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setSolidColor - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetSolidColorRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/DataLabels/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/DataLabels/Format/Font/FontRequestBuilder.cs index f5d0a02208b..38480145934 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/DataLabels/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/DataLabels/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart data label. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart data label. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart data label. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart data label. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart data label. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart data label. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes (font name, font size, color, etc.) for a chart data label. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/DataLabels/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/DataLabels/Format/FormatRequestBuilder.cs index cbb83ffe64f..e94922b2512 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/DataLabels/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/DataLabels/Format/FormatRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.DataLabels.Format.Font; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,23 +28,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the format of chart data labels, which includes fill and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -74,15 +73,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the format of chart data labels, which includes fill and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -96,20 +95,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,15 +117,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the format of chart data labels, which includes fill and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -135,14 +133,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -214,42 +211,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartDataLabelFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the format of chart data labels, which includes fill and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the format of chart data labels, which includes fill and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the format of chart data labels, which includes fill and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartDataLabelFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the format of chart data labels, which includes fill and font formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Format/Fill/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Format/Fill/Clear/ClearRequestBuilder.cs index 8336c7b033e..70e967441fa 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Format/Fill/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Format/Fill/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Format/Fill/FillRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Format/Fill/FillRequestBuilder.cs index fa8d18a1ea5..8ab06bbd0d2 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Format/Fill/FillRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Format/Fill/FillRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Format.Fill.SetSolidColor; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,23 +34,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the fill format of an object, which includes background formatting information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the fill format of an object, which includes background formatting information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,15 +105,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the fill format of an object, which includes background formatting information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -123,14 +121,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFill body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the fill format of an object, which includes background formatting information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of an object, which includes background formatting information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of an object, which includes background formatting information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFill model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the fill format of an object, which includes background formatting information. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs index ea529d9f6dd..1cf29e88346 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setSolidColor"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SetSolidColorRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setSolidColor - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetSolidColorRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Format/Font/FontRequestBuilder.cs index 7e9ea6b63f5..a91a8dd46ee 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Format/FormatRequestBuilder.cs index 4e31dea8145..cdf62405a22 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Format/FormatRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Format.Font; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,23 +28,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Encapsulates the format properties for the chart area. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -74,15 +73,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Encapsulates the format properties for the chart area. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -96,20 +95,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,15 +117,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Encapsulates the format properties for the chart area. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -135,14 +133,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -214,42 +211,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAreaFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Encapsulates the format properties for the chart area. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Encapsulates the format properties for the chart area. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Encapsulates the format properties for the chart area. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAreaFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Encapsulates the format properties for the chart area. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Image/ImageRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Image/ImageRequestBuilder.cs index 516a10b964a..812330ac04c 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Image/ImageRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Image/ImageRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,30 +25,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function image"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, outputOption); return command; } /// @@ -79,16 +78,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function image - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/ImageWithWidth/ImageWithWidthRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/ImageWithWidth/ImageWithWidthRequestBuilder.cs index afe2cee4e2a..a84c9191a15 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/ImageWithWidth/ImageWithWidthRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/ImageWithWidth/ImageWithWidthRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function image"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -41,18 +41,17 @@ public Command BuildGetCommand() { }; widthOption.IsRequired = true; command.AddOption(widthOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, int? width) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, int? width, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, widthOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, widthOption, outputOption); return command; } /// @@ -85,16 +84,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function image - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/ImageWithWidthWithHeight/ImageWithWidthWithHeightRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/ImageWithWidthWithHeight/ImageWithWidthWithHeightRequestBuilder.cs index ce5127898b7..873f3eb1ddc 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/ImageWithWidthWithHeight/ImageWithWidthWithHeightRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/ImageWithWidthWithHeight/ImageWithWidthWithHeightRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function image"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -45,18 +45,17 @@ public Command BuildGetCommand() { }; heightOption.IsRequired = true; command.AddOption(heightOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, int? width, int? height) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, int? width, int? height, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, widthOption, heightOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, widthOption, heightOption, outputOption); return command; } /// @@ -91,16 +90,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function image - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/ImageWithWidthWithHeightWithFittingMode/ImageWithWidthWithHeightWithFittingModeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/ImageWithWidthWithHeightWithFittingMode/ImageWithWidthWithHeightWithFittingModeRequestBuilder.cs index 691fde8aedc..9cd62684a6b 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/ImageWithWidthWithHeightWithFittingMode/ImageWithWidthWithHeightWithFittingModeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/ImageWithWidthWithHeightWithFittingMode/ImageWithWidthWithHeightWithFittingModeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function image"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -45,22 +45,21 @@ public Command BuildGetCommand() { }; heightOption.IsRequired = true; command.AddOption(heightOption); - var fittingModeOption = new Option("--fittingmode", description: "Usage: fittingMode={fittingMode}") { + var fittingModeOption = new Option("--fitting-mode", description: "Usage: fittingMode={fittingMode}") { }; fittingModeOption.IsRequired = true; command.AddOption(fittingModeOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, int? width, int? height, string fittingMode) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, int? width, int? height, string fittingMode, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, widthOption, heightOption, fittingModeOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, widthOption, heightOption, fittingModeOption, outputOption); return command; } /// @@ -97,16 +96,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function image - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Legend/Format/Fill/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Legend/Format/Fill/Clear/ClearRequestBuilder.cs index e5dc3eac79a..3f1d1960287 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Legend/Format/Fill/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Legend/Format/Fill/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Legend/Format/Fill/FillRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Legend/Format/Fill/FillRequestBuilder.cs index d7b42397471..44d243b6a03 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Legend/Format/Fill/FillRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Legend/Format/Fill/FillRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Legend.Format.Fill.SetSolidColor; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,23 +34,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the fill format of an object, which includes background formating information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the fill format of an object, which includes background formating information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,15 +105,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the fill format of an object, which includes background formating information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -123,14 +121,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFill body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the fill format of an object, which includes background formating information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of an object, which includes background formating information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of an object, which includes background formating information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFill model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the fill format of an object, which includes background formating information. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Legend/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Legend/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs index b851092ea9c..9536009f78d 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Legend/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Legend/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setSolidColor"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SetSolidColorRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setSolidColor - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetSolidColorRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Legend/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Legend/Format/Font/FontRequestBuilder.cs index 106aee0cdeb..3712898d866 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Legend/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Legend/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes such as font name, font size, color, etc. of a chart legend. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes such as font name, font size, color, etc. of a chart legend. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes such as font name, font size, color, etc. of a chart legend. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes such as font name, font size, color, etc. of a chart legend. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes such as font name, font size, color, etc. of a chart legend. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes such as font name, font size, color, etc. of a chart legend. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes such as font name, font size, color, etc. of a chart legend. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Legend/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Legend/Format/FormatRequestBuilder.cs index 2a0b357894b..6c6f6c0fc8d 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Legend/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Legend/Format/FormatRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Legend.Format.Font; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,23 +28,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of a chart legend, which includes fill and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -74,15 +73,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of a chart legend, which includes fill and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -96,20 +95,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,15 +117,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of a chart legend, which includes fill and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -135,14 +133,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -214,42 +211,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLegendForma requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of a chart legend, which includes fill and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart legend, which includes fill and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart legend, which includes fill and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLegendFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of a chart legend, which includes fill and font formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Legend/LegendRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Legend/LegendRequestBuilder.cs index 57b80f596de..2e0bd63efb4 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Legend/LegendRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Legend/LegendRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Legend.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the legend for the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -65,15 +64,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the legend for the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -87,20 +86,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,15 +108,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the legend for the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -126,14 +124,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -205,42 +202,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLegend body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the legend for the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the legend for the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the legend for the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLegend model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the legend for the chart. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Count/CountRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Count/CountRequestBuilder.cs index 651ccb34877..8cf068a5255 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Count/CountRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Count/CountRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,30 +25,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function count"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteIntValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, outputOption); return command; } /// @@ -79,16 +78,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function count - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Format/Fill/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Format/Fill/Clear/ClearRequestBuilder.cs index e2fe223ad7b..8165c89a06d 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Format/Fill/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Format/Fill/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,27 +25,26 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption); return command; @@ -78,16 +77,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Format/Fill/FillRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Format/Fill/FillRequestBuilder.cs index 5079908e9d1..4c8c3cfef6d 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Format/Fill/FillRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Format/Fill/FillRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Series.Item.Format.Fill.SetSolidColor; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,27 +34,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the fill format of a chart series, which includes background formating information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption); return command; @@ -66,19 +65,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the fill format of a chart series, which includes background formating information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -92,20 +91,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,19 +113,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the fill format of a chart series, which includes background formating information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -135,14 +133,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFill body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the fill format of a chart series, which includes background formating information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of a chart series, which includes background formating information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of a chart series, which includes background formating information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFill model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the fill format of a chart series, which includes background formating information. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs index 443ce3e2fcb..8736d2aebb7 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setSolidColor"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(SetSolidColorRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setSolidColor - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetSolidColorRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Format/FormatRequestBuilder.cs index 2d7f6136ef8..b4180489463 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Format/FormatRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Series.Item.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,27 +28,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of a chart series, which includes fill and line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption); return command; @@ -70,19 +69,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of a chart series, which includes fill and line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -96,20 +95,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -128,19 +126,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of a chart series, which includes fill and line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -148,14 +146,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, bodyOption); return command; @@ -227,42 +224,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartSeriesForma requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of a chart series, which includes fill and line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart series, which includes fill and line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart series, which includes fill and line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartSeriesFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of a chart series, which includes fill and line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Format/Line/Clear/ClearRequestBuilder.cs index 088e230915b..870ad5bb8f4 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,27 +25,26 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption); return command; @@ -78,16 +77,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Format/Line/LineRequestBuilder.cs index 1b80df4dc33..51405fd0f44 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Series.Item.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,27 +33,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption); return command; @@ -65,19 +64,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -91,20 +90,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -114,19 +112,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/Count/CountRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/Count/CountRequestBuilder.cs index 0f264ed3255..a1c966d2cee 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/Count/CountRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/Count/CountRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,34 +25,33 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function count"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteIntValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, outputOption); return command; } /// @@ -83,16 +82,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function count - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/Fill/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/Fill/Clear/ClearRequestBuilder.cs index ea7962c1295..eb3c33f1d60 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/Fill/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/Fill/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,31 +25,30 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption); return command; @@ -82,16 +81,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/Fill/FillRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/Fill/FillRequestBuilder.cs index e56a0b6d4c6..dff40709bfa 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/Fill/FillRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/Fill/FillRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Series.Item.Points.Item.Format.Fill.SetSolidColor; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,31 +34,30 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the fill format of a chart, which includes background formating information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption); return command; @@ -70,23 +69,23 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the fill format of a chart, which includes background formating information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); @@ -100,20 +99,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -123,23 +121,23 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the fill format of a chart, which includes background formating information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); @@ -147,14 +145,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, bodyOption); return command; @@ -232,42 +229,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFill body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the fill format of a chart, which includes background formating information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of a chart, which includes background formating information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of a chart, which includes background formating information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFill model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the fill format of a chart, which includes background formating information. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs index 9156cff31d6..768cf7f06f6 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,23 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setSolidColor"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); @@ -49,14 +49,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, bodyOption); return command; @@ -92,18 +91,5 @@ public RequestInformation CreatePostRequestInformation(SetSolidColorRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setSolidColor - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetSolidColorRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/FormatRequestBuilder.cs index fe57f3b2b99..dcda6e700d6 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/Item/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Series.Item.Points.Item.Format.Fill; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,31 +27,30 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Encapsulates the format properties chart point. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption); return command; @@ -73,23 +72,23 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Encapsulates the format properties chart point. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); @@ -103,20 +102,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -126,23 +124,23 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Encapsulates the format properties chart point. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); @@ -150,14 +148,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, bodyOption); return command; @@ -229,42 +226,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartPointFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Encapsulates the format properties chart point. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Encapsulates the format properties chart point. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Encapsulates the format properties chart point. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartPointFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Encapsulates the format properties chart point. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/Item/WorkbookChartPointRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/Item/WorkbookChartPointRequestBuilder.cs index 8d9d30292e1..8562e96932a 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/Item/WorkbookChartPointRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/Item/WorkbookChartPointRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Series.Item.Points.Item.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,31 +27,30 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents a collection of all points in the series. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption); return command; @@ -72,23 +71,23 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents a collection of all points in the series. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); @@ -102,20 +101,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -125,23 +123,23 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents a collection of all points in the series. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); @@ -149,14 +147,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, bodyOption); return command; @@ -228,42 +225,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartPoint body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents a collection of all points in the series. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a collection of all points in the series. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a collection of all points in the series. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartPoint model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents a collection of all points in the series. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs index 629be752d19..03dcb2e055c 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function itemAt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -46,18 +46,17 @@ public Command BuildGetCommand() { }; indexOption.IsRequired = true; command.AddOption(indexOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, int? index) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, int? index, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, indexOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, indexOption, outputOption); return command; } /// @@ -90,17 +89,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function itemAt - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookChartPoint public class ItemAtWithIndexResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/PointsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/PointsRequestBuilder.cs index e56ab8c5ea2..39261023852 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/PointsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/Points/PointsRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Series.Item.Points.ItemAtWithIndex; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -24,12 +24,11 @@ public class PointsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new WorkbookChartPointRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildFormatCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFormatCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -39,19 +38,19 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Represents a collection of all points in the series. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -59,21 +58,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, bodyOption, outputOption); return command; } /// @@ -83,19 +81,19 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Represents a collection of all points in the series. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -134,7 +132,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -145,15 +147,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -215,18 +212,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookChartPoint body, return requestInfo; } /// - /// Represents a collection of all points in the series. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\worksheet\charts\{workbookChart-id}\series\{workbookChartSeries-id}\points\microsoft.graph.itemAt(index={index}) /// Usage: index={index} /// @@ -234,19 +219,6 @@ public ItemAtWithIndexRequestBuilder ItemAtWithIndex(int? index) { _ = index ?? throw new ArgumentNullException(nameof(index)); return new ItemAtWithIndexRequestBuilder(PathParameters, RequestAdapter, index); } - /// - /// Represents a collection of all points in the series. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookChartPoint model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents a collection of all points in the series. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/WorkbookChartSeriesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/WorkbookChartSeriesRequestBuilder.cs index 0c211992d3f..8f26d3ee631 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/WorkbookChartSeriesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/Item/WorkbookChartSeriesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Series.Item.Points; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,27 +28,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents either a single series or collection of series in the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption); return command; @@ -70,19 +69,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents either a single series or collection of series in the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -96,20 +95,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,19 +117,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents either a single series or collection of series in the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -139,14 +137,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string workbookChartSeriesId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, workbookChartSeriesIdOption, bodyOption); return command; @@ -154,6 +151,9 @@ public Command BuildPatchCommand() { public Command BuildPointsCommand() { var command = new Command("points"); var builder = new ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Series.Item.Points.PointsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -225,42 +225,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartSeries body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents either a single series or collection of series in the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents either a single series or collection of series in the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents either a single series or collection of series in the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartSeries model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents either a single series or collection of series in the chart. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs index 327cb21407d..237a94a1454 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function itemAt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -42,18 +42,17 @@ public Command BuildGetCommand() { }; indexOption.IsRequired = true; command.AddOption(indexOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, int? index) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, int? index, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, indexOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, indexOption, outputOption); return command; } /// @@ -86,17 +85,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function itemAt - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookChartSeries public class ItemAtWithIndexResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/SeriesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/SeriesRequestBuilder.cs index cb116c931bd..7b2b85e1bc3 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/SeriesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Series/SeriesRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Series.ItemAtWithIndex; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -24,13 +24,12 @@ public class SeriesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new WorkbookChartSeriesRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildFormatCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildPointsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFormatCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPointsCommand()); return commands; } /// @@ -40,15 +39,15 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Represents either a single series or collection of series in the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption, outputOption); return command; } /// @@ -80,15 +78,15 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Represents either a single series or collection of series in the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -127,7 +125,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -138,15 +140,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -208,18 +205,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookChartSeries body, return requestInfo; } /// - /// Represents either a single series or collection of series in the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\worksheet\charts\{workbookChart-id}\series\microsoft.graph.itemAt(index={index}) /// Usage: index={index} /// @@ -227,19 +212,6 @@ public ItemAtWithIndexRequestBuilder ItemAtWithIndex(int? index) { _ = index ?? throw new ArgumentNullException(nameof(index)); return new ItemAtWithIndexRequestBuilder(PathParameters, RequestAdapter, index); } - /// - /// Represents either a single series or collection of series in the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookChartSeries model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents either a single series or collection of series in the chart. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/SetData/SetDataRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/SetData/SetDataRequestBuilder.cs index 2ed51d44f0d..528e2f1d7d4 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/SetData/SetDataRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/SetData/SetDataRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setData"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SetDataRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setData - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetDataRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/SetPosition/SetPositionRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/SetPosition/SetPositionRequestBuilder.cs index e653746d6ed..d847649614d 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/SetPosition/SetPositionRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/SetPosition/SetPositionRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setPosition"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SetPositionRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setPosition - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetPositionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Title/Format/Fill/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Title/Format/Fill/Clear/ClearRequestBuilder.cs index c9e58a8b1a1..bd5962e9a1d 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Title/Format/Fill/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Title/Format/Fill/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Title/Format/Fill/FillRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Title/Format/Fill/FillRequestBuilder.cs index 0a6f26d7b4f..a6f3254bc13 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Title/Format/Fill/FillRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Title/Format/Fill/FillRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Title.Format.Fill.SetSolidColor; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,23 +34,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the fill format of an object, which includes background formatting information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the fill format of an object, which includes background formatting information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,15 +105,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the fill format of an object, which includes background formatting information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -123,14 +121,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFill body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the fill format of an object, which includes background formatting information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of an object, which includes background formatting information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of an object, which includes background formatting information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFill model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the fill format of an object, which includes background formatting information. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Title/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Title/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs index 3bb0b59ab29..a221d322257 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Title/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Title/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setSolidColor"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SetSolidColorRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setSolidColor - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetSolidColorRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Title/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Title/Format/Font/FontRequestBuilder.cs index 339b3a7a0a7..5fdc956558b 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Title/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Title/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Title/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Title/Format/FormatRequestBuilder.cs index d3663b62a19..c63bef2eb62 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Title/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Title/Format/FormatRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Title.Format.Font; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,23 +28,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of a chart title, which includes fill and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -74,15 +73,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of a chart title, which includes fill and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -96,20 +95,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,15 +117,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of a chart title, which includes fill and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -135,14 +133,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -214,42 +211,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartTitleFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of a chart title, which includes fill and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart title, which includes fill and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart title, which includes fill and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartTitleFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of a chart title, which includes fill and font formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Title/TitleRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Title/TitleRequestBuilder.cs index 185c62d78af..ad6834fe32b 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Title/TitleRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Title/TitleRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Title.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the title of the specified chart, including the text, visibility, position and formating of the title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -65,15 +64,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the title of the specified chart, including the text, visibility, position and formating of the title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -87,20 +86,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,15 +108,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the title of the specified chart, including the text, visibility, position and formating of the title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -126,14 +124,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -205,42 +202,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartTitle body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the title of the specified chart, including the text, visibility, position and formating of the title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the title of the specified chart, including the text, visibility, position and formating of the title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the title of the specified chart, including the text, visibility, position and formating of the title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartTitle model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the title of the specified chart, including the text, visibility, position and formating of the title. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/WorkbookChartRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/WorkbookChartRequestBuilder.cs index 3e029cc4395..7c1e037300d 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/WorkbookChartRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/WorkbookChartRequestBuilder.cs @@ -14,10 +14,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Worksheet; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -59,23 +59,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns collection of charts that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -97,15 +96,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns collection of charts that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -119,20 +118,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLegendCommand() { @@ -151,15 +149,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns collection of charts that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -167,14 +165,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -182,6 +179,9 @@ public Command BuildPatchCommand() { public Command BuildSeriesCommand() { var command = new Command("series"); var builder = new ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Series.SeriesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -283,29 +283,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChart body, Acti return requestInfo; } /// - /// Returns collection of charts that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns collection of charts that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\worksheet\charts\{workbookChart-id}\microsoft.graph.image() /// public ImageRequestBuilder Image() { @@ -341,19 +318,6 @@ public ImageWithWidthWithHeightWithFittingModeRequestBuilder ImageWithWidthWithH _ = width ?? throw new ArgumentNullException(nameof(width)); return new ImageWithWidthWithHeightWithFittingModeRequestBuilder(PathParameters, RequestAdapter, width, height, fittingMode); } - /// - /// Returns collection of charts that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChart model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns collection of charts that are part of the worksheet. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs index c5707a0a36e..e0534f9b6f7 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function cell"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -46,18 +46,17 @@ public Command BuildGetCommand() { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, int? row, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, int? row, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, rowOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, rowOption, columnOption, outputOption); return command; } /// @@ -92,17 +91,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function cell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class CellWithRowWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Worksheet/Range/RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Worksheet/Range/RangeRequestBuilder.cs index 706c80679fb..ca637aaea1b 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Worksheet/Range/RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Worksheet/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs index 8171a96173b..eb9fd2022a4 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -42,18 +42,17 @@ public Command BuildGetCommand() { }; addressOption.IsRequired = true; command.AddOption(addressOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string address) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string address, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, addressOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, addressOption, outputOption); return command; } /// @@ -86,17 +85,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeWithAddressResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs index 740bf2e4bd5..241e1b3ee96 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs index 400ecd17f0e..566ba1f523a 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,34 +26,33 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var valuesOnlyOption = new Option("--valuesonly", description: "Usage: valuesOnly={valuesOnly}") { + var valuesOnlyOption = new Option("--values-only", description: "Usage: valuesOnly={valuesOnly}") { }; valuesOnlyOption.IsRequired = true; command.AddOption(valuesOnlyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, bool? valuesOnly) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, bool? valuesOnly, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, valuesOnlyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, valuesOnlyOption, outputOption); return command; } /// @@ -86,17 +85,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeWithValuesOnlyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Worksheet/WorksheetRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Worksheet/WorksheetRequestBuilder.cs index a5b692fb0f9..f83c60702f9 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Worksheet/WorksheetRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/Item/Worksheet/WorksheetRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.Item.Worksheet.UsedRangeWithValuesOnly; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,23 +31,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The worksheet containing the current chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption); return command; @@ -59,15 +58,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The worksheet containing the current chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -81,20 +80,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,15 +102,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The worksheet containing the current chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -120,14 +118,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookChartIdOption, bodyOption); return command; @@ -210,42 +207,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookWorksheet body, return requestInfo; } /// - /// The worksheet containing the current chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The worksheet containing the current chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The worksheet containing the current chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookWorksheet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\worksheet\charts\{workbookChart-id}\worksheet\microsoft.graph.range() /// public RangeRequestBuilder Range() { diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs index 4079988488c..88d3f03fc22 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function itemAt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; indexOption.IsRequired = true; command.AddOption(indexOption); - command.SetHandler(async (string driveItemId, string workbookTableId, int? index) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, int? index, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, indexOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, indexOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function itemAt - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookChart public class ItemAtWithIndexResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/ItemWithName/ItemWithNameRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/ItemWithName/ItemWithNameRequestBuilder.cs index e81531b3f6a..44d2df935d4 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/ItemWithName/ItemWithNameRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Charts/ItemWithName/ItemWithNameRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function item"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; nameOption.IsRequired = true; command.AddOption(nameOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string name) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string name, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, nameOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, nameOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function item - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookChart public class ItemWithNameResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/@Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/@Add/AddRequestBody.cs deleted file mode 100644 index fb277dccaf2..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/@Add/AddRequestBody.cs +++ /dev/null @@ -1,42 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Names.@Add { - public class AddRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string Comment { get; set; } - public string Name { get; set; } - public Json Reference { get; set; } - /// - /// Instantiates a new addRequestBody and sets the default values. - /// - public AddRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"comment", (o,n) => { (o as AddRequestBody).Comment = n.GetStringValue(); } }, - {"name", (o,n) => { (o as AddRequestBody).Name = n.GetStringValue(); } }, - {"reference", (o,n) => { (o as AddRequestBody).Reference = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("comment", Comment); - writer.WriteStringValue("name", Name); - writer.WriteObjectValue("reference", Reference); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/@Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/@Add/AddRequestBuilder.cs deleted file mode 100644 index 99525dee138..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/@Add/AddRequestBuilder.cs +++ /dev/null @@ -1,133 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Names.@Add { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\worksheet\names\microsoft.graph.add - public class AddRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action add - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action add"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { - }; - workbookTableIdOption.IsRequired = true; - command.AddOption(workbookTableIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AddRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/tables/{workbookTable_id}/worksheet/names/microsoft.graph.add"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action add - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action add - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookNamedItem - public class AddResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookNamedItem - public WorkbookNamedItem WorkbookNamedItem { get; set; } - /// - /// Instantiates a new addResponse and sets the default values. - /// - public AddResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookNamedItem", (o,n) => { (o as AddResponse).WorkbookNamedItem = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookNamedItem", WorkbookNamedItem); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Add/AddRequestBody.cs new file mode 100644 index 00000000000..d5ba2925875 --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Add/AddRequestBody.cs @@ -0,0 +1,42 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Names.Add { + public class AddRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string Comment { get; set; } + public string Name { get; set; } + public Json Reference { get; set; } + /// + /// Instantiates a new addRequestBody and sets the default values. + /// + public AddRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"comment", (o,n) => { (o as AddRequestBody).Comment = n.GetStringValue(); } }, + {"name", (o,n) => { (o as AddRequestBody).Name = n.GetStringValue(); } }, + {"reference", (o,n) => { (o as AddRequestBody).Reference = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("comment", Comment); + writer.WriteStringValue("name", Name); + writer.WriteObjectValue("reference", Reference); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Add/AddRequestBuilder.cs new file mode 100644 index 00000000000..4deb54f3eec --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Add/AddRequestBuilder.cs @@ -0,0 +1,119 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Names.Add { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\worksheet\names\microsoft.graph.add + public class AddRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action add + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action add"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { + }; + workbookTableIdOption.IsRequired = true; + command.AddOption(workbookTableIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new AddRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/tables/{workbookTable_id}/worksheet/names/microsoft.graph.add"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action add + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookNamedItem + public class AddResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookNamedItem + public WorkbookNamedItem WorkbookNamedItem { get; set; } + /// + /// Instantiates a new addResponse and sets the default values. + /// + public AddResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookNamedItem", (o,n) => { (o as AddResponse).WorkbookNamedItem = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookNamedItem", WorkbookNamedItem); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/AddFormulaLocal/AddFormulaLocalRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/AddFormulaLocal/AddFormulaLocalRequestBuilder.cs index 83d42141e36..56c945b1a88 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/AddFormulaLocal/AddFormulaLocalRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/AddFormulaLocal/AddFormulaLocalRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action addFormulaLocal"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(AddFormulaLocalRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action addFormulaLocal - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddFormulaLocalRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookNamedItem public class AddFormulaLocalResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Range/RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Range/RangeRequestBuilder.cs index e7e7a2d849a..4be185847ef 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Range/RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookNamedItemId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookNamedItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookNamedItemIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookNamedItemIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/WorkbookNamedItemRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/WorkbookNamedItemRequestBuilder.cs index f4922da70ca..c412b297a36 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/WorkbookNamedItemRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/WorkbookNamedItemRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Names.Item.Worksheet; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,23 +28,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns collection of names that are associated with the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookNamedItemId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookNamedItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookNamedItemIdOption); return command; @@ -56,15 +55,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns collection of names that are associated with the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -78,20 +77,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookNamedItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookNamedItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookNamedItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookNamedItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -101,15 +99,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns collection of names that are associated with the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -117,14 +115,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookNamedItemId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookNamedItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookNamedItemIdOption, bodyOption); return command; @@ -205,42 +202,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookNamedItem body, return requestInfo; } /// - /// Returns collection of names that are associated with the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns collection of names that are associated with the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns collection of names that are associated with the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookNamedItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\worksheet\names\{workbookNamedItem-id}\microsoft.graph.range() /// public RangeRequestBuilder Range() { diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs index 6711ebaa651..42c745f0883 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function cell"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -46,18 +46,17 @@ public Command BuildGetCommand() { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookNamedItemId, int? row, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookNamedItemId, int? row, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookNamedItemIdOption, rowOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookNamedItemIdOption, rowOption, columnOption, outputOption); return command; } /// @@ -92,17 +91,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function cell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class CellWithRowWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Worksheet/Range/RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Worksheet/Range/RangeRequestBuilder.cs index 8e3c4632714..e3336744931 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Worksheet/Range/RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Worksheet/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookNamedItemId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookNamedItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookNamedItemIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookNamedItemIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs index 2c65b7aa0f6..784bb862253 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -42,18 +42,17 @@ public Command BuildGetCommand() { }; addressOption.IsRequired = true; command.AddOption(addressOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookNamedItemId, string address) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookNamedItemId, string address, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookNamedItemIdOption, addressOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookNamedItemIdOption, addressOption, outputOption); return command; } /// @@ -86,17 +85,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeWithAddressResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs index cd94d8a59c5..0194e9ef58c 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookNamedItemId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookNamedItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookNamedItemIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookNamedItemIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs index 476496f6ebc..e1ed7fbfdac 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,34 +26,33 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var valuesOnlyOption = new Option("--valuesonly", description: "Usage: valuesOnly={valuesOnly}") { + var valuesOnlyOption = new Option("--values-only", description: "Usage: valuesOnly={valuesOnly}") { }; valuesOnlyOption.IsRequired = true; command.AddOption(valuesOnlyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookNamedItemId, bool? valuesOnly) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookNamedItemId, bool? valuesOnly, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookNamedItemIdOption, valuesOnlyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookNamedItemIdOption, valuesOnlyOption, outputOption); return command; } /// @@ -86,17 +85,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeWithValuesOnlyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Worksheet/WorksheetRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Worksheet/WorksheetRequestBuilder.cs index 75989c7d6e3..0743459d6a7 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Worksheet/WorksheetRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/Item/Worksheet/WorksheetRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Names.Item.Worksheet.UsedRangeWithValuesOnly; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,23 +31,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns the worksheet on which the named item is scoped to. Available only if the item is scoped to the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookNamedItemId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookNamedItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookNamedItemIdOption); return command; @@ -59,15 +58,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns the worksheet on which the named item is scoped to. Available only if the item is scoped to the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -81,20 +80,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookNamedItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookNamedItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookNamedItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookNamedItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,15 +102,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns the worksheet on which the named item is scoped to. Available only if the item is scoped to the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -120,14 +118,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookNamedItemId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookNamedItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookNamedItemIdOption, bodyOption); return command; @@ -210,42 +207,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookWorksheet body, return requestInfo; } /// - /// Returns the worksheet on which the named item is scoped to. Available only if the item is scoped to the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns the worksheet on which the named item is scoped to. Available only if the item is scoped to the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns the worksheet on which the named item is scoped to. Available only if the item is scoped to the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookWorksheet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\worksheet\names\{workbookNamedItem-id}\worksheet\microsoft.graph.range() /// public RangeRequestBuilder Range() { diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/NamesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/NamesRequestBuilder.cs index 7253b3b479d..9a5e03fe7f6 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/NamesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Names/NamesRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Names.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -24,7 +24,7 @@ public class NamesRequestBuilder { private string UrlTemplate { get; set; } public Command BuildAddCommand() { var command = new Command("add"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Names.@Add.AddRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Names.Add.AddRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } @@ -36,12 +36,11 @@ public Command BuildAddFormulaLocalCommand() { } public List BuildCommand() { var builder = new WorkbookNamedItemRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildWorksheetCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildWorksheetCommand()); return commands; } /// @@ -51,11 +50,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Returns collection of names that are associated with the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -63,21 +62,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, bodyOption, outputOption); return command; } /// @@ -87,11 +85,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Returns collection of names that are associated with the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -130,7 +128,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -141,15 +143,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -204,31 +201,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookNamedItem body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Returns collection of names that are associated with the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns collection of names that are associated with the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookNamedItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns collection of names that are associated with the worksheet. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Refresh/RefreshRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Refresh/RefreshRequestBuilder.cs index c10133107d7..8c1b4270880 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Refresh/RefreshRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Refresh/RefreshRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action refresh"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookPivotTableId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookPivotTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookPivotTableIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action refresh - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/WorkbookPivotTableRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/WorkbookPivotTableRequestBuilder.cs index 63cb43c9dbc..1c86d6a3ad4 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/WorkbookPivotTableRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/WorkbookPivotTableRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.PivotTables.Item.Worksheet; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,23 +28,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Collection of PivotTables that are part of the worksheet."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookPivotTableId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookPivotTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookPivotTableIdOption); return command; @@ -56,15 +55,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Collection of PivotTables that are part of the worksheet."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); @@ -78,20 +77,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookPivotTableId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookPivotTableId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookPivotTableIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookPivotTableIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -101,15 +99,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Collection of PivotTables that are part of the worksheet."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); @@ -117,14 +115,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookPivotTableId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookPivotTableId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookPivotTableIdOption, bodyOption); return command; @@ -210,42 +207,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookPivotTable body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of PivotTables that are part of the worksheet. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of PivotTables that are part of the worksheet. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of PivotTables that are part of the worksheet. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookPivotTable model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of PivotTables that are part of the worksheet. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs index cd4f6de5cf6..c699870a8f8 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function cell"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); @@ -46,18 +46,17 @@ public Command BuildGetCommand() { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookPivotTableId, int? row, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookPivotTableId, int? row, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookPivotTableIdOption, rowOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookPivotTableIdOption, rowOption, columnOption, outputOption); return command; } /// @@ -92,17 +91,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function cell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class CellWithRowWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Worksheet/Range/RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Worksheet/Range/RangeRequestBuilder.cs index 1ac4aba7c90..13571675936 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Worksheet/Range/RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Worksheet/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookPivotTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookPivotTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookPivotTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookPivotTableIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs index 19722ff67de..618ee20c9cd 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); @@ -42,18 +42,17 @@ public Command BuildGetCommand() { }; addressOption.IsRequired = true; command.AddOption(addressOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookPivotTableId, string address) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookPivotTableId, string address, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookPivotTableIdOption, addressOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookPivotTableIdOption, addressOption, outputOption); return command; } /// @@ -86,17 +85,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeWithAddressResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs index 116b8d4aeb3..177c11b9167 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookPivotTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookPivotTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookPivotTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookPivotTableIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs index 31fae180692..b38b7306189 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,34 +26,33 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); - var valuesOnlyOption = new Option("--valuesonly", description: "Usage: valuesOnly={valuesOnly}") { + var valuesOnlyOption = new Option("--values-only", description: "Usage: valuesOnly={valuesOnly}") { }; valuesOnlyOption.IsRequired = true; command.AddOption(valuesOnlyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookPivotTableId, bool? valuesOnly) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookPivotTableId, bool? valuesOnly, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookPivotTableIdOption, valuesOnlyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookPivotTableIdOption, valuesOnlyOption, outputOption); return command; } /// @@ -86,17 +85,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeWithValuesOnlyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Worksheet/WorksheetRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Worksheet/WorksheetRequestBuilder.cs index 768ef499699..7531607b19e 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Worksheet/WorksheetRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/Item/Worksheet/WorksheetRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.PivotTables.Item.Worksheet.UsedRangeWithValuesOnly; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,23 +31,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The worksheet containing the current PivotTable. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookPivotTableId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookPivotTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookPivotTableIdOption); return command; @@ -59,15 +58,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The worksheet containing the current PivotTable. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); @@ -81,20 +80,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookPivotTableId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookPivotTableId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookPivotTableIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookPivotTableIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,15 +102,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The worksheet containing the current PivotTable. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); @@ -120,14 +118,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookPivotTableId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookPivotTableId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookPivotTableIdOption, bodyOption); return command; @@ -210,42 +207,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookWorksheet body, return requestInfo; } /// - /// The worksheet containing the current PivotTable. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The worksheet containing the current PivotTable. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The worksheet containing the current PivotTable. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookWorksheet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\worksheet\pivotTables\{workbookPivotTable-id}\worksheet\microsoft.graph.range() /// public RangeRequestBuilder Range() { diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/PivotTablesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/PivotTablesRequestBuilder.cs index 2fc6549bcbf..92c10a6f074 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/PivotTablesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/PivotTablesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.PivotTables.RefreshAll; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,13 +23,12 @@ public class PivotTablesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new WorkbookPivotTableRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildRefreshCommand(), - builder.BuildWorksheetCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRefreshCommand()); + commands.Add(builder.BuildWorksheetCommand()); return commands; } /// @@ -39,11 +38,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Collection of PivotTables that are part of the worksheet."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -51,21 +50,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, bodyOption, outputOption); return command; } /// @@ -75,11 +73,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Collection of PivotTables that are part of the worksheet."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -129,15 +131,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefreshAllCommand() { @@ -198,31 +195,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookPivotTable body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of PivotTables that are part of the worksheet. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of PivotTables that are part of the worksheet. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookPivotTable model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of PivotTables that are part of the worksheet. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/RefreshAll/RefreshAllRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/RefreshAll/RefreshAllRequestBuilder.cs index 195e61be974..c6011699955 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/RefreshAll/RefreshAllRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/PivotTables/RefreshAll/RefreshAllRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,18 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action refreshAll"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action refreshAll - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Protection/Protect/ProtectRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Protection/Protect/ProtectRequestBuilder.cs index 04972df4dd4..0be9d5c8c75 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Protection/Protect/ProtectRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Protection/Protect/ProtectRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,11 +25,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action protect"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ProtectRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action protect - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ProtectRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Protection/ProtectionRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Protection/ProtectionRequestBuilder.cs index ed245b2379a..a10e80954ad 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Protection/ProtectionRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Protection/ProtectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Protection.Unprotect; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,19 +28,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns sheet protection object for a worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption); return command; @@ -52,11 +51,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns sheet protection object for a worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -70,20 +69,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -93,11 +91,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns sheet protection object for a worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -105,14 +103,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, bodyOption); return command; @@ -196,42 +193,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookWorksheetProtect requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Returns sheet protection object for a worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns sheet protection object for a worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns sheet protection object for a worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookWorksheetProtection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns sheet protection object for a worksheet. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Protection/Unprotect/UnprotectRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Protection/Unprotect/UnprotectRequestBuilder.cs index 8974634a738..0e089fd2e4d 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Protection/Unprotect/UnprotectRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Protection/Unprotect/UnprotectRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,18 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action unprotect"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action unprotect - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Range/RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Range/RangeRequestBuilder.cs index aa4eac0962d..6bd6a3dcff0 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Range/RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs index 195fa59ca78..739b0beaaee 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; addressOption.IsRequired = true; command.AddOption(addressOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string address) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string address, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, addressOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, addressOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeWithAddressResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/@Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/@Add/AddRequestBody.cs deleted file mode 100644 index e48b2b26f5b..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/@Add/AddRequestBody.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Tables.@Add { - public class AddRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string Address { get; set; } - public bool? HasHeaders { get; set; } - /// - /// Instantiates a new addRequestBody and sets the default values. - /// - public AddRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"address", (o,n) => { (o as AddRequestBody).Address = n.GetStringValue(); } }, - {"hasHeaders", (o,n) => { (o as AddRequestBody).HasHeaders = n.GetBoolValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("address", Address); - writer.WriteBoolValue("hasHeaders", HasHeaders); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/@Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/@Add/AddRequestBuilder.cs deleted file mode 100644 index f05b6f1e063..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/@Add/AddRequestBuilder.cs +++ /dev/null @@ -1,133 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Tables.@Add { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\worksheet\tables\microsoft.graph.add - public class AddRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action add - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action add"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { - }; - workbookTableIdOption.IsRequired = true; - command.AddOption(workbookTableIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AddRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/tables/{workbookTable_id}/worksheet/tables/microsoft.graph.add"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action add - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action add - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookTable - public class AddResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookTable - public WorkbookTable WorkbookTable { get; set; } - /// - /// Instantiates a new addResponse and sets the default values. - /// - public AddResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookTable", (o,n) => { (o as AddResponse).WorkbookTable = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookTable", WorkbookTable); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Add/AddRequestBody.cs new file mode 100644 index 00000000000..4ee99d2eca4 --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Add/AddRequestBody.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Tables.Add { + public class AddRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string Address { get; set; } + public bool? HasHeaders { get; set; } + /// + /// Instantiates a new addRequestBody and sets the default values. + /// + public AddRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"address", (o,n) => { (o as AddRequestBody).Address = n.GetStringValue(); } }, + {"hasHeaders", (o,n) => { (o as AddRequestBody).HasHeaders = n.GetBoolValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("address", Address); + writer.WriteBoolValue("hasHeaders", HasHeaders); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Add/AddRequestBuilder.cs new file mode 100644 index 00000000000..7400bbfaa9b --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Add/AddRequestBuilder.cs @@ -0,0 +1,119 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Tables.Add { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\worksheet\tables\microsoft.graph.add + public class AddRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action add + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action add"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { + }; + workbookTableIdOption.IsRequired = true; + command.AddOption(workbookTableIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new AddRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/tables/{workbookTable_id}/worksheet/tables/microsoft.graph.add"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action add + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookTable + public class AddResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookTable + public WorkbookTable WorkbookTable { get; set; } + /// + /// Instantiates a new addResponse and sets the default values. + /// + public AddResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookTable", (o,n) => { (o as AddResponse).WorkbookTable = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookTable", WorkbookTable); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Count/CountRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Count/CountRequestBuilder.cs index 4872c3babb3..5b76deb161f 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Count/CountRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Count/CountRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,26 +25,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function count"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteIntValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -75,16 +74,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function count - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/ClearFilters/ClearFiltersRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/ClearFilters/ClearFiltersRequestBuilder.cs index 3b3c3bf2d63..41e1797a68d 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/ClearFilters/ClearFiltersRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/ClearFilters/ClearFiltersRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clearFilters"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableId1Option = new Option("--workbooktable-id1", description: "key: id of workbookTable") { + var workbookTableId1Option = new Option("--workbook-table-id1", description: "key: id of workbookTable") { }; workbookTableId1Option.IsRequired = true; command.AddOption(workbookTableId1Option); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableId1) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookTableId1Option); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clearFilters - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/ConvertToRange/ConvertToRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/ConvertToRange/ConvertToRangeRequestBuilder.cs index ed1bd257853..6189e9a8ac0 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/ConvertToRange/ConvertToRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/ConvertToRange/ConvertToRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action convertToRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableId1Option = new Option("--workbooktable-id1", description: "key: id of workbookTable") { + var workbookTableId1Option = new Option("--workbook-table-id1", description: "key: id of workbookTable") { }; workbookTableId1Option.IsRequired = true; command.AddOption(workbookTableId1Option); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableId1) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableId1, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookTableId1Option); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookTableId1Option, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action convertToRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ConvertToRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs index a91c4da4d58..e8f0f5dbe77 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function dataBodyRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableId1Option = new Option("--workbooktable-id1", description: "key: id of workbookTable") { + var workbookTableId1Option = new Option("--workbook-table-id1", description: "key: id of workbookTable") { }; workbookTableId1Option.IsRequired = true; command.AddOption(workbookTableId1Option); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableId1) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableId1, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookTableId1Option); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookTableId1Option, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function dataBodyRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class DataBodyRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs index bea27431e43..b28a2fdd94e 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function headerRowRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableId1Option = new Option("--workbooktable-id1", description: "key: id of workbookTable") { + var workbookTableId1Option = new Option("--workbook-table-id1", description: "key: id of workbookTable") { }; workbookTableId1Option.IsRequired = true; command.AddOption(workbookTableId1Option); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableId1) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableId1, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookTableId1Option); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookTableId1Option, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function headerRowRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class HeaderRowRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/Range/RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/Range/RangeRequestBuilder.cs index edadbe7eb23..ba010cf671d 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/Range/RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableId1Option = new Option("--workbooktable-id1", description: "key: id of workbookTable") { + var workbookTableId1Option = new Option("--workbook-table-id1", description: "key: id of workbookTable") { }; workbookTableId1Option.IsRequired = true; command.AddOption(workbookTableId1Option); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableId1) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableId1, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookTableId1Option); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookTableId1Option, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/ReapplyFilters/ReapplyFiltersRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/ReapplyFilters/ReapplyFiltersRequestBuilder.cs index 6e8f6a53477..c43bb290ac6 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/ReapplyFilters/ReapplyFiltersRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/ReapplyFilters/ReapplyFiltersRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action reapplyFilters"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableId1Option = new Option("--workbooktable-id1", description: "key: id of workbookTable") { + var workbookTableId1Option = new Option("--workbook-table-id1", description: "key: id of workbookTable") { }; workbookTableId1Option.IsRequired = true; command.AddOption(workbookTableId1Option); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableId1) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookTableId1Option); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action reapplyFilters - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs index 888bed60d64..f81555d67da 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function totalRowRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableId1Option = new Option("--workbooktable-id1", description: "key: id of workbookTable") { + var workbookTableId1Option = new Option("--workbook-table-id1", description: "key: id of workbookTable") { }; workbookTableId1Option.IsRequired = true; command.AddOption(workbookTableId1Option); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableId1) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableId1, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookTableId1Option); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookTableId1Option, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function totalRowRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class TotalRowRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/WorkbookTableRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/WorkbookTableRequestBuilder.cs index 3d134da5218..cf9711d7f8e 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/WorkbookTableRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/Item/WorkbookTableRequestBuilder.cs @@ -8,10 +8,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Tables.Item.TotalRowRange; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -45,23 +45,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Collection of tables that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableId1Option = new Option("--workbooktable-id1", description: "key: id of workbookTable") { + var workbookTableId1Option = new Option("--workbook-table-id1", description: "key: id of workbookTable") { }; workbookTableId1Option.IsRequired = true; command.AddOption(workbookTableId1Option); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableId1) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableId1, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookTableId1Option); return command; @@ -73,15 +72,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Collection of tables that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableId1Option = new Option("--workbooktable-id1", description: "key: id of workbookTable") { + var workbookTableId1Option = new Option("--workbook-table-id1", description: "key: id of workbookTable") { }; workbookTableId1Option.IsRequired = true; command.AddOption(workbookTableId1Option); @@ -95,20 +94,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableId1, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableId1, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, workbookTableId1Option, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, workbookTableId1Option, selectOption, expandOption, outputOption); return command; } /// @@ -118,15 +116,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Collection of tables that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableId1Option = new Option("--workbooktable-id1", description: "key: id of workbookTable") { + var workbookTableId1Option = new Option("--workbook-table-id1", description: "key: id of workbookTable") { }; workbookTableId1Option.IsRequired = true; command.AddOption(workbookTableId1Option); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableId1, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string workbookTableId1, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, workbookTableId1Option, bodyOption); return command; @@ -226,48 +223,12 @@ public DataBodyRangeRequestBuilder DataBodyRange() { return new DataBodyRangeRequestBuilder(PathParameters, RequestAdapter); } /// - /// Collection of tables that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of tables that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\worksheet\tables\{workbookTable-id1}\microsoft.graph.headerRowRange() /// public HeaderRowRangeRequestBuilder HeaderRowRange() { return new HeaderRowRangeRequestBuilder(PathParameters, RequestAdapter); } /// - /// Collection of tables that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookTable model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\worksheet\tables\{workbookTable-id1}\microsoft.graph.range() /// public RangeRequestBuilder Range() { diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs index f09ee008826..07e6b304170 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function itemAt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; indexOption.IsRequired = true; command.AddOption(indexOption); - command.SetHandler(async (string driveItemId, string workbookTableId, int? index) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, int? index, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, indexOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, indexOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function itemAt - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookTable public class ItemAtWithIndexResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/TablesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/TablesRequestBuilder.cs index 694cf7a8724..75e1a5fc44e 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/TablesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/Tables/TablesRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Tables.ItemAtWithIndex; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,20 +25,19 @@ public class TablesRequestBuilder { private string UrlTemplate { get; set; } public Command BuildAddCommand() { var command = new Command("add"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Tables.@Add.AddRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Tables.Add.AddRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } public List BuildCommand() { var builder = new WorkbookTableRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildClearFiltersCommand(), - builder.BuildConvertToRangeCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildReapplyFiltersCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildClearFiltersCommand()); + commands.Add(builder.BuildConvertToRangeCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildReapplyFiltersCommand()); return commands; } /// @@ -48,11 +47,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Collection of tables that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -60,21 +59,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, bodyOption, outputOption); return command; } /// @@ -84,11 +82,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Collection of tables that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -127,7 +125,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -138,15 +140,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -208,18 +205,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookTable body, Actio return requestInfo; } /// - /// Collection of tables that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\worksheet\tables\microsoft.graph.itemAt(index={index}) /// Usage: index={index} /// @@ -227,19 +212,6 @@ public ItemAtWithIndexRequestBuilder ItemAtWithIndex(int? index) { _ = index ?? throw new ArgumentNullException(nameof(index)); return new ItemAtWithIndexRequestBuilder(PathParameters, RequestAdapter, index); } - /// - /// Collection of tables that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookTable model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of tables that are part of the worksheet. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs index 57fc4b506c8..5aea84d4f7f 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs index 397aa25c75d..e77b779da9b 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var valuesOnlyOption = new Option("--valuesonly", description: "Usage: valuesOnly={valuesOnly}") { + var valuesOnlyOption = new Option("--values-only", description: "Usage: valuesOnly={valuesOnly}") { }; valuesOnlyOption.IsRequired = true; command.AddOption(valuesOnlyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, bool? valuesOnly) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, bool? valuesOnly, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, valuesOnlyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, valuesOnlyOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeWithValuesOnlyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/WorksheetRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/WorksheetRequestBuilder.cs index 344be349a53..2aa9578f2e9 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/WorksheetRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/Item/Worksheet/WorksheetRequestBuilder.cs @@ -11,10 +11,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.UsedRangeWithValuesOnly; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,6 +33,9 @@ public Command BuildChartsCommand() { var command = new Command("charts"); var builder = new ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Charts.ChartsRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -44,19 +47,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The worksheet containing the current table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookTableId) => { + command.SetHandler(async (string driveItemId, string workbookTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption); return command; @@ -68,11 +70,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The worksheet containing the current table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -86,20 +88,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookTableId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookTableIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookTableIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildNamesCommand() { @@ -107,6 +108,9 @@ public Command BuildNamesCommand() { var builder = new ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Names.NamesRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCommand()); command.AddCommand(builder.BuildAddFormulaLocalCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -118,11 +122,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The worksheet containing the current table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -130,14 +134,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookTableId, string body) => { + command.SetHandler(async (string driveItemId, string workbookTableId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookTableIdOption, bodyOption); return command; @@ -145,6 +148,9 @@ public Command BuildPatchCommand() { public Command BuildPivotTablesCommand() { var command = new Command("pivot-tables"); var builder = new ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.PivotTables.PivotTablesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); command.AddCommand(builder.BuildRefreshAllCommand()); @@ -164,6 +170,9 @@ public Command BuildTablesCommand() { var command = new Command("tables"); var builder = new ApiSdk.Workbooks.Item.Workbook.Tables.Item.Worksheet.Tables.TablesRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -246,42 +255,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookWorksheet body, return requestInfo; } /// - /// The worksheet containing the current table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The worksheet containing the current table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The worksheet containing the current table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookWorksheet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\{workbookTable-id}\worksheet\microsoft.graph.range() /// public RangeRequestBuilder Range() { diff --git a/src/generated/Workbooks/Item/Workbook/Tables/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs index 9af3d357c1a..e9070cd4f9d 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,7 +26,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function itemAt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -34,18 +34,17 @@ public Command BuildGetCommand() { }; indexOption.IsRequired = true; command.AddOption(indexOption); - command.SetHandler(async (string driveItemId, int? index) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, int? index, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, indexOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, indexOption, outputOption); return command; } /// @@ -78,17 +77,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function itemAt - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookTable public class ItemAtWithIndexResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Tables/TablesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Tables/TablesRequestBuilder.cs index a47613fff41..7064023db8b 100644 --- a/src/generated/Workbooks/Item/Workbook/Tables/TablesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Tables/TablesRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Workbooks.Item.Workbook.Tables.ItemAtWithIndex; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,24 +25,23 @@ public class TablesRequestBuilder { private string UrlTemplate { get; set; } public Command BuildAddCommand() { var command = new Command("add"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Tables.@Add.AddRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Tables.Add.AddRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } public List BuildCommand() { var builder = new WorkbookTableRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildClearFiltersCommand(), - builder.BuildColumnsCommand(), - builder.BuildConvertToRangeCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildReapplyFiltersCommand(), - builder.BuildRowsCommand(), - builder.BuildSortCommand(), - builder.BuildWorksheetCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildClearFiltersCommand()); + commands.Add(builder.BuildColumnsCommand()); + commands.Add(builder.BuildConvertToRangeCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildReapplyFiltersCommand()); + commands.Add(builder.BuildRowsCommand()); + commands.Add(builder.BuildSortCommand()); + commands.Add(builder.BuildWorksheetCommand()); return commands; } /// @@ -52,7 +51,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Represents a collection of tables associated with the workbook. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -60,21 +59,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -84,7 +82,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Represents a collection of tables associated with the workbook. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -123,7 +121,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -134,15 +136,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -204,18 +201,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookTable body, Actio return requestInfo; } /// - /// Represents a collection of tables associated with the workbook. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\tables\microsoft.graph.itemAt(index={index}) /// Usage: index={index} /// @@ -223,19 +208,6 @@ public ItemAtWithIndexRequestBuilder ItemAtWithIndex(int? index) { _ = index ?? throw new ArgumentNullException(nameof(index)); return new ItemAtWithIndexRequestBuilder(PathParameters, RequestAdapter, index); } - /// - /// Represents a collection of tables associated with the workbook. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookTable model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents a collection of tables associated with the workbook. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/WorkbookRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/WorkbookRequestBuilder.cs index f68d86839bf..e1fd4299dbf 100644 --- a/src/generated/Workbooks/Item/Workbook/WorkbookRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/WorkbookRequestBuilder.cs @@ -13,10 +13,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -49,6 +49,9 @@ public Command BuildCloseSessionCommand() { public Command BuildCommentsCommand() { var command = new Command("comments"); var builder = new ApiSdk.Workbooks.Item.Workbook.Comments.CommentsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -66,15 +69,14 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "For files that are Excel spreadsheets, accesses the workbook API to work with the spreadsheet's contents. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - command.SetHandler(async (string driveItemId) => { + command.SetHandler(async (string driveItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption); return command; @@ -460,7 +462,7 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "For files that are Excel spreadsheets, accesses the workbook API to work with the spreadsheet's contents. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -469,19 +471,18 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, expandOption, outputOption); return command; } public Command BuildNamesCommand() { @@ -489,6 +490,9 @@ public Command BuildNamesCommand() { var builder = new ApiSdk.Workbooks.Item.Workbook.Names.NamesRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCommand()); command.AddCommand(builder.BuildAddFormulaLocalCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -496,6 +500,9 @@ public Command BuildNamesCommand() { public Command BuildOperationsCommand() { var command = new Command("operations"); var builder = new ApiSdk.Workbooks.Item.Workbook.Operations.OperationsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -507,7 +514,7 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "For files that are Excel spreadsheets, accesses the workbook API to work with the spreadsheet's contents. Nullable."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -515,14 +522,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + command.SetHandler(async (string driveItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, bodyOption); return command; @@ -537,6 +543,9 @@ public Command BuildTablesCommand() { var command = new Command("tables"); var builder = new ApiSdk.Workbooks.Item.Workbook.Tables.TablesRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -545,6 +554,9 @@ public Command BuildWorksheetsCommand() { var command = new Command("worksheets"); var builder = new ApiSdk.Workbooks.Item.Workbook.Worksheets.WorksheetsRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -617,42 +629,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft. return requestInfo; } /// - /// For files that are Excel spreadsheets, accesses the workbook API to work with the spreadsheet's contents. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// For files that are Excel spreadsheets, accesses the workbook API to work with the spreadsheet's contents. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// For files that are Excel spreadsheets, accesses the workbook API to work with the spreadsheet's contents. Nullable. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Workbook model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\microsoft.graph.sessionInfoResource(key='{key}') /// Usage: key={key} /// diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/@Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/@Add/AddRequestBody.cs deleted file mode 100644 index 7537fa2fb04..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/@Add/AddRequestBody.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Worksheets.@Add { - public class AddRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string Name { get; set; } - /// - /// Instantiates a new addRequestBody and sets the default values. - /// - public AddRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"name", (o,n) => { (o as AddRequestBody).Name = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("name", Name); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/@Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/@Add/AddRequestBuilder.cs deleted file mode 100644 index 29d15721304..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/@Add/AddRequestBuilder.cs +++ /dev/null @@ -1,129 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Worksheets.@Add { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\microsoft.graph.add - public class AddRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action add - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action add"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AddRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/worksheets/microsoft.graph.add"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action add - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action add - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookWorksheet - public class AddResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookWorksheet - public WorkbookWorksheet WorkbookWorksheet { get; set; } - /// - /// Instantiates a new addResponse and sets the default values. - /// - public AddResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookWorksheet", (o,n) => { (o as AddResponse).WorkbookWorksheet = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookWorksheet", WorkbookWorksheet); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Add/AddRequestBody.cs new file mode 100644 index 00000000000..f570d841d92 --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Add/AddRequestBody.cs @@ -0,0 +1,35 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Workbooks.Item.Workbook.Worksheets.Add { + public class AddRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string Name { get; set; } + /// + /// Instantiates a new addRequestBody and sets the default values. + /// + public AddRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"name", (o,n) => { (o as AddRequestBody).Name = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("name", Name); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Add/AddRequestBuilder.cs new file mode 100644 index 00000000000..3f21d75cdd4 --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Add/AddRequestBuilder.cs @@ -0,0 +1,115 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Worksheets.Add { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\microsoft.graph.add + public class AddRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action add + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action add"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new AddRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/worksheets/microsoft.graph.add"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action add + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookWorksheet + public class AddResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookWorksheet + public WorkbookWorksheet WorkbookWorksheet { get; set; } + /// + /// Instantiates a new addResponse and sets the default values. + /// + public AddResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookWorksheet", (o,n) => { (o as AddResponse).WorkbookWorksheet = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookWorksheet", WorkbookWorksheet); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs index c5fdc7dac55..1ccb9bb4e89 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function cell"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); @@ -42,18 +42,17 @@ public Command BuildGetCommand() { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, int? row, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, int? row, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, rowOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, rowOption, columnOption, outputOption); return command; } /// @@ -88,17 +87,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function cell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class CellWithRowWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/@Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/@Add/AddRequestBody.cs deleted file mode 100644 index 6df1fa945d4..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/@Add/AddRequestBody.cs +++ /dev/null @@ -1,42 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.@Add { - public class AddRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string SeriesBy { get; set; } - public Json SourceData { get; set; } - public string Type { get; set; } - /// - /// Instantiates a new addRequestBody and sets the default values. - /// - public AddRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"seriesBy", (o,n) => { (o as AddRequestBody).SeriesBy = n.GetStringValue(); } }, - {"sourceData", (o,n) => { (o as AddRequestBody).SourceData = n.GetObjectValue(); } }, - {"type", (o,n) => { (o as AddRequestBody).Type = n.GetStringValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("seriesBy", SeriesBy); - writer.WriteObjectValue("sourceData", SourceData); - writer.WriteStringValue("type", Type); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/@Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/@Add/AddRequestBuilder.cs deleted file mode 100644 index b2716a56c98..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/@Add/AddRequestBuilder.cs +++ /dev/null @@ -1,133 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.@Add { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\charts\microsoft.graph.add - public class AddRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action add - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action add"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { - }; - workbookWorksheetIdOption.IsRequired = true; - command.AddOption(workbookWorksheetIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AddRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/worksheets/{workbookWorksheet_id}/charts/microsoft.graph.add"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action add - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action add - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookChart - public class AddResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookChart - public WorkbookChart WorkbookChart { get; set; } - /// - /// Instantiates a new addResponse and sets the default values. - /// - public AddResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookChart", (o,n) => { (o as AddResponse).WorkbookChart = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookChart", WorkbookChart); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Add/AddRequestBody.cs new file mode 100644 index 00000000000..d59ea268aab --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Add/AddRequestBody.cs @@ -0,0 +1,42 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Add { + public class AddRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string SeriesBy { get; set; } + public Json SourceData { get; set; } + public string Type { get; set; } + /// + /// Instantiates a new addRequestBody and sets the default values. + /// + public AddRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"seriesBy", (o,n) => { (o as AddRequestBody).SeriesBy = n.GetStringValue(); } }, + {"sourceData", (o,n) => { (o as AddRequestBody).SourceData = n.GetObjectValue(); } }, + {"type", (o,n) => { (o as AddRequestBody).Type = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("seriesBy", SeriesBy); + writer.WriteObjectValue("sourceData", SourceData); + writer.WriteStringValue("type", Type); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Add/AddRequestBuilder.cs new file mode 100644 index 00000000000..fd40fb0d24a --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Add/AddRequestBuilder.cs @@ -0,0 +1,119 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Add { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\charts\microsoft.graph.add + public class AddRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action add + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action add"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { + }; + workbookWorksheetIdOption.IsRequired = true; + command.AddOption(workbookWorksheetIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new AddRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/worksheets/{workbookWorksheet_id}/charts/microsoft.graph.add"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action add + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookChart + public class AddResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookChart + public WorkbookChart WorkbookChart { get; set; } + /// + /// Instantiates a new addResponse and sets the default values. + /// + public AddResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookChart", (o,n) => { (o as AddResponse).WorkbookChart = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookChart", WorkbookChart); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/ChartsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/ChartsRequestBuilder.cs index ca44bcc33d1..519b64e2d9d 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/ChartsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/ChartsRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.ItemWithName; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public class ChartsRequestBuilder { private string UrlTemplate { get; set; } public Command BuildAddCommand() { var command = new Command("add"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.@Add.AddRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Add.AddRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } public List BuildCommand() { var builder = new WorkbookChartRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAxesCommand(), - builder.BuildDataLabelsCommand(), - builder.BuildDeleteCommand(), - builder.BuildFormatCommand(), - builder.BuildGetCommand(), - builder.BuildLegendCommand(), - builder.BuildPatchCommand(), - builder.BuildSeriesCommand(), - builder.BuildSetDataCommand(), - builder.BuildSetPositionCommand(), - builder.BuildTitleCommand(), - builder.BuildWorksheetCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAxesCommand()); + commands.Add(builder.BuildDataLabelsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFormatCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildLegendCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildSeriesCommand()); + commands.Add(builder.BuildSetDataCommand()); + commands.Add(builder.BuildSetPositionCommand()); + commands.Add(builder.BuildTitleCommand()); + commands.Add(builder.BuildWorksheetCommand()); return commands; } /// @@ -55,11 +54,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Returns collection of charts that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); @@ -67,21 +66,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, bodyOption, outputOption); return command; } /// @@ -91,11 +89,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Returns collection of charts that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); @@ -134,7 +132,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -145,15 +147,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -215,18 +212,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookChart body, Actio return requestInfo; } /// - /// Returns collection of charts that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\charts\microsoft.graph.itemAt(index={index}) /// Usage: index={index} /// @@ -242,19 +227,6 @@ public ItemWithNameRequestBuilder ItemWithName(string name) { if(string.IsNullOrEmpty(name)) throw new ArgumentNullException(nameof(name)); return new ItemWithNameRequestBuilder(PathParameters, RequestAdapter, name); } - /// - /// Returns collection of charts that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookChart model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns collection of charts that are part of the worksheet. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Count/CountRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Count/CountRequestBuilder.cs index aeeab2cc73e..8cde0f4df8c 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Count/CountRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Count/CountRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,26 +25,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function count"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteIntValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, outputOption); return command; } /// @@ -75,16 +74,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function count - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/AxesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/AxesRequestBuilder.cs index eaae86ec42a..2ee02b76aa6 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/AxesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/AxesRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.ValueAxis; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,23 +41,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart axes. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -69,15 +68,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart axes. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -91,20 +90,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -114,15 +112,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart axes. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -130,14 +128,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -233,42 +230,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxes body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart axes. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart axes. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart axes. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxes model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart axes. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/CategoryAxisRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/CategoryAxisRequestBuilder.cs index ce76a1a4401..b9c2a918305 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/CategoryAxisRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/CategoryAxisRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.CategoryAxis.Title; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the category axis in a chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -68,15 +67,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the category axis in a chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildMajorGridlinesCommand() { @@ -131,15 +129,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the category axis in a chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -147,14 +145,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -235,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxis body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the category axis in a chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the category axis in a chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the category axis in a chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxis model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the category axis in a chart. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Format/Font/FontRequestBuilder.cs index 46f4bcb8f52..89194176b0e 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Format/FormatRequestBuilder.cs index 8a269a19ea2..479462cadac 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Format/FormatRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.CategoryAxis.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,23 +28,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of a chart object, which includes line and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of a chart object, which includes line and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -118,15 +116,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of a chart object, which includes line and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxisFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxisFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Format/Line/Clear/ClearRequestBuilder.cs index 72d6d693de9..f996fc88d8b 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Format/Line/LineRequestBuilder.cs index 4d17a9c7490..f6c25d654e4 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.CategoryAxis.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/FormatRequestBuilder.cs index 5361412cdc5..e0be2f203bf 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.CategoryAxis.MajorGridlines.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -55,15 +54,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlinesFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlinesFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of chart gridlines. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs index ba8b78b557b..f65fea221c0 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs index dec1acbac07..0c1f00e5400 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.CategoryAxis.MajorGridlines.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs index 129a99a20b7..4a4b2553a50 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.CategoryAxis.MajorGridlines.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns a gridlines object that represents the major gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns a gridlines object that represents the major gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns a gridlines object that represents the major gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlines b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlines model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/FormatRequestBuilder.cs index 5fd76c8106b..8ef97f50292 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.CategoryAxis.MinorGridlines.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -55,15 +54,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlinesFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlinesFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of chart gridlines. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs index 3a096623798..a3b246a9af2 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs index e7c42ec09af..0df4d9949be 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.CategoryAxis.MinorGridlines.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs index b0cbaebfec2..e1a3997cebf 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.CategoryAxis.MinorGridlines.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlines b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlines model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Title/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Title/Format/Font/FontRequestBuilder.cs index 7d5d182e491..29c81a98aea 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Title/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Title/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Title/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Title/Format/FormatRequestBuilder.cs index be24f7b137f..a819179a19f 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Title/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Title/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.CategoryAxis.Title.Format.Font; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of chart axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -63,15 +62,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of chart axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -85,20 +84,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -108,15 +106,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of chart axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -124,14 +122,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -203,42 +200,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxisTitleFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of chart axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxisTitleFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of chart axis title. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Title/TitleRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Title/TitleRequestBuilder.cs index c683e2a3d4b..79ff64230fc 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Title/TitleRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/CategoryAxis/Title/TitleRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.CategoryAxis.Title.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxisTitle b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxisTitle model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the axis title. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Format/Font/FontRequestBuilder.cs index b80e18c43ed..e2bd3fa6df3 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Format/FormatRequestBuilder.cs index 8e7958fe369..f992a088435 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Format/FormatRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.SeriesAxis.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,23 +28,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of a chart object, which includes line and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of a chart object, which includes line and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -118,15 +116,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of a chart object, which includes line and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxisFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxisFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Format/Line/Clear/ClearRequestBuilder.cs index 9c41f33cef6..77a2c9a2149 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Format/Line/LineRequestBuilder.cs index 7c1f252db47..3378f473b00 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.SeriesAxis.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/FormatRequestBuilder.cs index 0421789fbf4..eff01207749 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.SeriesAxis.MajorGridlines.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -55,15 +54,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlinesFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlinesFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of chart gridlines. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs index 47bc2888524..822b7a2a111 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs index aa7a3e4d4b8..c720ff10192 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.SeriesAxis.MajorGridlines.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs index 4b996ff3e37..b5d981748a1 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.SeriesAxis.MajorGridlines.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns a gridlines object that represents the major gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns a gridlines object that represents the major gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns a gridlines object that represents the major gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlines b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlines model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/FormatRequestBuilder.cs index c2baf3a04b1..8eeb0c53757 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.SeriesAxis.MinorGridlines.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -55,15 +54,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlinesFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlinesFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of chart gridlines. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs index 6b0b1df118b..6e8f36870bd 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs index c45dada46a5..c87ca7e73db 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.SeriesAxis.MinorGridlines.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs index fb92ca0663f..e9df89f0bd4 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.SeriesAxis.MinorGridlines.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlines b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlines model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/SeriesAxisRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/SeriesAxisRequestBuilder.cs index 9a97d743fb5..f695b1915f0 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/SeriesAxisRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/SeriesAxisRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.SeriesAxis.Title; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the series axis of a 3-dimensional chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -68,15 +67,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the series axis of a 3-dimensional chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildMajorGridlinesCommand() { @@ -131,15 +129,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the series axis of a 3-dimensional chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -147,14 +145,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -235,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxis body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the series axis of a 3-dimensional chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the series axis of a 3-dimensional chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the series axis of a 3-dimensional chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxis model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the series axis of a 3-dimensional chart. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Title/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Title/Format/Font/FontRequestBuilder.cs index f9572766a69..5cd7c1b06f2 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Title/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Title/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Title/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Title/Format/FormatRequestBuilder.cs index 979ced135ab..05abd7ef06b 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Title/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Title/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.SeriesAxis.Title.Format.Font; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of chart axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -63,15 +62,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of chart axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -85,20 +84,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -108,15 +106,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of chart axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -124,14 +122,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -203,42 +200,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxisTitleFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of chart axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxisTitleFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of chart axis title. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Title/TitleRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Title/TitleRequestBuilder.cs index 41269b30904..19a5e9ad864 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Title/TitleRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/SeriesAxis/Title/TitleRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.SeriesAxis.Title.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxisTitle b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxisTitle model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the axis title. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Format/Font/FontRequestBuilder.cs index 8e8e4fe46d0..b319348fa21 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Format/FormatRequestBuilder.cs index 05046fbac99..2a5e8a70c9d 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Format/FormatRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.ValueAxis.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,23 +28,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of a chart object, which includes line and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of a chart object, which includes line and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -118,15 +116,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of a chart object, which includes line and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxisFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxisFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of a chart object, which includes line and font formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Format/Line/Clear/ClearRequestBuilder.cs index 25246811a45..2eb9da5be8d 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Format/Line/LineRequestBuilder.cs index 81a292e1e30..e056306ce87 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.ValueAxis.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/FormatRequestBuilder.cs index f668e6302af..63c18c1e869 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.ValueAxis.MajorGridlines.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -55,15 +54,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlinesFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlinesFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of chart gridlines. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs index a2baaa44ee2..24956801bc6 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs index 62a9a46effe..420d28fa951 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MajorGridlines/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.ValueAxis.MajorGridlines.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs index 9e22d35e3d0..a4e8c6217e3 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MajorGridlines/MajorGridlinesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.ValueAxis.MajorGridlines.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns a gridlines object that represents the major gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns a gridlines object that represents the major gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns a gridlines object that represents the major gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlines b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlines model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/FormatRequestBuilder.cs index 4f544f393b2..7aec2d5b809 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.ValueAxis.MinorGridlines.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -55,15 +54,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -77,20 +76,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of chart gridlines. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlinesFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart gridlines. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlinesFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of chart gridlines. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs index 477cb883762..c22a6486954 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs index e0f00d3db3e..468922843f2 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MinorGridlines/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.ValueAxis.MinorGridlines.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,23 +33,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -61,15 +60,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -83,20 +82,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -106,15 +104,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents chart line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -122,14 +120,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -201,42 +198,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents chart line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents chart line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs index cf34979cf23..e8f56c43f3a 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/MinorGridlines/MinorGridlinesRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.ValueAxis.MinorGridlines.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartGridlines b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartGridlines model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Title/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Title/Format/Font/FontRequestBuilder.cs index 97d5da50c21..a6bf4d534b9 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Title/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Title/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Title/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Title/Format/FormatRequestBuilder.cs index 4e2a89b20f5..555cd8b7c85 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Title/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Title/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.ValueAxis.Title.Format.Font; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of chart axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -63,15 +62,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of chart axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -85,20 +84,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -108,15 +106,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of chart axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -124,14 +122,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -203,42 +200,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxisTitleFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of chart axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of chart axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxisTitleFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of chart axis title. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Title/TitleRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Title/TitleRequestBuilder.cs index dfbe0f30713..cf457ec7a41 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Title/TitleRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/Title/TitleRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.ValueAxis.Title.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -64,15 +63,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -86,20 +85,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -109,15 +107,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the axis title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -125,14 +123,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -204,42 +201,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxisTitle b requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the axis title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxisTitle model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the axis title. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/ValueAxisRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/ValueAxisRequestBuilder.cs index 4c830fca5dd..fae6134aa74 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/ValueAxisRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Axes/ValueAxis/ValueAxisRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Axes.ValueAxis.Title; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -30,23 +30,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the value axis in an axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -68,15 +67,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the value axis in an axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -90,20 +89,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildMajorGridlinesCommand() { @@ -131,15 +129,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the value axis in an axis. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -147,14 +145,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -235,42 +232,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAxis body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the value axis in an axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the value axis in an axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the value axis in an axis. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAxis model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the value axis in an axis. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/DataLabels/DataLabelsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/DataLabels/DataLabelsRequestBuilder.cs index 7e2afb32032..e577c81915c 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/DataLabels/DataLabelsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/DataLabels/DataLabelsRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.DataLabels.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the datalabels on the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -65,15 +64,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the datalabels on the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -87,20 +86,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,15 +108,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the datalabels on the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -126,14 +124,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -205,42 +202,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartDataLabels requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the datalabels on the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the datalabels on the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the datalabels on the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartDataLabels model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the datalabels on the chart. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/DataLabels/Format/Fill/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/DataLabels/Format/Fill/Clear/ClearRequestBuilder.cs index ed53466ba00..d48a96de50c 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/DataLabels/Format/Fill/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/DataLabels/Format/Fill/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/DataLabels/Format/Fill/FillRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/DataLabels/Format/Fill/FillRequestBuilder.cs index 63dfc1d57e8..45edf54fc07 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/DataLabels/Format/Fill/FillRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/DataLabels/Format/Fill/FillRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.DataLabels.Format.Fill.SetSolidColor; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,23 +34,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the fill format of the current chart data label. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the fill format of the current chart data label. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,15 +105,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the fill format of the current chart data label. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -123,14 +121,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFill body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the fill format of the current chart data label. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of the current chart data label. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of the current chart data label. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFill model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the fill format of the current chart data label. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/DataLabels/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/DataLabels/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs index d63265ec73c..7632ae6289a 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/DataLabels/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/DataLabels/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setSolidColor"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SetSolidColorRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setSolidColor - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetSolidColorRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/DataLabels/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/DataLabels/Format/Font/FontRequestBuilder.cs index 4f38cb20052..327f47cabe6 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/DataLabels/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/DataLabels/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart data label. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart data label. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for a chart data label. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart data label. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart data label. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for a chart data label. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes (font name, font size, color, etc.) for a chart data label. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/DataLabels/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/DataLabels/Format/FormatRequestBuilder.cs index c97739af932..95e2a93abde 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/DataLabels/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/DataLabels/Format/FormatRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.DataLabels.Format.Font; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,23 +28,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the format of chart data labels, which includes fill and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -74,15 +73,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the format of chart data labels, which includes fill and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -96,20 +95,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,15 +117,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the format of chart data labels, which includes fill and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -135,14 +133,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -214,42 +211,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartDataLabelFo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the format of chart data labels, which includes fill and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the format of chart data labels, which includes fill and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the format of chart data labels, which includes fill and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartDataLabelFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the format of chart data labels, which includes fill and font formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Format/Fill/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Format/Fill/Clear/ClearRequestBuilder.cs index a9b16aac9c8..bab650ed4cf 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Format/Fill/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Format/Fill/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Format/Fill/FillRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Format/Fill/FillRequestBuilder.cs index e1367d753a6..5352982ab6c 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Format/Fill/FillRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Format/Fill/FillRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Format.Fill.SetSolidColor; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,23 +34,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the fill format of an object, which includes background formatting information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the fill format of an object, which includes background formatting information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,15 +105,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the fill format of an object, which includes background formatting information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -123,14 +121,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFill body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the fill format of an object, which includes background formatting information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of an object, which includes background formatting information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of an object, which includes background formatting information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFill model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the fill format of an object, which includes background formatting information. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs index 5e982fd7f06..e3903d7aa0e 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setSolidColor"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SetSolidColorRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setSolidColor - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetSolidColorRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Format/Font/FontRequestBuilder.cs index 9c1c10006f2..422d87bfeca 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Format/FormatRequestBuilder.cs index 2e1d0b9a0c1..730e3b63c64 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Format/FormatRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Format.Font; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,23 +28,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Encapsulates the format properties for the chart area. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -74,15 +73,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Encapsulates the format properties for the chart area. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -96,20 +95,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,15 +117,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Encapsulates the format properties for the chart area. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -135,14 +133,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -214,42 +211,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartAreaFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Encapsulates the format properties for the chart area. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Encapsulates the format properties for the chart area. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Encapsulates the format properties for the chart area. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartAreaFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Encapsulates the format properties for the chart area. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Image/ImageRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Image/ImageRequestBuilder.cs index 0b9295aef5f..7b8b5ed5013 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Image/ImageRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Image/ImageRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,30 +25,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function image"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, outputOption); return command; } /// @@ -79,16 +78,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function image - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/ImageWithWidth/ImageWithWidthRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/ImageWithWidth/ImageWithWidthRequestBuilder.cs index 5925e9cf11d..1d4e6052c48 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/ImageWithWidth/ImageWithWidthRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/ImageWithWidth/ImageWithWidthRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function image"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -41,18 +41,17 @@ public Command BuildGetCommand() { }; widthOption.IsRequired = true; command.AddOption(widthOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, int? width) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, int? width, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, widthOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, widthOption, outputOption); return command; } /// @@ -85,16 +84,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function image - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/ImageWithWidthWithHeight/ImageWithWidthWithHeightRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/ImageWithWidthWithHeight/ImageWithWidthWithHeightRequestBuilder.cs index d2c0ab22a92..7ac61a6a130 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/ImageWithWidthWithHeight/ImageWithWidthWithHeightRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/ImageWithWidthWithHeight/ImageWithWidthWithHeightRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function image"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -45,18 +45,17 @@ public Command BuildGetCommand() { }; heightOption.IsRequired = true; command.AddOption(heightOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, int? width, int? height) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, int? width, int? height, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, widthOption, heightOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, widthOption, heightOption, outputOption); return command; } /// @@ -91,16 +90,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function image - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/ImageWithWidthWithHeightWithFittingMode/ImageWithWidthWithHeightWithFittingModeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/ImageWithWidthWithHeightWithFittingMode/ImageWithWidthWithHeightWithFittingModeRequestBuilder.cs index 91982600ac3..c055132a51e 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/ImageWithWidthWithHeightWithFittingMode/ImageWithWidthWithHeightWithFittingModeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/ImageWithWidthWithHeightWithFittingMode/ImageWithWidthWithHeightWithFittingModeRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function image"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -45,22 +45,21 @@ public Command BuildGetCommand() { }; heightOption.IsRequired = true; command.AddOption(heightOption); - var fittingModeOption = new Option("--fittingmode", description: "Usage: fittingMode={fittingMode}") { + var fittingModeOption = new Option("--fitting-mode", description: "Usage: fittingMode={fittingMode}") { }; fittingModeOption.IsRequired = true; command.AddOption(fittingModeOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, int? width, int? height, string fittingMode) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, int? width, int? height, string fittingMode, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteStringValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, widthOption, heightOption, fittingModeOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, widthOption, heightOption, fittingModeOption, outputOption); return command; } /// @@ -97,16 +96,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function image - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Legend/Format/Fill/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Legend/Format/Fill/Clear/ClearRequestBuilder.cs index 3b584cc5f05..108c86e1d6d 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Legend/Format/Fill/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Legend/Format/Fill/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Legend/Format/Fill/FillRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Legend/Format/Fill/FillRequestBuilder.cs index 991edf55aa9..b25e29c2925 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Legend/Format/Fill/FillRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Legend/Format/Fill/FillRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Legend.Format.Fill.SetSolidColor; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,23 +34,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the fill format of an object, which includes background formating information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the fill format of an object, which includes background formating information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,15 +105,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the fill format of an object, which includes background formating information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -123,14 +121,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFill body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the fill format of an object, which includes background formating information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of an object, which includes background formating information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of an object, which includes background formating information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFill model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the fill format of an object, which includes background formating information. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Legend/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Legend/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs index c089b9f38b2..8811845aa40 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Legend/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Legend/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setSolidColor"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SetSolidColorRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setSolidColor - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetSolidColorRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Legend/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Legend/Format/Font/FontRequestBuilder.cs index c63b9934ea3..d2b0ac009c5 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Legend/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Legend/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes such as font name, font size, color, etc. of a chart legend. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes such as font name, font size, color, etc. of a chart legend. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes such as font name, font size, color, etc. of a chart legend. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes such as font name, font size, color, etc. of a chart legend. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes such as font name, font size, color, etc. of a chart legend. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes such as font name, font size, color, etc. of a chart legend. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes such as font name, font size, color, etc. of a chart legend. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Legend/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Legend/Format/FormatRequestBuilder.cs index ad068e560a9..af0aeafd9f3 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Legend/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Legend/Format/FormatRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Legend.Format.Font; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,23 +28,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of a chart legend, which includes fill and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -74,15 +73,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of a chart legend, which includes fill and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -96,20 +95,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,15 +117,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of a chart legend, which includes fill and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -135,14 +133,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -214,42 +211,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLegendForma requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of a chart legend, which includes fill and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart legend, which includes fill and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart legend, which includes fill and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLegendFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of a chart legend, which includes fill and font formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Legend/LegendRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Legend/LegendRequestBuilder.cs index 4002bb1cbcf..52fc8db6bc3 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Legend/LegendRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Legend/LegendRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Legend.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the legend for the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -65,15 +64,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the legend for the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -87,20 +86,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,15 +108,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the legend for the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -126,14 +124,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -205,42 +202,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLegend body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the legend for the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the legend for the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the legend for the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLegend model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the legend for the chart. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Count/CountRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Count/CountRequestBuilder.cs index 41e146242b9..5e2f59545e4 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Count/CountRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Count/CountRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,30 +25,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function count"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteIntValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, outputOption); return command; } /// @@ -79,16 +78,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function count - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Format/Fill/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Format/Fill/Clear/ClearRequestBuilder.cs index e87593ab871..1d7183a1415 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Format/Fill/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Format/Fill/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,27 +25,26 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption); return command; @@ -78,16 +77,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Format/Fill/FillRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Format/Fill/FillRequestBuilder.cs index 4c08cf0b690..05ac2a57cb0 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Format/Fill/FillRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Format/Fill/FillRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Series.Item.Format.Fill.SetSolidColor; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,27 +34,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the fill format of a chart series, which includes background formating information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption); return command; @@ -66,19 +65,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the fill format of a chart series, which includes background formating information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -92,20 +91,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -115,19 +113,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the fill format of a chart series, which includes background formating information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -135,14 +133,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, bodyOption); return command; @@ -220,42 +217,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFill body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the fill format of a chart series, which includes background formating information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of a chart series, which includes background formating information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of a chart series, which includes background formating information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFill model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the fill format of a chart series, which includes background formating information. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs index 076230398b5..ccc44ad3e32 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setSolidColor"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(SetSolidColorRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setSolidColor - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetSolidColorRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Format/FormatRequestBuilder.cs index 6a61ed5a148..d223e614f04 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Format/FormatRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Series.Item.Format.Line; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,27 +28,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of a chart series, which includes fill and line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption); return command; @@ -70,19 +69,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of a chart series, which includes fill and line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -96,20 +95,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLineCommand() { @@ -128,19 +126,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of a chart series, which includes fill and line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -148,14 +146,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, bodyOption); return command; @@ -227,42 +224,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartSeriesForma requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of a chart series, which includes fill and line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart series, which includes fill and line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart series, which includes fill and line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartSeriesFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of a chart series, which includes fill and line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Format/Line/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Format/Line/Clear/ClearRequestBuilder.cs index ca4fcf9ecb7..fb14100f346 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Format/Line/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Format/Line/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,27 +25,26 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption); return command; @@ -78,16 +77,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Format/Line/LineRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Format/Line/LineRequestBuilder.cs index f3a3bfe0c69..d7a82f4adf6 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Format/Line/LineRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Format/Line/LineRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Series.Item.Format.Line.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,27 +33,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption); return command; @@ -65,19 +64,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -91,20 +90,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -114,19 +112,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents line formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -134,14 +132,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, bodyOption); return command; @@ -213,42 +210,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartLineFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents line formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartLineFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents line formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/Count/CountRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/Count/CountRequestBuilder.cs index d5bdd76611b..a773ec00213 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/Count/CountRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/Count/CountRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,34 +25,33 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function count"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteIntValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, outputOption); return command; } /// @@ -83,16 +82,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function count - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/Item/Format/Fill/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/Item/Format/Fill/Clear/ClearRequestBuilder.cs index 4521ce39131..81ac9f5aa43 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/Item/Format/Fill/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/Item/Format/Fill/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,31 +25,30 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption); return command; @@ -82,16 +81,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/Item/Format/Fill/FillRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/Item/Format/Fill/FillRequestBuilder.cs index f27219298f5..3ed97347229 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/Item/Format/Fill/FillRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/Item/Format/Fill/FillRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Series.Item.Points.Item.Format.Fill.SetSolidColor; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,31 +34,30 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the fill format of a chart, which includes background formating information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption); return command; @@ -70,23 +69,23 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the fill format of a chart, which includes background formating information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); @@ -100,20 +99,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -123,23 +121,23 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the fill format of a chart, which includes background formating information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); @@ -147,14 +145,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, bodyOption); return command; @@ -232,42 +229,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFill body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the fill format of a chart, which includes background formating information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of a chart, which includes background formating information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of a chart, which includes background formating information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFill model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the fill format of a chart, which includes background formating information. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs index 6bef483aab1..660e35c4ad6 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/Item/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,23 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setSolidColor"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); @@ -49,14 +49,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, bodyOption); return command; @@ -92,18 +91,5 @@ public RequestInformation CreatePostRequestInformation(SetSolidColorRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setSolidColor - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetSolidColorRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/Item/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/Item/Format/FormatRequestBuilder.cs index bdeb321b83b..80b3231138d 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/Item/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/Item/Format/FormatRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Series.Item.Points.Item.Format.Fill; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,31 +27,30 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Encapsulates the format properties chart point. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption); return command; @@ -73,23 +72,23 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Encapsulates the format properties chart point. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); @@ -103,20 +102,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -126,23 +124,23 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Encapsulates the format properties chart point. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); @@ -150,14 +148,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, bodyOption); return command; @@ -229,42 +226,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartPointFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Encapsulates the format properties chart point. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Encapsulates the format properties chart point. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Encapsulates the format properties chart point. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartPointFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Encapsulates the format properties chart point. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/Item/WorkbookChartPointRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/Item/WorkbookChartPointRequestBuilder.cs index be6f2ca46d1..0a453d9f27c 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/Item/WorkbookChartPointRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/Item/WorkbookChartPointRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Series.Item.Points.Item.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,31 +27,30 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents a collection of all points in the series. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption); return command; @@ -72,23 +71,23 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents a collection of all points in the series. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); @@ -102,20 +101,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -125,23 +123,23 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents a collection of all points in the series. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - var workbookChartPointIdOption = new Option("--workbookchartpoint-id", description: "key: id of workbookChartPoint") { + var workbookChartPointIdOption = new Option("--workbook-chart-point-id", description: "key: id of workbookChartPoint") { }; workbookChartPointIdOption.IsRequired = true; command.AddOption(workbookChartPointIdOption); @@ -149,14 +147,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string workbookChartPointId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, workbookChartPointIdOption, bodyOption); return command; @@ -228,42 +225,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartPoint body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents a collection of all points in the series. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a collection of all points in the series. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a collection of all points in the series. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartPoint model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents a collection of all points in the series. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs index 997a82a1f35..b1e51101629 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,19 +26,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function itemAt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -46,18 +46,17 @@ public Command BuildGetCommand() { }; indexOption.IsRequired = true; command.AddOption(indexOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, int? index) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, int? index, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, indexOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, indexOption, outputOption); return command; } /// @@ -90,17 +89,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function itemAt - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookChartPoint public class ItemAtWithIndexResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/PointsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/PointsRequestBuilder.cs index b4e90c3bb72..69a0a629f9b 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/PointsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/Points/PointsRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Series.Item.Points.ItemAtWithIndex; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -24,12 +24,11 @@ public class PointsRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new WorkbookChartPointRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildFormatCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFormatCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -39,19 +38,19 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Represents a collection of all points in the series. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -59,21 +58,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, bodyOption, outputOption); return command; } /// @@ -83,19 +81,19 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Represents a collection of all points in the series. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -134,7 +132,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -145,15 +147,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -215,18 +212,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookChartPoint body, return requestInfo; } /// - /// Represents a collection of all points in the series. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\charts\{workbookChart-id}\series\{workbookChartSeries-id}\points\microsoft.graph.itemAt(index={index}) /// Usage: index={index} /// @@ -234,19 +219,6 @@ public ItemAtWithIndexRequestBuilder ItemAtWithIndex(int? index) { _ = index ?? throw new ArgumentNullException(nameof(index)); return new ItemAtWithIndexRequestBuilder(PathParameters, RequestAdapter, index); } - /// - /// Represents a collection of all points in the series. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookChartPoint model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents a collection of all points in the series. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/WorkbookChartSeriesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/WorkbookChartSeriesRequestBuilder.cs index be2601a48c8..6797909c82c 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/WorkbookChartSeriesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/Item/WorkbookChartSeriesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Series.Item.Points; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,27 +28,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents either a single series or collection of series in the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption); return command; @@ -70,19 +69,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents either a single series or collection of series in the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -96,20 +95,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,19 +117,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents either a single series or collection of series in the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var workbookChartSeriesIdOption = new Option("--workbookchartseries-id", description: "key: id of workbookChartSeries") { + var workbookChartSeriesIdOption = new Option("--workbook-chart-series-id", description: "key: id of workbookChartSeries") { }; workbookChartSeriesIdOption.IsRequired = true; command.AddOption(workbookChartSeriesIdOption); @@ -139,14 +137,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string workbookChartSeriesId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, workbookChartSeriesIdOption, bodyOption); return command; @@ -154,6 +151,9 @@ public Command BuildPatchCommand() { public Command BuildPointsCommand() { var command = new Command("points"); var builder = new ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Series.Item.Points.PointsRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -225,42 +225,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartSeries body requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents either a single series or collection of series in the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents either a single series or collection of series in the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents either a single series or collection of series in the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartSeries model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents either a single series or collection of series in the chart. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs index 35ed7a3bded..f08cc30b6d9 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function itemAt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -42,18 +42,17 @@ public Command BuildGetCommand() { }; indexOption.IsRequired = true; command.AddOption(indexOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, int? index) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, int? index, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, indexOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, indexOption, outputOption); return command; } /// @@ -86,17 +85,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function itemAt - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookChartSeries public class ItemAtWithIndexResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/SeriesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/SeriesRequestBuilder.cs index 82b48be23b4..61e2c26b44d 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/SeriesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Series/SeriesRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Series.ItemAtWithIndex; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -24,13 +24,12 @@ public class SeriesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new WorkbookChartSeriesRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildFormatCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildPointsCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFormatCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPointsCommand()); return commands; } /// @@ -40,15 +39,15 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Represents either a single series or collection of series in the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption, outputOption); return command; } /// @@ -80,15 +78,15 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Represents either a single series or collection of series in the chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -127,7 +125,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -138,15 +140,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -208,18 +205,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookChartSeries body, return requestInfo; } /// - /// Represents either a single series or collection of series in the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\charts\{workbookChart-id}\series\microsoft.graph.itemAt(index={index}) /// Usage: index={index} /// @@ -227,19 +212,6 @@ public ItemAtWithIndexRequestBuilder ItemAtWithIndex(int? index) { _ = index ?? throw new ArgumentNullException(nameof(index)); return new ItemAtWithIndexRequestBuilder(PathParameters, RequestAdapter, index); } - /// - /// Represents either a single series or collection of series in the chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookChartSeries model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents either a single series or collection of series in the chart. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/SetData/SetDataRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/SetData/SetDataRequestBuilder.cs index f00bc1d7117..032097b5ed4 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/SetData/SetDataRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/SetData/SetDataRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setData"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SetDataRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setData - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetDataRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/SetPosition/SetPositionRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/SetPosition/SetPositionRequestBuilder.cs index bed3b3813c9..03018c679fc 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/SetPosition/SetPositionRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/SetPosition/SetPositionRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setPosition"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SetPositionRequestBody bo requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setPosition - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetPositionRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Title/Format/Fill/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Title/Format/Fill/Clear/ClearRequestBuilder.cs index d91dc8c57e5..59e99cb6c22 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Title/Format/Fill/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Title/Format/Fill/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Title/Format/Fill/FillRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Title/Format/Fill/FillRequestBuilder.cs index 5d3d93a6c1f..83f3c9fcaa7 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Title/Format/Fill/FillRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Title/Format/Fill/FillRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Title.Format.Fill.SetSolidColor; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -34,23 +34,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the fill format of an object, which includes background formatting information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -62,15 +61,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the fill format of an object, which includes background formatting information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -84,20 +83,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -107,15 +105,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the fill format of an object, which includes background formatting information. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -123,14 +121,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFill body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the fill format of an object, which includes background formatting information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of an object, which includes background formatting information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the fill format of an object, which includes background formatting information. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFill model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the fill format of an object, which includes background formatting information. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Title/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Title/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs index 67859a795ff..a03a6a71807 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Title/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Title/Format/Fill/SetSolidColor/SetSolidColorRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action setSolidColor"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(SetSolidColorRequestBody requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action setSolidColor - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(SetSolidColorRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Title/Format/Font/FontRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Title/Format/Font/FontRequestBuilder.cs index f13759431a9..5f3fd1f9ea5 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Title/Format/Font/FontRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Title/Format/Font/FontRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,23 +26,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -54,15 +53,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -76,20 +75,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -99,15 +97,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -115,14 +113,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -194,42 +191,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartFont body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartFont model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Title/Format/FormatRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Title/Format/FormatRequestBuilder.cs index afc1e2d487d..78cfaa583a2 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Title/Format/FormatRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Title/Format/FormatRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Title.Format.Font; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,23 +28,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the formatting of a chart title, which includes fill and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -74,15 +73,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the formatting of a chart title, which includes fill and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -96,20 +95,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -119,15 +117,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the formatting of a chart title, which includes fill and font formatting. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -135,14 +133,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -214,42 +211,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartTitleFormat requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the formatting of a chart title, which includes fill and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart title, which includes fill and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the formatting of a chart title, which includes fill and font formatting. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartTitleFormat model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the formatting of a chart title, which includes fill and font formatting. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Title/TitleRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Title/TitleRequestBuilder.cs index c9df699a726..7668f752ec3 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Title/TitleRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Title/TitleRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Title.Format; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,23 +27,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the title of the specified chart, including the text, visibility, position and formating of the title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -65,15 +64,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the title of the specified chart, including the text, visibility, position and formating of the title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -87,20 +86,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -110,15 +108,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the title of the specified chart, including the text, visibility, position and formating of the title. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -126,14 +124,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -205,42 +202,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChartTitle body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the title of the specified chart, including the text, visibility, position and formating of the title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the title of the specified chart, including the text, visibility, position and formating of the title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the title of the specified chart, including the text, visibility, position and formating of the title. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChartTitle model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the title of the specified chart, including the text, visibility, position and formating of the title. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/WorkbookChartRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/WorkbookChartRequestBuilder.cs index 75a814a710c..75c9785ebf5 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/WorkbookChartRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/WorkbookChartRequestBuilder.cs @@ -14,10 +14,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Worksheet; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -59,23 +59,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns collection of charts that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -97,15 +96,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns collection of charts that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -119,20 +118,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildLegendCommand() { @@ -151,15 +149,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns collection of charts that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -167,14 +165,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -182,6 +179,9 @@ public Command BuildPatchCommand() { public Command BuildSeriesCommand() { var command = new Command("series"); var builder = new ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Series.SeriesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -283,29 +283,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookChart body, Acti return requestInfo; } /// - /// Returns collection of charts that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns collection of charts that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\charts\{workbookChart-id}\microsoft.graph.image() /// public ImageRequestBuilder Image() { @@ -341,19 +318,6 @@ public ImageWithWidthWithHeightWithFittingModeRequestBuilder ImageWithWidthWithH _ = width ?? throw new ArgumentNullException(nameof(width)); return new ImageWithWidthWithHeightWithFittingModeRequestBuilder(PathParameters, RequestAdapter, width, height, fittingMode); } - /// - /// Returns collection of charts that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookChart model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns collection of charts that are part of the worksheet. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs index 3c3f198fd77..fb73a4e8de5 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function cell"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -46,18 +46,17 @@ public Command BuildGetCommand() { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, int? row, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, int? row, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, rowOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, rowOption, columnOption, outputOption); return command; } /// @@ -92,17 +91,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function cell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class CellWithRowWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Worksheet/Range/RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Worksheet/Range/RangeRequestBuilder.cs index f4b343bb6aa..d3f752e2091 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Worksheet/Range/RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Worksheet/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs index 10361ab42a7..10b5eb0c3c9 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -42,18 +42,17 @@ public Command BuildGetCommand() { }; addressOption.IsRequired = true; command.AddOption(addressOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string address) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string address, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, addressOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, addressOption, outputOption); return command; } /// @@ -86,17 +85,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeWithAddressResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs index cb5899da212..8ab419722d5 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs index dafc3892943..b8d099c8f80 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,34 +26,33 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - var valuesOnlyOption = new Option("--valuesonly", description: "Usage: valuesOnly={valuesOnly}") { + var valuesOnlyOption = new Option("--values-only", description: "Usage: valuesOnly={valuesOnly}") { }; valuesOnlyOption.IsRequired = true; command.AddOption(valuesOnlyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, bool? valuesOnly) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, bool? valuesOnly, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, valuesOnlyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, valuesOnlyOption, outputOption); return command; } /// @@ -86,17 +85,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeWithValuesOnlyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Worksheet/WorksheetRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Worksheet/WorksheetRequestBuilder.cs index 70e7f1d8bd4..c28378a9842 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Worksheet/WorksheetRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/Item/Worksheet/WorksheetRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.Item.Worksheet.UsedRangeWithValuesOnly; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,23 +31,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The worksheet containing the current chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption); return command; @@ -59,15 +58,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The worksheet containing the current chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -81,20 +80,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,15 +102,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The worksheet containing the current chart. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookChartIdOption = new Option("--workbookchart-id", description: "key: id of workbookChart") { + var workbookChartIdOption = new Option("--workbook-chart-id", description: "key: id of workbookChart") { }; workbookChartIdOption.IsRequired = true; command.AddOption(workbookChartIdOption); @@ -120,14 +118,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookChartId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookChartIdOption, bodyOption); return command; @@ -210,42 +207,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookWorksheet body, return requestInfo; } /// - /// The worksheet containing the current chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The worksheet containing the current chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The worksheet containing the current chart. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookWorksheet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\charts\{workbookChart-id}\worksheet\microsoft.graph.range() /// public RangeRequestBuilder Range() { diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs index 3cf15bebd71..4542640848b 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function itemAt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; indexOption.IsRequired = true; command.AddOption(indexOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, int? index) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, int? index, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, indexOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, indexOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function itemAt - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookChart public class ItemAtWithIndexResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/ItemWithName/ItemWithNameRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/ItemWithName/ItemWithNameRequestBuilder.cs index e286d504fec..6f8418f300a 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/ItemWithName/ItemWithNameRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Charts/ItemWithName/ItemWithNameRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function item"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; nameOption.IsRequired = true; command.AddOption(nameOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string name) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string name, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, nameOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, nameOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function item - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookChart public class ItemWithNameResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/@Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/@Add/AddRequestBody.cs deleted file mode 100644 index 51411fa61ff..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/@Add/AddRequestBody.cs +++ /dev/null @@ -1,42 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Names.@Add { - public class AddRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string Comment { get; set; } - public string Name { get; set; } - public Json Reference { get; set; } - /// - /// Instantiates a new addRequestBody and sets the default values. - /// - public AddRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"comment", (o,n) => { (o as AddRequestBody).Comment = n.GetStringValue(); } }, - {"name", (o,n) => { (o as AddRequestBody).Name = n.GetStringValue(); } }, - {"reference", (o,n) => { (o as AddRequestBody).Reference = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("comment", Comment); - writer.WriteStringValue("name", Name); - writer.WriteObjectValue("reference", Reference); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/@Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/@Add/AddRequestBuilder.cs deleted file mode 100644 index d69f55e2c56..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/@Add/AddRequestBuilder.cs +++ /dev/null @@ -1,133 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Names.@Add { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\names\microsoft.graph.add - public class AddRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action add - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action add"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { - }; - workbookWorksheetIdOption.IsRequired = true; - command.AddOption(workbookWorksheetIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AddRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/worksheets/{workbookWorksheet_id}/names/microsoft.graph.add"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action add - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action add - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookNamedItem - public class AddResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookNamedItem - public WorkbookNamedItem WorkbookNamedItem { get; set; } - /// - /// Instantiates a new addResponse and sets the default values. - /// - public AddResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookNamedItem", (o,n) => { (o as AddResponse).WorkbookNamedItem = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookNamedItem", WorkbookNamedItem); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Add/AddRequestBody.cs new file mode 100644 index 00000000000..e8b95292dca --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Add/AddRequestBody.cs @@ -0,0 +1,42 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Names.Add { + public class AddRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string Comment { get; set; } + public string Name { get; set; } + public Json Reference { get; set; } + /// + /// Instantiates a new addRequestBody and sets the default values. + /// + public AddRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"comment", (o,n) => { (o as AddRequestBody).Comment = n.GetStringValue(); } }, + {"name", (o,n) => { (o as AddRequestBody).Name = n.GetStringValue(); } }, + {"reference", (o,n) => { (o as AddRequestBody).Reference = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("comment", Comment); + writer.WriteStringValue("name", Name); + writer.WriteObjectValue("reference", Reference); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Add/AddRequestBuilder.cs new file mode 100644 index 00000000000..eea6a5e5926 --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Add/AddRequestBuilder.cs @@ -0,0 +1,119 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Names.Add { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\names\microsoft.graph.add + public class AddRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action add + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action add"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { + }; + workbookWorksheetIdOption.IsRequired = true; + command.AddOption(workbookWorksheetIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new AddRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/worksheets/{workbookWorksheet_id}/names/microsoft.graph.add"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action add + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookNamedItem + public class AddResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookNamedItem + public WorkbookNamedItem WorkbookNamedItem { get; set; } + /// + /// Instantiates a new addResponse and sets the default values. + /// + public AddResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookNamedItem", (o,n) => { (o as AddResponse).WorkbookNamedItem = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookNamedItem", WorkbookNamedItem); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/AddFormulaLocal/AddFormulaLocalRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/AddFormulaLocal/AddFormulaLocalRequestBuilder.cs index 2be461516b5..10e059586b6 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/AddFormulaLocal/AddFormulaLocalRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/AddFormulaLocal/AddFormulaLocalRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action addFormulaLocal"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); @@ -38,21 +38,20 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, bodyOption, outputOption); return command; } /// @@ -86,19 +85,6 @@ public RequestInformation CreatePostRequestInformation(AddFormulaLocalRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action addFormulaLocal - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddFormulaLocalRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookNamedItem public class AddFormulaLocalResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Range/RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Range/RangeRequestBuilder.cs index d83c6663bbc..7bcbb4b6ecf 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Range/RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookNamedItemId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookNamedItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookNamedItemIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookNamedItemIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/WorkbookNamedItemRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/WorkbookNamedItemRequestBuilder.cs index 4778cf352db..8a8afaa2894 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/WorkbookNamedItemRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/WorkbookNamedItemRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Names.Item.Worksheet; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,23 +28,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns collection of names that are associated with the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookNamedItemId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookNamedItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookNamedItemIdOption); return command; @@ -56,15 +55,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns collection of names that are associated with the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -78,20 +77,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookNamedItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookNamedItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookNamedItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookNamedItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -101,15 +99,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns collection of names that are associated with the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -117,14 +115,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookNamedItemId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookNamedItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookNamedItemIdOption, bodyOption); return command; @@ -205,42 +202,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookNamedItem body, return requestInfo; } /// - /// Returns collection of names that are associated with the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns collection of names that are associated with the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns collection of names that are associated with the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookNamedItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\names\{workbookNamedItem-id}\microsoft.graph.range() /// public RangeRequestBuilder Range() { diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs index 67e97d7b681..e94d73fbb9b 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function cell"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -46,18 +46,17 @@ public Command BuildGetCommand() { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookNamedItemId, int? row, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookNamedItemId, int? row, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookNamedItemIdOption, rowOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookNamedItemIdOption, rowOption, columnOption, outputOption); return command; } /// @@ -92,17 +91,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function cell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class CellWithRowWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Worksheet/Range/RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Worksheet/Range/RangeRequestBuilder.cs index a44e6b4b0c0..075f64b049a 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Worksheet/Range/RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Worksheet/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookNamedItemId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookNamedItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookNamedItemIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookNamedItemIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs index a42d9bd197a..b553c86ff96 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -42,18 +42,17 @@ public Command BuildGetCommand() { }; addressOption.IsRequired = true; command.AddOption(addressOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookNamedItemId, string address) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookNamedItemId, string address, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookNamedItemIdOption, addressOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookNamedItemIdOption, addressOption, outputOption); return command; } /// @@ -86,17 +85,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeWithAddressResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs index 0ad7a38542c..4fcba3686f6 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookNamedItemId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookNamedItemId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookNamedItemIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookNamedItemIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs index 3ed506187c6..ff23d2c1899 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,34 +26,33 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - var valuesOnlyOption = new Option("--valuesonly", description: "Usage: valuesOnly={valuesOnly}") { + var valuesOnlyOption = new Option("--values-only", description: "Usage: valuesOnly={valuesOnly}") { }; valuesOnlyOption.IsRequired = true; command.AddOption(valuesOnlyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookNamedItemId, bool? valuesOnly) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookNamedItemId, bool? valuesOnly, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookNamedItemIdOption, valuesOnlyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookNamedItemIdOption, valuesOnlyOption, outputOption); return command; } /// @@ -86,17 +85,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeWithValuesOnlyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Worksheet/WorksheetRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Worksheet/WorksheetRequestBuilder.cs index b51af10977e..a17a6fdd99a 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Worksheet/WorksheetRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/Item/Worksheet/WorksheetRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Names.Item.Worksheet.UsedRangeWithValuesOnly; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,23 +31,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns the worksheet on which the named item is scoped to. Available only if the item is scoped to the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookNamedItemId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookNamedItemId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookNamedItemIdOption); return command; @@ -59,15 +58,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns the worksheet on which the named item is scoped to. Available only if the item is scoped to the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -81,20 +80,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookNamedItemId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookNamedItemId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookNamedItemIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookNamedItemIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,15 +102,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns the worksheet on which the named item is scoped to. Available only if the item is scoped to the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookNamedItemIdOption = new Option("--workbooknameditem-id", description: "key: id of workbookNamedItem") { + var workbookNamedItemIdOption = new Option("--workbook-named-item-id", description: "key: id of workbookNamedItem") { }; workbookNamedItemIdOption.IsRequired = true; command.AddOption(workbookNamedItemIdOption); @@ -120,14 +118,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookNamedItemId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookNamedItemId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookNamedItemIdOption, bodyOption); return command; @@ -210,42 +207,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookWorksheet body, return requestInfo; } /// - /// Returns the worksheet on which the named item is scoped to. Available only if the item is scoped to the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns the worksheet on which the named item is scoped to. Available only if the item is scoped to the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns the worksheet on which the named item is scoped to. Available only if the item is scoped to the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookWorksheet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\names\{workbookNamedItem-id}\worksheet\microsoft.graph.range() /// public RangeRequestBuilder Range() { diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/NamesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/NamesRequestBuilder.cs index 2a4002c3208..e5b7307c0fd 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/NamesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Names/NamesRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Names.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -24,7 +24,7 @@ public class NamesRequestBuilder { private string UrlTemplate { get; set; } public Command BuildAddCommand() { var command = new Command("add"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Names.@Add.AddRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Names.Add.AddRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } @@ -36,12 +36,11 @@ public Command BuildAddFormulaLocalCommand() { } public List BuildCommand() { var builder = new WorkbookNamedItemRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildWorksheetCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildWorksheetCommand()); return commands; } /// @@ -51,11 +50,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Returns collection of names that are associated with the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); @@ -63,21 +62,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, bodyOption, outputOption); return command; } /// @@ -87,11 +85,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Returns collection of names that are associated with the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); @@ -130,7 +128,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -141,15 +143,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -204,31 +201,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookNamedItem body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Returns collection of names that are associated with the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns collection of names that are associated with the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookNamedItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns collection of names that are associated with the worksheet. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Refresh/RefreshRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Refresh/RefreshRequestBuilder.cs index 06f7fceba29..642b5169533 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Refresh/RefreshRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Refresh/RefreshRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action refresh"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookPivotTableId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookPivotTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookPivotTableIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action refresh - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/WorkbookPivotTableRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/WorkbookPivotTableRequestBuilder.cs index 50e2e0bb3f4..9ec34e470af 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/WorkbookPivotTableRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/WorkbookPivotTableRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.PivotTables.Item.Worksheet; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,23 +28,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Collection of PivotTables that are part of the worksheet."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookPivotTableId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookPivotTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookPivotTableIdOption); return command; @@ -56,15 +55,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Collection of PivotTables that are part of the worksheet."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); @@ -78,20 +77,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookPivotTableId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookPivotTableId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookPivotTableIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookPivotTableIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -101,15 +99,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Collection of PivotTables that are part of the worksheet."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); @@ -117,14 +115,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookPivotTableId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookPivotTableId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookPivotTableIdOption, bodyOption); return command; @@ -210,42 +207,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookPivotTable body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of PivotTables that are part of the worksheet. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of PivotTables that are part of the worksheet. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of PivotTables that are part of the worksheet. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookPivotTable model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of PivotTables that are part of the worksheet. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs index 03f8a50233e..8b8a3210557 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function cell"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); @@ -46,18 +46,17 @@ public Command BuildGetCommand() { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookPivotTableId, int? row, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookPivotTableId, int? row, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookPivotTableIdOption, rowOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookPivotTableIdOption, rowOption, columnOption, outputOption); return command; } /// @@ -92,17 +91,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function cell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class CellWithRowWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Worksheet/Range/RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Worksheet/Range/RangeRequestBuilder.cs index bec3660a6c5..9abe68173ff 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Worksheet/Range/RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Worksheet/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookPivotTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookPivotTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookPivotTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookPivotTableIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs index 9b001710f2b..3d164109a53 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); @@ -42,18 +42,17 @@ public Command BuildGetCommand() { }; addressOption.IsRequired = true; command.AddOption(addressOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookPivotTableId, string address) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookPivotTableId, string address, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookPivotTableIdOption, addressOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookPivotTableIdOption, addressOption, outputOption); return command; } /// @@ -86,17 +85,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeWithAddressResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs index 0c586c7e13f..5beac2f2a5e 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookPivotTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookPivotTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookPivotTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookPivotTableIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs index 6849798ec14..85003deaf17 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,34 +26,33 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); - var valuesOnlyOption = new Option("--valuesonly", description: "Usage: valuesOnly={valuesOnly}") { + var valuesOnlyOption = new Option("--values-only", description: "Usage: valuesOnly={valuesOnly}") { }; valuesOnlyOption.IsRequired = true; command.AddOption(valuesOnlyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookPivotTableId, bool? valuesOnly) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookPivotTableId, bool? valuesOnly, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookPivotTableIdOption, valuesOnlyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookPivotTableIdOption, valuesOnlyOption, outputOption); return command; } /// @@ -86,17 +85,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeWithValuesOnlyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Worksheet/WorksheetRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Worksheet/WorksheetRequestBuilder.cs index cc746233d86..e306f7a54e2 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Worksheet/WorksheetRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/Item/Worksheet/WorksheetRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.PivotTables.Item.Worksheet.UsedRangeWithValuesOnly; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,23 +31,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The worksheet containing the current PivotTable. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookPivotTableId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookPivotTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookPivotTableIdOption); return command; @@ -59,15 +58,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The worksheet containing the current PivotTable. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); @@ -81,20 +80,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookPivotTableId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookPivotTableId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookPivotTableIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookPivotTableIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,15 +102,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The worksheet containing the current PivotTable. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookPivotTableIdOption = new Option("--workbookpivottable-id", description: "key: id of workbookPivotTable") { + var workbookPivotTableIdOption = new Option("--workbook-pivot-table-id", description: "key: id of workbookPivotTable") { }; workbookPivotTableIdOption.IsRequired = true; command.AddOption(workbookPivotTableIdOption); @@ -120,14 +118,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookPivotTableId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookPivotTableId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookPivotTableIdOption, bodyOption); return command; @@ -210,42 +207,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookWorksheet body, return requestInfo; } /// - /// The worksheet containing the current PivotTable. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The worksheet containing the current PivotTable. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The worksheet containing the current PivotTable. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookWorksheet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\pivotTables\{workbookPivotTable-id}\worksheet\microsoft.graph.range() /// public RangeRequestBuilder Range() { diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/PivotTablesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/PivotTablesRequestBuilder.cs index 501fa443515..cacbee7ff4e 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/PivotTablesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/PivotTablesRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.PivotTables.RefreshAll; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,13 +23,12 @@ public class PivotTablesRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new WorkbookPivotTableRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildRefreshCommand(), - builder.BuildWorksheetCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildRefreshCommand()); + commands.Add(builder.BuildWorksheetCommand()); return commands; } /// @@ -39,11 +38,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Collection of PivotTables that are part of the worksheet."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); @@ -51,21 +50,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, bodyOption, outputOption); return command; } /// @@ -75,11 +73,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Collection of PivotTables that are part of the worksheet."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); @@ -118,7 +116,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -129,15 +131,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } public Command BuildRefreshAllCommand() { @@ -198,31 +195,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookPivotTable body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Collection of PivotTables that are part of the worksheet. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of PivotTables that are part of the worksheet. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookPivotTable model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of PivotTables that are part of the worksheet. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/RefreshAll/RefreshAllRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/RefreshAll/RefreshAllRequestBuilder.cs index 741371f46c7..7340f0b55e6 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/RefreshAll/RefreshAllRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/PivotTables/RefreshAll/RefreshAllRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,18 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action refreshAll"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action refreshAll - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Protection/Protect/ProtectRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Protection/Protect/ProtectRequestBuilder.cs index 015201740d7..4c0507f58e0 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Protection/Protect/ProtectRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Protection/Protect/ProtectRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,11 +25,11 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action protect"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); @@ -37,14 +37,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, bodyOption); return command; @@ -80,18 +79,5 @@ public RequestInformation CreatePostRequestInformation(ProtectRequestBody body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action protect - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ProtectRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Protection/ProtectionRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Protection/ProtectionRequestBuilder.cs index 041f07dfcc7..57d1ab2e849 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Protection/ProtectionRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Protection/ProtectionRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Protection.Unprotect; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -28,19 +28,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Returns sheet protection object for a worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption); return command; @@ -52,11 +51,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Returns sheet protection object for a worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); @@ -70,20 +69,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -93,11 +91,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Returns sheet protection object for a worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); @@ -105,14 +103,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, bodyOption); return command; @@ -196,42 +193,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookWorksheetProtect requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Returns sheet protection object for a worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns sheet protection object for a worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Returns sheet protection object for a worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookWorksheetProtection model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Returns sheet protection object for a worksheet. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Protection/Unprotect/UnprotectRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Protection/Unprotect/UnprotectRequestBuilder.cs index 555717a436e..9df00516e92 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Protection/Unprotect/UnprotectRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Protection/Unprotect/UnprotectRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,18 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action unprotect"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption); return command; @@ -70,16 +69,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action unprotect - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Range/RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Range/RangeRequestBuilder.cs index 3bd54a09515..57bad86c6bc 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Range/RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/RangeWithAddress/RangeWithAddressRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/RangeWithAddress/RangeWithAddressRequestBuilder.cs index f75c98e90a5..d3e2a7b1170 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/RangeWithAddress/RangeWithAddressRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/RangeWithAddress/RangeWithAddressRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; addressOption.IsRequired = true; command.AddOption(addressOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string address) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string address, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, addressOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, addressOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeWithAddressResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/@Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/@Add/AddRequestBody.cs deleted file mode 100644 index 3670e161211..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/@Add/AddRequestBody.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.@Add { - public class AddRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public string Address { get; set; } - public bool? HasHeaders { get; set; } - /// - /// Instantiates a new addRequestBody and sets the default values. - /// - public AddRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"address", (o,n) => { (o as AddRequestBody).Address = n.GetStringValue(); } }, - {"hasHeaders", (o,n) => { (o as AddRequestBody).HasHeaders = n.GetBoolValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteStringValue("address", Address); - writer.WriteBoolValue("hasHeaders", HasHeaders); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/@Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/@Add/AddRequestBuilder.cs deleted file mode 100644 index d36095aa135..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/@Add/AddRequestBuilder.cs +++ /dev/null @@ -1,133 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.@Add { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\tables\microsoft.graph.add - public class AddRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action add - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action add"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { - }; - workbookWorksheetIdOption.IsRequired = true; - command.AddOption(workbookWorksheetIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AddRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/worksheets/{workbookWorksheet_id}/tables/microsoft.graph.add"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action add - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action add - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookTable - public class AddResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookTable - public WorkbookTable WorkbookTable { get; set; } - /// - /// Instantiates a new addResponse and sets the default values. - /// - public AddResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookTable", (o,n) => { (o as AddResponse).WorkbookTable = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookTable", WorkbookTable); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Add/AddRequestBody.cs new file mode 100644 index 00000000000..8664123540f --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Add/AddRequestBody.cs @@ -0,0 +1,38 @@ +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.Add { + public class AddRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public string Address { get; set; } + public bool? HasHeaders { get; set; } + /// + /// Instantiates a new addRequestBody and sets the default values. + /// + public AddRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"address", (o,n) => { (o as AddRequestBody).Address = n.GetStringValue(); } }, + {"hasHeaders", (o,n) => { (o as AddRequestBody).HasHeaders = n.GetBoolValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("address", Address); + writer.WriteBoolValue("hasHeaders", HasHeaders); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Add/AddRequestBuilder.cs new file mode 100644 index 00000000000..fd2a5d52439 --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Add/AddRequestBuilder.cs @@ -0,0 +1,119 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.Add { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\tables\microsoft.graph.add + public class AddRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action add + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action add"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { + }; + workbookWorksheetIdOption.IsRequired = true; + command.AddOption(workbookWorksheetIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new AddRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/worksheets/{workbookWorksheet_id}/tables/microsoft.graph.add"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action add + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookTable + public class AddResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookTable + public WorkbookTable WorkbookTable { get; set; } + /// + /// Instantiates a new addResponse and sets the default values. + /// + public AddResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookTable", (o,n) => { (o as AddResponse).WorkbookTable = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookTable", WorkbookTable); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Count/CountRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Count/CountRequestBuilder.cs index 80bdf310622..c8428c63d28 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Count/CountRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Count/CountRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,26 +25,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function count"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteIntValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, outputOption); return command; } /// @@ -75,16 +74,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function count - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/ClearFilters/ClearFiltersRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/ClearFilters/ClearFiltersRequestBuilder.cs index 7b462a3d5f3..e67bbbf02c1 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/ClearFilters/ClearFiltersRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/ClearFilters/ClearFiltersRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clearFilters"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clearFilters - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/@Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/@Add/AddRequestBody.cs deleted file mode 100644 index d15aa03fc25..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/@Add/AddRequestBody.cs +++ /dev/null @@ -1,42 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.Item.Columns.@Add { - public class AddRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public int? Index { get; set; } - public string Name { get; set; } - public Json Values { get; set; } - /// - /// Instantiates a new addRequestBody and sets the default values. - /// - public AddRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"index", (o,n) => { (o as AddRequestBody).Index = n.GetIntValue(); } }, - {"name", (o,n) => { (o as AddRequestBody).Name = n.GetStringValue(); } }, - {"values", (o,n) => { (o as AddRequestBody).Values = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteIntValue("index", Index); - writer.WriteStringValue("name", Name); - writer.WriteObjectValue("values", Values); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/@Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/@Add/AddRequestBuilder.cs deleted file mode 100644 index 83dfadfd821..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/@Add/AddRequestBuilder.cs +++ /dev/null @@ -1,137 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.Item.Columns.@Add { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\tables\{workbookTable-id}\columns\microsoft.graph.add - public class AddRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action add - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action add"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { - }; - workbookWorksheetIdOption.IsRequired = true; - command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { - }; - workbookTableIdOption.IsRequired = true; - command.AddOption(workbookTableIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AddRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/worksheets/{workbookWorksheet_id}/tables/{workbookTable_id}/columns/microsoft.graph.add"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action add - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action add - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookTableColumn - public class AddResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookTableColumn - public WorkbookTableColumn WorkbookTableColumn { get; set; } - /// - /// Instantiates a new addResponse and sets the default values. - /// - public AddResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookTableColumn", (o,n) => { (o as AddResponse).WorkbookTableColumn = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookTableColumn", WorkbookTableColumn); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Add/AddRequestBody.cs new file mode 100644 index 00000000000..9b35e8a1d35 --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Add/AddRequestBody.cs @@ -0,0 +1,42 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.Item.Columns.Add { + public class AddRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public int? Index { get; set; } + public string Name { get; set; } + public Json Values { get; set; } + /// + /// Instantiates a new addRequestBody and sets the default values. + /// + public AddRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"index", (o,n) => { (o as AddRequestBody).Index = n.GetIntValue(); } }, + {"name", (o,n) => { (o as AddRequestBody).Name = n.GetStringValue(); } }, + {"values", (o,n) => { (o as AddRequestBody).Values = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteIntValue("index", Index); + writer.WriteStringValue("name", Name); + writer.WriteObjectValue("values", Values); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Add/AddRequestBuilder.cs new file mode 100644 index 00000000000..74215c95b27 --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Add/AddRequestBuilder.cs @@ -0,0 +1,123 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.Item.Columns.Add { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\tables\{workbookTable-id}\columns\microsoft.graph.add + public class AddRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action add + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action add"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { + }; + workbookWorksheetIdOption.IsRequired = true; + command.AddOption(workbookWorksheetIdOption); + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { + }; + workbookTableIdOption.IsRequired = true; + command.AddOption(workbookTableIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new AddRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/worksheets/{workbookWorksheet_id}/tables/{workbookTable_id}/columns/microsoft.graph.add"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action add + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookTableColumn + public class AddResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookTableColumn + public WorkbookTableColumn WorkbookTableColumn { get; set; } + /// + /// Instantiates a new addResponse and sets the default values. + /// + public AddResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookTableColumn", (o,n) => { (o as AddResponse).WorkbookTableColumn = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookTableColumn", WorkbookTableColumn); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/ColumnsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/ColumnsRequestBuilder.cs index bcde5fce0d3..78cd01b507e 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/ColumnsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/ColumnsRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.Item.Columns.ItemAtWithIndex; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,18 +25,17 @@ public class ColumnsRequestBuilder { private string UrlTemplate { get; set; } public Command BuildAddCommand() { var command = new Command("add"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.Item.Columns.@Add.AddRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.Item.Columns.Add.AddRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } public List BuildCommand() { var builder = new WorkbookTableColumnRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildFilterCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFilterCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -46,15 +45,15 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Represents a collection of all the columns in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -62,21 +61,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, bodyOption, outputOption); return command; } /// @@ -86,15 +84,15 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Represents a collection of all the columns in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -133,7 +131,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -144,15 +146,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -214,18 +211,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookTableColumn body, return requestInfo; } /// - /// Represents a collection of all the columns in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\tables\{workbookTable-id}\columns\microsoft.graph.itemAt(index={index}) /// Usage: index={index} /// @@ -233,19 +218,6 @@ public ItemAtWithIndexRequestBuilder ItemAtWithIndex(int? index) { _ = index ?? throw new ArgumentNullException(nameof(index)); return new ItemAtWithIndexRequestBuilder(PathParameters, RequestAdapter, index); } - /// - /// Represents a collection of all the columns in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookTableColumn model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents a collection of all the columns in the table. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Count/CountRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Count/CountRequestBuilder.cs index a22cddb53bd..90dd405e1b9 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Count/CountRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Count/CountRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,30 +25,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function count"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteIntValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -79,16 +78,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function count - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs index 15ea48178f4..ee500e61579 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,34 +26,33 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function dataBodyRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function dataBodyRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class DataBodyRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/Apply/ApplyRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/Apply/ApplyRequestBuilder.cs index dc52ea5f21a..fceaa8ac27b 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/Apply/ApplyRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/Apply/ApplyRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action apply"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ApplyRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action apply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyBottomItemsFilter/ApplyBottomItemsFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyBottomItemsFilter/ApplyBottomItemsFilterRequestBuilder.cs index d2b085f36d1..8db4db945c1 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyBottomItemsFilter/ApplyBottomItemsFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyBottomItemsFilter/ApplyBottomItemsFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyBottomItemsFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ApplyBottomItemsFilterReq requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyBottomItemsFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyBottomItemsFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyBottomPercentFilter/ApplyBottomPercentFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyBottomPercentFilter/ApplyBottomPercentFilterRequestBuilder.cs index 75bf26920dd..821040cf78d 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyBottomPercentFilter/ApplyBottomPercentFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyBottomPercentFilter/ApplyBottomPercentFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyBottomPercentFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ApplyBottomPercentFilterR requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyBottomPercentFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyBottomPercentFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyCellColorFilter/ApplyCellColorFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyCellColorFilter/ApplyCellColorFilterRequestBuilder.cs index cce3f12ccec..fa39b5ba203 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyCellColorFilter/ApplyCellColorFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyCellColorFilter/ApplyCellColorFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyCellColorFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ApplyCellColorFilterReque requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyCellColorFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyCellColorFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyCustomFilter/ApplyCustomFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyCustomFilter/ApplyCustomFilterRequestBuilder.cs index 8996509a233..51b9662a12f 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyCustomFilter/ApplyCustomFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyCustomFilter/ApplyCustomFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyCustomFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ApplyCustomFilterRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyCustomFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyCustomFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyDynamicFilter/ApplyDynamicFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyDynamicFilter/ApplyDynamicFilterRequestBuilder.cs index 3c7b8be0ebb..66738dcf9a9 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyDynamicFilter/ApplyDynamicFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyDynamicFilter/ApplyDynamicFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyDynamicFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ApplyDynamicFilterRequest requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyDynamicFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyDynamicFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyFontColorFilter/ApplyFontColorFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyFontColorFilter/ApplyFontColorFilterRequestBuilder.cs index f863e81cc2a..00e2249d2aa 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyFontColorFilter/ApplyFontColorFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyFontColorFilter/ApplyFontColorFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyFontColorFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ApplyFontColorFilterReque requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyFontColorFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyFontColorFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyIconFilter/ApplyIconFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyIconFilter/ApplyIconFilterRequestBuilder.cs index 93422617154..3a34a661c8c 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyIconFilter/ApplyIconFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyIconFilter/ApplyIconFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyIconFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ApplyIconFilterRequestBod requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyIconFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyIconFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyTopItemsFilter/ApplyTopItemsFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyTopItemsFilter/ApplyTopItemsFilterRequestBuilder.cs index 008489a06d6..9287b74310d 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyTopItemsFilter/ApplyTopItemsFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyTopItemsFilter/ApplyTopItemsFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyTopItemsFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ApplyTopItemsFilterReques requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyTopItemsFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyTopItemsFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyTopPercentFilter/ApplyTopPercentFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyTopPercentFilter/ApplyTopPercentFilterRequestBuilder.cs index 77ee829c0b9..4f32d438cd2 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyTopPercentFilter/ApplyTopPercentFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyTopPercentFilter/ApplyTopPercentFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyTopPercentFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ApplyTopPercentFilterRequ requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyTopPercentFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyTopPercentFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyValuesFilter/ApplyValuesFilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyValuesFilter/ApplyValuesFilterRequestBuilder.cs index 9893e2aed27..4451d42b2d9 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyValuesFilter/ApplyValuesFilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/ApplyValuesFilter/ApplyValuesFilterRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,19 +25,19 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action applyValuesFilter"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -45,14 +45,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -88,18 +87,5 @@ public RequestInformation CreatePostRequestInformation(ApplyValuesFilterRequestB requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action applyValuesFilter - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyValuesFilterRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/Clear/ClearRequestBuilder.cs index 37fc4a26f49..a5544c4c947 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,27 +25,26 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption); return command; @@ -78,16 +77,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/FilterRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/FilterRequestBuilder.cs index 8225bb046dc..8ee0ae01c63 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/FilterRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Filter/FilterRequestBuilder.cs @@ -13,10 +13,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.Item.Columns.Item.Filter.Clear; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -110,27 +110,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Retrieve the filter applied to the column. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption); return command; @@ -142,19 +141,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Retrieve the filter applied to the column. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -168,20 +167,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -191,19 +189,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Retrieve the filter applied to the column. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -211,14 +209,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -290,42 +287,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookFilter body, Act requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Retrieve the filter applied to the column. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Retrieve the filter applied to the column. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Retrieve the filter applied to the column. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookFilter model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Retrieve the filter applied to the column. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs index 8144c33beaf..9e53c6d380c 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,34 +26,33 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function headerRowRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function headerRowRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class HeaderRowRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Range/RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Range/RangeRequestBuilder.cs index ae4cd581132..cee46761715 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Range/RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,34 +26,33 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs index b08e9d01647..6e3471a2540 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,34 +26,33 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function totalRowRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function totalRowRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class TotalRowRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/WorkbookTableColumnRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/WorkbookTableColumnRequestBuilder.cs index 8bc1a2fc507..18224f62248 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/WorkbookTableColumnRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/Item/WorkbookTableColumnRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.Item.Columns.Item.TotalRowRange; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,27 +31,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents a collection of all the columns in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption); return command; @@ -83,19 +82,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents a collection of all the columns in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -109,20 +108,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -132,19 +130,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents a collection of all the columns in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableColumnIdOption = new Option("--workbooktablecolumn-id", description: "key: id of workbookTableColumn") { + var workbookTableColumnIdOption = new Option("--workbook-table-column-id", description: "key: id of workbookTableColumn") { }; workbookTableColumnIdOption.IsRequired = true; command.AddOption(workbookTableColumnIdOption); @@ -152,14 +150,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableColumnId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableColumnIdOption, bodyOption); return command; @@ -238,48 +235,12 @@ public DataBodyRangeRequestBuilder DataBodyRange() { return new DataBodyRangeRequestBuilder(PathParameters, RequestAdapter); } /// - /// Represents a collection of all the columns in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a collection of all the columns in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\tables\{workbookTable-id}\columns\{workbookTableColumn-id}\microsoft.graph.headerRowRange() /// public HeaderRowRangeRequestBuilder HeaderRowRange() { return new HeaderRowRangeRequestBuilder(PathParameters, RequestAdapter); } /// - /// Represents a collection of all the columns in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookTableColumn model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\tables\{workbookTable-id}\columns\{workbookTableColumn-id}\microsoft.graph.range() /// public RangeRequestBuilder Range() { diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs index b3aff74c94a..f50c038d398 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Columns/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function itemAt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -42,18 +42,17 @@ public Command BuildGetCommand() { }; indexOption.IsRequired = true; command.AddOption(indexOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, int? index) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, int? index, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, indexOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, indexOption, outputOption); return command; } /// @@ -86,17 +85,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function itemAt - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookTableColumn public class ItemAtWithIndexResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/ConvertToRange/ConvertToRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/ConvertToRange/ConvertToRangeRequestBuilder.cs index bb740feb229..1b1f73e0c55 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/ConvertToRange/ConvertToRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/ConvertToRange/ConvertToRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action convertToRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action convertToRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class ConvertToRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs index 5106e101e70..1760d417afc 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/DataBodyRange/DataBodyRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function dataBodyRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function dataBodyRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class DataBodyRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs index a37b3478f33..8c3ed9fd144 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/HeaderRowRange/HeaderRowRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function headerRowRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function headerRowRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class HeaderRowRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Range/RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Range/RangeRequestBuilder.cs index 7f21be5b5a4..cba18f554b7 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Range/RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/ReapplyFilters/ReapplyFiltersRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/ReapplyFilters/ReapplyFiltersRequestBuilder.cs index 77525ac0417..e51ed6897d2 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/ReapplyFilters/ReapplyFiltersRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/ReapplyFilters/ReapplyFiltersRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action reapplyFilters"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action reapplyFilters - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/@Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/@Add/AddRequestBody.cs deleted file mode 100644 index f32bcab1c3a..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/@Add/AddRequestBody.cs +++ /dev/null @@ -1,39 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -namespace ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.Item.Rows.@Add { - public class AddRequestBody : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - public int? Index { get; set; } - public Json Values { get; set; } - /// - /// Instantiates a new addRequestBody and sets the default values. - /// - public AddRequestBody() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"index", (o,n) => { (o as AddRequestBody).Index = n.GetIntValue(); } }, - {"values", (o,n) => { (o as AddRequestBody).Values = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteIntValue("index", Index); - writer.WriteObjectValue("values", Values); - writer.WriteAdditionalData(AdditionalData); - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/@Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/@Add/AddRequestBuilder.cs deleted file mode 100644 index f627494e74a..00000000000 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/@Add/AddRequestBuilder.cs +++ /dev/null @@ -1,137 +0,0 @@ -using ApiSdk.Models.Microsoft.Graph; -using Microsoft.Kiota.Abstractions; -using Microsoft.Kiota.Abstractions.Serialization; -using System; -using System.Collections.Generic; -using System.CommandLine; -using System.CommandLine.Invocation; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -namespace ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.Item.Rows.@Add { - /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\tables\{workbookTable-id}\rows\microsoft.graph.add - public class AddRequestBuilder { - /// Path parameters for the request - private Dictionary PathParameters { get; set; } - /// The request adapter to use to execute the requests. - private IRequestAdapter RequestAdapter { get; set; } - /// Url template to use to build the URL for the current request builder - private string UrlTemplate { get; set; } - /// - /// Invoke action add - /// - public Command BuildPostCommand() { - var command = new Command("post"); - command.Description = "Invoke action add"; - // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { - }; - driveItemIdOption.IsRequired = true; - command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { - }; - workbookWorksheetIdOption.IsRequired = true; - command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { - }; - workbookTableIdOption.IsRequired = true; - command.AddOption(workbookTableIdOption); - var bodyOption = new Option("--body") { - }; - bodyOption.IsRequired = true; - command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string body) => { - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); - var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); - var model = parseNode.GetObjectValue(); - var requestInfo = CreatePostRequestInformation(model, q => { - }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, bodyOption); - return command; - } - /// - /// Instantiates a new AddRequestBuilder and sets the default values. - /// Path parameters for the request - /// The request adapter to use to execute the requests. - /// - public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { - _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); - _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/worksheets/{workbookWorksheet_id}/tables/{workbookTable_id}/rows/microsoft.graph.add"; - var urlTplParams = new Dictionary(pathParameters); - PathParameters = urlTplParams; - RequestAdapter = requestAdapter; - } - /// - /// Invoke action add - /// - /// Request headers - /// Request options - /// - public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { - _ = body ?? throw new ArgumentNullException(nameof(body)); - var requestInfo = new RequestInformation { - HttpMethod = Method.POST, - UrlTemplate = UrlTemplate, - PathParameters = PathParameters, - }; - requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); - h?.Invoke(requestInfo.Headers); - requestInfo.AddRequestOptions(o?.ToArray()); - return requestInfo; - } - /// - /// Invoke action add - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(AddRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// Union type wrapper for classes workbookTableRow - public class AddResponse : IParsable { - /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. - public IDictionary AdditionalData { get; set; } - /// Union type representation for type workbookTableRow - public WorkbookTableRow WorkbookTableRow { get; set; } - /// - /// Instantiates a new addResponse and sets the default values. - /// - public AddResponse() { - AdditionalData = new Dictionary(); - } - /// - /// The deserialization information for the current model - /// - public IDictionary> GetFieldDeserializers() { - return new Dictionary> { - {"workbookTableRow", (o,n) => { (o as AddResponse).WorkbookTableRow = n.GetObjectValue(); } }, - }; - } - /// - /// Serializes information the current object - /// Serialization writer to use to serialize this model - /// - public void Serialize(ISerializationWriter writer) { - _ = writer ?? throw new ArgumentNullException(nameof(writer)); - writer.WriteObjectValue("workbookTableRow", WorkbookTableRow); - writer.WriteAdditionalData(AdditionalData); - } - } - } -} diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/Add/AddRequestBody.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/Add/AddRequestBody.cs new file mode 100644 index 00000000000..800df7deb76 --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/Add/AddRequestBody.cs @@ -0,0 +1,39 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +namespace ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.Item.Rows.Add { + public class AddRequestBody : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + public int? Index { get; set; } + public Json Values { get; set; } + /// + /// Instantiates a new addRequestBody and sets the default values. + /// + public AddRequestBody() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"index", (o,n) => { (o as AddRequestBody).Index = n.GetIntValue(); } }, + {"values", (o,n) => { (o as AddRequestBody).Values = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteIntValue("index", Index); + writer.WriteObjectValue("values", Values); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/Add/AddRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/Add/AddRequestBuilder.cs new file mode 100644 index 00000000000..fd9d6604162 --- /dev/null +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/Add/AddRequestBuilder.cs @@ -0,0 +1,123 @@ +using ApiSdk.Models.Microsoft.Graph; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +namespace ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.Item.Rows.Add { + /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\tables\{workbookTable-id}\rows\microsoft.graph.add + public class AddRequestBuilder { + /// Path parameters for the request + private Dictionary PathParameters { get; set; } + /// The request adapter to use to execute the requests. + private IRequestAdapter RequestAdapter { get; set; } + /// Url template to use to build the URL for the current request builder + private string UrlTemplate { get; set; } + /// + /// Invoke action add + /// + public Command BuildPostCommand() { + var command = new Command("post"); + command.Description = "Invoke action add"; + // Create options for all the parameters + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { + }; + driveItemIdOption.IsRequired = true; + command.AddOption(driveItemIdOption); + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { + }; + workbookWorksheetIdOption.IsRequired = true; + command.AddOption(workbookWorksheetIdOption); + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { + }; + workbookTableIdOption.IsRequired = true; + command.AddOption(workbookTableIdOption); + var bodyOption = new Option("--body") { + }; + bodyOption.IsRequired = true; + command.AddOption(bodyOption); + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); + var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); + var model = parseNode.GetObjectValue(); + var requestInfo = CreatePostRequestInformation(model, q => { + }); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, bodyOption, outputOption); + return command; + } + /// + /// Instantiates a new AddRequestBuilder and sets the default values. + /// Path parameters for the request + /// The request adapter to use to execute the requests. + /// + public AddRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) { + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); + UrlTemplate = "{+baseurl}/workbooks/{driveItem_id}/workbook/worksheets/{workbookWorksheet_id}/tables/{workbookTable_id}/rows/microsoft.graph.add"; + var urlTplParams = new Dictionary(pathParameters); + PathParameters = urlTplParams; + RequestAdapter = requestAdapter; + } + /// + /// Invoke action add + /// + /// Request headers + /// Request options + /// + public RequestInformation CreatePostRequestInformation(AddRequestBody body, Action> h = default, IEnumerable o = default) { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation { + HttpMethod = Method.POST, + UrlTemplate = UrlTemplate, + PathParameters = PathParameters, + }; + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + h?.Invoke(requestInfo.Headers); + requestInfo.AddRequestOptions(o?.ToArray()); + return requestInfo; + } + /// Union type wrapper for classes workbookTableRow + public class AddResponse : IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// Union type representation for type workbookTableRow + public WorkbookTableRow WorkbookTableRow { get; set; } + /// + /// Instantiates a new addResponse and sets the default values. + /// + public AddResponse() { + AdditionalData = new Dictionary(); + } + /// + /// The deserialization information for the current model + /// + public IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"workbookTableRow", (o,n) => { (o as AddResponse).WorkbookTableRow = n.GetObjectValue(); } }, + }; + } + /// + /// Serializes information the current object + /// Serialization writer to use to serialize this model + /// + public void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("workbookTableRow", WorkbookTableRow); + writer.WriteAdditionalData(AdditionalData); + } + } + } +} diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/Count/CountRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/Count/CountRequestBuilder.cs index c075397520f..5b6f4c2a447 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/Count/CountRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/Count/CountRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,30 +25,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function count"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendPrimitiveAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteIntValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -79,16 +78,5 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function count - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendPrimitiveAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/Item/Range/RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/Item/Range/RangeRequestBuilder.cs index a26e35da79f..07de7644524 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/Item/Range/RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/Item/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,34 +26,33 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableRowIdOption = new Option("--workbooktablerow-id", description: "key: id of workbookTableRow") { + var workbookTableRowIdOption = new Option("--workbook-table-row-id", description: "key: id of workbookTableRow") { }; workbookTableRowIdOption.IsRequired = true; command.AddOption(workbookTableRowIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableRowId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableRowId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableRowIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableRowIdOption, outputOption); return command; } /// @@ -84,17 +83,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/Item/WorkbookTableRowRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/Item/WorkbookTableRowRequestBuilder.cs index 4b2ce370f3e..00888ff4c71 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/Item/WorkbookTableRowRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/Item/WorkbookTableRowRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.Item.Rows.Item.Range; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -27,27 +27,26 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents a collection of all the rows in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableRowIdOption = new Option("--workbooktablerow-id", description: "key: id of workbookTableRow") { + var workbookTableRowIdOption = new Option("--workbook-table-row-id", description: "key: id of workbookTableRow") { }; workbookTableRowIdOption.IsRequired = true; command.AddOption(workbookTableRowIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableRowId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableRowId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableRowIdOption); return command; @@ -59,19 +58,19 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents a collection of all the rows in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableRowIdOption = new Option("--workbooktablerow-id", description: "key: id of workbookTableRow") { + var workbookTableRowIdOption = new Option("--workbook-table-row-id", description: "key: id of workbookTableRow") { }; workbookTableRowIdOption.IsRequired = true; command.AddOption(workbookTableRowIdOption); @@ -85,20 +84,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableRowId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableRowId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableRowIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableRowIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -108,19 +106,19 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents a collection of all the rows in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var workbookTableRowIdOption = new Option("--workbooktablerow-id", description: "key: id of workbookTableRow") { + var workbookTableRowIdOption = new Option("--workbook-table-row-id", description: "key: id of workbookTableRow") { }; workbookTableRowIdOption.IsRequired = true; command.AddOption(workbookTableRowIdOption); @@ -128,14 +126,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableRowId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string workbookTableRowId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, workbookTableRowIdOption, bodyOption); return command; @@ -208,42 +205,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookTableRow body, A return requestInfo; } /// - /// Represents a collection of all the rows in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a collection of all the rows in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a collection of all the rows in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookTableRow model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\tables\{workbookTable-id}\rows\{workbookTableRow-id}\microsoft.graph.range() /// public RangeRequestBuilder Range() { diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs index d8a865f238f..5db0e09ac99 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function itemAt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -42,18 +42,17 @@ public Command BuildGetCommand() { }; indexOption.IsRequired = true; command.AddOption(indexOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, int? index) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, int? index, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, indexOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, indexOption, outputOption); return command; } /// @@ -86,17 +85,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function itemAt - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookTableRow public class ItemAtWithIndexResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/RowsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/RowsRequestBuilder.cs index f5a55645bd9..62f92ccad6a 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/RowsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Rows/RowsRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.Item.Rows.ItemAtWithIndex; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,17 +25,16 @@ public class RowsRequestBuilder { private string UrlTemplate { get; set; } public Command BuildAddCommand() { var command = new Command("add"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.Item.Rows.@Add.AddRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.Item.Rows.Add.AddRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } public List BuildCommand() { var builder = new WorkbookTableRowRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); return commands; } /// @@ -45,15 +44,15 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Represents a collection of all the rows in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -61,21 +60,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, bodyOption, outputOption); return command; } /// @@ -85,15 +83,15 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Represents a collection of all the rows in the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -132,7 +130,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -143,15 +145,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -213,18 +210,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookTableRow body, Ac return requestInfo; } /// - /// Represents a collection of all the rows in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\tables\{workbookTable-id}\rows\microsoft.graph.itemAt(index={index}) /// Usage: index={index} /// @@ -232,19 +217,6 @@ public ItemAtWithIndexRequestBuilder ItemAtWithIndex(int? index) { _ = index ?? throw new ArgumentNullException(nameof(index)); return new ItemAtWithIndexRequestBuilder(PathParameters, RequestAdapter, index); } - /// - /// Represents a collection of all the rows in the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookTableRow model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents a collection of all the rows in the table. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Sort/Apply/ApplyRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Sort/Apply/ApplyRequestBuilder.cs index 74032a4b18e..565ab057d64 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Sort/Apply/ApplyRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Sort/Apply/ApplyRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,15 +25,15 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action apply"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -41,14 +41,13 @@ public Command BuildPostCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, bodyOption); return command; @@ -84,18 +83,5 @@ public RequestInformation CreatePostRequestInformation(ApplyRequestBody body, Ac requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Invoke action apply - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApplyRequestBody model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Sort/Clear/ClearRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Sort/Clear/ClearRequestBuilder.cs index 089aa5f90ad..b900186ab60 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Sort/Clear/ClearRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Sort/Clear/ClearRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action clear"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action clear - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Sort/Reapply/ReapplyRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Sort/Reapply/ReapplyRequestBuilder.cs index 98c2ac22621..28afb838a6c 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Sort/Reapply/ReapplyRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Sort/Reapply/ReapplyRequestBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,23 +25,22 @@ public Command BuildPostCommand() { var command = new Command("post"); command.Description = "Invoke action reapply"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreatePostRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption); return command; @@ -74,16 +73,5 @@ public RequestInformation CreatePostRequestInformation(Action - /// Invoke action reapply - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreatePostRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } } } diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Sort/SortRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Sort/SortRequestBuilder.cs index 83131ec0e32..9887289daef 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Sort/SortRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Sort/SortRequestBuilder.cs @@ -4,10 +4,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.Item.Sort.Reapply; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -41,23 +41,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents the sorting for the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption); return command; @@ -69,15 +68,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents the sorting for the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -91,20 +90,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -114,15 +112,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents the sorting for the table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -130,14 +128,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, bodyOption); return command; @@ -215,42 +212,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookTableSort body, requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents the sorting for the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the sorting for the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents the sorting for the table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookTableSort model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents the sorting for the table. Read-only. public class GetQueryParameters : QueryParametersBase { /// Expand related entities diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs index 73df22d324c..daba55d2e7a 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/TotalRowRange/TotalRowRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function totalRowRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function totalRowRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class TotalRowRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/WorkbookTableRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/WorkbookTableRequestBuilder.cs index a47931a6590..0d04398d59a 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/WorkbookTableRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/WorkbookTableRequestBuilder.cs @@ -12,10 +12,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.Item.Worksheet; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -40,6 +40,9 @@ public Command BuildColumnsCommand() { var command = new Command("columns"); var builder = new ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.Item.Columns.ColumnsRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -57,23 +60,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Collection of tables that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption); return command; @@ -85,15 +87,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Collection of tables that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -107,20 +109,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -130,15 +131,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Collection of tables that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -146,14 +147,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, bodyOption); return command; @@ -168,6 +168,9 @@ public Command BuildRowsCommand() { var command = new Command("rows"); var builder = new ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.Item.Rows.RowsRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -265,48 +268,12 @@ public DataBodyRangeRequestBuilder DataBodyRange() { return new DataBodyRangeRequestBuilder(PathParameters, RequestAdapter); } /// - /// Collection of tables that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Collection of tables that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\tables\{workbookTable-id}\microsoft.graph.headerRowRange() /// public HeaderRowRangeRequestBuilder HeaderRowRange() { return new HeaderRowRangeRequestBuilder(PathParameters, RequestAdapter); } /// - /// Collection of tables that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookTable model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\tables\{workbookTable-id}\microsoft.graph.range() /// public RangeRequestBuilder Range() { diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs index 8d20b735541..70aef49621f 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Worksheet/CellWithRowWithColumn/CellWithRowWithColumnRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function cell"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -46,18 +46,17 @@ public Command BuildGetCommand() { }; columnOption.IsRequired = true; command.AddOption(columnOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, int? row, int? column) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, int? row, int? column, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, rowOption, columnOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, rowOption, columnOption, outputOption); return command; } /// @@ -92,17 +91,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function cell - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class CellWithRowWithColumnResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Worksheet/Range/RangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Worksheet/Range/RangeRequestBuilder.cs index 51d13c0f84a..bcef894cc0e 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Worksheet/Range/RangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Worksheet/Range/RangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs index 06bad40094f..d9281b47ed3 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Worksheet/RangeWithAddress/RangeWithAddressRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,15 +26,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function range"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -42,18 +42,17 @@ public Command BuildGetCommand() { }; addressOption.IsRequired = true; command.AddOption(addressOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string address) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string address, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, addressOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, addressOption, outputOption); return command; } /// @@ -86,17 +85,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function range - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class RangeWithAddressResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs index 824f7f63829..f644d163918 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Worksheet/UsedRange/UsedRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, outputOption); return command; } /// @@ -80,17 +79,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs index 627827e6c81..ae067e5d657 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Worksheet/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,34 +26,33 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - var valuesOnlyOption = new Option("--valuesonly", description: "Usage: valuesOnly={valuesOnly}") { + var valuesOnlyOption = new Option("--values-only", description: "Usage: valuesOnly={valuesOnly}") { }; valuesOnlyOption.IsRequired = true; command.AddOption(valuesOnlyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, bool? valuesOnly) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, bool? valuesOnly, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, valuesOnlyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, valuesOnlyOption, outputOption); return command; } /// @@ -86,17 +85,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeWithValuesOnlyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Worksheet/WorksheetRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Worksheet/WorksheetRequestBuilder.cs index 8582068f23e..87ef88011f5 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Worksheet/WorksheetRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/Item/Worksheet/WorksheetRequestBuilder.cs @@ -6,10 +6,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.Item.Worksheet.UsedRangeWithValuesOnly; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -31,23 +31,22 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "The worksheet containing the current table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption); return command; @@ -59,15 +58,15 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "The worksheet containing the current table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -81,20 +80,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, selectOption, expandOption, outputOption); return command; } /// @@ -104,15 +102,15 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "The worksheet containing the current table. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var workbookTableIdOption = new Option("--workbooktable-id", description: "key: id of workbookTable") { + var workbookTableIdOption = new Option("--workbook-table-id", description: "key: id of workbookTable") { }; workbookTableIdOption.IsRequired = true; command.AddOption(workbookTableIdOption); @@ -120,14 +118,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string workbookTableId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, workbookTableIdOption, bodyOption); return command; @@ -210,42 +207,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookWorksheet body, return requestInfo; } /// - /// The worksheet containing the current table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The worksheet containing the current table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// The worksheet containing the current table. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookWorksheet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\tables\{workbookTable-id}\worksheet\microsoft.graph.range() /// public RangeRequestBuilder Range() { diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs index ca8c8a27a78..2f4726432ba 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/ItemAtWithIndex/ItemAtWithIndexRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,11 +26,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function itemAt"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); @@ -38,18 +38,17 @@ public Command BuildGetCommand() { }; indexOption.IsRequired = true; command.AddOption(indexOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, int? index) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, int? index, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, indexOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, indexOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function itemAt - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookTable public class ItemAtWithIndexResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/TablesRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/TablesRequestBuilder.cs index 5662f76b586..22ab8c3e227 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/TablesRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/Tables/TablesRequestBuilder.cs @@ -5,10 +5,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.ItemAtWithIndex; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -25,24 +25,23 @@ public class TablesRequestBuilder { private string UrlTemplate { get; set; } public Command BuildAddCommand() { var command = new Command("add"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.@Add.AddRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.Add.AddRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } public List BuildCommand() { var builder = new WorkbookTableRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildClearFiltersCommand(), - builder.BuildColumnsCommand(), - builder.BuildConvertToRangeCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildPatchCommand(), - builder.BuildReapplyFiltersCommand(), - builder.BuildRowsCommand(), - builder.BuildSortCommand(), - builder.BuildWorksheetCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildClearFiltersCommand()); + commands.Add(builder.BuildColumnsCommand()); + commands.Add(builder.BuildConvertToRangeCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildReapplyFiltersCommand()); + commands.Add(builder.BuildRowsCommand()); + commands.Add(builder.BuildSortCommand()); + commands.Add(builder.BuildWorksheetCommand()); return commands; } /// @@ -52,11 +51,11 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Collection of tables that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); @@ -64,21 +63,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, bodyOption, outputOption); return command; } /// @@ -88,11 +86,11 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Collection of tables that are part of the worksheet. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); @@ -131,7 +129,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -142,15 +144,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -212,18 +209,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookTable body, Actio return requestInfo; } /// - /// Collection of tables that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\tables\microsoft.graph.itemAt(index={index}) /// Usage: index={index} /// @@ -231,19 +216,6 @@ public ItemAtWithIndexRequestBuilder ItemAtWithIndex(int? index) { _ = index ?? throw new ArgumentNullException(nameof(index)); return new ItemAtWithIndexRequestBuilder(PathParameters, RequestAdapter, index); } - /// - /// Collection of tables that are part of the worksheet. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookTable model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Collection of tables that are part of the worksheet. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/UsedRange/UsedRangeRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/UsedRange/UsedRangeRequestBuilder.cs index ad82d445a00..83ae89277f9 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/UsedRange/UsedRangeRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/UsedRange/UsedRangeRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,26 +26,25 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, outputOption); return command; } /// @@ -76,17 +75,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs index f4372156682..52eaea3d47a 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/UsedRangeWithValuesOnly/UsedRangeWithValuesOnlyRequestBuilder.cs @@ -1,10 +1,10 @@ using ApiSdk.Models.Microsoft.Graph; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -26,30 +26,29 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Invoke function usedRange"; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - var valuesOnlyOption = new Option("--valuesonly", description: "Usage: valuesOnly={valuesOnly}") { + var valuesOnlyOption = new Option("--values-only", description: "Usage: valuesOnly={valuesOnly}") { }; valuesOnlyOption.IsRequired = true; command.AddOption(valuesOnlyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, bool? valuesOnly) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, bool? valuesOnly, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, valuesOnlyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, valuesOnlyOption, outputOption); return command; } /// @@ -82,17 +81,6 @@ public RequestInformation CreateGetRequestInformation(Action - /// Invoke function usedRange - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Union type wrapper for classes workbookRange public class UsedRangeWithValuesOnlyResponse : IParsable { /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/WorkbookWorksheetRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/WorkbookWorksheetRequestBuilder.cs index 06d7fd89f4d..06460edab7b 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/Item/WorkbookWorksheetRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/Item/WorkbookWorksheetRequestBuilder.cs @@ -11,10 +11,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.UsedRangeWithValuesOnly; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -33,6 +33,9 @@ public Command BuildChartsCommand() { var command = new Command("charts"); var builder = new ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Charts.ChartsRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -44,19 +47,18 @@ public Command BuildDeleteCommand() { var command = new Command("delete"); command.Description = "Represents a collection of worksheets associated with the workbook. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateDeleteRequestInformation(q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption); return command; @@ -68,11 +70,11 @@ public Command BuildGetCommand() { var command = new Command("get"); command.Description = "Represents a collection of worksheets associated with the workbook. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); @@ -86,20 +88,19 @@ public Command BuildGetCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, workbookWorksheetIdOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, workbookWorksheetIdOption, selectOption, expandOption, outputOption); return command; } public Command BuildNamesCommand() { @@ -107,6 +108,9 @@ public Command BuildNamesCommand() { var builder = new ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Names.NamesRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCommand()); command.AddCommand(builder.BuildAddFormulaLocalCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -118,11 +122,11 @@ public Command BuildPatchCommand() { var command = new Command("patch"); command.Description = "Represents a collection of worksheets associated with the workbook. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); - var workbookWorksheetIdOption = new Option("--workbookworksheet-id", description: "key: id of workbookWorksheet") { + var workbookWorksheetIdOption = new Option("--workbook-worksheet-id", description: "key: id of workbookWorksheet") { }; workbookWorksheetIdOption.IsRequired = true; command.AddOption(workbookWorksheetIdOption); @@ -130,14 +134,13 @@ public Command BuildPatchCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string workbookWorksheetId, string body) => { + command.SetHandler(async (string driveItemId, string workbookWorksheetId, string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePatchRequestInformation(model, q => { }); - await RequestAdapter.SendNoContentAsync(requestInfo); - // Print request output. What if the request has no return? + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); Console.WriteLine("Success"); }, driveItemIdOption, workbookWorksheetIdOption, bodyOption); return command; @@ -145,6 +148,9 @@ public Command BuildPatchCommand() { public Command BuildPivotTablesCommand() { var command = new Command("pivot-tables"); var builder = new ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.PivotTables.PivotTablesRequestBuilder(PathParameters, RequestAdapter); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); command.AddCommand(builder.BuildRefreshAllCommand()); @@ -164,6 +170,9 @@ public Command BuildTablesCommand() { var command = new Command("tables"); var builder = new ApiSdk.Workbooks.Item.Workbook.Worksheets.Item.Tables.TablesRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildAddCommand()); + foreach (var cmd in builder.BuildCommand()) { + command.AddCommand(cmd); + } command.AddCommand(builder.BuildCreateCommand()); command.AddCommand(builder.BuildListCommand()); return command; @@ -246,42 +255,6 @@ public RequestInformation CreatePatchRequestInformation(WorkbookWorksheet body, return requestInfo; } /// - /// Represents a collection of worksheets associated with the workbook. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task DeleteAsync(Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateDeleteRequestInformation(h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a collection of worksheets associated with the workbook. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a collection of worksheets associated with the workbook. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PatchAsync(WorkbookWorksheet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePatchRequestInformation(model, h, o); - await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken); - } - /// /// Builds and executes requests for operations under \workbooks\{driveItem-id}\workbook\worksheets\{workbookWorksheet-id}\microsoft.graph.range() /// public RangeRequestBuilder Range() { diff --git a/src/generated/Workbooks/Item/Workbook/Worksheets/WorksheetsRequestBuilder.cs b/src/generated/Workbooks/Item/Workbook/Worksheets/WorksheetsRequestBuilder.cs index 2921d7e0567..6792b8a2f2e 100644 --- a/src/generated/Workbooks/Item/Workbook/Worksheets/WorksheetsRequestBuilder.cs +++ b/src/generated/Workbooks/Item/Workbook/Worksheets/WorksheetsRequestBuilder.cs @@ -3,10 +3,10 @@ using ApiSdk.Workbooks.Item.Workbook.Worksheets.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -23,22 +23,21 @@ public class WorksheetsRequestBuilder { private string UrlTemplate { get; set; } public Command BuildAddCommand() { var command = new Command("add"); - var builder = new ApiSdk.Workbooks.Item.Workbook.Worksheets.@Add.AddRequestBuilder(PathParameters, RequestAdapter); + var builder = new ApiSdk.Workbooks.Item.Workbook.Worksheets.Add.AddRequestBuilder(PathParameters, RequestAdapter); command.AddCommand(builder.BuildPostCommand()); return command; } public List BuildCommand() { var builder = new WorkbookWorksheetRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildChartsCommand(), - builder.BuildDeleteCommand(), - builder.BuildGetCommand(), - builder.BuildNamesCommand(), - builder.BuildPatchCommand(), - builder.BuildPivotTablesCommand(), - builder.BuildProtectionCommand(), - builder.BuildTablesCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildChartsCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildNamesCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPivotTablesCommand()); + commands.Add(builder.BuildProtectionCommand()); + commands.Add(builder.BuildTablesCommand()); return commands; } /// @@ -48,7 +47,7 @@ public Command BuildCreateCommand() { var command = new Command("create"); command.Description = "Represents a collection of worksheets associated with the workbook. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -56,21 +55,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string driveItemId, string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, bodyOption, outputOption); return command; } /// @@ -80,7 +78,7 @@ public Command BuildListCommand() { var command = new Command("list"); command.Description = "Represents a collection of worksheets associated with the workbook. Read-only."; // Create options for all the parameters - var driveItemIdOption = new Option("--driveitem-id", description: "key: id of driveItem") { + var driveItemIdOption = new Option("--drive-item-id", description: "key: id of driveItem") { }; driveItemIdOption.IsRequired = true; command.AddOption(driveItemIdOption); @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (string driveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string driveItemId, int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -130,15 +132,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, driveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, driveItemIdOption, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -193,31 +190,6 @@ public RequestInformation CreatePostRequestInformation(WorkbookWorksheet body, A requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Represents a collection of worksheets associated with the workbook. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Represents a collection of worksheets associated with the workbook. Read-only. - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(WorkbookWorksheet model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Represents a collection of worksheets associated with the workbook. Read-only. public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/generated/Workbooks/WorkbooksRequestBuilder.cs b/src/generated/Workbooks/WorkbooksRequestBuilder.cs index c9268d938b2..4edac480b8b 100644 --- a/src/generated/Workbooks/WorkbooksRequestBuilder.cs +++ b/src/generated/Workbooks/WorkbooksRequestBuilder.cs @@ -2,10 +2,10 @@ using ApiSdk.Workbooks.Item; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Cli.Commons.IO; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Linq; using System.Text; @@ -22,31 +22,30 @@ public class WorkbooksRequestBuilder { private string UrlTemplate { get; set; } public List BuildCommand() { var builder = new DriveItemRequestBuilder(PathParameters, RequestAdapter); - var commands = new List { - builder.BuildAnalyticsCommand(), - builder.BuildCheckinCommand(), - builder.BuildCheckoutCommand(), - builder.BuildChildrenCommand(), - builder.BuildContentCommand(), - builder.BuildCopyCommand(), - builder.BuildCreateLinkCommand(), - builder.BuildCreateUploadSessionCommand(), - builder.BuildDeleteCommand(), - builder.BuildFollowCommand(), - builder.BuildGetCommand(), - builder.BuildInviteCommand(), - builder.BuildListItemCommand(), - builder.BuildPatchCommand(), - builder.BuildPermissionsCommand(), - builder.BuildPreviewCommand(), - builder.BuildRestoreCommand(), - builder.BuildSubscriptionsCommand(), - builder.BuildThumbnailsCommand(), - builder.BuildUnfollowCommand(), - builder.BuildValidatePermissionCommand(), - builder.BuildVersionsCommand(), - builder.BuildWorkbookCommand(), - }; + var commands = new List(); + commands.Add(builder.BuildAnalyticsCommand()); + commands.Add(builder.BuildCheckinCommand()); + commands.Add(builder.BuildCheckoutCommand()); + commands.Add(builder.BuildChildrenCommand()); + commands.Add(builder.BuildContentCommand()); + commands.Add(builder.BuildCopyCommand()); + commands.Add(builder.BuildCreateLinkCommand()); + commands.Add(builder.BuildCreateUploadSessionCommand()); + commands.Add(builder.BuildDeleteCommand()); + commands.Add(builder.BuildFollowCommand()); + commands.Add(builder.BuildGetCommand()); + commands.Add(builder.BuildInviteCommand()); + commands.Add(builder.BuildListItemCommand()); + commands.Add(builder.BuildPatchCommand()); + commands.Add(builder.BuildPermissionsCommand()); + commands.Add(builder.BuildPreviewCommand()); + commands.Add(builder.BuildRestoreCommand()); + commands.Add(builder.BuildSubscriptionsCommand()); + commands.Add(builder.BuildThumbnailsCommand()); + commands.Add(builder.BuildUnfollowCommand()); + commands.Add(builder.BuildValidatePermissionCommand()); + commands.Add(builder.BuildVersionsCommand()); + commands.Add(builder.BuildWorkbookCommand()); return commands; } /// @@ -60,21 +59,20 @@ public Command BuildCreateCommand() { }; bodyOption.IsRequired = true; command.AddOption(bodyOption); - command.SetHandler(async (string body) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body)); var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream); var model = parseNode.GetObjectValue(); var requestInfo = CreatePostRequestInformation(model, q => { }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, bodyOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, bodyOption, outputOption); return command; } /// @@ -119,7 +117,11 @@ public Command BuildListCommand() { }; expandOption.IsRequired = false; command.AddOption(expandOption); - command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => { + var outputOption = new Option("--output", () => FormatterType.JSON){ + IsRequired = true + }; + command.AddOption(outputOption); + command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => { var requestInfo = CreateGetRequestInformation(q => { q.Top = top; q.Skip = skip; @@ -130,15 +132,10 @@ public Command BuildListCommand() { q.Select = select; q.Expand = expand; }); - var result = await RequestAdapter.SendAsync(requestInfo); - // Print request output. What if the request has no return? - using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json"); - serializer.WriteObjectValue(null, result); - using var content = serializer.GetSerializedContent(); - using var reader = new StreamReader(content); - var strContent = await reader.ReadToEndAsync(); - Console.Write(strContent + "\n"); - }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption); + var response = await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken); + var formatter = outputFormatterFactory.GetFormatter(output); + formatter.WriteOutput(response); + }, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption); return command; } /// @@ -193,31 +190,6 @@ public RequestInformation CreatePostRequestInformation(ApiSdk.Models.Microsoft.G requestInfo.AddRequestOptions(o?.ToArray()); return requestInfo; } - /// - /// Get entities from workbooks - /// Cancellation token to use when cancelling requests - /// Request headers - /// Request options - /// Request query parameters - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task GetAsync(Action q = default, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - var requestInfo = CreateGetRequestInformation(q, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } - /// - /// Add new entity to workbooks - /// Cancellation token to use when cancelling requests - /// Request headers - /// - /// Request options - /// Response handler to use in place of the default response handling provided by the core service - /// - public async Task PostAsync(ApiSdk.Models.Microsoft.Graph.DriveItem model, Action> h = default, IEnumerable o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) { - _ = model ?? throw new ArgumentNullException(nameof(model)); - var requestInfo = CreatePostRequestInformation(model, h, o); - return await RequestAdapter.SendAsync(requestInfo, responseHandler, cancellationToken); - } /// Get entities from workbooks public class GetQueryParameters : QueryParametersBase { /// Include count of items diff --git a/src/msgraph-cli.csproj b/src/msgraph-cli.csproj index 35414be42e2..7fac990a396 100644 --- a/src/msgraph-cli.csproj +++ b/src/msgraph-cli.csproj @@ -10,7 +10,7 @@ false true mgc - 0.1.0-preview.1 + 0.1.0-preview.2 @@ -25,10 +25,9 @@ - - - - + + +